TraverseParallel.cc 1.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#include "TraverseParallel.h"
#include "OpenMP.h"
#include "Mesh.h"

#ifdef _OPENMP

namespace AMDiS {

  TraverseParallelStack::TraverseParallelStack(int nThreads)
  {
    if (nThreads == 0) {
12
      nThreads_ = omp_get_num_procs();
13
14
15
16
17
18
    } else {
      nThreads_ = nThreads;
    }

    stacks_.resize(nThreads_);
    int i = 0;
19
    for (std::vector<TraverseStack*>::iterator it = stacks_.begin();
20
21
22
23
24
25
26
27
28
29
30
31
	 it != stacks_.end();
	 ++it) {

      (*it) = NEW TraverseStack();

      (*it)->setMyThreadId(i++);
      (*it)->setMaxThreads(nThreads_);
    }
  }

  TraverseParallelStack::~TraverseParallelStack()
  {
32
    for (std::vector<TraverseStack*>::iterator it = stacks_.begin();
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	 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");

    return stacks_[omp_get_thread_num()]->traverseFirst(mesh, level, fill_flag);
  }
}

#endif // _OPENMP