1 //------------------------------------------------------------------------------ 2 // GB_omp.h: definitions using OpenMP in SuiteSparse:GraphBLAS 3 //------------------------------------------------------------------------------ 4 5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 6 // SPDX-License-Identifier: Apache-2.0 7 8 //------------------------------------------------------------------------------ 9 10 #ifndef GB_OMP_H 11 #define GB_OMP_H 12 13 //------------------------------------------------------------------------------ 14 // determine the OpenMP version 15 //------------------------------------------------------------------------------ 16 17 #if GB_MICROSOFT 18 19 // MS Visual Studio supports OpenMP 2.0, and does not have the atomic 20 // capture clause. However, it has interlocked compare/exchange functions 21 // that are used instead (see GB_atomics.h). 22 #include <intrin.h> 23 24 #elif defined ( _OPENMP ) 25 26 // All other compilers must either support OpenMP 3.1 or later, or not use 27 // OpenMP at all. 28 #if _OPENMP < 201107 29 #error "OpenMP 3.1 or later required (recompile without OpenMP)" 30 #endif 31 32 #endif 33 34 //------------------------------------------------------------------------------ 35 // OpenMP definitions 36 //------------------------------------------------------------------------------ 37 38 #if defined ( _OPENMP ) 39 40 #include <omp.h> 41 #define GB_OPENMP_MAX_THREADS omp_get_max_threads ( ) 42 #define GB_OPENMP_GET_NUM_THREADS omp_get_num_threads ( ) 43 #define GB_OPENMP_GET_WTIME omp_get_wtime ( ) 44 #define GB_OPENMP_GET_THREAD_ID omp_get_thread_num ( ) 45 46 #else 47 48 #define GB_OPENMP_MAX_THREADS (1) 49 #define GB_OPENMP_GET_NUM_THREADS (1) 50 #define GB_OPENMP_GET_WTIME (0) 51 #define GB_OPENMP_GET_THREAD_ID (0) 52 53 #endif 54 55 #endif 56 57