File rocrand.spec of Package rocrand
%global upstreamname rocRAND
%global rocm_release 6.2
%global rocm_patch 0
%global rocm_version %{rocm_release}.%{rocm_patch}
# rocRAND version
%define so_major 1
%define so_version %{so_major}.1
%define so_name librocrand
%define libname %{so_name}%{so_major}
%define rocrand_version 3.1.0
%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 -fuse-ld=lld-rocm
%bcond_with debug
%if %{with debug}
%global build_type DEBUG
%else
%global build_type RelWithDebInfo
%endif
# Option to build the test suite
%bcond_without test
# Option to run the test suite for testing on real HW:
%bcond_with check
Name: rocrand
Version: %{rocm_version}
Release: 0
Summary: ROCm random number generator
Url: https://github.com/ROCm/rocRAND
License: MIT
Source0: %{url}/archive/rocm-%{version}.tar.gz#/%{upstreamname}-rocm-%{version}.tar.gz
BuildRequires: git
BuildRequires: cmake
BuildRequires: ninja
BuildRequires: rocm-cmake
BuildRequires: rocm-comgr-devel
BuildRequires: rocm-hip-devel
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
Requires: %{libname}%{?_isa} = %{rocrand_version}
Provides: rocm-release(%{name}) = %{rocm_release}
# Only x86_64 works right now:
ExclusiveArch: x86_64
%description
The rocRAND project provides functions that generate pseudo-random and
quasi-random numbers.
%package -n %{libname}
Summary: ROCm random number generator library
Group: System/Libraries/C and C++
Provides: %{libname}%{?_isa} = %{rocrand_version}
%description -n %{libname}
The rocRAND library is implemented in the HIP programming language and
optimized for AMD's latest discrete GPUs. It is designed to run on top of AMD's
Radeon Open Compute ROCm runtime, but it also works on CUDA enabled GPUs.
%package devel
Summary: The rocRAND development package
Group: Development/Tools/Building
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{libname}%{?_isa} = %{rocrand_version}
Provides: rocm-release(%{name}-devel) = %{rocm_release}
%description devel
The rocRAND development package.
%if %{with test}
%package test
Summary: Tests for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{libname}%{?_isa} = %{rocrand_version}
%description test
This package contains the test files to be run on real hardware.
%endif
%prep
%autosetup -p1 -n %{upstreamname}-rocm-%{version}
# Fixup the build
sed -i -e '/INSTALL_RPATH/d' -e 's/set(CMAKE_CXX_STANDARD.*/set(CMAKE_CXX_STANDARD 17)/' CMakeLists.txt
%build
# enable ccache during build if available
if command -v ccache > /dev/null; then
export HIP_CLANG_LAUNCHER=ccache
fi
%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 \
-DCMAKE_INSTALL_LIBDIR=${_lib} \
-DROCM_SYMLINK_LIBS=OFF \
-DAMDGPU_TARGETS="%{list_sep rocm_gpu_list ;}"
%cmake_build
%install
%cmake_install
# we don't need the installed 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}
# Assumes default
%ctest
%endif
%ldconfig_scriptlets -n %{libname}
%files
%doc README.md
%license LICENSE.txt
%files -n %{libname}
%{_libdir}/%{so_name}.so.%{so_major}
%{_libdir}/%{so_name}.so.%{so_version}
%files devel
%{_includedir}/%{name}
%{_libdir}/cmake/%{name}
%{_libdir}/%{so_name}.so
%if %{with test}
%files test
%{_libexecdir}/%{name}-test
%endif
%changelog