Commit cb9077d1 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Bugfix for OpenMP parallelization when using interpolFct on dof vectors.

parent c9a31add
......@@ -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 "
......
......@@ -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();
......
......@@ -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;
......
......@@ -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]];
......
......@@ -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];
......
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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];
}
}
......
......@@ -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();
......
......@@ -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;
};
......
......@@ -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 ==