-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from HappySeaFox/feature/openmp
Feature/openmp
- Loading branch information
Showing
5 changed files
with
236 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Intended to be included by SAIL. | ||
# | ||
function(sail_check_openmp) | ||
# This may require setting OpenMP_ROOT on macOS | ||
# | ||
find_package(OpenMP COMPONENTS C) | ||
|
||
if (OpenMP_FOUND) | ||
# We want OpenMP 3.0 to support unsigned integers in loops. | ||
# The default OpenMP implementation in MSVC 2022 still supports 2.0, | ||
# so switch to the LLVM option with OpenMP 3.1. | ||
# | ||
if (MSVC) | ||
set(SAIL_OPENMP_FLAGS "/openmp:llvm" CACHE INTERNAL "") | ||
else() | ||
set(SAIL_OPENMP_FLAGS ${OpenMP_C_FLAGS} CACHE INTERNAL "") | ||
endif() | ||
|
||
set(SAIL_OPENMP_INCLUDE_DIRS ${OpenMP_C_INCLUDE_DIRS} CACHE INTERNAL "") | ||
|
||
# Build a list of direct paths to libraries. This is needed on macOS with brew specifically | ||
# as the installed libomp version lays in /usr/local/opt/libomp and is not globally visible. | ||
# | ||
foreach(lib IN LISTS OpenMP_C_LIB_NAMES) | ||
set(SAIL_OPENMP_LIBS ${SAIL_OPENMP_LIBS} "${OpenMP_${lib}_LIBRARY}" CACHE INTERNAL "") | ||
endforeach() | ||
|
||
# Try to compile a sample program to make sure the compiler | ||
# supports at least OpenMP 3.0 with unsigned integers in for loops. | ||
# | ||
cmake_push_check_state(RESET) | ||
set(CMAKE_REQUIRED_FLAGS ${SAIL_OPENMP_FLAGS}) | ||
set(CMAKE_REQUIRED_INCLUDES ${SAIL_OPENMP_INCLUDE_DIRS}) | ||
set(CMAKE_REQUIRED_LIBRARIES ${SAIL_OPENMP_LIBS}) | ||
|
||
check_c_source_compiles( | ||
" | ||
#include <stdio.h> | ||
int main(int argc, char *argv[]) { | ||
unsigned i; | ||
#pragma omp parallel for | ||
for (i = 0; i < 10; i++) { | ||
printf(\"%d\", i); | ||
} | ||
return 0; | ||
} | ||
" | ||
SAIL_HAVE_OPENMP | ||
) | ||
cmake_pop_check_state() | ||
endif() | ||
|
||
if (SAIL_HAVE_OPENMP) | ||
set(SAIL_HAVE_OPENMP_DISPLAY ON CACHE INTERNAL "") | ||
else() | ||
set(SAIL_HAVE_OPENMP_DISPLAY OFF CACHE INTERNAL "") | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.