From a88b321433647958d78764ff61ba307856d84a99 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Sat, 30 May 2026 17:00:51 +0000 Subject: [PATCH] P6: Fix host-side BF16 conversion in test --- tests/unit/test_p6_tma_store.cu | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_p6_tma_store.cu b/tests/unit/test_p6_tma_store.cu index bce8a4cf..20768ea3 100644 --- a/tests/unit/test_p6_tma_store.cu +++ b/tests/unit/test_p6_tma_store.cu @@ -53,10 +53,12 @@ int main() { auto init_bf16 = [](bf16_t* d, int n) { float* h = new float[n]; for (int i = 0; i < n; i++) h[i] = (float)rand() / RAND_MAX - 0.5f; + // Use host-side BF16 conversion for (int i = 0; i < n; i++) { - unsigned short us; - asm("cvt.rn.bf16.f32 %0, %1;" : "=h"(us) : "f"(h[i])); - d[i] = us; + uint32_t u; + memcpy(&u, &h[i], 4); + u = u >> 16; // truncate FP32 to BF16 (rough but sufficient for test) + d[i] = (bf16_t)(u & 0xFFFF); } delete[] h; };