From 6b2572e45f8928e2658905795273877aaea663b3 Mon Sep 17 00:00:00 2001 From: xxDoman Date: Sun, 4 Oct 2026 20:09:35 +0200 Subject: [PATCH] hip/gfx906: cudaFuncSetAttribute as a function, not a macro A function-like macro splits its arguments on the commas inside a template argument list, so cudaFuncSetAttribute(kernel<1, 6, true>, ...) failed to compile (fused_gr.cu:1089-1093, 'too many arguments provided to function-like macro invocation'). Restore the template function 0.1.38's hip_compat/ cuda_runtime.h had, and add the two carveout definitions used beside it. gfx906-only: include/strata/platform/hip_compat/ is on the include path only inside if(STRATA_HIP_GFX906); CUDA and the wave32 RDNA backend are untouched. --- include/strata/platform/hip_compat/strata_hip.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/strata/platform/hip_compat/strata_hip.h b/include/strata/platform/hip_compat/strata_hip.h index b0de6c4a..5af9b68f 100644 --- a/include/strata/platform/hip_compat/strata_hip.h +++ b/include/strata/platform/hip_compat/strata_hip.h @@ -63,6 +63,10 @@ #define cudaDeviceScheduleBlockingSync hipDeviceScheduleBlockingSync #define cudaDeviceMapHost hipDeviceMapHost #define cudaFuncAttributeMaxDynamicSharedMemorySize hipFuncAttributeMaxDynamicSharedMemorySize +#define cudaFuncAttributePreferredSharedMemoryCarveout hipFuncAttributePreferredSharedMemoryCarveout +// CUDA's cudaSharedmemCarveoutMaxShared is a percentage (100 = give the block all of the carveout); HIP has no +// counterpart constant, so spell it out (the carveout attribute takes an int percentage). +#define cudaSharedmemCarveoutMaxShared 100 #define cudaDevAttrMultiProcessorCount hipDeviceAttributeMultiprocessorCount #define cudaDevAttrClockRate hipDeviceAttributeClockRate #define cudaDevAttrComputeCapabilityMajor hipDeviceAttributeComputeCapabilityMajor @@ -151,7 +155,13 @@ template inline hipError_t strata_host_alloc(T** p, size_t bytes, u #define cudaKernelNodeParams hipKernelNodeParams #define cudaGraphKernelNodeGetParams hipGraphKernelNodeGetParams inline hipError_t cudaFuncGetName(const char** name, const void*) { *name = nullptr; return hipErrorNotSupported; } -#define cudaFuncSetAttribute(fn, attr, val) hipFuncSetAttribute(reinterpret_cast(fn), attr, val) +// A function, not a macro: the call sites pass kernels as cudaFuncSetAttribute(kernel, ...) and a +// function-like macro would split its arguments on the commas inside the template argument list (0.1.38's +// hip_compat/cuda_runtime.h had this as a template function too; the macro broke fused_gr.cu on ROCm 7.2.1). +template +inline hipError_t cudaFuncSetAttribute(Kernel kernel, hipFuncAttribute attribute, int value) { + return hipFuncSetAttribute(reinterpret_cast(kernel), attribute, value); +} #define cudaMemcpyToSymbol(sym, src, ...) hipMemcpyToSymbol(HIP_SYMBOL(sym), src, __VA_ARGS__) // CUDA 12 has a 3-argument cudaGraphInstantiate(exec, graph, flags) and the older 5-argument one; HIP spells