public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/kokkos] epel10: Add ROCm Support
@ 2026-07-11  7:20 Tom Rix
  0 siblings, 0 replies; only message in thread
From: Tom Rix @ 2026-07-11  7:20 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/kokkos
            Branch : epel10
            Commit : eb4c661aad582bdc1d7aa19aace9664b87284367
            Author : Tom Rix <Tom.Rix@amd.com>
            Date   : 2025-01-03T15:59:11-08:00
            Stats  : +120/-2 in 1 file(s)
            URL    : https://src.fedoraproject.org/rpms/kokkos/c/eb4c661aad582bdc1d7aa19aace9664b87284367?branch=epel10

            Log:
            Add ROCm Support

Signed-off-by: Tom Rix <Tom.Rix@amd.com>

---
diff --git a/kokkos.spec b/kokkos.spec
index 41ad4d0..cffe4df 100644
--- a/kokkos.spec
+++ b/kokkos.spec
@@ -1,10 +1,41 @@
+%if 0%{?rhel} < 9
 # Needed for EPEL8
 %undefine __cmake_in_source_build
+%endif
+
+# For ROCm
+%if 0%{?fedora}
+%ifarch x86_64
+%bcond_without rocm
+%endif
+%endif
+
+%if %{with rocm}
+# Kokkos only builds one gpu at a time, so need to loop over them
+# $gpu will be evaluated in the loops below
+%global _vpath_builddir %{_vendor}-%{_target_os}-build-${gpu:-normal}
+
+# For testing gpus, depends on having a gpu
+%bcond_with rocm_test
+%if %{with rocm_test}
+# Only build the for the gpu you are testing
+%global gpu_test gfx1100
+%global kokkos_gpu_list %{gpu_test}
+%global build_rocm_test ON
+%else
+# kokkos only supports some GPUs, of these pick the important ones
+%global kokkos_gpu_list gfx942 gfx90a gfx1100
+%global build_rocm_test OFF
+%endif
+
+# hippc is clang based, the toolchain is gcc, remove the gcc options that are not supported on clang
+%global rocm_cxxflags %(echo %{optflags} | sed -e 's/-fstack-protector-strong/-Xarch_host -fstack-protector-strong/' -e 's/-fcf-protection/-Xarch_host -fcf-protection/' -e 's/-mtls-dialect=gnu2//')
+%endif
 
 Name:           kokkos
 Version:        4.4.01
 %global         sover 4.4
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Kokkos C++ Performance Portability Programming
 # no support for 32-bit archs https://github.com/kokkos/kokkos/issues/2312
 ExcludeArch: i686 armv7hl
@@ -21,6 +52,19 @@ BuildRequires:  hwloc-devel
 %global gts_version 13
 BuildRequires: gcc-toolset-%{gts_version}
 %endif
+%if %{with rocm}
+BuildRequires:  rocm-cmake
+BuildRequires:  rocm-comgr-devel
+BuildRequires:  rocm-compilersupport-macros
+BuildRequires:  rocm-hip-devel
+BuildRequires:  rocm-rpm-macros
+BuildRequires:  rocm-rpm-macros-modules
+BuildRequires:  rocm-runtime-devel
+BuildRequires:  rocprim-devel
+BuildRequires:  rocthrust-devel
+Requires:       rocm-rpm-macros-modules
+%endif
+
 
 %global kokkos_desc \
 Kokkos Core implements a programming model in C++ for writing performance \
@@ -42,10 +86,25 @@ Requires:       hwloc-devel
 
 This package contains the development files of %{name}.
 
+%package -n %{name}-rocm
+Summary:        %{name} ROCm package
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+
+%description -n %{name}-rocm
+%{summary}
+
+%package -n %{name}-rocm-devel
+Summary:        %{name} ROCm development package
+Requires:       %{name}-devel%{?_isa} = %{version}-%{release}
+
+%description -n %{name}-rocm-devel
+%{summary}
+
 %prep
 %autosetup -p1
 
 %build
