# Part of ROCM Stack, see rocm-llvm for build order # rocm-cmake # rocm-llvm # rocm-runtime # rocm-core # rocminfo # rocm-amd-opencl #Build Time of this package ~ 0 minutes 58 seconds %define somajor 1 %define sominor 2 %global rocm_release 6.4 %global rocm_patch 3 %global rocm_version %{rocm_release}.%{rocm_patch} %define rocmname rocm%{rocm_release}-opencl-runtime %define libname %mklibname %{rocmname} %define devel_name %mklibname %{rocmname} -d %global install_prefix %{_libdir}/rocm-%{rocm_release} # No need to intall huge rocm-llvm # Not sure this apply as device.libs now comes from rocm-llvm #global __requires_exclude ^rocm%{rocm_release}-llvm(.*) #To determine why fail build with shared libs %bcond_without shared_libs Name: rocm-amd-opencl Version: %{rocm_version} Release: %mkrel 1 Summary: ROCm OpenCL Runtime for AMD GPU Group: System/Kernel and hardware Url: https://github.com/ROCm-Developer-Tools/clr License: MIT Source0: https://github.com/ROCm-Developer-Tools/clr/archive/rocm-%{version}.tar.gz#/clr-rocm-%{version}.tar.gz #Patch0: rocm-and-opencl_cmake_min_version.patch #Fedora # a fix for building blender Patch8: 0001-add-long-variants-for-__ffsll.patch #https://github.com/ROCm/clr/pull/97 patch10: %{url}/pull/97/commits/909fa3dcb644f7ca422ed1a980a54ac426d831b1.patch #Only the following architectures are useful for ROCm packages: ExclusiveArch: x86_64 aarch64 BuildRequires: cmake BuildRequires: mesa-common-devel BuildRequires: pkgconfig(opengl) BuildRequires: pkgconfig(numa) BuildRequires: pkgconfig(ocl-icd) #This is fetched by the above #BuildRequires: pkgconfig(OpenCL-Headers) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libedit) #ROCM stack BuildRequires: rocm%{rocm_release}-macros BuildRequires: rocm%{rocm_release}-comgr-devel = %{version} #hsakmt-devel BuildRequires: %{_lib}rocm%{rocm_release}-runtime-devel = %{version} #BuildRequires: rocm%{rocm_release}-cmake = %{version} #squidf version #BuildRequires: rocm%{rocm_release}-llvm #BuildRequires: rocm%{rocm_release}-llvm-static BuildRequires: rocm%{rocm_release}-lld BuildRequires: rocm%{rocm_release}-llvm-devel # The kernel support only exists for x86_64, aarch64 # However, for aarch64 immintrin.h: error: "This header is only meant to be used on x86 and x64 architecture" #ExclusiveArch: x86_64 %description ROCm OpenCL language runtime. Supports offline and in-process/in-memory compilation. %package -n rocm%{rocm_release}-amd-opencl Summary: ROCm OpenCL Runtime for AMD GPU Requires: %{devel_name} = %{version}-%{release} Requires: rocm%{rocm_release}-comgr = %{version} Requires: %{_lib}rocm%{rocm_release}-runtime = %{version} Requires: %{_lib}rocm%{rocm_release}-core = %{version} Requires: rocm%{rocm_release}-device-libs = %{version} Requires: rocm%{rocm_release}-rocminfo = %{version} Conflicts: amdgpupro-opencl-orca Conflicts: amdgpupro-opencl-pal #conflict older packages to get the new in same transaction Conflicts: clr(rocm) < %{version} Conflicts: rocm-clinfo < %{version} Recommends: rocm%{rocm_release}-clinfo = %{version}-%{release} %description -n rocm%{rocm_release}-amd-opencl ROCm OpenCL language runtime. Supports offline and in-process/in-memory compilation. %package -n %{libname} Summary: ROCm OpenCL Libraries Group: System/Libraries #For easier update Provides: clr(rocm) = %{version}-%{release} %description -n %{libname} Libraires for AMD ROCm OpenCL. %package -n %{devel_name} Summary: ROCm OpenCL development package Group: Development/Other #For easier update Provides: clr-devel(rocm) = %{version}-%{release} Requires: clr(rocm) = %{version}-%{release} Requires: pkgconfig(ocl-icd) %description -n %{devel_name} The AMD ROCm OpenCL development package. %package -n rocm%{rocm_release}-clinfo Summary: ROCm OpenCL platform and device tool Group: System/Configuration %description -n rocm%{rocm_release}-clinfo A simple ROCm OpenCL application that enumerates all possible platform and device information. %prep %autosetup -p1 -n clr-rocm-%{version} # Enable experimental pre vega platforms #sed -i 's/\(ROC_ENABLE_PRE_VEGA.*\)false/\1true/' rocclr/utils/flags.hpp cat > README.%_real_vendor <" and logout/in or reboot ============================================================= EOF #Change harcoded path sed -i 's|/opt/rocm/lib/llvm/bin|%{install_prefix}/bin|' CMakeLists.txt #Fedora rocclr # Disable RPATH # https://github.com/ROCm-Developer-Tools/hipamd/issues/22 sed -i '/INSTALL_RPATH/d' \ opencl/tools/clinfo/CMakeLists.txt hipamd/CMakeLists.txt # Upstream doesn't want OpenCL sonames because they don't guarantee API/ABI. # For Fedora, SOVERSION can be major.minor (i.e. rocm_release) as rocm patch # releases are very unlikely to break anything: echo "set_target_properties(amdocl PROPERTIES VERSION %{version} SOVERSION %rocm_release)" \ >> opencl/amdocl/CMakeLists.txt echo "set_target_properties(cltrace PROPERTIES VERSION %{version} SOVERSION %rocm_release)" \ >> opencl/tools/cltrace/CMakeLists.txt # Don't change default C FLAGS and CXX FLAGS: sed -i '/CMAKE_C.*_FLAGS/d' hipamd/src/CMakeLists.txt # Use cpack is not needed when we are doing the packaging here # Gets confused on TW sed -i -e 's@add_subdirectory(packaging)@#add_subdirectory(packaging)@' hipamd/CMakeLists.txt sed -i -e 's@add_subdirectory(packaging)@#add_subdirectory(packaging)@' opencl/CMakeLists.txt #End Fedora #Don't know why reject or not right detected sed -i 's|amd_comgr 2.9|amd_comgr 3.0|' rocclr/cmake/ROCclrLC.cmake %build export ROCM_PATH="%{install_prefix}" # Something searches for clang in its path export PATH=%{rocmllvm_bindir}:$PATH %cmake \ -Wno-dev \ -S "." \ -B build %{!?with_shared_libs:-DBUILD_SHARED_LIBS=OFF} \ -DCLR_BUILD_OCL=ON \ -DBUILD_ICD=True\ -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ -DCMAKE_INSTALL_LIBDIR=%{install_prefix}/lib \ -DCMAKE_INSTALL_INCLUDEDIR=%{install_prefix}/include \ -DCMAKE_AR=%rocmllvm_bindir/llvm-ar \ -DCMAKE_C_COMPILER=%rocmllvm_bindir/clang \ -DCMAKE_CXX_COMPILER=%rocmllvm_bindir/clang++ \ -DCMAKE_LINKER=%rocmllvm_bindir/ld.lld \ -DCMAKE_RANLIB=%rocmllvm_bindir/llvm-ranlib \ -DCMAKE_PREFIX_PATH=%{rocmllvm_cmakedir}/.. #export CC=%rocmllvm_bindir/clang #export CXX=%rocmllvm_bindir/clang++ #export LD="%rocmllvm_bindir/ld.lld" %cmake_build %install %cmake_install install -m644 README.%_real_vendor README.urpmi %if %{with shared_libs} cat > rocm.conf < 'amdocl64.icd' install -Dm644 amdocl64.icd %{buildroot}%{_sysconfdir}/OpenCL/vendors/amdocl64.icd ### Just keep for reference not needed # I do this on build stage #Specific lib folder for ROCm #mkdir -p %{buildroot}%{install_prefix} #mv %{buildroot}%{_libdir}/lib* %{buildroot}%{install_prefix} #Avoid file conflicts with opencl-headers package: #mkdir -p %{buildroot}%{_includedir}/rocm #mv %{buildroot}%{_includedir}/CL %{buildroot}%{_includedir}/rocm/CL ### #Avoid file conflicts with clinfo package: mv %{buildroot}/%{install_prefix}/bin/clinfo %{buildroot}/%{install_prefix}/bin/rocm-clinfo #Avoid duplicate rm -rf %{buildroot}/%{_usr}/opencl %post %if %{with shared_libs} #apply configuration echo "Run ldconfig" ldconfig %endif %files -n rocm%{rocm_release}-amd-opencl %doc README.urpmi README.md CHANGELOG.md README.mageia %files -n %{libname} %license LICENSE.txt #%exclude %{install_prefix}/share/doc/opencl-asan/LICENSE.txt #%exclude %{install_prefix}/share/doc/opencl/LICENSE.txt #%exclude %{install_prefix}/share/doc/rocm-ocl-icd/LICENSE %dir %{_sysconfdir}/OpenCL %dir %{_sysconfdir}/OpenCL/vendors %{_sysconfdir}/OpenCL/vendors/amdocl64.icd %dir %{install_prefix} %{install_prefix}/lib/libamdocl64.%{!?with_shared_libs:a}%{?with_shared_libs:so.%{rocm_release}{,.*}} %if %{with shared_libs} %{_sysconfdir}/ld.so.conf.d/rocm.conf %{install_prefix}/lib/libOpenCL.so.%{somajor} %{install_prefix}/lib/libOpenCL.so.%{somajor}.%{sominor} %{install_prefix}/lib/libcltrace.so.%{rocm_release}{,.*} %endif %files -n %{devel_name} %dir %{install_prefix} %{install_prefix}/lib/libcltrace.so %{install_prefix}/lib/libamdocl64.so %if %{with shared_libs} %{install_prefix}/lib/libOpenCL.so %endif %dir %{install_prefix}/include %{install_prefix}/include/CL{.,*} %files -n rocm%{rocm_release}-clinfo %license LICENSE.txt %{install_prefix}/bin/rocm-clinfo