Package test update
MODIFY
.gitlab-ci.yml
.gitlab-ci.yml
@@ -58,7 +58,7 @@ build:rocm:
# CXX=hcc cmake -DBUILD_TEST=ON -DBUILD_EXAMPLE=ON -DBUILD_BENCHMARK=ON ../.
- CXX=hcc cmake -DBUILD_TEST=ON ../.
- make -j16
- # - make package
+ - make package
artifacts:
paths:
- build/library/
@@ -82,3 +82,49 @@ build:rocm:
- $SUDO_CMD ctest --output-on-failure --repeat-until-fail 2
include: '.gitlab-ci-gputest.yml'
+
+# test:rocm_package:
+# stage: test
+# tags:
+# - rocm
+# variables:
+# SUDO_CMD: "sudo -E"
+# dependencies:
+# - build:rocm
+# script:
+# # Install rocPRIM package
+# - echo ${ROCPRIM_GIT_URL}
+# - echo $ROCPRIM_GIT_URL
+# - git clone -b develop_thrust_stream https://gitlab-ci-token:${CI_JOB_TOKEN}@${ROCPRIM_GIT_URL}
+# - cd rocPRIM
+# - mkdir build
+# - cd build
+# - CXX=hcc cmake -DBUILD_TEST=OFF ../.
+# - make package
+# - $SUDO_CMD dpkg -i rocprim-*.deb
+# - cd ../..
+# # rocThrust
+# - cd build
+# - $SUDO_CMD dpkg -i rocthrust-*.deb
+# - mkdir ../package_test && cd ../package_test
+# - CXX=hcc cmake ../extra/. -Drocprim_DIR="/opt/rocm/rocprim"
+# - make VERBOSE=1
+# - $SUDO_CMD ctest --output-on-failure --repeat-until-fail 2
+# - $SUDO_CMD dpkg -r rocthrust
+# - $SUDO_CMD dpkg -r rocprim
+
+test:rocm_install:
+ stage: test
+ tags:
+ - rocm
+ variables:
+ SUDO_CMD: "sudo -E"
+ script:
+ - mkdir build_only_install
+ - cd build_only_install
+ - CXX=hcc cmake -DBUILD_TEST=OFF ../.
+ - $SUDO_CMD make install
+ - mkdir ../install_test && cd ../install_test
+ - CXX=hcc cmake ../extra/.
+ - make VERBOSE=1
+ - $SUDO_CMD ctest --output-on-failure --repeat-until-fail 2

MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -62,13 +62,13 @@ option(BUILD_TEST "Build tests" ON)
# Get dependencies
include(cmake/Dependencies.cmake)
+# AMD targets
+set(AMDGPU_TARGETS gfx803;gfx900;gfx906 CACHE STRING "List of specific machine types for library to target")
+
# Print configuration summary
include(cmake/Summary.cmake)
print_configuration_summary()
-# AMD targets
-set(AMDGPU_TARGETS gfx803;gfx900;gfx906 CACHE STRING "List of specific machine types for library to target")
-
# Thrust (with HIP backend)
add_subdirectory(thrust)

