From 83e18cc9c3de8f2f9c48b663cf3189361e891054 Mon Sep 17 00:00:00 2001 From: Richard Geslot Date: Thu, 5 Sep 2024 17:56:58 +0200 Subject: [PATCH] update cmake from latest internal repo --- CMakeLists.txt | 100 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2b980c..5dd3008 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(hiprt) # Options -option(BAKE_KERNEL "enable the use of encrypted and baked kernels" OFF) +option(BAKE_KERNEL "Enable the use of encrypted and baked kernels" OFF) option(BITCODE "Enable bitcode linking" OFF) option(PRECOMPILE "Precompile kernels" OFF) option(HIPRTEW "Use hiprtew" OFF) @@ -31,6 +31,9 @@ add_definitions(-DGTEST_HAS_TR1_TUPLE=0) + + + # Functions function(copy_dir src_dir dst_dir pattern) file(GLOB_RECURSE files "${src_dir}/${pattern}") @@ -252,8 +255,13 @@ endif() add_definitions(-D__USE_HIP__) +# this define is to identify that we are on the public repository of HIPRT. +# it helps AMD to maintain both a public and a private repo for experimentation. +add_definitions(-DHIPRT_PUBLIC_REPO) + + # Enable CUDA if possible -include(${CMAKE_SOURCE_DIR}/contrib/Orochi/Orochi/enable_cuew.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/Orochi/enable_cuew.cmake) @@ -282,8 +290,8 @@ endif() # Write version info set(version_str_ "UNDEF") -write_version_info("${CMAKE_SOURCE_DIR}/hiprt/hiprt.h.in" "${CMAKE_SOURCE_DIR}/hiprt/hiprt.h" "${CMAKE_SOURCE_DIR}/version.txt" version_str_) -write_version_info("${CMAKE_SOURCE_DIR}/hiprt/hiprtew.h.in" "${CMAKE_SOURCE_DIR}/hiprt/hiprtew.h" "${CMAKE_SOURCE_DIR}/version.txt" version_str_) +write_version_info("${CMAKE_CURRENT_SOURCE_DIR}/hiprt/hiprt.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/hiprt.h" "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" version_str_) +write_version_info("${CMAKE_CURRENT_SOURCE_DIR}/hiprt/hiprtew.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/hiprtew.h" "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" version_str_) set(HIPRT_NAME "hiprt${version_str_}") @@ -321,13 +329,13 @@ endif() if(PRECOMPILE) execute_process( COMMAND python compile.py --nvidia --hipSdkPath ${HIP_PATH} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/scripts/bitcodes + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/bitcodes ) if(NOT NO_UNITTEST) execute_process( COMMAND python precompile_bitcode.py --nvidia --hipSdkPath ${HIP_PATH} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/scripts/bitcodes + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/bitcodes ) endif() @@ -337,32 +345,46 @@ endif() if(BAKE_KERNEL OR GENERATE_BAKE_KERNEL) message(">> BakeKernel Executed") if(WIN32) - execute_process(COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/hiprt/cache) - execute_process(COMMAND ${CMAKE_SOURCE_DIR}/tools/bakeKernel.bat) + execute_process( + COMMAND mkdir -p ${CMAKE_CURRENT_SOURCE_DIR}/hiprt/cache + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + execute_process( + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/bakeKernel.bat + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) else() - execute_process(COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/hiprt/cache) - execute_process(COMMAND ${CMAKE_SOURCE_DIR}/tools/bakeKernel.sh) + execute_process( + COMMAND mkdir -p ${CMAKE_CURRENT_SOURCE_DIR}/hiprt/cache + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + execute_process( + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/bakeKernel.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) endif() - if(BAKE_KERNEL) - target_compile_definitions(${HIPRT_NAME} PRIVATE HIPRT_LOAD_FROM_STRING ORO_PP_LOAD_FROM_STRING) - endif() - target_compile_definitions(${HIPRT_NAME} PRIVATE HIPRT_BAKE_KERNEL_GENERATED) - + +endif() + +if(BAKE_KERNEL) + target_compile_definitions(${HIPRT_NAME} PRIVATE HIPRT_LOAD_FROM_STRING ORO_PP_LOAD_FROM_STRING) endif() + + if(WIN32) target_link_libraries(${HIPRT_NAME} version) endif() -target_include_directories(${HIPRT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}) -target_include_directories(${HIPRT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/contrib/Orochi) +target_include_directories(${HIPRT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(${HIPRT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi) -file(GLOB_RECURSE hiprt_sources "${CMAKE_SOURCE_DIR}/hiprt/*.h" "${CMAKE_SOURCE_DIR}/hiprt/*.cpp" "${CMAKE_SOURCE_DIR}/hiprt/*.inl") +file(GLOB_RECURSE hiprt_sources "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/*.inl") list(FILTER hiprt_sources EXCLUDE REGEX "hiprt/bitcodes/.*") -file(GLOB_RECURSE orochi_sources "${CMAKE_SOURCE_DIR}/contrib/Orochi/Orochi/*.h" "${CMAKE_SOURCE_DIR}/contrib/Orochi/Orochi/*.cpp" "${CMAKE_SOURCE_DIR}/contrib/Orochi/contrib/cuew/*.h" "${CMAKE_SOURCE_DIR}/contrib/Orochi/contrib/cuew/*.cpp" "${CMAKE_SOURCE_DIR}/contrib/Orochi/contrib/hipew/*.h" "${CMAKE_SOURCE_DIR}/contrib/Orochi/contrib/hipew/*.cpp" "${CMAKE_SOURCE_DIR}/contrib/Orochi/ParallelPrimitives/*.h" "${CMAKE_SOURCE_DIR}/contrib/Orochi/ParallelPrimitives/*.cpp") +file(GLOB_RECURSE orochi_sources "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/Orochi/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/Orochi/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/contrib/cuew/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/contrib/cuew/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/contrib/hipew/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/contrib/hipew/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/ParallelPrimitives/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/ParallelPrimitives/*.cpp") target_sources(${HIPRT_NAME} PRIVATE ${hiprt_sources} ${orochi_sources}) @@ -375,10 +397,20 @@ target_sources(${HIPRT_NAME} PRIVATE ${hiprt_sources} ${orochi_sources}) install(TARGETS ${HIPRT_NAME} DESTINATION bin) # add header files -file(GLOB HIPRT_HEADERS "${CMAKE_SOURCE_DIR}/hiprt/*.h") +file(GLOB HIPRT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/*.h") install(FILES ${HIPRT_HEADERS} DESTINATION include/hiprt) +# add header files from implementation folder +file(GLOB HIPRT_IMPL_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/hiprt/impl/*.h") +install(FILES ${HIPRT_IMPL_HEADERS} + DESTINATION include/hiprt/impl) + +# add some header files from Orochi +file(GLOB HIPRT_ORO_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/ParallelPrimitives/*.h") +install(FILES ${HIPRT_ORO_HEADERS} + DESTINATION include/contrib/Orochi/ParallelPrimitives) + # add hipfb files file(GLOB HIPRT_HIPFB_FILES "${BASE_OUTPUT_DIR}/${CMAKE_BUILD_TYPE}/*.hipfb") install(FILES ${HIPRT_HIPFB_FILES} @@ -407,40 +439,40 @@ if(NOT NO_UNITTEST) endif() - target_include_directories(unittest PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/contrib/Orochi) + target_include_directories(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi) target_link_libraries(unittest PRIVATE ${HIPRT_NAME}) if(UNIX) target_link_libraries(unittest PRIVATE pthread dl) endif() - file(GLOB_RECURSE unittest_sources "${CMAKE_SOURCE_DIR}/test/hiprtT*.h" "${CMAKE_SOURCE_DIR}/test/hiprtT*.cpp" "${CMAKE_SOURCE_DIR}/test/shared.h" "${CMAKE_SOURCE_DIR}/test/main.cpp" "${CMAKE_SOURCE_DIR}/test/CornellBox.h" "${CMAKE_SOURCE_DIR}/test/kernels/*.h" "${CMAKE_SOURCE_DIR}/contrib/gtest-1.6.0/gtest-all.cc") + file(GLOB_RECURSE unittest_sources "${CMAKE_CURRENT_SOURCE_DIR}/test/hiprtT*.h" "${CMAKE_CURRENT_SOURCE_DIR}/test/hiprtT*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/test/shared.h" "${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/test/CornellBox.h" "${CMAKE_CURRENT_SOURCE_DIR}/test/kernels/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/gtest-1.6.0/gtest-all.cc") target_sources(unittest PRIVATE ${unittest_sources} ${orochi_sources}) - target_include_directories(unittest PRIVATE ${CMAKE_SOURCE_DIR}/contrib/gtest-1.6.0 ${CMAKE_SOURCE_DIR}/contrib/embree/include) + target_include_directories(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/gtest-1.6.0 ${CMAKE_CURRENT_SOURCE_DIR}/contrib/embree/include) if(WIN32) # Use target_link_directories to specify additional library directories - target_link_directories(unittest PRIVATE ${CMAKE_SOURCE_DIR}/contrib/embree/win) - target_link_directories(unittest PRIVATE ${CMAKE_SOURCE_DIR}/contrib/bin/win64) + target_link_directories(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/embree/win) + target_link_directories(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/bin/win64) - copy_dir(${CMAKE_SOURCE_DIR}/contrib/embree/win ${CMAKE_SOURCE_DIR}/dist/bin/Release "*.dll") - copy_dir(${CMAKE_SOURCE_DIR}/contrib/embree/win ${CMAKE_SOURCE_DIR}/dist/bin/Debug "*.dll") - copy_dir(${CMAKE_SOURCE_DIR}/contrib/Orochi/contrib/bin/win64 ${CMAKE_SOURCE_DIR}/dist/bin/Release "*.dll") - copy_dir(${CMAKE_SOURCE_DIR}/contrib/Orochi/contrib/bin/win64 ${CMAKE_SOURCE_DIR}/dist/bin/Debug "*.dll") + copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/contrib/embree/win ${CMAKE_CURRENT_SOURCE_DIR}/dist/bin/Release "*.dll") + copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/contrib/embree/win ${CMAKE_CURRENT_SOURCE_DIR}/dist/bin/Debug "*.dll") + copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/contrib/bin/win64 ${CMAKE_CURRENT_SOURCE_DIR}/dist/bin/Release "*.dll") + copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi/contrib/bin/win64 ${CMAKE_CURRENT_SOURCE_DIR}/dist/bin/Debug "*.dll") # Explicitly link libraries from contrib/embree/win and contrib/bin/win64 - target_link_libraries(unittest PRIVATE ${CMAKE_SOURCE_DIR}/contrib/embree/win/embree4.lib) + target_link_libraries(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/embree/win/embree4.lib) endif() if(UNIX) - target_link_directories(unittest PRIVATE ${CMAKE_SOURCE_DIR}/contrib/embree/linux) + target_link_directories(unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/embree/linux) endif() target_link_libraries(unittest PRIVATE embree4 tbb) @@ -458,15 +490,15 @@ if(HIPRTEW) target_link_libraries(hiprtewtest PRIVATE version) endif() - target_include_directories(hiprtewtest PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/contrib/Orochi) + target_include_directories(hiprtewtest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Orochi) if(UNIX) target_link_libraries(hiprtewtest PRIVATE pthread dl) endif() - file(GLOB_RECURSE hiprtewtest_sources "${CMAKE_SOURCE_DIR}/test/hiprtewTest.h" "${CMAKE_SOURCE_DIR}/test/hiprtewTest.cpp" "${CMAKE_SOURCE_DIR}/contrib/gtest-1.6.0/gtest-all.cc") + file(GLOB_RECURSE hiprtewtest_sources "${CMAKE_CURRENT_SOURCE_DIR}/test/hiprtewTest.h" "${CMAKE_CURRENT_SOURCE_DIR}/test/hiprtewTest.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/gtest-1.6.0/gtest-all.cc") target_sources(hiprtewtest PRIVATE ${hiprtewtest_sources} ${orochi_sources}) - target_include_directories(hiprtewtest PRIVATE ${CMAKE_SOURCE_DIR}/contrib/gtest-1.6.0) + target_include_directories(hiprtewtest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/gtest-1.6.0) target_compile_definitions(hiprtewtest PRIVATE GTEST_HAS_TR1_TUPLE=0) endif()