+
 %{?el9:. /opt/rh/gcc-toolset-%{gts_version}/enable}
 %cmake \
   -DKokkos_ENABLE_TESTS=On \
@@ -58,12 +117,48 @@ This package contains the development files of %{name}.
   -DKokkos_ENABLE_OPENMP=ON \
   -DKokkos_ENABLE_SERIAL=ON \
   -DKokkos_ENABLE_HWLOC=ON \
+  -DKokkos_ENABLE_HIP=OFF \
   %{nil}
 %cmake_build
 
+%if %{with rocm}
+rocm_clang=`hipconfig -l`/clang++
+for gpu in %{kokkos_gpu_list}
+do
+    module load rocm/$gpu
+    ugpu=${gpu^^}
+    %cmake \
+	   -DCMAKE_CXX_COMPILER=${rocm_clang} \
+	   -DCMAKE_CXX_FLAGS="%{rocm_cxxflags}" \
+	   -DCMAKE_CXX_STANDARD=17 \
+	   -DCMAKE_INSTALL_BINDIR=$ROCM_BIN \
+	   -DCMAKE_INSTALL_INCLUDEDIR=include/kokkos \
+	   -DCMAKE_INSTALL_LIBDIR=$ROCM_LIB \
+	   -DKokkos_ARCH_AMD_${ugpu}=ON \
+	   -DKokkos_ENABLE_AGGRESSIVE_VECTORIZATION=ON \
+	   -DKokkos_ENABLE_DEPRECATED_CODE=ON \
+	   -DKokkos_ENABLE_HIP=ON \
+	   -DKokkos_ENABLE_HWLOC=ON \
+	   -DKokkos_ENABLE_OPENMP=OFF \
+	   -DKokkos_ENABLE_SERIAL=ON \
+	   -DKokkos_ENABLE_TESTS=%{build_rocm_test}
+
+    %cmake_build
+    module purge
+done
+%endif
+
 %install
+
 %cmake_install
 
+%if %{with rocm}
+for gpu in %{kokkos_gpu_list}
+do
+    %cmake_install
+done
+%endif
+
 %check
 # https://github.com/kokkos/kokkos/issues/2959 - unstable test
 %ifarch s390x
@@ -71,20 +166,43 @@ This package contains the development files of %{name}.
 %endif
 %ctest %{?testargs} --timeout 6000
 
+%if %{with rocm_test}
+gpu=%{gpu_test}
+module load rocm/$gpu
+%ctest %{?testargs} --timeout 6000
+module purge
+%endif
+
 %files
 %doc README.md
 %license LICENSE
 %{_libdir}/libkokkos*.so.%{sover}*
 
 %files devel
+%{_includedir}/kokkos
 %{_libdir}/libkokkos*.so
 %{_libdir}/cmake/Kokkos
-%{_includedir}/kokkos
 %{_bindir}/nvcc_wrapper
 %{_bindir}/hpcbind
 %{_bindir}/kokkos_launch_compiler
 
+%if %{with rocm}
+%files -n %{name}-rocm
+%{_libdir}/rocm/gfx*/lib/libkokkos*.so.%{sover}*
+
+%files -n %{name}-rocm-devel
+%{_libdir}/rocm/gfx*/lib/libkokkos*.so
+%{_libdir}/rocm/gfx*/lib/cmake/Kokkos
+%{_libdir}/rocm/gfx*/bin/nvcc_wrapper
+%{_libdir}/rocm/gfx*/bin/hpcbind
+%{_libdir}/rocm/gfx*/bin/kokkos_launch_compiler
+%endif
+
+
 %changelog
+* Fri Jan 3 2025 Tom Rix <Tom.Rix@amd.com> - 4.4.01-2
+- Add ROCm support
+
 * Sat Nov 30 2024 Richard Berger <richard.berger@outlook.com> - 4.4.01-1
 - Version bump to v4.4.01
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-11  7:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-11  7:20 [rpms/kokkos] epel10: Add ROCm Support Tom Rix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox