Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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$" )
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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})

Expand Down
16 changes: 14 additions & 2 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand All @@ -34,6 +35,7 @@ run_tests=false
rocm_path=/opt/rocm
build_relocatable=false
build_address_sanitizer=false
build_freorg_bkwdcomp=true

# #################################################
# Parameter parsing
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 21 additions & 6 deletions thrust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:rocthrust/include/>
$<INSTALL_INTERFACE:include/>
)

target_link_libraries(rocthrust
Expand All @@ -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")
Expand All @@ -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"
Expand All @@ -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)