ARTS  2.2.66
arts_omp.cc
Go to the documentation of this file.
1 /* Copyright (C) 2012 Stefan Buehler <sbuehler(at)ltu.se>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of the
6  License, or (at your option) any later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16  USA. */
17 
33 #include "arts.h"
34 
35 #include <iostream>
36 using namespace std;
37 
38 #include "arts_omp.h"
39 
40 
42 
48 {
49 
50 #ifdef _OPENMP
51  int max_threads = omp_get_max_threads();
52 #else
53  int max_threads = 1;
54 #endif
55 
56  return max_threads;
57 }
58 
59 
61 
67 {
68 
69 #ifdef _OPENMP
70  return omp_in_parallel();
71 #else
72  return false;
73 #endif
74 }
75 
76 
78 
84 {
85 
86 #ifdef _OPENMP
87  int thread_num = omp_get_thread_num();
88 #else
89  int thread_num = 0;
90 #endif
91 
92  return thread_num;
93 }
94 
95 
97 
103 {
104 
105 #ifdef _OPENMP
106  int nested = omp_get_nested();
107 #else
108  int nested = 0;
109 #endif
110 
111  return nested;
112 }
113 
114 
116 
121 #ifdef _OPENMP
122 void arts_omp_set_nested(int i)
123 #else
125 #endif
126 {
127 
128 #ifdef _OPENMP
129  omp_set_nested(i);
130 #else
131  // Nothing to do here.
132 #endif
133 
134 }
135 
136 
138 
143 #ifdef _OPENMP
144 void arts_omp_set_dynamic(int i)
145 #else
147 #endif
148 {
149 
150 #ifdef _OPENMP
151  omp_set_dynamic(i);
152 #else
153  // Nothing to do here.
154 #endif
155 
156 }
157 
arts_omp_get_thread_num
int arts_omp_get_thread_num()
Wrapper for omp_get_thread_num.
Definition: arts_omp.cc:83
arts_omp_get_max_threads
int arts_omp_get_max_threads()
Wrapper for omp_get_max_threads.
Definition: arts_omp.cc:47
arts_omp_set_dynamic
void arts_omp_set_dynamic(int i)
Wrapper for omp_set_dynamic.
Definition: arts_omp.cc:146
arts_omp_get_nested
int arts_omp_get_nested()
Wrapper for omp_get_nested.
Definition: arts_omp.cc:102
arts_omp_in_parallel
bool arts_omp_in_parallel()
Wrapper for omp_in_parallel.
Definition: arts_omp.cc:66
_U_
#define _U_
Definition: config.h:167
arts_omp_set_nested
void arts_omp_set_nested(int i)
Wrapper for omp_set_nested.
Definition: arts_omp.cc:124
arts_omp.h
Header file for helper functions for OpenMP.
arts.h
The global header file for ARTS.