NVIDIA / AMGX

Distributed multigrid linear solver library on GPU
479 stars 139 forks source link

CMAKE cannot find OpenMP_C #238

Closed lavenklau closed 1 year ago

lavenklau commented 1 year ago

Hi! I am configuring AMGX with CMAKE, but it tells me that it cannot find OpenMP_C, here is my output information

Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
The C compiler identification is MSVC 19.35.32215.0
The CXX compiler identification is MSVC 19.35.32215.0
The CUDA compiler identification is NVIDIA 12.1.66
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Detecting CUDA compiler ABI info
Detecting CUDA compiler ABI info - done
Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/bin/nvcc.exe - skipped
Detecting CUDA compile features
Detecting CUDA compile features - done
Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS) 
Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS) 
Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND) 
Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include (found suitable version "12.1.66", minimum required is "10.0") 
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
This is a MPI build:FALSE
CMake Deprecation Warning at thrust/CMakeLists.txt:9 (cmake_policy):
  The OLD behavior for policy CMP0104 will be removed from a future version
  of CMake.
  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

Found Thrust: C:/Users/xxx/source/AMGX/AMGX/thrust/thrust/cmake/thrust-config.cmake (found version "1.17.0.0") 
Found CUB: C:/Users/xxx/source/AMGX/AMGX/thrust/dependencies/cub/cub/cmake/cub-config.cmake (found suitable version "1.17.0.0", minimum required is "1.17.0.0") 
Configuring done (9.4s)

However in a test project, the OpenMP library can be found :

cmake_minimum_required (VERSION 3.18)
project (AMG LANGUAGES C CXX)
find_package(OpenMP REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test OpenMP::OpenMP_C)

and the output is

Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
The C compiler identification is MSVC 19.35.32215.0
The CXX compiler identification is MSVC 19.35.32215.0
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Found OpenMP_C: -openmp (found version "2.0") 
Found OpenMP_CXX: -openmp (found version "2.0") 
Found OpenMP: TRUE (found version "2.0")  
Configuring done (4.0s)

The version of my cmake is 3.26, and I use Visual Studio 2019 as the generator. Does any one know how to fix this problem? Thanks a lot!

lavenklau commented 1 year ago

OK, I found that putting the line find_package(OpenMP) after set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" ${CMAKE_MODULE_PATH}) in CMakeLists works for me.