6 #ifndef METALL_UTILITY_OPEN_MP_HPP
7 #define METALL_UTILITY_OPEN_MP_HPP
16 #ifdef OPEN_MP_PRAGMA_OPERATOR
17 #error "OPEN_MP_PRAGMA_OPERATOR is already defined"
21 #error "OMP_DIRECTIVE is already defined"
24 #define OPEN_MP_PRAGMA_OPERATOR(x) _Pragma(#x)
26 #define OMP_DIRECTIVE(directive) OPEN_MP_PRAGMA_OPERATOR(omp directive)
28 #define OMP_DIRECTIVE(directive)
50 if (kind == omp_sched_static ||
51 kind == (omp_sched_static | omp_sched_monotonic)) {
52 name =
"omp_sched_static";
53 }
else if (kind == omp_sched_dynamic ||
54 kind == (omp_sched_dynamic | omp_sched_monotonic)) {
55 name =
"omp_sched_dynamic";
56 }
else if (kind == omp_sched_guided ||
57 kind == (omp_sched_guided | omp_sched_monotonic)) {
58 name =
"omp_sched_guided";
59 }
else if (kind == omp_sched_auto ||
60 kind == (omp_sched_auto | omp_sched_monotonic)) {
61 name =
"omp_sched_auto";
63 name =
"Unknown kind (" + std::to_string((uint64_t)kind) +
")";
65 if (kind & omp_sched_monotonic) {
66 name +=
" with omp_sched_monotonic";
69 if (kind == omp_sched_static) {
70 name =
"omp_sched_static";
71 }
else if (kind == omp_sched_dynamic) {
72 name =
"omp_sched_dynamic";
73 }
else if (kind == omp_sched_guided) {
74 name =
"omp_sched_guided";
75 }
else if (kind == omp_sched_auto) {
76 name =
"omp_sched_auto";
78 name =
"Unknown kind (" + std::to_string((uint64_t)kind) +
")";
82 name =
"OpenMP is not supported";
92 ::omp_get_schedule(&kind, &chunk_size);
94 return std::make_pair(kind, chunk_size);
96 return std::make_pair(0, 0);
102 return ::omp_get_num_threads();
110 return ::omp_get_thread_num();
118 ::omp_set_num_threads(n);