File rocthrust.spec of Package rocthrust
%global upstreamname rocThrust
%global rocm_release 6.2
%global rocm_patch 0
%global rocm_version %{rocm_release}.%{rocm_patch}
# rocPRIM version
%define rocthrust_version 3.1.0
# Compiler is hipcc, which is clang based:
%global toolchain clang
# hipcc does not support some clang flags
%global build_cxxflags %(echo %{optflags} | sed -e 's/-fstack-protector-strong/-Xarch_host -fstack-protector-strong/' -e 's/-fcf-protection/-Xarch_host -fcf-protection/') -Wdeprecated-declarations
# there is no debug package
%global debug_package %{nil}
# Option to build the test suite
%bcond_without test
# Option to run the test suite for testing on real HW:
%bcond_with check
Name: rocthrust
Version: %{rocm_version}
Release: 0
Summary: ROCm Thrust libary
Url: https://github.com/ROCm
License: Apache-2.0 and BSD-2-Clause and BSD-3-Clause and MIT and Public Domain
# All files are Apache 2.0 with some exceptions:
# ./cmake contains only files under MIT
# ./internal/benchmark/*.py are dual licensed Apache 2.0 and Boost 1.0
# ./thrust/ contain some headers files that are Boost 1.0 licensed
# ./thrust/ contain some headers that are dual Apache 2.0 and Boost 1.0
# ./thrust/cmake/FindTBB.cmake is public domain
# ./thrust/detail/allocator/allocator_traits.h is dual Apache 2.0 and MIT
# ./thrust/detail/complex contains BSD 2 clause licensed headers
Source0: %{url}/%{upstreamname}/archive/refs/tags/rocm-%{version}.tar.gz#/%{upstreamname}-rocm-%{version}.tar.gz
BuildRequires: cmake
BuildRequires: ninja
BuildRequires: rocm-cmake
BuildRequires: rocm-comgr-devel
BuildRequires: rocm-hip-devel
BuildRequires: rocm-release(rocprim-headers) = %{rocm_release}
BuildRequires: rocm-runtime-devel
BuildRequires: rocm-rpm-macros
%if 0%{?sle_version} == 150600
BuildRequires: gcc12-c++
BuildRequires: libstdc++6-devel-gcc12
%else
BuildRequires: libstdc++-devel
%endif
%if %{with check} || %{with test}
BuildRequires: googletest-devel
%endif
# Only headers, cmake infra, noarch confuses libdir
# BuildArch: noarch
# Only x86_64 works right now:
ExclusiveArch: x86_64
%description
Thrust is a parallel algorithm library. This library has been
ported to HIP/ROCm platform, which uses the rocPRIM library.
%package devel
Summary: The %{upstreamname} development package
Provides: %{name}-headers = %{version}-%{release}
Provides: rocm-release(%{name}-headers) = %{rocm_release}
%description devel
The %{upstreamname} development package.
%if %{with test}
%package test
Summary: Tests for %{name}
%description test
This package contains the test files to be run on real hardware.
%endif
%prep
%autosetup -p1 -n %{upstreamname}-rocm-%{version}
# The ROCMExportTargetsHeaderOnly.cmake file
# generates a files that reference the install location of other files
# Make this change so they match
sed -i -e 's/ROCM_INSTALL_LIBDIR lib/ROCM_INSTALL_LIBDIR share/' cmake/ROCMExportTargetsHeaderOnly.cmake
%if 0%{?sle_version} == 0
sed -i -e 's/CMAKE_CXX_STANDARD 14/CMAKE_CXX_STANDARD 17/' -e '110s/.*/# &/' CMakeLists.txt
%endif
%build
%define __builder ninja
%cmake \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
%if %{with check} || %{with test}
-DBUILD_TEST=ON \
%endif
-DCMAKE_CXX_COMPILER=%rocm_cxx \
-DCMAKE_CXX_FLAGS="%build_cxxflags" \
-DCMAKE_PREFIX_PATH="%rocm_path" \
-DCMAKE_SKIP_INSTALL_RPATH=ON \
-DROCM_SYMLINK_LIBS=OFF \
-DAMDGPU_TARGETS="%{list_sep rocm_gpu_list ;}"
%cmake_build
%install
%cmake_install
# don't need the docs
rm -rf %{buildroot}%{_docdir}/%{name}
%if %{with test}
# move tests to libexec
mkdir -p %{buildroot}%{_libexecdir}/%{name}-test
mv %{buildroot}%{_bindir}/* %{buildroot}%{_libexecdir}/%{name}-test/
%endif
%check
%if %{with check}
%ctest
%endif
%files devel
%doc README.md
%license LICENSE NOTICES.txt
%{_includedir}/thrust
%{_datadir}/cmake/%{name}
%if %{with test}
%files test
%{_libexecdir}/%{name}-test
%endif
%changelog