From 2ab3a8ca48b2b4f05da84fa3b29b29eac93ff92b Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Wed, 14 Oct 2026 16:56:45 +0200 Subject: [PATCH] test(cuda): run the stub pass through clang's CUDA frontend (host/device call legality, __shared__ rules, <<<>>>); fix qsa variants block_q4_0 packing, de-duplicate native_head_native.cu - check-cu.py now defaults to clang -x cuda --cuda-host-only with real qualifiers; --plain keeps the C++-only pass. - qsa_prompt_attention_variants.cu: block_q4_0 under pack(1) as in kv_q4.hpp (cu_pin refreshed). - native_head_native.cu: orphan copy had __launch_bounds__ before extern "C" __global__ (never nvcc-built); now the sealed twin's text. Co-Authored-By: Claude Sonnet 5.5 --- crates/cuda-driver/src/native_head_native.cu | 717 ++++++------------ .../src/qsa_prompt_attention_variants.cu | 2 + docs/cuda-seal-plan-additions.json | 4 +- scripts/cuda-stubs/check-cu.py | 20 +- scripts/cuda-stubs/cooperative_groups.h | 6 + scripts/cuda-stubs/cublas_v2.h | 6 + scripts/cuda-stubs/cuda_bf16.h | 6 + scripts/cuda-stubs/cuda_fp16.h | 6 + scripts/cuda-stubs/cuda_fp4.h | 6 + scripts/cuda-stubs/cuda_fp8.h | 6 + scripts/cuda-stubs/cuda_stub.h | 157 +++- scripts/cuda-stubs/mma.h | 6 + 12 files changed, 444 insertions(+), 498 deletions(-) diff --git a/crates/cuda-driver/src/native_head_native.cu b/crates/cuda-driver/src/native_head_native.cu index 48e958fa..0dd73151 100644 --- a/crates/cuda-driver/src/native_head_native.cu +++ b/crates/cuda-driver/src/native_head_native.cu @@ -137,8 +137,7 @@ __device__ __forceinline__ float warp_max(float x) { return x; } -__launch_bounds__(QUANT_THREADS, 1) -__global__ void native_quantize_q8_1_kernel(const float* __restrict__ x, +__global__ __launch_bounds__(QUANT_THREADS, 1) void native_quantize_q8_1_kernel(const float* __restrict__ x, Q81Block* __restrict__ y, int n_in) { const int i = int(blockIdx.x) * QUANT_THREADS + int(threadIdx.x); if (i >= n_in) return; // n_in is a multiple of 32: only whole warps return. @@ -217,8 +216,7 @@ __device__ __forceinline__ float q5_q8_dot(const Q5KBlock* __restrict__ bq5, // The generic ncols=1 oracle uses 4 warps and 1 row (or 4 rows for small K), // eight weight blocks per K iteration, warp-ascending shared sum, then XOR tree. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_q5_k_mmvq_kernel(const Q5KBlock* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_q5_k_mmvq_kernel(const Q5KBlock* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -285,8 +283,7 @@ __device__ __forceinline__ float q2_q8_dot(const Q20Block* __restrict__ w, // Q2_0 generic MMVQ: QK=64, QI=2, VDR=1, 64 blocks per iteration. // Preserve the same outer accumulation and cross-warp reduction as the oracle. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_q2_0_mmvq_kernel(const Q20Block* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_q2_0_mmvq_kernel(const Q20Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -373,8 +370,7 @@ __device__ __forceinline__ float q3_q8_dot(const Q3KBlock* __restrict__ w, // Q3_K generic MMVQ: QK=256, QI=16, VDR=1, eight blocks per iteration. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_q3_k_mmvq_kernel(const Q3KBlock* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_q3_k_mmvq_kernel(const Q3KBlock* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -454,8 +450,7 @@ __device__ __forceinline__ float iq4_xs_q8_dot(const IQ4XSBlock* __restrict__ w, // IQ4_XS generic MMVQ: QK=256, QI=32, VDR=4,16 blocks per iteration. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_iq4_xs_mmvq_kernel(const IQ4XSBlock* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_iq4_xs_mmvq_kernel(const IQ4XSBlock* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -549,8 +544,7 @@ __device__ __forceinline__ float q4_q8_dot(const Q4KBlock* __restrict__ bq4, // The generic ncols=1 oracle uses 4 warps and 1 row (or 4 rows for small K), // eight weight blocks per K iteration, warp-ascending shared sum, then XOR tree. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_q4_k_mmvq_kernel(const Q4KBlock* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_q4_k_mmvq_kernel(const Q4KBlock* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -624,8 +618,7 @@ __device__ __forceinline__ float q6_q8_dot(const Q6KBlock* __restrict__ w, // Q6_K generic MMVQ: QK=256, QI=32, VDR=1, four blocks per iteration. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_q6_k_mmvq_kernel(const Q6KBlock* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_q6_k_mmvq_kernel(const Q6KBlock* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -736,8 +729,7 @@ __device__ __forceinline__ float small_q8_dot(const IQ4NLBlock* __restrict__ w, // QI=4 for Q4_0/Q5_0/IQ4_NL and QI=8 for Q8_0. With VDR=2 this preserves // the pinned 64/32-block iteration and 2048/1024-element small-K thresholds. template -__launch_bounds__(WARPS * WARP, 1) -__global__ void native_small_mmvq_kernel(const Weight* __restrict__ w, +__global__ __launch_bounds__(WARPS * WARP, 1) void native_small_mmvq_kernel(const Weight* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = SmallK ? WARPS : 1; @@ -996,8 +988,7 @@ struct SmallTraits { // equal to ncols = 1 only to float rounding (the cross-warp reduction groups partial sums differently). -__launch_bounds__(QUANT_THREADS, 1) -extern "C" __global__ void head_quant(const float* __restrict__ x, +extern "C" __global__ __launch_bounds__(QUANT_THREADS, 1) void head_quant(const float* __restrict__ x, Q81Block* __restrict__ y, int n_in) { const int i = int(blockIdx.x) * QUANT_THREADS + int(threadIdx.x); if (i >= n_in) return; // n_in is a multiple of 32: only whole warps return. @@ -1010,8 +1001,7 @@ extern "C" __global__ void head_quant(const float* __restrict__ x, if (i % Q8K == 0) y[i / Q8K].ds = make_half2(d, sum); } -__launch_bounds__(WARPS * WARP, 1) -extern "C" __global__ void head_n2_s0(const Q40Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(WARPS * WARP, 1) void head_n2_s0(const Q40Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = false ? WARPS : 1; @@ -1046,8 +1036,7 @@ extern "C" __global__ void head_n2_s0(const Q40Block* __restrict__ w, } } -__launch_bounds__(WARPS * WARP, 1) -extern "C" __global__ void head_n2_s1(const Q40Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(WARPS * WARP, 1) void head_n2_s1(const Q40Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int ROWS = true ? WARPS : 1; @@ -1082,8 +1071,7 @@ extern "C" __global__ void head_n2_s1(const Q40Block* __restrict__ w, } } -__launch_bounds__(4 * WARP, 1) -extern "C" __global__ void head_n2_t2_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t2_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1127,8 +1115,7 @@ extern "C" __global__ void head_n2_t2_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t2_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1172,8 +1159,7 @@ extern "C" __global__ void head_n2_t2_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t2_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1217,8 +1203,7 @@ extern "C" __global__ void head_n2_t2_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t3_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1262,8 +1247,7 @@ extern "C" __global__ void head_n2_t3_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t3_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1307,8 +1291,7 @@ extern "C" __global__ void head_n2_t3_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t3_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1352,8 +1335,7 @@ extern "C" __global__ void head_n2_t3_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t4_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1397,8 +1379,7 @@ extern "C" __global__ void head_n2_t4_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t4_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1442,8 +1423,7 @@ extern "C" __global__ void head_n2_t4_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t4_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1487,8 +1467,7 @@ extern "C" __global__ void head_n2_t4_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t5_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1532,8 +1511,7 @@ extern "C" __global__ void head_n2_t5_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t5_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1577,8 +1555,7 @@ extern "C" __global__ void head_n2_t5_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n2_t5_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -1622,8 +1599,7 @@ extern "C" __global__ void head_n2_t5_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t6_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1667,8 +1643,7 @@ extern "C" __global__ void head_n2_t6_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t6_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1712,8 +1687,7 @@ extern "C" __global__ void head_n2_t6_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n2_t6_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -1757,8 +1731,7 @@ extern "C" __global__ void head_n2_t6_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t7_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1802,8 +1775,7 @@ extern "C" __global__ void head_n2_t7_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t7_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1847,8 +1819,7 @@ extern "C" __global__ void head_n2_t7_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n2_t7_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -1892,8 +1863,7 @@ extern "C" __global__ void head_n2_t7_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t8_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1937,8 +1907,7 @@ extern "C" __global__ void head_n2_t8_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n2_t8_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -1982,8 +1951,7 @@ extern "C" __global__ void head_n2_t8_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n2_t8_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -2027,8 +1995,7 @@ extern "C" __global__ void head_n2_t8_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t2_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2144,8 +2109,7 @@ extern "C" __global__ void head_n6_t2_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t2_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2189,8 +2153,7 @@ extern "C" __global__ void head_n6_t2_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t2_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2234,8 +2197,7 @@ extern "C" __global__ void head_n6_t2_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t3_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2279,8 +2241,7 @@ extern "C" __global__ void head_n6_t3_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t3_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2324,8 +2285,7 @@ extern "C" __global__ void head_n6_t3_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t3_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2369,8 +2329,7 @@ extern "C" __global__ void head_n6_t3_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t4_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2414,8 +2373,7 @@ extern "C" __global__ void head_n6_t4_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t4_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2459,8 +2417,7 @@ extern "C" __global__ void head_n6_t4_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t4_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2504,8 +2461,7 @@ extern "C" __global__ void head_n6_t4_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t5_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2549,8 +2505,7 @@ extern "C" __global__ void head_n6_t5_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t5_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2594,8 +2549,7 @@ extern "C" __global__ void head_n6_t5_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n6_t5_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -2639,8 +2593,7 @@ extern "C" __global__ void head_n6_t5_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t6_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2684,8 +2637,7 @@ extern "C" __global__ void head_n6_t6_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t6_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2729,8 +2681,7 @@ extern "C" __global__ void head_n6_t6_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n6_t6_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -2774,8 +2725,7 @@ extern "C" __global__ void head_n6_t6_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t7_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2819,8 +2769,7 @@ extern "C" __global__ void head_n6_t7_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t7_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2864,8 +2813,7 @@ extern "C" __global__ void head_n6_t7_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n6_t7_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -2909,8 +2857,7 @@ extern "C" __global__ void head_n6_t7_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t8_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2954,8 +2901,7 @@ extern "C" __global__ void head_n6_t8_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n6_t8_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -2999,8 +2945,7 @@ extern "C" __global__ void head_n6_t8_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n6_t8_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -3044,8 +2989,7 @@ extern "C" __global__ void head_n6_t8_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t2_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3161,8 +3103,7 @@ extern "C" __global__ void head_n8_t2_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t2_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3206,8 +3147,7 @@ extern "C" __global__ void head_n8_t2_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t2_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3251,8 +3191,7 @@ extern "C" __global__ void head_n8_t2_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t3_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3296,8 +3235,7 @@ extern "C" __global__ void head_n8_t3_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t3_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3341,8 +3279,7 @@ extern "C" __global__ void head_n8_t3_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t3_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3386,8 +3323,7 @@ extern "C" __global__ void head_n8_t3_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t4_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3431,8 +3367,7 @@ extern "C" __global__ void head_n8_t4_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t4_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3476,8 +3411,7 @@ extern "C" __global__ void head_n8_t4_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t4_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3521,8 +3455,7 @@ extern "C" __global__ void head_n8_t4_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t5_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3566,8 +3499,7 @@ extern "C" __global__ void head_n8_t5_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t5_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3611,8 +3543,7 @@ extern "C" __global__ void head_n8_t5_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n8_t5_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -3656,8 +3587,7 @@ extern "C" __global__ void head_n8_t5_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t6_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3701,8 +3631,7 @@ extern "C" __global__ void head_n8_t6_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t6_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3746,8 +3675,7 @@ extern "C" __global__ void head_n8_t6_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n8_t6_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -3791,8 +3719,7 @@ extern "C" __global__ void head_n8_t6_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t7_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3836,8 +3763,7 @@ extern "C" __global__ void head_n8_t7_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t7_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3881,8 +3807,7 @@ extern "C" __global__ void head_n8_t7_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n8_t7_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -3926,8 +3851,7 @@ extern "C" __global__ void head_n8_t7_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t8_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -3971,8 +3895,7 @@ extern "C" __global__ void head_n8_t8_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n8_t8_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4016,8 +3939,7 @@ extern "C" __global__ void head_n8_t8_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n8_t8_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -4061,8 +3983,7 @@ extern "C" __global__ void head_n8_t8_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t2_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4178,8 +4097,7 @@ extern "C" __global__ void head_n20_t2_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t2_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4223,8 +4141,7 @@ extern "C" __global__ void head_n20_t2_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t2_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4268,8 +4185,7 @@ extern "C" __global__ void head_n20_t2_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t3_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4313,8 +4229,7 @@ extern "C" __global__ void head_n20_t3_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t3_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4358,8 +4273,7 @@ extern "C" __global__ void head_n20_t3_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t3_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4403,8 +4317,7 @@ extern "C" __global__ void head_n20_t3_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t4_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4448,8 +4361,7 @@ extern "C" __global__ void head_n20_t4_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t4_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4493,8 +4405,7 @@ extern "C" __global__ void head_n20_t4_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t4_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4538,8 +4449,7 @@ extern "C" __global__ void head_n20_t4_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t5_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4583,8 +4493,7 @@ extern "C" __global__ void head_n20_t5_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t5_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4628,8 +4537,7 @@ extern "C" __global__ void head_n20_t5_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n20_t5_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -4673,8 +4581,7 @@ extern "C" __global__ void head_n20_t5_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t6_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4718,8 +4625,7 @@ extern "C" __global__ void head_n20_t6_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t6_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4763,8 +4669,7 @@ extern "C" __global__ void head_n20_t6_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n20_t6_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -4808,8 +4713,7 @@ extern "C" __global__ void head_n20_t6_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t7_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4853,8 +4757,7 @@ extern "C" __global__ void head_n20_t7_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t7_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4898,8 +4801,7 @@ extern "C" __global__ void head_n20_t7_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n20_t7_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -4943,8 +4845,7 @@ extern "C" __global__ void head_n20_t7_upstream(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t8_large(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -4988,8 +4889,7 @@ extern "C" __global__ void head_n20_t8_large(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(4 * WARP, 1) void head_n20_t8_small(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 4 / WARPS; // blocks per iteration scale with the warp count @@ -5033,8 +4933,7 @@ extern "C" __global__ void head_n20_t8_small(const typename SmallTraits::Block* __restrict__ w, +extern "C" __global__ __launch_bounds__(2 * WARP, 1) void head_n20_t8_upstream(const typename SmallTraits::Block* __restrict__ w, const Q81Block* __restrict__ x, float* __restrict__ y, int n_in, int n_out) { constexpr int BPI = SmallTraits::BPI * 2 / WARPS; // blocks per iteration scale with the warp count @@ -5078,8 +4977,7 @@ extern "C" __global__ void head_n20_t8_upstream(const typename SmallTraits>>(args) -> (cuda_stub_cfg(a, b, c, d), K(args))""" while True: @@ -136,18 +142,21 @@ def lint(path): msgs.append(f'{path}:{n}: error: __shared__ variable with an initializer (nvcc: "initializer not allowed for __shared__ variable")') return msgs -def check(path, fast_math, keep): +def check(path, fast_math, keep, cuda=True): inc = [] for d in INCLUDES: inc += ['-I', d] extra = ['-D__USE_FAST_MATH__=1'] if fast_math else [] - pre = subprocess.run(['clang++', '-E', '-x', 'c++', '-include', 'cuda_runtime.h'] + COMMON + extra + inc + [path], capture_output=True, text=True) + lang = ['-x', 'cuda', '--cuda-host-only', '-nocudainc', '-nocudalib'] if cuda else ['-x', 'c++'] + pre = subprocess.run(['clang++', '-E'] + lang + ['-include', 'cuda_runtime.h'] + COMMON + extra + inc + [path], capture_output=True, text=True) if pre.returncode != 0: return path, False, pre.stderr, 0 - src = rewrite_launches(rewrite_asm(pre.stdout)) + src = rewrite_asm(pre.stdout) + if cuda: src = rewrite_printf(src) + if not cuda: src = rewrite_launches(src) fd, tmp = tempfile.mkstemp(suffix='.ii', dir=keep) os.write(fd, src.encode()); os.close(fd) try: - r = subprocess.run(['clang++', '-fsyntax-only', '-x', 'c++-cpp-output'] + COMMON + WARN + [tmp], capture_output=True, text=True) + r = subprocess.run(['clang++', '-fsyntax-only'] + (['-x', 'cuda-cpp-output', '--cuda-host-only', '-nocudainc', '-nocudalib'] if cuda else ['-x', 'c++-cpp-output']) + COMMON + WARN + [tmp], capture_output=True, text=True) finally: if not keep: os.unlink(tmp) nwarn = r.stderr.count('warning:') @@ -160,13 +169,14 @@ def main(): ap.add_argument('-j', type=int, default=os.cpu_count() or 4) ap.add_argument('-v', action='store_true', help='print diagnostics of passing files too') ap.add_argument('--fast-math', action='store_true') + ap.add_argument('--plain', action='store_true', help='C++-only pass (qualifiers erased) instead of clang\'s CUDA frontend') ap.add_argument('--keep', help='directory to keep the rewritten translation units in') ap.add_argument('--max-errors', type=int, default=12) a = ap.parse_args() files = a.files or sorted(os.path.join(SRC, f) for f in os.listdir(SRC) if f.endswith('.cu')) bad = 0 with concurrent.futures.ThreadPoolExecutor(a.j) as ex: - for path, ok, err, nwarn in ex.map(lambda p: check(os.path.abspath(p), a.fast_math, a.keep), files): + for path, ok, err, nwarn in ex.map(lambda p: check(os.path.abspath(p), a.fast_math, a.keep, not a.plain), files): name = os.path.relpath(path, ROOT) if ok: print(f'ok {name}' + (f' ({nwarn} warnings)' if nwarn else '')) diff --git a/scripts/cuda-stubs/cooperative_groups.h b/scripts/cuda-stubs/cooperative_groups.h index cef6f242..9ab0b355 100644 --- a/scripts/cuda-stubs/cooperative_groups.h +++ b/scripts/cuda-stubs/cooperative_groups.h @@ -1,6 +1,9 @@ // Stub of : thread_block / tiled_partition / this_thread_block / reduce. #pragma once #include "cuda_stub.h" +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif namespace cooperative_groups { struct thread_block { void sync() const; unsigned thread_rank() const; unsigned size() const; dim3 group_index() const; uint3 thread_index() const; dim3 group_dim() const; @@ -17,3 +20,6 @@ template struct maximum { T operator()(T a, T b) const { return a > b template struct less { T operator()(T a, T b) const { return a < b ? a : b; } }; template T reduce(const G&, T v, Op) { return v; } } +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif diff --git a/scripts/cuda-stubs/cublas_v2.h b/scripts/cuda-stubs/cublas_v2.h index eaa273e3..05ef928d 100644 --- a/scripts/cuda-stubs/cublas_v2.h +++ b/scripts/cuda-stubs/cublas_v2.h @@ -1,6 +1,9 @@ // Stub of : only the handle and status names ggml-cuda/common.cuh mentions. #pragma once #include "cuda_stub.h" +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif typedef void* cublasHandle_t; typedef int cublasStatus_t; typedef int cublasComputeType_t; @@ -11,3 +14,6 @@ cublasStatus_t cublasCreate(cublasHandle_t*); cublasStatus_t cublasDestroy(cublasHandle_t); cublasStatus_t cublasSetStream(cublasHandle_t, cudaStream_t); cublasStatus_t cublasSetMathMode(cublasHandle_t, int); +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif diff --git a/scripts/cuda-stubs/cuda_bf16.h b/scripts/cuda-stubs/cuda_bf16.h index 83c8ab77..a5106750 100644 --- a/scripts/cuda-stubs/cuda_bf16.h +++ b/scripts/cuda-stubs/cuda_bf16.h @@ -3,6 +3,9 @@ #include "cuda_stub.h" #ifndef LELEKA_CUDA_STUB_BF16 #define LELEKA_CUDA_STUB_BF16 +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif struct __nv_bfloat16_raw { unsigned short x; }; struct __nv_bfloat162_raw { unsigned short x, y; }; struct __nv_bfloat16 { @@ -45,4 +48,7 @@ __nv_bfloat16 __hneg(__nv_bfloat16); __nv_bfloat16 __habs(__nv_bfloat16); __nv_bfloat162 __hadd2(__nv_bfloat162, __nv_bfloat162); __nv_bfloat162 __hmul2(__nv_bfloat162, __nv_bfloat162); __nv_bfloat162 __hfma2(__nv_bfloat162, __nv_bfloat162, __nv_bfloat162); struct __nv_bfloat16_raw __nv_cvt_e8m0_to_bf16raw(unsigned char); +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif #endif diff --git a/scripts/cuda-stubs/cuda_fp16.h b/scripts/cuda-stubs/cuda_fp16.h index 07b6b473..2096e14a 100644 --- a/scripts/cuda-stubs/cuda_fp16.h +++ b/scripts/cuda-stubs/cuda_fp16.h @@ -4,6 +4,9 @@ #include "cuda_stub.h" #ifndef LELEKA_CUDA_STUB_FP16 #define LELEKA_CUDA_STUB_FP16 +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif struct __half_raw { unsigned short x; }; struct __half2_raw { unsigned short x, y; }; struct __half { @@ -96,4 +99,7 @@ __half2 __shfl_sync(unsigned, __half2, int, int = 32); __half2 __ldg(const __half2*); __half __ldg(const __half*); void atomicAdd(__half*, __half); __half2 atomicAdd(__half2*, __half2); +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif #endif diff --git a/scripts/cuda-stubs/cuda_fp4.h b/scripts/cuda-stubs/cuda_fp4.h index e296efc1..f092e6a5 100644 --- a/scripts/cuda-stubs/cuda_fp4.h +++ b/scripts/cuda-stubs/cuda_fp4.h @@ -1,6 +1,9 @@ // Stub of (CUDA >= 12.8 FP4 E2M1 types, used by the Blackwell MMA path of ggml-cuda/quantize.cu). #pragma once #include "cuda_stub.h" +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif #include "cuda_fp16.h" #include "cuda_bf16.h" typedef unsigned char __nv_fp4_storage_t; @@ -12,3 +15,6 @@ struct __nv_fp4x2_e2m1 { __nv_fp4x2_storage_t __x; __nv_fp4x2_e2m1() = default; struct __nv_fp4x4_e2m1 { __nv_fp4x4_storage_t __x; __nv_fp4x4_e2m1() = default; __nv_fp4x4_e2m1(float4); __nv_fp4x4_e2m1(float2, float2); __nv_fp4x4_e2m1(__half2, __half2); }; __half2_raw __nv_cvt_fp4x2_to_halfraw2(__nv_fp4x2_storage_t, __nv_fp4_interpretation_t); __nv_fp4x2_storage_t __nv_cvt_float2_to_fp4x2(float2, __nv_fp4_interpretation_t, int); +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif diff --git a/scripts/cuda-stubs/cuda_fp8.h b/scripts/cuda-stubs/cuda_fp8.h index fbc2fe1c..22b88a37 100644 --- a/scripts/cuda-stubs/cuda_fp8.h +++ b/scripts/cuda-stubs/cuda_fp8.h @@ -1,6 +1,12 @@ // Stub of . #pragma once #include "cuda_stub.h" +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif typedef unsigned char __nv_fp8_storage_t; struct __nv_fp8_e4m3 { __nv_fp8_storage_t __x; __nv_fp8_e4m3() = default; __nv_fp8_e4m3(float); __nv_fp8_e4m3(double); __nv_fp8_e4m3(int); operator float() const; }; struct __nv_fp8_e5m2 { __nv_fp8_storage_t __x; __nv_fp8_e5m2() = default; __nv_fp8_e5m2(float); __nv_fp8_e5m2(double); operator float() const; }; +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif diff --git a/scripts/cuda-stubs/cuda_stub.h b/scripts/cuda-stubs/cuda_stub.h index 773f6bcd..8e166c68 100644 --- a/scripts/cuda-stubs/cuda_stub.h +++ b/scripts/cuda-stubs/cuda_stub.h @@ -39,6 +39,21 @@ #define __CUDA_ARCH_LIST__ 1200 // ---------------------------------------------------------------------------------------------------- qualifiers +#if defined(__CUDA__) +// clang's CUDA frontend (check-cu.py --cuda): the qualifiers are real, so host/device call legality, __shared__ rules and +// the <<<>>> syntax are checked by the compiler itself. Everything below is declared __host__ __device__ (the region ends +// at the bottom of this file); the builtin variables and the libm overloads are __device__. +#define __global__ __attribute__((global)) +#define __device__ __attribute__((device)) +#define __host__ __attribute__((host)) +#define __shared__ __attribute__((shared)) +#define __constant__ __attribute__((constant)) +#define __managed__ __attribute__((managed)) +#define __forceinline__ __inline__ __attribute__((always_inline)) +#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__))) +#define __grid_constant__ __attribute__((grid_constant)) +#define CUDA_STUB_DEVVAR __device__ +#else #define __global__ #define __device__ #define __host__ @@ -47,15 +62,19 @@ #define __shared__ #define __constant__ #define __managed__ +#define __launch_bounds__(...) +#define __grid_constant__ +#define CUDA_STUB_DEVVAR +#endif #define __restrict__ __restrict #define __align__(n) __attribute__((aligned(n))) -#define __launch_bounds__(...) #define __builtin_align__(n) __attribute__((aligned(n))) #define __maxnreg__(n) #define __cluster_dims__(...) -#define __grid_constant__ #define __builtin_assume(x) ((void) 0) -#define CUDA_STUB_HOST_DEVICE +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif // ---------------------------------------------------------------------------------------------------- vector types #define CUDA_STUB_VEC1(T, N) struct N##1 { T x; }; static inline N##1 make_##N##1(T x) { return N##1{x}; } @@ -124,11 +143,11 @@ struct dim3 { constexpr dim3(uint3 v) : x(v.x), y(v.y), z(v.z) {} constexpr operator uint3() const { return uint3{x, y, z}; } }; -extern const uint3 threadIdx; -extern const uint3 blockIdx; -extern const dim3 blockDim; -extern const dim3 gridDim; -extern const int warpSize; +extern CUDA_STUB_DEVVAR const uint3 threadIdx; +extern CUDA_STUB_DEVVAR const uint3 blockIdx; +extern CUDA_STUB_DEVVAR const dim3 blockDim; +extern CUDA_STUB_DEVVAR const dim3 gridDim; +extern CUDA_STUB_DEVVAR const int warpSize; // ---------------------------------------------------------------------------------------------------- errors / runtime API typedef int cudaError_t; @@ -186,6 +205,9 @@ cudaError_t cudaMemGetInfo(size_t*, size_t*); cudaError_t cudaMallocHost(void**, size_t); cudaError_t cudaFreeHost(void*); cudaError_t cudaMemset(void*, int, size_t); +// driver API / cuBLAS names that ggml-cuda/common.cuh mentions in host helpers +CUresult cuGetErrorString(CUresult, const char**); +const char* cublasGetStatusString(int); cudaError_t cudaLaunchKernel(const void*, dim3, dim3, void**, size_t, cudaStream_t); // ---------------------------------------------------------------------------------------------------- integer / float intrinsics @@ -351,7 +373,9 @@ static inline int __vimax_s32(int a, int b) { return max(a, b); } static inline int __vimin_s32(int a, int b) { return min(a, b); } // ---------------------------------------------------------------------------------------------------- synchronisation, warp, memory +#if !defined(__CUDA__) void __syncthreads(); +#endif int __syncthreads_count(int); int __syncthreads_and(int); int __syncthreads_or(int); @@ -361,7 +385,6 @@ void __threadfence_block(); void __threadfence_system(); void __nanosleep(unsigned); long long clock64(); -clock_t clock(); void __trap(); void __brkpt(); unsigned __activemask(); @@ -445,8 +468,116 @@ template cuda_stub_cfg_t cuda_stub_cfg(A&&, B&&) { return {}; template cuda_stub_cfg_t cuda_stub_cfg(A&&, B&&, C&&) { return {}; } template cuda_stub_cfg_t cuda_stub_cfg(A&&, B&&, C&&, D&&) { return {}; } +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif +#if defined(__CUDA__) +extern "C" unsigned __cudaPushCallConfiguration(dim3, dim3, size_t = 0, void* = nullptr); +extern "C" int cudaConfigureCall(dim3, dim3, size_t = 0, void* = nullptr); // older toolkit spelling, clang looks for either +#endif +// ---- device libm: __host__ __device__ statics so device code resolves expf(x) etc. (clang's own wrappers do the same) +#if defined(__CUDA__) +static __device__ inline float sinf(float x) { return __builtin_sinf(x); } +static __device__ inline float cosf(float x) { return __builtin_cosf(x); } +static __device__ inline float tanf(float x) { return __builtin_tanf(x); } +static __device__ inline float asinf(float x) { return __builtin_asinf(x); } +static __device__ inline float acosf(float x) { return __builtin_acosf(x); } +static __device__ inline float atanf(float x) { return __builtin_atanf(x); } +static __device__ inline float sinhf(float x) { return __builtin_sinhf(x); } +static __device__ inline float coshf(float x) { return __builtin_coshf(x); } +static __device__ inline float tanhf(float x) { return __builtin_tanhf(x); } +static __device__ inline float asinhf(float x) { return __builtin_asinhf(x); } +static __device__ inline float acoshf(float x) { return __builtin_acoshf(x); } +static __device__ inline float atanhf(float x) { return __builtin_atanhf(x); } +static __device__ inline float expf(float x) { return __builtin_expf(x); } +static __device__ inline float exp2f(float x) { return __builtin_exp2f(x); } +static __device__ inline float expm1f(float x) { return __builtin_expm1f(x); } +static __device__ inline float logf(float x) { return __builtin_logf(x); } +static __device__ inline float log2f(float x) { return __builtin_log2f(x); } +static __device__ inline float log10f(float x) { return __builtin_log10f(x); } +static __device__ inline float log1pf(float x) { return __builtin_log1pf(x); } +static __device__ inline float sqrtf(float x) { return __builtin_sqrtf(x); } +static __device__ inline float cbrtf(float x) { return __builtin_cbrtf(x); } +static __device__ inline float fabsf(float x) { return __builtin_fabsf(x); } +static __device__ inline float floorf(float x) { return __builtin_floorf(x); } +static __device__ inline float ceilf(float x) { return __builtin_ceilf(x); } +static __device__ inline float roundf(float x) { return __builtin_roundf(x); } +static __device__ inline float rintf(float x) { return __builtin_rintf(x); } +static __device__ inline float truncf(float x) { return __builtin_truncf(x); } +static __device__ inline float nearbyintf(float x) { return __builtin_nearbyintf(x); } +static __device__ inline float erff(float x) { return __builtin_erff(x); } +static __device__ inline float erfcf(float x) { return __builtin_erfcf(x); } +static __device__ inline float lgammaf(float x) { return __builtin_lgammaf(x); } +static __device__ inline float tgammaf(float x) { return __builtin_tgammaf(x); } +static __device__ inline float logbf(float x) { return __builtin_logbf(x); } +static __device__ inline float atan2f(float x, float y) { return __builtin_atan2f(x, y); } +static __device__ inline float powf(float x, float y) { return __builtin_powf(x, y); } +static __device__ inline float fmaxf(float x, float y) { return __builtin_fmaxf(x, y); } +static __device__ inline float fminf(float x, float y) { return __builtin_fminf(x, y); } +static __device__ inline float fmodf(float x, float y) { return __builtin_fmodf(x, y); } +static __device__ inline float copysignf(float x, float y) { return __builtin_copysignf(x, y); } +static __device__ inline float hypotf(float x, float y) { return __builtin_hypotf(x, y); } +static __device__ inline float remainderf(float x, float y) { return __builtin_remainderf(x, y); } +static __device__ inline float nextafterf(float x, float y) { return __builtin_nextafterf(x, y); } +static __device__ inline float fdimf(float x, float y) { return __builtin_fdimf(x, y); } +static __device__ inline double sin(double x) { return __builtin_sin(x); } +static __device__ inline double cos(double x) { return __builtin_cos(x); } +static __device__ inline double tan(double x) { return __builtin_tan(x); } +static __device__ inline double asin(double x) { return __builtin_asin(x); } +static __device__ inline double acos(double x) { return __builtin_acos(x); } +static __device__ inline double atan(double x) { return __builtin_atan(x); } +static __device__ inline double sinh(double x) { return __builtin_sinh(x); } +static __device__ inline double cosh(double x) { return __builtin_cosh(x); } +static __device__ inline double tanh(double x) { return __builtin_tanh(x); } +static __device__ inline double exp(double x) { return __builtin_exp(x); } +static __device__ inline double exp2(double x) { return __builtin_exp2(x); } +static __device__ inline double expm1(double x) { return __builtin_expm1(x); } +static __device__ inline double log(double x) { return __builtin_log(x); } +static __device__ inline double log2(double x) { return __builtin_log2(x); } +static __device__ inline double log10(double x) { return __builtin_log10(x); } +static __device__ inline double log1p(double x) { return __builtin_log1p(x); } +static __device__ inline double sqrt(double x) { return __builtin_sqrt(x); } +static __device__ inline double cbrt(double x) { return __builtin_cbrt(x); } +static __device__ inline double fabs(double x) { return __builtin_fabs(x); } +static __device__ inline double floor(double x) { return __builtin_floor(x); } +static __device__ inline double ceil(double x) { return __builtin_ceil(x); } +static __device__ inline double round(double x) { return __builtin_round(x); } +static __device__ inline double rint(double x) { return __builtin_rint(x); } +static __device__ inline double trunc(double x) { return __builtin_trunc(x); } +static __device__ inline double nearbyint(double x) { return __builtin_nearbyint(x); } +static __device__ inline double erf(double x) { return __builtin_erf(x); } +static __device__ inline double erfc(double x) { return __builtin_erfc(x); } +static __device__ inline double lgamma(double x) { return __builtin_lgamma(x); } +static __device__ inline double tgamma(double x) { return __builtin_tgamma(x); } +static __device__ inline double atan2(double x, double y) { return __builtin_atan2(x, y); } +static __device__ inline double pow(double x, double y) { return __builtin_pow(x, y); } +static __device__ inline double fmax(double x, double y) { return __builtin_fmax(x, y); } +static __device__ inline double fmin(double x, double y) { return __builtin_fmin(x, y); } +static __device__ inline double fmod(double x, double y) { return __builtin_fmod(x, y); } +static __device__ inline double copysign(double x, double y) { return __builtin_copysign(x, y); } +static __device__ inline double hypot(double x, double y) { return __builtin_hypot(x, y); } +static __device__ inline double remainder(double x, double y) { return __builtin_remainder(x, y); } +static __device__ inline float fmaf(float x, float y, float z) { return __builtin_fmaf(x, y, z); } +static __device__ inline double fma(double x, double y, double z) { return __builtin_fma(x, y, z); } +static __device__ inline float ldexpf(float x, int e) { return __builtin_ldexpf(x, e); } +static __device__ inline float frexpf(float x, int* e) { return __builtin_frexpf(x, e); } +static __device__ inline float scalbnf(float x, int e) { return __builtin_scalbnf(x, e); } +static __device__ inline long lroundf(float x) { return __builtin_lroundf(x); } +static __device__ inline long lrintf(float x) { return __builtin_lrintf(x); } +static __device__ inline int abs(int x) { return x < 0 ? -x : x; } +static __device__ inline long long llabs(long long x) { return x < 0 ? -x : x; } +static __device__ inline bool isnan(float x) { return __builtin_isnan(x); } +static __device__ inline bool isinf(float x) { return __builtin_isinf(x); } +static __device__ inline bool isfinite(float x) { return __builtin_isfinite(x); } +static __device__ inline bool isnan(double x) { return __builtin_isnan(x); } +static __device__ inline bool isinf(double x) { return __builtin_isinf(x); } +static __device__ inline bool isfinite(double x) { return __builtin_isfinite(x); } +static __device__ inline void* memcpy(void* d, const void* s, size_t n) { return __builtin_memcpy(d, s, n); } +static __device__ inline void* memset(void* d, int c, size_t n) { return __builtin_memset(d, c, n); } +static __device__ inline void* memmove(void* d, const void* s, size_t n) { return __builtin_memmove(d, s, n); } +static __device__ inline int memcmp(const void* a, const void* b, size_t n) { return __builtin_memcmp(a, b, n); } +extern "C" __device__ int vprintf(const char*, const char*); +template __device__ inline int cuda_stub_printf(const char*, A...) { return 0; } // check-cu.py rewrites printf( call sites to it +static __device__ inline bool signbit(float x) { return __builtin_signbit(x); } +#endif #endif - -// driver API / cuBLAS names that ggml-cuda/common.cuh mentions in host helpers -CUresult cuGetErrorString(CUresult, const char**); -const char* cublasGetStatusString(int); diff --git a/scripts/cuda-stubs/mma.h b/scripts/cuda-stubs/mma.h index 7fbcc327..474a8f5c 100644 --- a/scripts/cuda-stubs/mma.h +++ b/scripts/cuda-stubs/mma.h @@ -1,6 +1,9 @@ // Stub of (nvcuda::wmma): fragment types only, enough for declarations to parse. #pragma once #include "cuda_stub.h" +#if defined(__CUDA__) +#pragma clang force_cuda_host_device begin +#endif namespace nvcuda { namespace wmma { struct row_major {}; struct col_major {}; struct matrix_a {}; struct matrix_b {}; struct accumulator {}; @@ -12,3 +15,6 @@ template void load_matrix_sync(F&, const T*, unsigned, layout template void store_matrix_sync(T*, const F&, unsigned, layout_t); template void mma_sync(D&, const A&, const B&, const C&); } } +#if defined(__CUDA__) +#pragma clang force_cuda_host_device end +#endif