Rocm cmake package
MODIFY
CMakeLists.txt
CMakeLists.txt
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
+# Install prefix
+if(WIN32)
+ set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/package)
+else()
+ set(CMAKE_INSTALL_PREFIX /opt/rocm)
+endif()
+
+# Thrust project
project(thrust VERSION 0.0.1.0 LANGUAGES CXX)
# CMake modules
@@ -72,8 +80,9 @@ if(BUILD_TEST)
endif()
# Package
-set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_hcc (>= 1.5.18263)") # 1.5.18263 is HIP version in ROCm 1.8.2
-set(CPACK_RPM_PACKAGE_REQUIRES "hip_hcc >= 1.5.18263")
+set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar")
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_hcc (>= 1.5.18263), rocprim (>= 1.0)") # 1.5.18263 is HIP version in ROCm 1.8.2
+set(CPACK_RPM_PACKAGE_REQUIRES "hip_hcc >= 1.5.18263, rocprim >= 1.0")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
@@ -82,13 +91,7 @@ endif()
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "\${CPACK_PACKAGING_INSTALL_PREFIX}" "\${CPACK_PACKAGING_INSTALL_PREFIX}/include")
rocm_create_package(
- NAME thrust
+ NAME rocthrust
DESCRIPTION "Radeon Open Compute Thrust library"
- MAINTAINER "Stream HPC Maintainers <maintainer@streamhpc.com>"
-)
-
-rocm_install_targets(
- INCLUDE
- ${CMAKE_SOURCE_DIR}/thrust/
- PREFIX thrust
+ MAINTAINER "Saad Rahim <saad.rahim@amd.com>"
)

MODIFY
thrust/CMakeLists.txt
thrust/CMakeLists.txt
# SOFTWARE.
# Only header target, does not include dependencies
-add_library(thrust_headers INTERFACE)
-target_include_directories(thrust_headers
+
+# Configure a header file to pass the rocThrust version
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/rocthrust_version.hpp.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/rocthrust_version.hpp"
+ @ONLY
+)
+
+# 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>
)
-add_library(rocthrust INTERFACE)
target_link_libraries(rocthrust
INTERFACE
- thrust_headers
- hcc::hccrt
- hcc::hc_am
+ roc::rocprim_hip
+ hip::device
)
-# Remove this check when we no longer build with older rocm stack(ie < 1.8.2)
-if(TARGET hip::device)
- target_link_libraries(rocthrust INTERFACE hip::device)
-else()
- target_link_libraries(rocthrust INTERFACE hip::hip_hcc hip::hip_device)
-endif()
+# TODO: Remove after the Rocprim HC API removal
# We will use rocPRIM HIP API
target_compile_definitions(rocthrust
INTERFACE
ROCPRIM_HIP_API=1
)
+
+# Installation
+
+include(GNUInstallDirs)
+
+# We need to install headers manually as rocm_install_targets
+# does not support header-only libraries (INTERFACE targets)
+rocm_install_targets(
+ TARGETS rocthrust
+ EXPORT rocthrust-targets
+# INCLUDE
+# ${CMAKE_SOURCE_DIR}/thrust
+# ${CMAKE_BINARY_DIR}/thrust
+ PREFIX rocthrust
+)
+install(
+ DIRECTORY
+ "./"
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/rocthrust/include/thrust/
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN "*.cuh"
+ PATTERN "*.hpp"
+ PATTERN "*.in"
+ PATTERN "*.inl"
+ PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
+)
+
+# Export targets
+rocm_export_targets(
+ TARGETS rocthrust-targets
+ NAME rocthrust
+ PREFIX rocthrust
+)
+
+# TODO: Add symlinks later
+# Create symlinks
+# rocm_install_symlink_subdir(rocthrust)

ADD
thrust/rocthrust_version.hpp.in
+// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#ifndef ROCTHRUST_VERSION_HPP_
+#define ROCTHRUST_VERSION_HPP_
+
+/// \def ROCTHRUST_VERSION
+/// \brief ROCTHRUST library version
+///
+/// Version number may not be visible in the documentation.
+///
+/// ROCTHRUST_VERSION % 100 is the patch level,
+/// ROCTHRUST_VERSION / 100 % 1000 is the minor version,
+/// ROCTHRUST_VERSION / 100000 is the major version.
+///
+/// For example, if ROCTHRUST_VERSION is 100500, then the major version is 1,
+/// the minor version is 5, and the patch level is 0.
+#define ROCTHRUST_VERSION @rocthrust_VERSION_MAJOR@ * 100000 + @rocthrust_VERSION_MINOR@ * 100 + @rocthrust_VERSION_PATCH@
+
+#define ROCTHRUST_VERSION_MAJOR @rocthrust_VERSION_MAJOR@
+#define ROCTHRUST_VERSION_MINOR @rocthrust_VERSION_MINOR@
+#define ROCTHRUST_VERSION_PATCH @rocthrust_VERSION_PATCH@
+
+#endif // ROCTHRUST_VERSION_HPP_

Rocm cmake package