1 /*!
2  *  Copyright (c) 2015 by Contributors
3  * \file omp.h
4  * \brief header to handle OpenMP compatibility issues
5  */
6 #ifndef DMLC_OMP_H_
7 #define DMLC_OMP_H_
8 
9 
10 #if defined(_OPENMP)
11 #include <omp.h>
12 #else
13 
14 #if defined(__ANDROID__) || defined (__clang__)
15 #undef __GOMP_NOTHROW
16 #define __GOMP_NOTHROW
17 #elif defined(__cplusplus)
18 #undef __GOMP_NOTHROW
19 #define __GOMP_NOTHROW throw()
20 #else
21 #undef __GOMP_NOTHROW
22 #define __GOMP_NOTHROW __attribute__((__nothrow__))
23 #endif
24 
25 //! \cond Doxygen_Suppress
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
omp_get_thread_num()29 inline int omp_get_thread_num() __GOMP_NOTHROW { return 0; }
omp_get_num_threads()30 inline int omp_get_num_threads() __GOMP_NOTHROW { return 1; }
omp_get_max_threads()31 inline int omp_get_max_threads() __GOMP_NOTHROW { return 1; }
omp_get_num_procs()32 inline int omp_get_num_procs() __GOMP_NOTHROW { return 1; }
omp_set_num_threads(int nthread)33 inline void omp_set_num_threads(int nthread) __GOMP_NOTHROW {}
34 #ifdef __cplusplus
35 }
36 #endif  // __cplusplus
37 #endif  // _OPENMP
38 
39 // loop variable used in openmp
40 namespace dmlc {
41 #ifdef _MSC_VER
42 typedef int omp_uint;
43 typedef long omp_ulong;  // NOLINT(*)
44 #else
45 typedef unsigned omp_uint;
46 typedef unsigned long omp_ulong; // NOLINT(*)
47 #endif
48 //! \endcond
49 }  // namespace dmlc
50 #endif  // DMLC_OMP_H_
51