--- trunk/gadget/hooke.cc 2015/07/30 12:36:46 14 +++ trunk/gadget/hooke.cc 2015/09/01 19:14:33 15 @@ -184,7 +184,7 @@ * · 2 threads per coord to parallelize the calculation of +delta/-delta * · parallelize the calculation of the best nearby of the coord */ -double OptInfoHooke::bestNearbyOMP(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) { +double OptInfoHooke::bestNearbyRepro(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) { double minf;//, ftmp; int i, j, k; DoubleVector z(point); @@ -209,11 +209,11 @@ return -1; } + omp_set_dynamic(0); + omp_set_nested(1); //permit the nested parallelization while ( i < nvars) { if ((i + paral_tokens -1) >= nvars) paral_tokens = nvars - i; - omp_set_dynamic(0); - omp_set_nested(1); //permit the nested parallelization #pragma omp parallel for num_threads(paral_tokens) private(k) //parallelize the parameters (numThr/2) for (j = 0; j < paral_tokens; ++j) { storage[j].z = z; @@ -260,7 +260,7 @@ } } } - + delete[] storage; for (i = 0; i < nvars; ++i) point[i] = z[i]; return minf; @@ -360,7 +360,7 @@ for (i = 0; i < nvars; i++) trialx[i] = x[i]; #ifndef NO_OPENMP - newf = this->bestNearbyOMP(delta, trialx, bestf, param); + newf = this->bestNearbyRepro(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n"); @@ -455,7 +455,7 @@ x[i] = trialx[i]; #ifndef NO_OPENMP - newf = this->bestNearbyOMP(delta, trialx, bestf, param); + newf = this->bestNearbyRepro(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n"); @@ -524,8 +524,8 @@ } /* Functions to perform the parallelization of the algorithm of HJ with OpenMP*/ -#ifdef GADGET_OPENMP -double OptInfoHooke::bestNearbyOMP2(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) { +#ifdef SPECULATIVE +double OptInfoHooke::bestNearbySpec(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param) { double minf; int i, j, k, ii; DoubleVector z(point); @@ -549,13 +549,13 @@ return -1; } + omp_set_dynamic(0); + omp_set_nested(1); //permit the nested parallelization for (ii=0; ii< paral_tokens; ii++) { i = 0; while ( i < nvars) { if ((i + paral_tokens -1) >= nvars) paral_tokens = nvars - i; - omp_set_dynamic(0); - omp_set_nested(1); #pragma omp parallel for num_threads(paral_tokens) private(k) for (j = 0; j < paral_tokens; ++j) { storage[j].z = z; @@ -704,7 +704,7 @@ for (i = 0; i < nvars; i++) trialx[i] = x[i]; #ifndef NO_OPENMP - newf = this->bestNearbyOMP2(delta, trialx, bestf, param); + newf = this->bestNearbySpec(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n"); @@ -799,7 +799,7 @@ x[i] = trialx[i]; #ifndef NO_OPENMP - newf = this->bestNearbyOMP2(delta, trialx, bestf, param); + newf = this->bestNearbySpec(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");