Skip to content

Commit

Permalink
Enable running without openmp
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed May 13, 2021
1 parent 1c74e5f commit 464b636
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
4 changes: 3 additions & 1 deletion advanced_examples/01_parallel_for/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ if( Kokkos_ENABLE_CUDA )
endif()
else()
if( Kokkos_ENABLE_OPENMP )
add_definitions(-fopenmp)
add_definitions(-fopenmp -DUSE_OMP=1)
else()
add_definitions(-DUSE_OMP=0)
endif()
add_definitions(-DSIMD_SIZE=32 -DVEC_LEN=32 -DUSE_GPU=0)
endif()
Expand Down
4 changes: 3 additions & 1 deletion advanced_examples/02_push/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ if( Kokkos_ENABLE_CUDA )
endif()
else()
if( Kokkos_ENABLE_OPENMP )
add_definitions(-fopenmp)
add_definitions(-fopenmp -DUSE_OMP=1)
else()
add_definitions(-DUSE_OMP=0)
endif()
add_definitions(-DSIMD_SIZE=32 -DVEC_LEN=32 -DUSE_GPU=0)
endif()
Expand Down
4 changes: 3 additions & 1 deletion advanced_examples/03_scatter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ if( Kokkos_ENABLE_CUDA )
endif()
else()
if( Kokkos_ENABLE_OPENMP )
add_definitions(-fopenmp)
add_definitions(-fopenmp -DUSE_OMP=1)
else()
add_definitions(-DUSE_OMP=0)
endif()
add_definitions(-DSIMD_SIZE=32 -DVEC_LEN=32 -DUSE_GPU=0)
endif()
Expand Down
4 changes: 2 additions & 2 deletions advanced_examples/04_unmanaged_aosoa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ if (("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI") AND ("${CMAKE_CXX_COMPILER_I
set(CMAKE_Fortran_FLAGS "-ta=tesla:cuda9.0 -Minfo=accel -Mcuda=cuda9.0")
set(CMAKE_CXX_FLAGS "--relocatable-device-code=true")
elseif( Kokkos_ENABLE_OPENMP )
target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0)
target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0 -DUSE_OMP=1)
set(CMAKE_Fortran_FLAGS "-ta=multicore -mp")
elseif( Kokkos_ENABLE_SERIAL )
target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0)
target_compile_definitions(ForParallelForUnmanaged PUBLIC -DUSE_GPU=0 -DUSE_OMP=0)
set(CMAKE_Fortran_FLAGS "-ta=host")
endif()

Expand Down
18 changes: 16 additions & 2 deletions advanced_examples/Fortran_features/cabana_fortran_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#define USE_GPU 0
#endif

#ifndef USE_OMP
#define USE_OMP 0
#endif

#if USE_GPU == 1
#define ATTR_DEVICE attributes(device) &
#define ATTR_HOST attributes(host) &
Expand All @@ -24,7 +28,11 @@
#define CABANA_DEF_THREAD_NUM cabana_istat
#define CABANA_GET_THREAD_NUM(x) x=1
#define CABANA_ADD(x,y) cabana_istat=atomicAdd(x,y)
#if USE_OMP == 1
#define CABANA_DEF_MAX_THREADS omp_get_max_threads
#else
#define CABANA_DEF_MAX_THREADS x=1
#endif
#define CABANA_GET_MAX_THREADS(x) x=1


Expand All @@ -44,12 +52,18 @@
#define CABANA_COUNT_KIND


#if USE_OMP == 1
#define CABANA_DEF_THREAD_NUM omp_get_thread_num
#define CABANA_GET_THREAD_NUM(x) x=1+OMP_GET_THREAD_NUM()
#define CABANA_ADD(x,y) x=x+y
#define CABANA_DEF_MAX_THREADS omp_get_max_threads
#define CABANA_GET_MAX_THREADS(x) x=OMP_GET_MAX_THREADS()

#else
#define CABANA_DEF_THREAD_NUM x=1
#define CABANA_GET_THREAD_NUM(x) x=1
#define CABANA_DEF_MAX_THREADS x=1
#define CABANA_GET_MAX_THREADS(x) x=1
#endif
#define CABANA_ADD(x,y) x=x+y

#endif

Expand Down

0 comments on commit 464b636

Please sign in to comment.