diff --git a/hpvm/CMakeLists.txt b/hpvm/CMakeLists.txt index 809a30cfa52e16f436dac4e22843f4c5a3add3d9..431c042b634af412399ea2a8902592cfe6e37d88 100644 --- a/hpvm/CMakeLists.txt +++ b/hpvm/CMakeLists.txt @@ -7,7 +7,7 @@ message(STATUS "CUDA Architecture: ${CMAKE_CUDA_ARCHITECTURES}") # find_package will use the auxillary cmake/Find*.cmake we provide list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -find_package(CUDNN 7 EXACT REQUIRED) # CUDNN_INCLUDE_PATH, CUDNN_LIBRARY_PATH +find_package(CUDNN 7 EXACT REQUIRED) # CUDNN_INCLUDE_PATH, CUDNN_LIBRARY_DIR and CUDNN::cudnn include_directories(./include/) # find_package will use the auxillary cmake/Find*.cmake we provide diff --git a/hpvm/cmake/FindCUDNN.cmake b/hpvm/cmake/FindCUDNN.cmake index e5a427f0317a6f3b8f7e7b2cc89fd176fd4362dc..bb4918f704a5fe210f0e25e893e1b33335189add 100644 --- a/hpvm/cmake/FindCUDNN.cmake +++ b/hpvm/cmake/FindCUDNN.cmake @@ -10,8 +10,9 @@ # The following are set after configuration is done: # CUDNN_FOUND # CUDNN_INCLUDE_PATH -# CUDNN_LIBRARY_PATH +# CUDNN_LIBRARY_DIR # +# It also provides the IMPORTed target CUDNN::cudnn. include(FindPackageHandleStandardArgs) @@ -45,11 +46,8 @@ endif() find_library(CUDNN_LIBRARY_PATH ${CUDNN_LIBNAME} PATHS ${CUDNN_LIBRARY} PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64) -# Get director from filename ${CUDNN_LIBRARY_PATH} -get_filename_component( - CUDNN_LIBRARY_PATH - "${CUDNN_LIBRARY_PATH}/.." ABSOLUTE -) +# Get directory from filename ${CUDNN_LIBRARY_PATH} +get_filename_component(CUDNN_LIBRARY_DIR "${CUDNN_LIBRARY_PATH}/.." ABSOLUTE) # This version check is from OpenCV repo: https://github.com/opencv/opencv/blob/master/cmake/FindCUDNN.cmake # extract version from the include @@ -80,4 +78,8 @@ find_package_handle_standard_args( VERSION_VAR CUDNN_VERSION ) +add_library(CUDNN::cudnn IMPORTED INTERFACE) +target_include_directories(CUDNN::cudnn SYSTEM INTERFACE "${CUDNN_INCLUDE_PATH}") +target_link_libraries(CUDNN::cudnn INTERFACE "${CUDNN_LIBRARY_PATH}") + mark_as_advanced(CUDNN_ROOT CUDNN_INCLUDE_DIR CUDNN_LIBRARY) diff --git a/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt b/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt index a142d524b69cb605b85c496aa140c806ad258dfd..5652cdf71513ac4d93c3b0ec634f5013153321d8 100644 --- a/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt +++ b/hpvm/projects/hpvm-tensor-rt/CMakeLists.txt @@ -24,8 +24,8 @@ configure_file( # -- Default include directories set( INCLUDES - ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} - ${CUDNN_INCLUDE_PATH} + # Have to add these because of tensor_runtime.ll (see below) + ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDNN_INCLUDE_PATH} ./tensor_runtime/include ${CMAKE_CURRENT_BINARY_DIR}/tensor_runtime/include ./dnn_sources/include ) @@ -39,9 +39,16 @@ add_library(soc_simulator SHARED soc_simulator/promise_timing_model.cpp) target_include_directories(soc_simulator PUBLIC soc_simulator/) # -- Link libraries -find_package(OpenMP REQUIRED) # Provides ${OpenMP_CXX_FLAGS} -set(LINK_DIR CUDNN_LIBRARY_PATH) -set(LINK_LIBS gpu_profiler soc_simulator stdc++fs cudnn curand cublas) +find_package(OpenMP REQUIRED) # Provides ${OpenMP_CXX_FLAGS} and OpenMP::OpenMP_CXX +# This will use the CUDA found by CUDA language support in the root CMake, +# but it exports the CUDA::* targets (used below) so we can freely add libraries to link to. +find_package(CUDAToolkit REQUIRED) +set( + LINK_LIBS + gpu_profiler soc_simulator + CUDA::cublas CUDA::curand CUDNN::cudnn + OpenMP::OpenMP_CXX +) if(USE_GFLAGS) list(APPEND LINK_LIBS gflags) endif() @@ -77,15 +84,14 @@ endforeach() # -- Adding tensor_runtime targets function(add_tensor_runtime target_name) add_library(${target_name} SHARED ${RUNTIME_SRCS}) - set_property(TARGET ${target_name} PROPERTY CUDA_ARCHITECTURES 60) + set_target_properties(${target_name} PROPERTIES CUDA_ARCHITECTURES 60) target_compile_options( ${target_name} PRIVATE --expt-relaxed-constexpr -maxrregcount 32 -Xcompiler=${OpenMP_CXX_FLAGS} $<$<CONFIG:DEBUG>:-lineinfo -Xcompiler=-ggdb> ) target_include_directories(${target_name} PUBLIC ${INCLUDES}) - target_link_directories(${target_name} PUBLIC ${LINK_DIR}) - target_link_libraries(${target_name} PUBLIC ${LINK_LIBS} ${OpenMP_CXX_FLAGS}) + target_link_libraries(${target_name} PUBLIC ${LINK_LIBS}) target_compile_definitions(${target_name} PRIVATE ${DEFS} ${ARGN}) endfunction(add_tensor_runtime) diff --git a/hpvm/tools/py-approxhpvm/CMakeLists.txt b/hpvm/tools/py-approxhpvm/CMakeLists.txt index f93f96dd0578a67630cc859bba2e24e071b39299..d751823a08662aa927b4f5af6f2c6350a816a6a1 100644 --- a/hpvm/tools/py-approxhpvm/CMakeLists.txt +++ b/hpvm/tools/py-approxhpvm/CMakeLists.txt @@ -21,8 +21,8 @@ set( LLVMClearDFG LLVMGenHPVM ) -# CUDA_TOOLKIT_ROOT_DIR and CUDNN_LIBRARY_PATH has been defined globally -set(CUDNN_DIR ${CUDNN_LIBRARY_PATH}) +# CUDA_TOOLKIT_ROOT_DIR and CUDNN_LIBRARY_DIR has been defined globally +set(CUDNN_DIR ${CUDNN_LIBRARY_DIR}) # First resolve all `@symbol@` by configuring the file configure_file(main.py.in ${CMAKE_CURRENT_BINARY_DIR}/main.py.conf) # Then resolve all generator expressions we configured into the previous file