File rocmlir.spec of Package rocMLIR
%global upstreamname rocMLIR
%global rocm_release 6.2
%global rocm_patch 2
%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}
%bcond_with debug
%if %{with debug}
%global build_type DEBUG
%else
%global build_type RelWithDebInfo
%endif
# It is necessary to use this with a local build
# export QA_RPATHS=0xff
%bcond_with test
%if %{with test}
%global build_test ON
%else
%global build_test OFF
%endif
# Option to test suite for testing on real HW:
%bcond_with check
Name: rocmlir
Version: %{rocm_version}
Release: 1
Summary: rocMLIR is for a MLIR-based convolution and GEMM kernel generator targetting AMD hardware.
Url: https://github.com/ROCm/rocMLIR
License: MIT and BSD
Source0: %{url}/archive/rocm-%{version}.tar.gz#/%{upstreamname}-%{version}.tar.gz
Patch0: 0001-Fix-build-on-riscv64.patch
BuildRequires: git
BuildRequires: cmake
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: rocblas-devel
#Use compat if LLVM is not latest, 1 is enable
%global compat_build 1
%global maj_ver 18
%if %{compat_build}
BuildRequires: llvm%{maj_ver}
BuildRequires: llvm%{maj_ver}-devel
BuildRequires: llvm%{maj_ver}-test
BuildRequires: llvm%{maj_ver}-cmake-utils
BuildRequires: llvm%{maj_ver}-libs
BuildRequires: lld%{maj_ver}
BuildRequires: lld%{maj_ver}-devel
BuildRequires: clang%{maj_ver}
BuildRequires: clang%{maj_ver}-devel
BuildRequires: clang%{maj_ver}-libs
BuildRequires: clang%{maj_ver}-tools-extra
%else
BuildRequires: llvm-devel = %{version}
BuildRequires: llvm-test = %{version}
BuildRequires: llvm-cmake-utils = %{version}
%endif
%if %{with test}
BuildRequires: gtest-devel
%endif
Requires: rocm-rpm-macros-modules
# Only x86_64 works right now:
ExclusiveArch: x86_64 riscv64
%description
rocMLIR is for a MLIR-based convolution and GEMM kernel generator
targetting AMD hardware. This generator is mainly used from MIGraphX,
but it can be used on a standalone basis. (The ability to use this code
via torch-mlir is being investigated as well.)
%package devel
Summary: The rocRAND development package
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
The rocRAND development package.
%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
mkdir %{_target_platform}-$gpu
pushd %{_target_platform}-$gpu
# We can't compile all the targets at once
export ROCM_GPUS='gfx1030;gfx1100'
%cmake .. \
-DCMAKE_BUILD_TYPE=%build_type \
-DAMDGPU_TARGETS=${ROCM_GPUS} \
-DCMAKE_INSTALL_LIBDIR=$ROCM_LIB \
-DCMAKE_INSTALL_BINDIR=$ROCM_BIN \
-DBUILD_FAT_LIBROCKCOMPILER=ON \
-DCMAKE_C_FLAGS="-Wno-gnu-line-marker" \
-DCMAKE_C_COMPILER=/usr/lib64/llvm18/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/lib64/llvm18/bin/clang++ \
-DCMAKE_CXX_FLAGS="-Wno-gnu-line-marker -std=c++11" \
-DBUILD_TEST=%build_test
popd
cmake --build %{_target_platform}-$gpu %{?_smp_mflags} --verbose
module purge
done
%install
for gpu in %{rocm_gpu_list}
do
DESTDIR=%{buildroot} cmake --install %{_target_platform}-$gpu
done
echo s@%{buildroot}@@ > br.sed
find %{buildroot}%{_libdir} -name '*.so.*.[0-9]' | sed -f br.sed > %{name}.files
find %{buildroot}%{_libdir} -name '*.so.[0-9]' | sed -f br.sed >> %{name}.files
find %{buildroot}%{_libdir} -name '*.so' | sed -f br.sed > %{name}.devel
find %{buildroot}%{_libdir} -name '*.cmake' | sed -f br.sed >> %{name}.devel
%if %{with test}
find %{buildroot} -name 'test_*' | sed -f br.sed > %{name}.test
find %{buildroot} -name '*RAND' | sed -f br.sed >> %{name}.test
%endif
%check
%if %{with test}
%if %{with check}
# Assumes default
%ctest
%endif
%endif
%files -f %{name}.files
%doc README.md
%license %{_docdir}/%{name}/LICENSE.txt
%files devel -f %{name}.devel
%{_includedir}/%{name}
%if %{with test}
%files test -f %{name}.test
%endif
%changelog
* Tue Nov 26 2024 misaka00251 <liuxin@iscas.ac.cn> - 6.2.2-1
- Init package