Files
leleka/scripts/cuda-stubs/cuda_bf16.h
T
Pavlo RatushnyiandClaude Sonnet 5.5 2ab3a8ca48 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 <noreply@anthropic.com>
2026-10-14 16:56:45 +02:00

55 lines
3.5 KiB
C

// Stub of <cuda_bf16.h> (class shape and intrinsics only; numerics are NOT modelled).
#pragma once
#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 {
unsigned short __x;
__nv_bfloat16() = default;
__nv_bfloat16(const __nv_bfloat16_raw& r) : __x(r.x) {}
__nv_bfloat16(float); __nv_bfloat16(double); __nv_bfloat16(short); __nv_bfloat16(unsigned short);
__nv_bfloat16(int); __nv_bfloat16(unsigned int); __nv_bfloat16(long long); __nv_bfloat16(unsigned long long);
operator __nv_bfloat16_raw() const { return __nv_bfloat16_raw{__x}; }
operator float() const; operator short() const; operator unsigned short() const; operator int() const; operator unsigned int() const;
operator long long() const; operator unsigned long long() const; operator char() const; operator signed char() const; operator unsigned char() const;
explicit operator bool() const;
__nv_bfloat16& operator=(float);
};
typedef __nv_bfloat16 nv_bfloat16;
struct __attribute__((aligned(4))) __nv_bfloat162 {
__nv_bfloat16 x, y;
__nv_bfloat162() = default;
__nv_bfloat162(const __nv_bfloat16& a, const __nv_bfloat16& b) : x(a), y(b) {}
};
typedef __nv_bfloat162 nv_bfloat162;
__nv_bfloat16 operator+(const __nv_bfloat16&, const __nv_bfloat16&); __nv_bfloat16 operator-(const __nv_bfloat16&, const __nv_bfloat16&);
__nv_bfloat16 operator*(const __nv_bfloat16&, const __nv_bfloat16&); __nv_bfloat16 operator/(const __nv_bfloat16&, const __nv_bfloat16&);
__nv_bfloat16 operator-(const __nv_bfloat16&);
bool operator==(const __nv_bfloat16&, const __nv_bfloat16&); bool operator!=(const __nv_bfloat16&, const __nv_bfloat16&);
bool operator<(const __nv_bfloat16&, const __nv_bfloat16&); bool operator>(const __nv_bfloat16&, const __nv_bfloat16&);
bool operator<=(const __nv_bfloat16&, const __nv_bfloat16&); bool operator>=(const __nv_bfloat16&, const __nv_bfloat16&);
__nv_bfloat16 __float2bfloat16(float); __nv_bfloat16 __float2bfloat16_rn(float); __nv_bfloat16 __float2bfloat16_rz(float);
__nv_bfloat16 __double2bfloat16(double);
float __bfloat162float(__nv_bfloat16);
__nv_bfloat162 __float2bfloat162_rn(float); __nv_bfloat162 __floats2bfloat162_rn(float, float); __nv_bfloat162 __halves2bfloat162(__nv_bfloat16, __nv_bfloat16);
float2 __bfloat1622float2(__nv_bfloat162); __nv_bfloat162 __float22bfloat162_rn(float2);
float __low2float(__nv_bfloat162); float __high2float(__nv_bfloat162); __nv_bfloat16 __low2bfloat16(__nv_bfloat162); __nv_bfloat16 __high2bfloat16(__nv_bfloat162);
__nv_bfloat162 __low2bfloat162(__nv_bfloat162); __nv_bfloat162 __high2bfloat162(__nv_bfloat162);
unsigned short __bfloat16_as_ushort(__nv_bfloat16); short __bfloat16_as_short(__nv_bfloat16);
__nv_bfloat16 __ushort_as_bfloat16(unsigned short); __nv_bfloat16 __short_as_bfloat16(short);
__nv_bfloat16 __hadd(__nv_bfloat16, __nv_bfloat16); __nv_bfloat16 __hsub(__nv_bfloat16, __nv_bfloat16);
__nv_bfloat16 __hmul(__nv_bfloat16, __nv_bfloat16); __nv_bfloat16 __hfma(__nv_bfloat16, __nv_bfloat16, __nv_bfloat16);
__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