%global upstreamname AMDMIGraphX %global rocm_release 6.4 %global rocm_patch 3 %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/' -e 's/-mtls-dialect=gnu2//') # Compression type and level for source/binary package payloads. # "w7T0.xzdio" xz level 7 using %%{getncpus} threads %global _source_payload w7T0.xzdio %global _binary_payload w7T0.xzdio # The llvm build has its LLVM_PARALLEL_COMPILE|LINK_JOBS switches %global _smp_mflags %{nil} %global gpu_list gfx1100 %bcond_with test %if %{with test} %global build_test ON %else %global build_test OFF %endif Name: migraphx Version: %{rocm_version} Release: 1%{?dist} Summary: AMD's graph optimization engine # MIGraphX is MIT # rocMLIR has a clang fork so it is Apache-2.0 WITH LLVM-exception os NCSA License: MIT AND Apache-2.0 WITH LLVM-exception OR NCSA URL: https://github.com/ROCm/AMDMIGraphX Source0: %{url}/archive/rocm-%{version}.tar.gz#/%{upstreamname}-%{version}.tar.gz Source1: https://github.com/ROCm/rocMLIR/archive/rocm-%{version}.tar.gz#/rocMLIR-%{version}.tar.gz # Need to manually patch Source1 # https://github.com/ROCm/rocMLIR/pull/1953 Source100: 0001-rocmlir-add-job-pools.patch # ROCm only works on x86_64 ExclusiveArch: x86_64 BuildRequires: ccache BuildRequires: chrpath BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: half-devel BuildRequires: miopen-devel BuildRequires: msgpack-devel BuildRequires: ninja-build BuildRequires: pkgconfig(nlohmann_json) BuildRequires: pkgconfig(sqlite3) BuildRequires: protobuf-devel BuildRequires: rocblas-devel BuildRequires: rocm-clang BuildRequires: rocm-cmake BuildRequires: rocm-compilersupport-macros BuildRequires: rocm-hip-devel BuildRequires: rocm-runtime-devel BuildRequires: rocm-rpm-macros # rocMLIR bundles a fork of rocm-llvm which itself is a fork of the upstream llvm Provides: bundled(llvm-project) = 21.0.0 %description AMD MIGraphX is AMD's graph inference engine, which accelerates machine learning model inference. %package devel Summary: The development package 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} tar xf %{SOURCE1} cd rocMLIR-rocm-%{version} patch -p1 < %{SOURCE100} cp LICENSE.TXT ../LICENSE.rocMLIR %build # Real cores, No hyperthreading COMPILE_JOBS=`cat /proc/cpuinfo | grep -m 1 'cpu cores' | awk '{ print $4 }'` if [ ${COMPILE_JOBS}x = x ]; then COMPILE_JOBS=1 fi # Try again.. if [ ${COMPILE_JOBS} = 1 ]; then COMPILE_JOBS=`lscpu | grep '^CPU(s)' | awk '{ print $2 }'` if [ ${COMPILE_JOBS}x = x ]; then COMPILE_JOBS=4 fi fi # Take into account memmory usage per core, do not thrash real memory BUILD_MEM=2 MEM_KB=0 MEM_KB=`cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'` MEM_MB=`eval "expr ${MEM_KB} / 1024"` MEM_GB=`eval "expr ${MEM_MB} / 1024"` COMPILE_JOBS_MEM=`eval "expr 1 + ${MEM_GB} / ${BUILD_MEM}"` if [ "$COMPILE_JOBS_MEM" -lt "$COMPILE_JOBS" ]; then COMPILE_JOBS=$COMPILE_JOBS_MEM fi LINK_MEM=32 LINK_JOBS=`eval "expr 1 + ${MEM_GB} / ${LINK_MEM}"` %global _vpath_srcdir rocMLIR-rocm-%{version} %global _vpath_builddir build-rocmlir # so we can find install p=$PWD %cmake -G Ninja \ -DBUILD_FAT_LIBROCKCOMPILER=ON \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_C_COMPILER=%rocmllvm_bindir/clang \ -DCMAKE_CXX_COMPILER=%rocmllvm_bindir/clang++ \ -DCMAKE_INSTALL_PREFIX=$PWD/install \ -DROCMLIR_PARALLEL_COMPILE_JOBS=$COMPILE_JOBS \ -DROCMLIR_PARALLEL_LINK_JOBS=$LINK_JOBS %cmake_build %cmake_build -t install %global _vpath_srcdir $PWD %global _vpath_builddir build-migraphx %cmake -G Ninja \ -DBoost_USE_STATIC_LIBS=OFF \ -DBUILD_TESTING=%{build_test} \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_COMPILER=%rocmllvm_bindir/clang \ -DCMAKE_CXX_COMPILER=%rocmllvm_bindir/clang++ \ -DCMAKE_INSTALL_LIBDIR=%{_lib} \ -DCMAKE_PREFIX_PATH=${p}/install/lib64/cmake \ -DGPU_TARGETS=%{gpu_list} \ -DMIGRAPHX_ENABLE_PYTHON=OFF \ -DMIGRAPHX_USE_COMPOSABLEKERNEL=OFF \ -DMIGRAPHX_USE_HIPBLASLT=OFF \ -DMIOPEN_BACKEND=HIP %cmake_build -j $COMPILE_JOBS %install %global _vpath_builddir build-migraphx %cmake_install # Remove rpaths like # chrpath -l libmigraphx_gpu.so.2012000.0 # libmigraphx_gpu.so.2012000.0: RUNPATH=$ORIGIN/../lib:$ORIGIN/../../ chrpath -d %{buildroot}%{_libdir}/libmigraphx*.so.* if [ -f %{buildroot}%{_prefix}/share/doc/migraphx/LICENSE ]; then rm %{buildroot}%{_prefix}/share/doc/migraphx/LICENSE fi %files %license LICENSE LICENSE.rocMLIR %{_bindir}/migraphx-driver %{_bindir}/migraphx-hiprtc-driver %{_libdir}/libmigraphx*.so.* %files devel %dir %{_includedir}/migraphx %dir %{_libdir}/cmake/migraphx %{_includedir}/migraphx/* %{_libdir}/libmigraphx*.so %{_libdir}/cmake/migraphx/*.cmake %if %{with test} %files test %endif %changelog * Sat Aug 16 2025 Tom Rix - 6.4.3-1 - Initial package