ADD
extra/CMakeLists.txt
+# MIT License
+#
+# Copyright (c) 2019 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.
+
+cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
+
+# This project includes tests that should be run after
+# rocThrust is installed from package or using `make install`
+project(rocThrust_package_install_test CXX)
+
+# CMake modules
+list(APPEND CMAKE_MODULE_PATH
+ ${CMAKE_CURRENT_SOURCE_DIR}/../cmake
+ ${HIP_PATH}/cmake /opt/rocm/hip/cmake # FindHIP.cmake
+)
+
+# Verify that hcc compiler is used on ROCM platform
+include(VerifyCompiler)
+include(DownloadProject)
+
+# Download rocPRIM (only for ROCm platform)
+if(HIP_PLATFORM STREQUAL "hcc")
+ if(NOT DEFINED rocprim_DIR)
+ message(STATUS "Downloading and building rocPRIM.")
+ set(rocprim_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocprim" CACHE PATH "")
+ download_project(
+ PROJ rocprim
+ GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/rocPRIM.git
+ GIT_TAG develop
+ INSTALL_DIR ${rocprim_DIR}
+ CMAKE_ARGS -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+ LOG_DOWNLOAD TRUE
+ LOG_CONFIGURE TRUE
+ LOG_BUILD TRUE
+ LOG_INSTALL TRUE
+ BUILD_PROJECT TRUE
+ ${UPDATE_DISCONNECTED_IF_AVAILABLE}
+ )
+ endif()
+ find_package(rocprim REQUIRED CONFIG PATHS "${rocprim_DIR}")
+endif()
+
+# Find rocThrust
+find_package(rocthrust REQUIRED CONFIG HINTS ${rocthrust_DIR} PATHS "/opt/rocm/rocthrust")
+
+# Build CXX flags
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
+
+# AMD targets
+set(AMDGPU_TARGETS gfx803;gfx900;gfx906 CACHE STRING "List of specific machine types for library to target")
+
+# Enable testing (ctest)
+enable_testing()
+
+function(add_rocthrust_test TEST_NAME TEST_SOURCES)
+ list(GET TEST_SOURCES 0 TEST_MAIN_SOURCE)
+ get_filename_component(TEST_TARGET ${TEST_MAIN_SOURCE} NAME_WE)
+ add_executable(${TEST_TARGET} ${TEST_SOURCES})
+ target_link_libraries(${TEST_TARGET}
+ PRIVATE
+ rocthrust
+ )
+ foreach(amdgpu_target ${AMDGPU_TARGETS})
+ target_link_libraries(${TEST_TARGET}
+ PRIVATE
+ --amdgpu-target=${amdgpu_target}
+ )
+ endforeach()
+ # Set HIP as device system for Thrust
+ target_compile_definitions(${TEST_TARGET}
+ PRIVATE
+ THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP
+ )
+ add_test(${TEST_NAME} ${TEST_TARGET})
+endfunction()
+
+# rocThrust package test
+add_rocthrust_test("test_rocthrust_package" test_rocthrust_package.cpp)

ADD
extra/test_rocthrust_package.cpp
+#include <thrust/version.h>
+#include <thrust/rocthrust_version.hpp>
+#include <thrust/transform.h>
+#include <thrust/execution_policy.h>
+#include <thrust/device_vector.h>
+#include <thrust/host_vector.h>
+
+#include <iostream>
+
+template<class T>
+struct unary_transform
+{
+ __device__ __host__ inline
+ constexpr T operator()(const T& a) const
+ {
+ return a + 5;
+ }
+};
+
+int main(void)
+{
+ int major = THRUST_MAJOR_VERSION;
+ int minor = THRUST_MINOR_VERSION;
+
+ std::cout << "Thrust v" << major << "." << minor << std::endl;
+
+ major = ROCTHRUST_VERSION_MAJOR;
+ minor = ROCTHRUST_VERSION_MINOR;
+
+ std::cout << "rocThrust v" << major << "." << minor << std::endl;
+
+ using T = int;
+ using U = long;
+
+ size_t size = 1<<16;
+ thrust::host_vector<T> h_input(size);
+ for(size_t i = 0; i < size; i++)
+ {
+ h_input[i] = i;
+ }
+
+ // Calculate expected results on host
+ thrust::host_vector<U> expected(size);
+ thrust::transform(h_input.begin(), h_input.end(), expected.begin(), unary_transform<U>());
+
+ thrust::device_vector<T> d_input(h_input);
+ thrust::device_vector<U> d_output(size);
+ thrust::transform(d_input.begin(), d_input.end(), d_output.begin(), unary_transform<U>());
+
+ thrust::host_vector<U> h_output = d_output;
+ for(size_t i = 0; i < size; i++)
+ {
+ if(h_output[i] != expected[i])
+ {
+ std::cout
+ << "Failure: output (" << h_output[i]
+ << ") != expected (" << expected[i] << ")"
+ << " at index:" << i
+ << std::endl;
+ return 1;
+ }
+ }
+
+ return 0;
+}

MODIFY
testing/CMakeLists.txt
testing/CMakeLists.txt
@@ -57,7 +57,7 @@ endfunction()
# Tests
# ****************************************************************************
-# add_thrust_test("adjacent_difference")
+add_thrust_test("adjacent_difference")
add_thrust_test("advance")
add_thrust_test("allocator")
add_thrust_test("binary_search")

MODIFY
thrust/CMakeLists.txt
thrust/CMakeLists.txt
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-# Only header target, does not include dependencies
+# rocThrust header-only library
# 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"
+ "${CMAKE_CURRENT_BINARY_DIR}/include/rocthrust_version.hpp"
@ONLY
)
@@ -35,13 +35,13 @@ target_include_directories(rocthrust
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
- $<INSTALL_INTERFACE:rocthrust/include>
+ $<INSTALL_INTERFACE:rocthrust/include/>
)
target_link_libraries(rocthrust
INTERFACE
roc::rocprim_hip
- hip::device
+# hip::device
)
# TODO: Remove after the Rocprim HC API removal
@@ -54,6 +54,7 @@ target_compile_definitions(rocthrust
# Installation
include(GNUInstallDirs)
+set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
# We need to install headers manually as rocm_install_targets
# does not support header-only libraries (INTERFACE targets)
@@ -68,7 +69,8 @@ rocm_install_targets(
install(
DIRECTORY
"./"
- DESTINATION ${CMAKE_INSTALL_PREFIX}/rocthrust/include/thrust/
+ "${PROJECT_BINARY_DIR}/thrust/include/"
+ DESTINATION rocthrust/include/thrust/
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.cuh"

MODIFY
thrust/rocthrust_version.hpp.in
thrust/rocthrust_version.hpp.in
///
/// 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 @thrust_VERSION_MAJOR@ * 100000 + @thrust_VERSION_MINOR@ * 100 + @thrust_VERSION_PATCH@
-#define ROCTHRUST_VERSION_MAJOR @rocthrust_VERSION_MAJOR@
-#define ROCTHRUST_VERSION_MINOR @rocthrust_VERSION_MINOR@
-#define ROCTHRUST_VERSION_PATCH @rocthrust_VERSION_PATCH@
+#define ROCTHRUST_VERSION_MAJOR @thrust_VERSION_MAJOR@
+#define ROCTHRUST_VERSION_MINOR @thrust_VERSION_MINOR@
+#define ROCTHRUST_VERSION_PATCH @thrust_VERSION_PATCH@
#endif // ROCTHRUST_VERSION_HPP_

Package test update