diff --git a/AMDiS/libtool b/AMDiS/libtool index e96f67065e881c5fbc2155783211a810082e9175..b24ee23d4db5c89b8becf2ee49cfa31486adc673 100755 --- a/AMDiS/libtool +++ b/AMDiS/libtool @@ -93,9 +93,6 @@ CC="gcc" # Is the compiler the GNU C compiler? with_gcc=yes -gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` -gcc_ver=`gcc -dumpversion` - # An ERE matcher. EGREP="grep -E" @@ -232,11 +229,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +predep_objects="" # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +postdep_objects="" # Dependencies to place before the objects being linked to create a # shared library. @@ -248,7 +245,7 @@ postdeps="" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +compiler_lib_search_path="" # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -328,7 +325,7 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=`echo " /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" # Run-time system search path for libraries sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib " @@ -6812,9 +6809,6 @@ CC="g++" # Is the compiler the GNU C compiler? with_gcc=yes -gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` -gcc_ver=`gcc -dumpversion` - # An ERE matcher. EGREP="grep -E" @@ -6948,11 +6942,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=`echo "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o" # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=`echo "/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +postdep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o" # Dependencies to place before the objects being linked to create a # shared library. @@ -6964,7 +6958,7 @@ postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=`echo "-L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +compiler_lib_search_path="-L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.." # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7044,7 +7038,7 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=`echo " /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" # Run-time system search path for libraries sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib " @@ -7120,9 +7114,6 @@ CC="g77" # Is the compiler the GNU C compiler? with_gcc=yes -gcc_dir=`gcc -print-file-name=. | /bin/sed 's,/\.$,,'` -gcc_ver=`gcc -dumpversion` - # An ERE matcher. EGREP="grep -E" @@ -7259,11 +7250,11 @@ striplib="strip --strip-unneeded" # Dependencies to place before the objects being linked to create a # shared library. -predep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +predep_objects="" # Dependencies to place after the objects being linked to create a # shared library. -postdep_objects=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +postdep_objects="" # Dependencies to place before the objects being linked to create a # shared library. @@ -7275,7 +7266,7 @@ postdeps="" # The library search path used internally by the compiler when linking # a shared library. -compiler_lib_search_path=`echo "" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +compiler_lib_search_path="" # Method to check whether dependent libraries are shared objects. deplibs_check_method="pass_all" @@ -7355,7 +7346,7 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM link_all_deplibs=unknown # Compile-time system search path for libraries -sys_lib_search_path_spec=`echo " /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ /lib/i386-redhat-linux/3.4.6/ /lib/ /usr/lib/i386-redhat-linux/3.4.6/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"` +sys_lib_search_path_spec=" /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ /lib/i386-redhat-linux/3.4.6/ /lib/ /usr/lib/i386-redhat-linux/3.4.6/ /usr/lib/" # Run-time system search path for libraries sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib " diff --git a/AMDiS/src/DOFVector.cc b/AMDiS/src/DOFVector.cc index 78f4c2b5dcf3edb8fd810332cd988cb723d04337..c0087e7567368add236d5472d4e69ea9e2da9e26 100644 --- a/AMDiS/src/DOFVector.cc +++ b/AMDiS/src/DOFVector.cc @@ -521,11 +521,9 @@ namespace AMDiS { &elInfo1, &elInfo2, &elInfoSmall, &elInfoLarge); while (nextTraverse) { - basisFcts->getLocalIndices(elInfo1->getElement(), - feSpace->getAdmin(), + basisFcts->getLocalIndices(elInfo1->getElement(), feSpace->getAdmin(), myLocalIndices); - source->getLocalVector(elInfo2->getElement(), - sourceLocalCoeffs); + source->getLocalVector(elInfo2->getElement(), sourceLocalCoeffs); for (int i = 0; i < nBasisFcts; i++) { if (vec[myLocalIndices[i]] == 0.0) { @@ -540,14 +538,14 @@ namespace AMDiS { } } - if (isPositive) { - vec[myLocalIndices[i]] = sourceBasisFcts->evalUh(coords2, sourceLocalCoeffs); - } + if (isPositive) + vec[myLocalIndices[i]] = + sourceBasisFcts->evalUh(coords2, sourceLocalCoeffs); } } - nextTraverse = dualStack.traverseNext(&elInfo1, &elInfo2, - &elInfoSmall, &elInfoLarge); + nextTraverse = + dualStack.traverseNext(&elInfo1, &elInfo2, &elInfoSmall, &elInfoLarge); } } @@ -677,7 +675,6 @@ namespace AMDiS { WorldVector<double> grd; while (elInfo) { - const DegreeOfFreedom **dof = elInfo->getElement()->getDOF(); const double *localUh = getLocalVector(elInfo->getElement(), NULL); const DimVec<WorldVector<double> > &grdLambda = elInfo->getGrdLambda(); diff --git a/AMDiS/src/DOFVector.h b/AMDiS/src/DOFVector.h index 4107f4d02b276931f22fc669225d55b47c4622bc..32a75d1fd1d47d3120495fc6fdfeb8e9276a2752 100644 --- a/AMDiS/src/DOFVector.h +++ b/AMDiS/src/DOFVector.h @@ -523,7 +523,7 @@ namespace AMDiS { T absMax() const; /// Used by interpol while mesh traversal - static int interpolFct(ElInfo* elinfo); + void interpolFct(ElInfo* elinfo); /// Prints \ref vec to stdout void print() const; diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh index 237c3503d5c2559ad7f8b4edc52777afe2ec585b..3feec5cd901bb3047831e5c141ec3f1639491bd0 100644 --- a/AMDiS/src/DOFVector.hh +++ b/AMDiS/src/DOFVector.hh @@ -428,20 +428,19 @@ namespace AMDiS { } template<typename T> - int DOFVector<T>::interpolFct(ElInfo* elinfo) + void DOFVector<T>::interpolFct(ElInfo* elinfo) { const BasisFunction *basFct = traverseVector->getFESpace()->getBasisFcts(); const DOFAdmin* admin = traverseVector->getFESpace()->getAdmin(); - const DegreeOfFreedom *dof = - basFct->getLocalIndices(const_cast<Element*>(elinfo->getElement()), admin, NULL); const T *inter_val = const_cast<BasisFunction*>(basFct)->interpol(elinfo, 0, NULL, traverseVector->interFct, NULL); + + DegreeOfFreedom *myLocalIndices = this->localIndices[omp_get_thread_num()]; + basFct->getLocalIndices(const_cast<Element*>(elinfo->getElement()), admin, myLocalIndices); int nBasFcts = basFct->getNumber(); for (int i = 0; i < nBasFcts; i++) - (*traverseVector)[dof[i]] = inter_val[i]; - - return 0; + (*traverseVector)[myLocalIndices[i]] = inter_val[i]; } template<typename T> @@ -456,11 +455,10 @@ namespace AMDiS { q = Quadrature::provideQuadrature(this->dim, deg); } - quad_fast = FastQuadrature::provideFastQuadrature(this->feSpace->getBasisFcts(), - *q, INIT_PHI); + quad_fast = + FastQuadrature::provideFastQuadrature(this->feSpace->getBasisFcts(), *q, INIT_PHI); norm = 0.0; traverseVector = const_cast<DOFVector<T>*>(this); - mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET, Int_fct); return norm; @@ -976,8 +974,13 @@ namespace AMDiS { result = localVec; } +#ifdef _OPENMP + std::vector<DegreeOfFreedom> localIndices(nBasFcts); + feSpace->getBasisFcts()->getLocalIndices(el, admin, &(localIndices[0])); +#else const DegreeOfFreedom *localIndices = feSpace->getBasisFcts()->getLocalIndices(el, admin, NULL); +#endif for (int i = 0; i < nBasFcts; i++) result[i] = (*this)[localIndices[i]]; diff --git a/AMDiS/src/Lagrange.cc b/AMDiS/src/Lagrange.cc index 4a2757bbf44dd5f1592da9efb8dae726aec92fdc..5142d21bfaa05f422e84072acdd72c84f304bbbf 100644 --- a/AMDiS/src/Lagrange.cc +++ b/AMDiS/src/Lagrange.cc @@ -920,6 +920,9 @@ namespace AMDiS { if (indices) { result = indices; } else { +#ifdef _OPENMP + ERROR_EXIT("Using static variable while using OpenMP parallelization!\n"); +#endif if (localVec && nBasFcts > localVecSize) { delete [] localVec; localVec = new DegreeOfFreedom[nBasFcts]; diff --git a/AMDiS/src/Operator.cc b/AMDiS/src/Operator.cc index c38dc53db64440c85abeac6af96142a3349c8a4a..9f5bc807e1e70f6fe739e2a04d2f749e476ef3f2 100644 --- a/AMDiS/src/Operator.cc +++ b/AMDiS/src/Operator.cc @@ -1730,18 +1730,16 @@ namespace AMDiS { double *result, double fac) const { - for (int iq = 0; iq < nPoints; iq++) { - result[iq] += fac * (*f)(vecAtQPs[iq], coordsAtQPs[iq]) * - uhAtQP[iq]; - } + for (int iq = 0; iq < nPoints; iq++) + result[iq] += fac * (*f)(vecAtQPs[iq], coordsAtQPs[iq]) * uhAtQP[iq]; } void FctGradientCoords_ZOT::getC(const ElInfo *, int nPoints, - std::vector<double> &C) const { - for (int iq = 0; iq < nPoints; iq++) { - C[iq] += (*f)(gradAtQPs[iq], coordsAtQPs[iq]); - } + std::vector<double> &C) const + { + for (int iq = 0; iq < nPoints; iq++) + C[iq] += (*f)(gradAtQPs[iq], coordsAtQPs[iq]); } void FctGradientCoords_ZOT::eval(int nPoints, @@ -1751,17 +1749,16 @@ namespace AMDiS { double *result, double fac) const { - for (int iq = 0; iq < nPoints; iq++) { - result[iq] += fac * (*f)(gradAtQPs[iq], coordsAtQPs[iq]) * - uhAtQP[iq]; - } + for (int iq = 0; iq < nPoints; iq++) + result[iq] += + fac * (*f)(gradAtQPs[iq], coordsAtQPs[iq]) * uhAtQP[iq]; } void VecGradCoordsAtQP_ZOT::getC(const ElInfo *, int nPoints, - std::vector<double> &C) const { - for (int iq = 0; iq < nPoints; iq++) { + std::vector<double> &C) const + { + for (int iq = 0; iq < nPoints; iq++) C[iq] += (*f)(vecAtQPs[iq], gradAtQPs[iq], coordsAtQPs[iq]); - } } void VecGradCoordsAtQP_ZOT::eval(int nPoints, @@ -1938,11 +1935,10 @@ namespace AMDiS { if (D2UhAtQP) { for (int iq = 0; iq < nPoints; iq++) { double resultQP = 0.0; - for (int i = 0; i < dow; i++) { - for (int j = 0; j < dow; j++) { - resultQP += matrix[i][j] * D2UhAtQP[iq][j][i]; - } - } + for (int i = 0; i < dow; i++) + for (int j = 0; j < dow; j++) + resultQP += matrix[i][j] * D2UhAtQP[iq][j][i]; + result[iq] += resultQP * factor; } } @@ -1952,15 +1948,11 @@ namespace AMDiS { const WorldVector<double> *grdUhAtQP, WorldVector<double> *result) const { - if (grdUhAtQP) { - for (int iq = 0; iq < nPoints; iq++) { + if (grdUhAtQP) + for (int iq = 0; iq < nPoints; iq++) result[iq] += matrix * grdUhAtQP[iq]; - } - } } - - void MatrixGradient_SOT::eval(int nPoints, const double *uhAtQP, const WorldVector<double> *grdUhAtQP, @@ -1975,17 +1967,13 @@ namespace AMDiS { WorldMatrix<double> A = (*f)(gradAtQPs[iq]); - if (D2UhAtQP) { - for (int i = 0; i < dow; i++) { - for (int j = 0; j < dow; j++) { + if (D2UhAtQP) + for (int i = 0; i < dow; i++) + for (int j = 0; j < dow; j++) resultQP += A[i][j] * D2UhAtQP[iq][j][i]; - } - } - } - if (grdUhAtQP) { - resultQP += (*divFct)(A) * grdUhAtQP[iq]; - } + if (grdUhAtQP) + resultQP += (*divFct)(A) * grdUhAtQP[iq]; result[iq] += resultQP * factor; } @@ -2017,9 +2005,8 @@ namespace AMDiS { for (int iq = 0; iq < nPoints; iq++) { double factor = (*f)(vecAtQPs[iq]); double resultQP = 0.0; - for (int i = 0; i < dow; i++) { - resultQP += D2UhAtQP[iq][i][i]; - } + for (int i = 0; i < dow; i++) + resultQP += D2UhAtQP[iq][i][i]; result[iq] += fac * factor * resultQP; } } @@ -2050,9 +2037,8 @@ namespace AMDiS { for (int iq = 0; iq < nPoints; iq++) { double factor = (*f)(vecAtQPs1[iq], vecAtQPs2[iq]); double resultQP = 0.0; - for (int i = 0; i < dow; i++) { - resultQP += D2UhAtQP[iq][i][i]; - } + for (int i = 0; i < dow; i++) + resultQP += D2UhAtQP[iq][i][i]; result[iq] += fac * factor * resultQP; } } diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc index 952458d7e11f8a3c91e747624ed539054ab17480..c97f69ba0f7e3bdbfc5dc8939f2a1bb09c1f21c2 100644 --- a/AMDiS/src/ProblemVec.cc +++ b/AMDiS/src/ProblemVec.cc @@ -1072,7 +1072,9 @@ namespace AMDiS { if (matrix) { #pragma omp critical - matrix->getBaseMatrix() += tmpMatrix->getBaseMatrix(); + { + matrix->getBaseMatrix() += tmpMatrix->getBaseMatrix(); + } } #pragma omp barrier @@ -1080,7 +1082,7 @@ namespace AMDiS { #pragma omp master { if (matrix) - matrix->startInsertion(); + matrix->startInsertion(); } #pragma omp barrier diff --git a/AMDiS/src/SecondOrderAssembler.cc b/AMDiS/src/SecondOrderAssembler.cc index dd808cbde22b1b036ec1c478d57c2907da338a5d..136d420a26b2e55c8f6cad31d8bb642da900d625 100644 --- a/AMDiS/src/SecondOrderAssembler.cc +++ b/AMDiS/src/SecondOrderAssembler.cc @@ -169,9 +169,9 @@ namespace AMDiS { if (!firstCall) { int nPoints = quadrature->getNumPoints(); for (int i = 0; i < static_cast<int>(tmpLALt.size()); i++) { - for (int j = 0; j < nPoints; j++) { + for (int j = 0; j < nPoints; j++) delete tmpLALt[i][j]; - } + delete [] tmpLALt[i]; } } diff --git a/AMDiS/src/Traverse.cc b/AMDiS/src/Traverse.cc index 9bfa1514e431a14c29841a41c2671637a862a34a..b62d032f29164e102a1ff5af9d02e63e91bc404b 100644 --- a/AMDiS/src/Traverse.cc +++ b/AMDiS/src/Traverse.cc @@ -53,8 +53,7 @@ namespace AMDiS { elinfo_old = parametric->removeParametricInfo(elinfo_old); TEST_EXIT_DBG(elinfo_old == elinfo_stack[stack_used])("invalid old elinfo\n"); - } - else { + } else { TEST_EXIT_DBG(elinfo_old == NULL)("invalid old elinfo != nil\n"); } @@ -332,14 +331,13 @@ namespace AMDiS { if (stack_used == 0) { /* first call */ currentMacro = traverse_mesh->firstMacroElement(); - while (((*currentMacro)->getIndex() % maxThreads_ != myThreadId_) && + while (((*currentMacro)->getIndex() % maxThreads != myThreadId) && (currentMacro != traverse_mesh->endOfMacroElements())) { currentMacro++; } - if (currentMacro == traverse_mesh->endOfMacroElements()) { + if (currentMacro == traverse_mesh->endOfMacroElements()) return NULL; - } traverse_mel = *currentMacro; stack_used = 1; @@ -347,9 +345,8 @@ namespace AMDiS { info_stack[stack_used] = 0; el = elinfo_stack[stack_used]->getElement(); - if ((el == NULL) || (el->getFirstChild() == NULL)) { - return (elinfo_stack[stack_used]); - } + if (el == NULL || el->getFirstChild() == NULL) + return (elinfo_stack[stack_used]); } else { el = elinfo_stack[stack_used]->getElement(); @@ -365,21 +362,19 @@ namespace AMDiS { do { currentMacro++; } while ((currentMacro != traverse_mesh->endOfMacroElements()) && - ((*currentMacro)->getIndex() % maxThreads_ != myThreadId_)); + ((*currentMacro)->getIndex() % maxThreads != myThreadId)); - if (currentMacro == traverse_mesh->endOfMacroElements()) { + if (currentMacro == traverse_mesh->endOfMacroElements()) return NULL; - } - traverse_mel = *currentMacro; - + + traverse_mel = *currentMacro; stack_used = 1; elinfo_stack[stack_used]->fillMacroInfo(traverse_mel); - info_stack[stack_used] = 0; - + info_stack[stack_used] = 0; el = elinfo_stack[stack_used]->getElement(); - if ((el == NULL) || (el->getFirstChild() == NULL)) { - return (elinfo_stack[stack_used]); - } + + if (el == NULL || el->getFirstChild() == NULL) + return (elinfo_stack[stack_used]); } } @@ -518,12 +513,11 @@ namespace AMDiS { el = elinfo_stack[stack_used]->getElement(); /* go up in tree until we can go down again */ - while((stack_used > 0) && - ((info_stack[stack_used] >= 2) || (el->getFirstChild()==NULL))) - { - stack_used--; - el = elinfo_stack[stack_used]->getElement(); - } + while (stack_used > 0 && + (info_stack[stack_used] >= 2 || el->getFirstChild() == NULL)) { + stack_used--; + el = elinfo_stack[stack_used]->getElement(); + } /* goto next macro element */ @@ -575,29 +569,27 @@ namespace AMDiS { Element *el; int i; - if (stack_used == 0) /* first call */ - { - currentMacro = traverse_mesh->firstMacroElement(); - if(currentMacro == traverse_mesh->endOfMacroElements()) return NULL; - traverse_mel = *currentMacro; - - stack_used = 1; - elinfo_stack[stack_used]->fillMacroInfo(traverse_mel); - info_stack[stack_used] = 0; - - //return(elinfo_stack[stack_used]); - } - else { /* don't go up on first call */ + if (stack_used == 0) { /* first call */ + currentMacro = traverse_mesh->firstMacroElement(); + if (currentMacro == traverse_mesh->endOfMacroElements()) + return NULL; + traverse_mel = *currentMacro; + + stack_used = 1; + elinfo_stack[stack_used]->fillMacroInfo(traverse_mel); + info_stack[stack_used] = 0; + + //return(elinfo_stack[stack_used]); + } else { /* don't go up on first call */ el = elinfo_stack[stack_used]->getElement(); /* go up in tree until we can go down again */ /* postorder!!! */ - while((stack_used > 0) && - ((info_stack[stack_used] >= 3) || (el->getFirstChild()==NULL))) - { - stack_used--; - el = elinfo_stack[stack_used]->getElement(); - } + while ((stack_used > 0) && + ((info_stack[stack_used] >= 3) || (el->getFirstChild()==NULL))) { + stack_used--; + el = elinfo_stack[stack_used]->getElement(); + } /* goto next macro element */ @@ -615,8 +607,8 @@ namespace AMDiS { } /* go down tree */ - while(elinfo_stack[stack_used]->getElement()->getFirstChild() - && (info_stack[stack_used] < 2)) { + while (elinfo_stack[stack_used]->getElement()->getFirstChild() + && (info_stack[stack_used] < 2)) { if (stack_used >= stack_size-1) enlargeTraverseStack(); diff --git a/AMDiS/src/Traverse.h b/AMDiS/src/Traverse.h index 751de9693743ab94511de9908791ab253c7ca850..2ecb504b655019946eb2e69f7763e7560e35ca7d 100644 --- a/AMDiS/src/Traverse.h +++ b/AMDiS/src/Traverse.h @@ -61,8 +61,8 @@ namespace AMDiS { stack_size(0), stack_used(0), save_stack_used(0), - myThreadId_(0), - maxThreads_(1) + myThreadId(0), + maxThreads(1) {} /// Destructor @@ -117,15 +117,15 @@ namespace AMDiS { void fillRefinementPath(ElInfo& elInfo, const ElInfo& upperElInfo); /// Is used for parallel mesh traverse. - inline void setMyThreadId(int myThreadId) + inline void setMyThreadId(int n) { - myThreadId_ = myThreadId; + myThreadId = n; } /// Is used for parallel mesh traverse. - inline void setMaxThreads(int maxThreads) + inline void setMaxThreads(int n) { - maxThreads_ = maxThreads; + maxThreads = n; } int getStackData(std::vector<ElInfo*> &elInfos, std::vector<int> &infos) @@ -229,14 +229,14 @@ namespace AMDiS { * myThreadId is only allowed to access coarse elements, which id * satisfies: elId % maxThreads = myThreadId. */ - int myThreadId_; + int myThreadId; /** \brief * Is used for parallel mesh traverse. The thread with the id * myThreadId is only allowed to access coarse elements, which id * satisfies: elId % maxThreads = myThreadId. */ - int maxThreads_; + int maxThreads; }; diff --git a/AMDiS/src/TraverseParallel.cc b/AMDiS/src/TraverseParallel.cc index cd2a1d00494840d1fec3761a1153bac43dc72875..e3a198b2af5979b087d837150dd38fd8ccde1d7c 100644 --- a/AMDiS/src/TraverseParallel.cc +++ b/AMDiS/src/TraverseParallel.cc @@ -6,43 +6,38 @@ namespace AMDiS { - TraverseParallelStack::TraverseParallelStack(int nThreads) + TraverseParallelStack::TraverseParallelStack(int n) { - if (nThreads == 0) { - nThreads_ = omp_get_overall_max_threads(); - } else { - nThreads_ = nThreads; - } - - stacks_.resize(nThreads_); + if (n == 0) + nThreads = omp_get_overall_max_threads(); + else + nThreads = n; + + stacks.resize(nThreads); int i = 0; - for (std::vector<TraverseStack*>::iterator it = stacks_.begin(); - it != stacks_.end(); - ++it) { + for (std::vector<TraverseStack*>::iterator it = stacks.begin(); + it != stacks.end(); ++it) { (*it) = new TraverseStack(); - (*it)->setMyThreadId(i++); - (*it)->setMaxThreads(nThreads_); + (*it)->setMaxThreads(nThreads); } } TraverseParallelStack::~TraverseParallelStack() { - for (std::vector<TraverseStack*>::iterator it = stacks_.begin(); - it != stacks_.end(); - ++it) { - + for (std::vector<TraverseStack*>::iterator it = stacks.begin(); + it != stacks.end(); ++it) delete (*it); - } } ElInfo* TraverseParallelStack::traverseFirst(Mesh *mesh, int level, Flag fill_flag) { TEST_EXIT(fill_flag.isSet(Mesh::CALL_LEAF_EL))("not yet implemented"); - TEST_EXIT(stacks_[omp_get_thread_num()])("something wrong with parallel stack traverse"); + TEST_EXIT(stacks[omp_get_thread_num()]) + ("something wrong with parallel stack traverse"); - return stacks_[omp_get_thread_num()]->traverseFirst(mesh, level, fill_flag); + return stacks[omp_get_thread_num()]->traverseFirst(mesh, level, fill_flag); } } diff --git a/AMDiS/src/TraverseParallel.h b/AMDiS/src/TraverseParallel.h index ff0d8c2f7142a6440ffbcc1ae8b5643faa702552..67077386672433a8302a8d792566a9790d184c33 100644 --- a/AMDiS/src/TraverseParallel.h +++ b/AMDiS/src/TraverseParallel.h @@ -42,16 +42,16 @@ namespace AMDiS { ElInfo* traverseFirst(Mesh *mesh, int level, Flag fill_flag); - inline ElInfo* traverseNext(ElInfo* elinfo_old) + inline ElInfo* traverseNext(ElInfo* elInfoOld) { - return stacks_[omp_get_thread_num()]->traverseNext(elinfo_old); + return stacks[omp_get_thread_num()]->traverseNext(elInfoOld); } private: /// Number of threads using the stack in parallel. - int nThreads_; + int nThreads; - std::vector<TraverseStack*> stacks_; + std::vector<TraverseStack*> stacks; }; }