diff --git a/CMakeLists.txt b/CMakeLists.txt index 049d39598..f6936e463 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,12 +15,13 @@ endif() project(rocthrust LANGUAGES CXX) #Adding CMAKE_PREFIX_PATH -list( APPEND CMAKE_PREFIX_PATH /opt/rocm/llvm /opt/rocm ) +list( APPEND CMAKE_PREFIX_PATH /opt/rocm/llvm /opt/rocm ${ROCM_PATH} ) # CMake modules list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${HIP_PATH}/cmake /opt/rocm/hip/cmake # FindHIP.cmake + ${ROCM_PATH}/lib/cmake/hip /opt/rocm/lib/cmake/hip # FindHIP.cmake ) # Set a default build type if none was specified @@ -40,9 +41,11 @@ include( ROCMCreatePackage ) include( ROCMInstallTargets ) include( ROCMPackageConfigHelpers ) include( ROCMInstallSymlinks ) +include( ROCMHeaderWrapper ) include( ROCMCheckTargetIds ) include( ROCMClients ) + # Detect compiler support for target ID # This section is deprecated. Please use rocm_check_target_ids for future use. if( CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" ) @@ -84,6 +87,8 @@ option(BUILD_BENCHMARKS "Build benchmarks" OFF) option(DOWNLOAD_ROCPRIM "Download rocPRIM and do not search for rocPRIM package" OFF) option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF) option(ENABLE_UPSTREAM_TESTS "Enable upstream tests" OFF) +#Set the header wrapper ON by default. +option(BUILD_FILE_REORG_BACKWARD_COMPATIBILITY "Build with file/folder reorg with backward compatibility enabled" ON) set(RNG_SEED_COUNT 0 CACHE STRING "Number of true random sequences to test each input size for") set(PRNG_SEEDS 1 CACHE STRING "Seeds of pseudo random sequences to test each input size for") @@ -166,6 +171,20 @@ if(BUILD_BENCHMARKS) add_subdirectory(internal/benchmark) endif() +#Create header wrapper for backward compatibility +if(BUILD_FILE_REORG_BACKWARD_COMPATIBILITY) + rocm_wrap_header_dir( + ${CMAKE_SOURCE_DIR}/thrust + PATTERNS "*.h" + PATTERNS "*.inl" + PATTERN "*.cuh" + PATTERN "*.hpp" + GUARDS SYMLINK WRAPPER + WRAPPER_LOCATIONS rocthrust/include/thrust + OUTPUT_LOCATIONS rocthrust/wrapper/include/thrust + ) +endif( ) + set(THRUST_OPTIONS_DEBUG ${THRUST_OPTIONS_WARNINGS}) set(THRUST_OPTIONS_RELEASE ${THRUST_OPTIONS_WARNINGS}) diff --git a/install b/install index 4c74609af..55ce59a22 100755 --- a/install +++ b/install @@ -18,6 +18,7 @@ function display_help() echo " [-g|--debug] -DCMAKE_BUILD_TYPE=Debug (default is =Release)" echo " [--hip-clang] build library for amdgpu backend using hip-clang" echo " [--address-sanitizer] build with address sanitizer enabled" + echo " [--rm-legacy-include-dir] Remove legacy include dir Packaging added for file/folder reorg backward compatibility" } @@ -34,6 +35,7 @@ run_tests=false rocm_path=/opt/rocm build_relocatable=false build_address_sanitizer=false +build_freorg_bkwdcomp=true # ################################################# # Parameter parsing @@ -42,7 +44,7 @@ build_address_sanitizer=false # check if we have a modern version of getopt that can handle whitespace and long parameters getopt -T if [[ $? -eq 4 ]]; then - GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,clients,debug,hip-clang,test,package,relocatable,address-sanitizer --options hicdtprg -- "$@") + GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,clients,debug,hip-clang,test,package,relocatable,address-sanitizer,rm-legacy-include-dir --options hicdtprg -- "$@") else echo "Need a new version of getopt" exit 1 @@ -94,6 +96,9 @@ while true; do --address-sanitizer) build_address_sanitizer=true shift ;; + --rm-legacy-include-dir) + build_freorg_bkwdcomp=false + shift ;; --) shift ; break ;; *) echo "Unexpected command line parameter received; aborting"; exit 1 @@ -144,11 +149,18 @@ if [[ "${build_address_sanitizer}" == true ]]; then cmake_common_options="$cmake_common_options -DBUILD_ADDRESS_SANITIZER=ON" fi +#Enable backward compatibility wrappers +if [[ "${build_freorg_bkwdcomp}" == true ]]; then + cmake_common_options="${cmake_common_options} -DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=ON" +else + cmake_common_options="${cmake_common_options} -DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF" +fi + if [[ "${build_relocatable}" == true ]]; then CXX=$rocm_path/bin/${compiler} ${cmake_executable} ${cmake_common_options} \ -DCMAKE_INSTALL_PREFIX=${rocm_path} \ -DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hip" \ - -DCMAKE_MODULE_PATH="${rocm_path}/hip/cmake" \ + -DCMAKE_MODULE_PATH="${rocm_path}/lib/cmake/hip ${rocm_path}/hip/cmake" \ -DROCPRIM_ROOT=${rocm_path}/rocprim ${build_test}\ ../../. # or cmake-gui ../. else diff --git a/thrust/CMakeLists.txt b/thrust/CMakeLists.txt index 29af652d2..a41cb2ad5 100644 --- a/thrust/CMakeLists.txt +++ b/thrust/CMakeLists.txt @@ -11,13 +11,22 @@ configure_file( @ONLY ) +#Creat wrapper for generated version file +if(BUILD_FILE_REORG_BACKWARD_COMPATIBILITY) + rocm_wrap_header_file( + "rocthrust_version.hpp" + WRAPPER_LOCATIONS rocthrust/include/thrust + OUTPUT_LOCATIONS rocthrust/wrapper/include/thrust + ) +endif() + # Only header target, does not include dependencies add_library(rocthrust INTERFACE) target_include_directories(rocthrust INTERFACE $ $ - $ + $ ) target_link_libraries(rocthrust @@ -34,7 +43,6 @@ set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) # does not support header-only libraries (INTERFACE targets) rocm_install_targets( TARGETS rocthrust - PREFIX rocthrust ) if(CMAKE_VERSION VERSION_LESS 3.7) # Workaround: old versions of CMake do not support set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar") @@ -46,7 +54,7 @@ rocm_install( DIRECTORY "./" "${PROJECT_BINARY_DIR}/thrust/include/" - DESTINATION rocthrust/include/thrust + DESTINATION include/rocthrust FILES_MATCHING PATTERN "*.h" PATTERN "*.cuh" @@ -57,14 +65,21 @@ rocm_install( PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ) +#Install the wrapper to rocthrust folder. +#So wrapper would be in /opt/rocm-xxx/rocthrust/include/thrust +if (BUILD_FILE_REORG_BACKWARD_COMPATIBILITY) + rocm_install( + DIRECTORY + "${PROJECT_BINARY_DIR}/rocthrust/wrapper/" + DESTINATION rocthrust/ + ) +endif() + include(ROCMExportTargetsHeaderOnly) # Export targets rocm_export_targets_header_only( TARGETS roc::rocthrust - PREFIX rocthrust DEPENDS PACKAGE rocprim NAMESPACE roc:: ) -# Create symlinks -rocm_install_symlink_subdir(rocthrust)