File hiprand.spec of Package hiprand
%global upstreamname hipRAND
%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 libhiprand
%define libname %{so_name}%{so_major}
%define hiprand_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/') -fuse-ld=lld-rocm
# Option to build the test suite
%bcond_without test
# Option to run the test suite for testing on real HW:
%bcond_with check
Name: hiprand
Version: %{rocm_version}
Release: 0
Summary: HIP random number generator
Url: https://github.com/ROCm/%{upstreamname}
License: MIT and BSD
Source0: %{url}/archive/refs/tags/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-rpm-macros
BuildRequires: rocm-runtime-devel
BuildRequires: rocrand-devel
%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} = %{hiprand_version}
Provides: rocm-release(%{name}) = %{rocm_release}
# Only x86_64 works right now:
ExclusiveArch: x86_64
%description
hipRAND is a RAND marshalling library, with multiple supported backends. It
sits between the application and the backend RAND library, marshalling inputs
into the backend and results back to the application. hipRAND exports an
interface that does not require the client to change, regardless of the chosen
backend. Currently, hipRAND supports either rocRAND or cuRAND.
%package -n %{libname}
Summary: HIP random number generator library
Group: System/Libraries/C and C++
Provides: %{libname}%{?_isa} = %{hiprand_version}
%description -n %{libname}
hipRAND is a RAND marshalling library, with multiple supported backends. It
sits between the application and the backend RAND library, marshalling inputs
into the backend and results back to the application. hipRAND exports an
interface that does not require the client to change, regardless of the chosen
backend. Currently, hipRAND supports either rocRAND or cuRAND.
%package devel
Summary: The hipRAND development package
Group: Development/Tools/Building
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{libname}%{?_isa} = %{hiprand_version}
Requires: rocm-release(rocrand-devel) = %{rocm_release}
Provides: rocm-release(%{name}-devel) = %{rocm_release}
%description devel
The hipRAND development package.
%if %{with test}
%package test
Summary: Tests for %{name}
Requires: %{libname}%{?_isa} = %{hiprand_version}
%description test
This package contains the test files to be run on real hardware.
%endif
%prep
%autosetup -p1 -n %{upstreamname}-rocm-%{version}
#Remove RPATH:
sed -i -e '/INSTALL_RPATH/d' -e 's/set(CMAKE_CXX_STANDARD.*/set(CMAKE_CXX_STANDARD 17)/' CMakeLists.txt
%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 \
-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