Add HIP shuffle macro shim to restore __shfl_sync support on gfx1151

This commit is contained in:
Donato Capitella
2025-11-12 09:43:12 +00:00
parent be28cb2ad5
commit ff0ef125cc
+15 -11
View File
@@ -49,23 +49,26 @@ RUN chmod +x /opt/apply-rocwmma-fix.sh && /opt/apply-rocwmma-fix.sh /opt/llama.c
RUN git clean -xdf \ RUN git clean -xdf \
&& git pull \ && git pull \
&& git submodule update --recursive \ && git submodule update --recursive \
&& rm -f /opt/llama.cpp/ggml/src/ggml-cuda/mma.cuh.tmp \
&& cat > /opt/llama.cpp/ggml/src/ggml-cuda/hip_shfl_fix.h <<'EOF' && cat > /opt/llama.cpp/ggml/src/ggml-cuda/hip_shfl_fix.h <<'EOF'
#ifndef HIP_SHFL_FIX_H #ifndef HIP_SHFL_FIX_H
#define HIP_SHFL_FIX_H #define HIP_SHFL_FIX_H
#include "common.cuh" // Keep vendor shims if present, add only whats missing.
#ifndef __shfl_sync #ifdef __HIP_PLATFORM_AMD__
#define __shfl_sync(mask,var,srcLane,width) __shfl(var,srcLane,width) #ifndef __shfl_sync
#endif #define __shfl_sync(mask,var,srcLane,width) __shfl((var),(srcLane),(width))
#ifndef __shfl_up_sync #endif
#define __shfl_up_sync(mask,var,delta,width) __shfl_up(var,delta,width) #ifndef __shfl_up_sync
#endif #define __shfl_up_sync(mask,var,delta,width) __shfl_up((var),(delta),(width))
#ifndef __shfl_xor_sync #endif
#define __shfl_xor_sync(mask,var,laneMask,width) __shfl_xor(var,laneMask,width) #ifndef __shfl_xor_sync
#define __shfl_xor_sync(mask,var,laneMask,width) __shfl_xor((var),(laneMask),(width))
#endif
#endif #endif
#endif #endif
EOF EOF
&& bash -lc 'f=/opt/llama.cpp/ggml/src/ggml-cuda/mma.cuh; \ && f=/opt/llama.cpp/ggml/src/ggml-cuda/mma.cuh; \
grep -q "hip_shfl_fix.h" "$f" || sed -i '\''1i #include "hip_shfl_fix.h"'\'' "$f"' \ grep -q 'hip_shfl_fix.h' "$f" || sed -i '1i #include "hip_shfl_fix.h"' "$f" \
&& cmake -S . -B build \ && cmake -S . -B build \
-DGGML_HIP=ON \ -DGGML_HIP=ON \
-DAMDGPU_TARGETS=gfx1151 \ -DAMDGPU_TARGETS=gfx1151 \
@@ -79,6 +82,7 @@ EOF
&& cmake --build build --config Release -- -j"$(nproc)" \ && cmake --build build --config Release -- -j"$(nproc)" \
&& cmake --install build --config Release && cmake --install build --config Release
# libs # libs
RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \
&& ldconfig && ldconfig