Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/gadget/hooke.cc
[mareframe] / trunk / gadget / hooke.cc Repository:
ViewVC logotype

Diff of /trunk/gadget/hooke.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14, Thu Jul 30 12:36:46 2015 UTC revision 15, Tue Sep 1 19:14:33 2015 UTC
# Line 184  Line 184 
184   * · 2 threads per coord to parallelize the calculation of +delta/-delta   * · 2 threads per coord to parallelize the calculation of +delta/-delta
185   * · parallelize the calculation of the best nearby of the coord   * · parallelize the calculation of the best nearby of the coord
186   */   */
187  double OptInfoHooke::bestNearbyOMP(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) {  double OptInfoHooke::bestNearbyRepro(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) {
188    double minf;//, ftmp;    double minf;//, ftmp;
189    int i, j, k;    int i, j, k;
190    DoubleVector z(point);    DoubleVector z(point);
# Line 209  Line 209 
209            return -1;            return -1;
210    }    }
211    
212      omp_set_dynamic(0);
213      omp_set_nested(1); //permit the nested parallelization
214    while ( i < nvars) {    while ( i < nvars) {
215            if ((i + paral_tokens -1) >= nvars)            if ((i + paral_tokens -1) >= nvars)
216                    paral_tokens = nvars - i;                    paral_tokens = nvars - i;
           omp_set_dynamic(0);  
           omp_set_nested(1); //permit the nested parallelization  
217  #pragma omp parallel for num_threads(paral_tokens) private(k) //parallelize the parameters (numThr/2)  #pragma omp parallel for num_threads(paral_tokens) private(k) //parallelize the parameters (numThr/2)
218            for (j = 0; j < paral_tokens; ++j) {            for (j = 0; j < paral_tokens; ++j) {
219                    storage[j].z = z;                    storage[j].z = z;
# Line 260  Line 260 
260                    }                    }
261            }            }
262    }    }
263      delete[] storage;
264    for (i = 0; i < nvars; ++i)    for (i = 0; i < nvars; ++i)
265      point[i] = z[i];      point[i] = z[i];
266    return minf;    return minf;
# Line 360  Line 360 
360      for (i = 0; i < nvars; i++)      for (i = 0; i < nvars; i++)
361        trialx[i] = x[i];        trialx[i] = x[i];
362  #ifndef NO_OPENMP  #ifndef NO_OPENMP
363      newf = this->bestNearbyOMP(delta, trialx, bestf, param);      newf = this->bestNearbyRepro(delta, trialx, bestf, param);
364      if (newf == -1) {      if (newf == -1) {
365          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
366          handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");          handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");
# Line 455  Line 455 
455          x[i] = trialx[i];          x[i] = trialx[i];
456    
457  #ifndef NO_OPENMP  #ifndef NO_OPENMP
458        newf = this->bestNearbyOMP(delta, trialx, bestf, param);        newf = this->bestNearbyRepro(delta, trialx, bestf, param);
459        if (newf == -1) {        if (newf == -1) {
460                  handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                  handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
461                  handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");                  handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");
# Line 524  Line 524 
524  }  }
525    
526  /* Functions to perform the parallelization of the algorithm of HJ with OpenMP*/  /* Functions to perform the parallelization of the algorithm of HJ with OpenMP*/
527  #ifdef GADGET_OPENMP  #ifdef SPECULATIVE
528  double OptInfoHooke::bestNearbyOMP2(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) {  double OptInfoHooke::bestNearbySpec(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) {
529    double minf;    double minf;
530    int i, j, k, ii;    int i, j, k, ii;
531    DoubleVector z(point);    DoubleVector z(point);
# Line 549  Line 549 
549            return -1;            return -1;
550    }    }
551    
552      omp_set_dynamic(0);
553      omp_set_nested(1); //permit the nested parallelization
554    for (ii=0; ii< paral_tokens; ii++) {    for (ii=0; ii< paral_tokens; ii++) {
555            i = 0;            i = 0;
556            while ( i < nvars) {            while ( i < nvars) {
557                    if ((i + paral_tokens -1) >= nvars)                    if ((i + paral_tokens -1) >= nvars)
558                            paral_tokens = nvars - i;                            paral_tokens = nvars - i;
                   omp_set_dynamic(0);  
                   omp_set_nested(1);  
559          #pragma omp parallel for num_threads(paral_tokens) private(k)          #pragma omp parallel for num_threads(paral_tokens) private(k)
560                    for (j = 0; j < paral_tokens; ++j) {                    for (j = 0; j < paral_tokens; ++j) {
561                            storage[j].z = z;                            storage[j].z = z;
# Line 704  Line 704 
704               for (i = 0; i < nvars; i++)               for (i = 0; i < nvars; i++)
705                 trialx[i] = x[i];                 trialx[i] = x[i];
706           #ifndef NO_OPENMP           #ifndef NO_OPENMP
707               newf = this->bestNearbyOMP2(delta, trialx, bestf, param);               newf = this->bestNearbySpec(delta, trialx, bestf, param);
708               if (newf == -1) {               if (newf == -1) {
709                  handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                  handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
710                  handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");                  handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");
# Line 799  Line 799 
799                   x[i] = trialx[i];                   x[i] = trialx[i];
800    
801           #ifndef NO_OPENMP           #ifndef NO_OPENMP
802                 newf = this->bestNearbyOMP2(delta, trialx, bestf, param);                 newf = this->bestNearbySpec(delta, trialx, bestf, param);
803                 if (newf == -1) {                 if (newf == -1) {
804                          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
805                          handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");                          handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");

Legend:
Removed from v.14  
changed lines
  Added in v.15

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge