From 83da5b07ead156a321dbfd9c9c858ce1570c274b Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Sun, 5 Nov 2023 05:05:31 -0800 Subject: [PATCH] Initial project Signed-off-by: Tom Rix --- .gitignore | 1 + 0001-prepare-rocsparse-cmake-for-fedora.patch | 71 ++++++++++ rocsparse.spec | 124 ++++++++++++++++++ sources | 1 + 4 files changed, 197 insertions(+) create mode 100644 .gitignore create mode 100644 0001-prepare-rocsparse-cmake-for-fedora.patch create mode 100644 rocsparse.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d482e9d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/rocSPARSE-5.7.1.tar.gz diff --git a/0001-prepare-rocsparse-cmake-for-fedora.patch b/0001-prepare-rocsparse-cmake-for-fedora.patch new file mode 100644 index 0000000..91ef42d --- /dev/null +++ b/0001-prepare-rocsparse-cmake-for-fedora.patch @@ -0,0 +1,71 @@ +From 9e73c29b401111f6ad828ebaf2cd21e4b398157a Mon Sep 17 00:00:00 2001 +From: Tom Rix +Date: Sun, 8 Oct 2023 06:04:04 -0700 +Subject: [PATCH] prepare rocsparse cmake for fedora + +Do not build fortran + +Signed-off-by: Tom Rix +--- + CMakeLists.txt | 2 +- + library/CMakeLists.txt | 11 ----------- + library/src/CMakeLists.txt | 8 -------- + 3 files changed, 1 insertion(+), 20 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0da59097..d4b7a970 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -51,7 +51,7 @@ if(POLICY CMP0066) + endif() + + # rocSPARSE project +-project(rocsparse LANGUAGES CXX Fortran C) ++project(rocsparse LANGUAGES CXX ) + + # Determine if CXX Compiler is hip-clang + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt +index 7d3b2f8f..637c3c6d 100644 +--- a/library/CMakeLists.txt ++++ b/library/CMakeLists.txt +@@ -56,17 +56,6 @@ source_group("Header Files\\Public" FILES ${rocsparse_headers_public}) + # Include sources + include(src/CMakeLists.txt) + +-if (NOT WIN32) +-# Set Fortran module output directory +-set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include/rocsparse) +- +-# Create rocSPARSE Fortran module +-add_library(rocsparse_fortran OBJECT ${rocsparse_fortran_source}) +- +-# Target compile options +-target_compile_options(rocsparse_fortran PRIVATE -std=f2003 -ffree-form -cpp) +-endif() +- + # Create rocSPARSE library + add_library(rocsparse ${rocsparse_source} ${rocsparse_headers_public}) + add_library(roc::rocsparse ALIAS rocsparse) +diff --git a/library/src/CMakeLists.txt b/library/src/CMakeLists.txt +index a6508a5f..22441e4e 100644 +--- a/library/src/CMakeLists.txt ++++ b/library/src/CMakeLists.txt +@@ -21,14 +21,6 @@ + # + # ######################################################################## + +-# rocSPARSE Fortran source +-if (NOT WIN32) +-set(rocsparse_fortran_source +- src/rocsparse_enums.f90 +- src/rocsparse.f90 +-) +-endif() +- + # rocSPARSE source + set(rocsparse_source + src/handle.cpp +-- +2.41.0 + diff --git a/rocsparse.spec b/rocsparse.spec new file mode 100644 index 0000000..158dcf8 --- /dev/null +++ b/rocsparse.spec @@ -0,0 +1,124 @@ +%global upstreamname rocSPARSE +%global rocm_release 5.7 +%global rocm_patch 1 +%global rocm_version %{rocm_release}.%{rocm_patch} + +%global toolchain rocm +# 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/') + +# $gpu will be evaluated in the loops below +%global _vpath_builddir %{_vendor}-%{_target_os}-build-${gpu} + +# Tests are downloaded so this option is only good for local building +# Also need to +# export QA_RPATHS=0xff +%bcond_with test + +Name: rocsparse +Version: %{rocm_version} +Release: 2%{?dist} +Summary: SPARSE implementation for ROCm +Url: https://github.com/ROCmSoftwarePlatform/%{upstreamname} +License: MIT + +# Only x86_64 works right now: +ExclusiveArch: x86_64 + +Source0: %{url}/archive/refs/tags/rocm-%{rocm_version}.tar.gz#/%{upstreamname}-%{rocm_version}.tar.gz +Patch0: 0001-prepare-rocsparse-cmake-for-fedora.patch + +BuildRequires: cmake +BuildRequires: compiler-rt +BuildRequires: clang-devel +BuildRequires: lld +BuildRequires: llvm-devel +BuildRequires: ninja-build +BuildRequires: rocm-cmake +BuildRequires: rocm-comgr-devel +BuildRequires: rocm-hip-devel +BuildRequires: rocm-runtime-devel +BuildRequires: rocm-rpm-macros +BuildRequires: rocm-rpm-macros-modules +BuildRequires: rocprim-devel + +%if %{with test} +BuildRequires: gtest-devel +BuildRequires: libomp-devel +BuildRequires: rocblas-devel +%endif + +%description +rocSPARSE exposes a common interface that provides Basic +Linear Algebra Subroutines for sparse computation +implemented on top of AMD's Radeon Open eCosystem Platform +ROCm runtime and toolchains. rocSPARSE is created using +the HIP programming language and optimized for AMD's +latest discrete GPUs. + +%package devel +Summary: Libraries and headers for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +%{summary} + +%if %{with test} +%package test +Summary: Tests for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description test +%{summary} +%endif + +%prep +%autosetup -p1 -n %{upstreamname}-rocm-%{version} + +%build +for gpu in %{rocm_gpu_list} +do + module load rocm/$gpu + %cmake %rocm_cmake_options \ +%if %{with test} + %rocm_cmake_test_options +%endif + + %cmake_build + module purge +done + +%cmake_build + +%install +for gpu in %{rocm_gpu_list} +do + %cmake_install +done + +%files +%license LICENSE.md +%exclude %{_docdir}/%{name}/LICENSE.md +%{_libdir}/lib%{name}.so.* +%{_libdir}/rocm/gfx*/lib/lib%{name}.so.* + +%files devel +%doc README.md +%{_includedir}/%{name} +%{_libdir}/cmake/%{name}/ +%{_libdir}/lib%{name}.so +%{_libdir}/rocm/gfx*/lib/lib%{name}.so +%{_libdir}/rocm/gfx*/lib/cmake/%{name}/ + +%if %{with test} +%files test +%{_bindir}/%{name}* +%{_libdir}/rocm/gfx*/bin/%{name}* +%endif + +%changelog +* Fri Nov 3 2023 Tom Rix - 5.7.1-2 +- Address review comments + +* Wed Nov 1 2023 Tom Rix - 5.7.1-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..e530ecd --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (rocSPARSE-5.7.1.tar.gz) = cd48884c51fcddcb26c42920cf477999160b3f06da4ab182f746a18d1fe54f697d89b1e470c550bd2330b26fb596d4a5baadf64366145e0d07f3fd8891f9af59