okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
86bed1c92
main
1#define DPCT_PROFILING_ENABLED 2#include <sycl/sycl.hpp> 3#include "strata/kprof.hpp" 4#include <dpct/dpct.hpp> 5#include "strata/sycl_queue.hpp" 6#include "strata/kernels/bf16_gemv.hpp" 7#include "s26_tsum.dp.hpp" 8#include "strata/kernels/bf16_bits.hpp" 9 10#include <cstdlib> 11#include <limits> 12#include <stdexcept> 13#include <string> 14#include <cmath> 15 16namespace strata::kernels { 17namespace { 18 19// The FP32-activation MMVF implementation below is adapted from llama.cpp 20// 3cf03257f219afbe7334045ff7c6a06ac68c627d, ggml/src/ggml-cuda/{mmvf.cu,common.cuh}. 21// Scope: ordinary contiguous BF16 matrix, one FP32 activation vector, no fusion/ids/channels. 22// 23// MIT License 24// Copyright (c) 2023-2026 The ggml authors 25// 26// Permission is hereby granted, free of charge, to any person obtaining a copy 27// of this software and associated documentation files (the "Software"), to deal 28// in the Software without restriction, including without limitation the rights 29// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 30// copies of the Software, and to permit persons to whom the Software is 31// furnished to do so, subject to the following conditions: 32// 33// The above copyright notice and this permission notice shall be included in all 34// copies or substantial portions of the Software. 35// 36// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 42// SOFTWARE. 43__dpct_inline__ float mmvf_warp_sum (float value ) { 44#pragma unroll 45for (int offset = 16 ;offset > 0 ;offset >>=1 ) 46/* 47DPCT1108: '__shfl_xor_sync' was migrated with the experimental 48feature masked sub_group function which may not be supported by all 49compilers or runtimes. You may need to adjust the code. 50*/ 51value += dpct::experimental::permute_sub_group_by_xor ( 520xffffffffu , sycl::ext::oneapi::this_work_item::get_sub_group (), 53value ,offset ); 54return value ; 55} 56 57template < int BLOCK_SIZE > 58__dpct_inline__ void bf16_f32_mmvf_kernel (const float * __restrict__x , 59const uint16_t * __restrict__w , 60float * __restrict__y ,int n_in ) { 61auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 62const int t = item_ct1 .get_local_id (2 ); 63const uint16_t * row = w + (size_t )item_ct1 .get_group (2 )* n_in ; 64const uint32_t * weights2 = reinterpret_cast < const uint32_t *> (row ); 65const sycl::float2 * inputs2 = reinterpret_cast < const sycl::float2 *> (x ); 66auto & partials = 67* sycl::ext::oneapi::group_local_memory_for_overwrite < float [32 ]> ( 68 sycl::ext::oneapi::this_work_item::get_work_group < 3 > ()); 69if (t < 32 )partials [t ]= 0.0f ; 70item_ct1 .barrier (sycl::access::fence_space::local_space ); 71float acc = 0.0f ; 72for (int pair = t ;pair < n_in /2 ;pair += BLOCK_SIZE ) { 73const uint32_t weight = weights2 [pair ]; 74const sycl::float2 input = inputs2 [pair ]; 75// Match the two ordered multiply-adds in ggml_cuda_mad, not a pair sum followed by one add. 76/* 77DPCT1013: The rounding mode could not be specified and the 78generated code may have different accuracy than the original code. 79Verify the correctness. SYCL math built-in function rounding mode is 80aligned with OpenCL C 1.2 standard. 81*/ 82acc = sycl::fma (f32_from_bf16 ((uint16_t )weight ),input .x (),acc ); 83/* 84DPCT1013: The rounding mode could not be specified and the 85generated code may have different accuracy than the original code. 86Verify the correctness. SYCL math built-in function rounding mode is 87aligned with OpenCL C 1.2 standard. 88*/ 89acc = 90 sycl::fma (f32_from_bf16 ((uint16_t )(weight >>16 )),input .y (),acc ); 91 } 92acc = mmvf_warp_sum (acc ); 93if constexpr (BLOCK_SIZE > 32 ) { 94// All lanes have the same reduced value; one store avoids a same-value shared-memory race. 95if ((t & 31 )== 0 )partials [t /32 ]= acc ; 96item_ct1 .barrier (sycl::access::fence_space::local_space ); 97if (t < 32 )acc = mmvf_warp_sum (partials [t ]); 98 } 99if (t == 0 )y [item_ct1 .get_group (2 )]= acc ; 100} 101 102// the same kernel for up to 8 activation rows - the weight row is read ONCE and every 103// token keeps its own accumulator with exactly the single-row kernel's order (pairs, two ordered FMAs, the same warp 104// and block reductions), so each output is bit-identical to a bf16_f32_mmvf_kernel launch of its own. 105template < int BLOCK_SIZE ,int NT ,bool EXACT_T = true> 106__dpct_inline__ void bf16_f32_mmvf_multi_kernel ( 107const float * __restrict__x ,int64_t ldx ,const uint16_t * __restrict__w , 108float * __restrict__y ,int64_t ldy ,int n_in ,int n_tok ) { 109auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 110const int t = item_ct1 .get_local_id (2 ); 111const uint16_t * row = w + (size_t )item_ct1 .get_group (2 )* n_in ; 112const uint32_t * weights2 = reinterpret_cast < const uint32_t *> (row ); 113auto & partials = 114* sycl::ext::oneapi::group_local_memory_for_overwrite < float [NT ][32 ]> ( 115 sycl::ext::oneapi::this_work_item::get_work_group < 3 > ()); 116if (t < 32 ) { 117#pragma unroll 118for (int k = 0 ;k < NT ;++ k )partials [k ][t ]= 0.0f ; 119 } 120item_ct1 .barrier (sycl::access::fence_space::local_space ); 121float acc [NT ]; 122#pragma unroll 123for (int k = 0 ;k < NT ;++ k )acc [k ]= 0.0f ; 124for (int pair = t ;pair < n_in /2 ;pair += BLOCK_SIZE ) { 125/* 126DPCT1098: The '*' expression is used instead of the __ldg call. 127These two expressions do not provide the exact same functionality. Check 128the generated code for potential precision and/or performance issues. 129*/ 130const uint32_t weight = * (weights2 + pair ); 131const float w0 = f32_from_bf16 ((uint16_t )weight ),w1 = f32_from_bf16 ((uint16_t ) (weight >>16 )); 132#pragma unroll 133for (int k = 0 ;k < NT ;++ k ) { 134if (EXACT_T || k < n_tok ) { 135/* 136DPCT1098: The '*' expression is used instead of the __ldg 137call. These two expressions do not provide the exact same 138functionality. Check the generated code for potential precision 139and/or performance issues. 140*/ 141const sycl::float2 input = 142* (reinterpret_cast < const sycl::float2 *> (x + 143 (size_t )k * ldx )+ 144pair ); 145/* 146DPCT1013: The rounding mode could not be specified and the 147generated code may have different accuracy than the original 148code. Verify the correctness. SYCL math built-in function 149rounding mode is aligned with OpenCL C 1.2 standard. 150*/ 151acc [k ]= sycl::fma (w0 ,input .x (),acc [k ]); 152/* 153DPCT1013: The rounding mode could not be specified and the 154generated code may have different accuracy than the original 155code. Verify the correctness. SYCL math built-in function 156rounding mode is aligned with OpenCL C 1.2 standard. 157*/ 158acc [k ]= sycl::fma (w1 ,input .y (),acc [k ]); 159 } 160 } 161 } 162#pragma unroll 163for (int k = 0 ;k < NT ;++ k ) 164if (EXACT_T || k < n_tok )acc [k ]= mmvf_warp_sum (acc [k ]); 165if constexpr (BLOCK_SIZE > 32 ) { 166if ((t & 31 )== 0 ) 167#pragma unroll 168for (int k = 0 ;k < NT ;++ k ) 169if (EXACT_T || k < n_tok )partials [k ][t /32 ]= acc [k ]; 170item_ct1 .barrier (sycl::access::fence_space::local_space ); 171if (t < 32 ) 172#pragma unroll 173for (int k = 0 ;k < NT ;++ k ) 174if (EXACT_T || k < n_tok )acc [k ]= mmvf_warp_sum (partials [k ][t ]); 175 } 176if (t == 0 ) 177#pragma unroll 178for (int k = 0 ;k < NT ;++ k ) 179if (EXACT_T || k < n_tok ) 180y [(size_t )k * ldy + item_ct1 .get_group (2 )]= acc [k ]; 181} 182 183// S25 (STRATA_MMVF_ROWS=1): RPB output rows per block. Each block read its row's weights once but all T activation 184// rows again (n_out blocks x T x n_in floats through L2 - the part that grew with T); here a block reads the 185// activations once for RPB rows. Per output, thread t still walks pairs t, t + BLOCK_SIZE, ... with the same two 186// ordered FMAs and the same warp and block reductions: bit-identical to bf16_f32_mmvf_multi_kernel. 187// S26 STRATA_LFUSE=1 (AUX): one more block computes row 0 of w_aux into y_aux[k * ldy_aux] - the same per-output 188// code, so each aux output is bitwise what its own bf16_f32_mmvf_multi_kernel launch gave (the shared expert's gate) 189template < int BLOCK_SIZE ,int NT ,int RPB ,bool TS = false,bool AUX = false> 190/* 191DPCT1110: The total declared local variable size in device function 192bf16_f32_mmvf_rows_kernel exceeds 128 bytes and may cause high register 193pressure. Consult with your hardware vendor to find the total register size 194available and adjust the code, or use smaller sub-group size to avoid high 195register pressure. 196*/ 197__dpct_inline__ void bf16_f32_mmvf_rows_kernel ( 198const float * __restrict__x ,int64_t ldx ,const uint16_t * __restrict__w , 199float * __restrict__y ,int64_t ldy ,int n_in ,int n_out ,int n_tok , 200const uint16_t * __restrict__w_aux = nullptr , 201float * __restrict__y_aux = nullptr ,int64_t ldy_aux = 0 ) { 202auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 203const int t = item_ct1 .get_local_id (2 ); 204int o0 = item_ct1 .get_group (2 )* RPB ; 205if constexpr (AUX ) { 206if (item_ct1 .get_group (2 )== item_ct1 .get_group_range (2 )- 1 ) { 207w = w_aux ;y = y_aux ;ldy = ldy_aux ;n_out = 1 ;o0 = 0 ; 208 } 209 } 210auto & partials = * sycl::ext::oneapi::group_local_memory_for_overwrite < 211float [RPB ][NT ][32 ]> ( 212 sycl::ext::oneapi::this_work_item::get_work_group < 3 > ()); 213if constexpr (BLOCK_SIZE > 32 ) { 214if (t < 32 ) 215#pragma unroll 216for (int r = 0 ;r < RPB ;++ r ) 217#pragma unroll 218for (int k = 0 ;k < NT ;++ k )partials [r ][k ][t ]= 0.0f ; 219item_ct1 .barrier (sycl::access::fence_space::local_space ); 220 } 221float acc [RPB ][NT ]; 222#pragma unroll 223for (int r = 0 ;r < RPB ;++ r ) 224#pragma unroll 225for (int k = 0 ;k < NT ;++ k )acc [r ][k ]= 0.0f ; 226for (int pair = t ;pair < n_in /2 ;pair += BLOCK_SIZE ) { 227 sycl::float2 in [NT ]; 228#pragma unroll 229for (int k = 0 ;k < NT ;++ k ) 230if (k < n_tok )in [k ]= reinterpret_cast < const sycl::float2 *> ( 231x + (size_t )k * ldx )[pair ]; 232#pragma unroll 233for (int r = 0 ;r < RPB ;++ r ) { 234if (o0 + r >=n_out )break ; 235const uint32_t weight = reinterpret_cast < const uint32_t *> (w + (size_t ) (o0 + r )* n_in )[pair ]; 236const float w0 = f32_from_bf16 ((uint16_t )weight ),w1 = f32_from_bf16 ((uint16_t ) (weight >>16 )); 237#pragma unroll 238for (int k = 0 ;k < NT ;++ k ) { 239if (k < n_tok ) { 240/* 241DPCT1013: The rounding mode could not be specified and 242the generated code may have different accuracy than the 243original code. Verify the correctness. SYCL math built-in 244function rounding mode is aligned with OpenCL C 1.2 245standard. 246*/ 247acc [r ][k ]= sycl::fma (w0 ,in [k ].x (),acc [r ][k ]); 248/* 249DPCT1013: The rounding mode could not be specified and 250the generated code may have different accuracy than the 251original code. Verify the correctness. SYCL math built-in 252function rounding mode is aligned with OpenCL C 1.2 253standard. 254*/ 255acc [r ][k ]= sycl::fma (w1 ,in [k ].y (),acc [r ][k ]); 256 } 257 } 258 } 259 } 260if constexpr (TS ) {// S26 STRATA_TSUM=1: the RPB x NT warp sums (both stages) as transposed butterflies, bitwise the same 261constexpr int V = RPB * NT ,P = s26ts::pow2_ceil (V ); 262const int lane = t & 31 ,j = s26ts::tsum_token < P > (lane ); 263const bool own = lane == s26ts::tsum_lane < P > (j )&& j < V ; 264float v [P ]; 265#pragma unroll 266for (int q = 0 ;q < P ;++ q )v [q ]= q < V ?acc [q /NT ][q %NT ] :0.0f ; 267float sum = s26ts::tsum < P > (v ,lane ); 268if constexpr (BLOCK_SIZE > 32 ) { 269if (own )partials [j /NT ][j %NT ][t /32 ]= sum ; 270item_ct1 .barrier (sycl::access::fence_space::local_space ); 271if (t >=32 )return ; 272#pragma unroll 273for (int q = 0 ;q < P ;++ q )v [q ]= q < V ?partials [q /NT ][q %NT ][t ] :0.0f ; 274sum = s26ts::tsum < P > (v ,lane ); 275 } 276const int r = j /NT ,k = j %NT ; 277if (own && o0 + r < n_out && k < n_tok )y [(size_t )k * ldy + o0 + r ]= sum ; 278return ; 279 } 280#pragma unroll 281for (int r = 0 ;r < RPB ;++ r ) 282#pragma unroll 283for (int k = 0 ;k < NT ;++ k )acc [r ][k ]= mmvf_warp_sum (acc [r ][k ]); 284if constexpr (BLOCK_SIZE > 32 ) { 285if ((t & 31 )== 0 ) 286#pragma unroll 287for (int r = 0 ;r < RPB ;++ r ) 288#pragma unroll 289for (int k = 0 ;k < NT ;++ k )partials [r ][k ][t /32 ]= acc [r ][k ]; 290/* 291DPCT1064: Migrated __syncthreads call is used in a macro/template 292definition and may not be valid for all macro/template uses. Adjust the 293code. 294*/ 295/* 296DPCT1065: Consider replacing sycl::nd_item::barrier() with 297sycl::nd_item::barrier(sycl::access::fence_space::local_space) for 298better performance if there is no access to global memory. 299*/ 300item_ct1 .barrier (); 301if (t < 32 ) 302#pragma unroll 303for (int r = 0 ;r < RPB ;++ r ) 304#pragma unroll 305for (int k = 0 ;k < NT ;++ k )acc [r ][k ]= mmvf_warp_sum (partials [r ][k ][t ]); 306 } 307if (t == 0 ) 308#pragma unroll 309for (int r = 0 ;r < RPB ;++ r ) 310if (o0 + r < n_out ) 311#pragma unroll 312for (int k = 0 ;k < NT ;++ k ) 313if (k < n_tok )y [(size_t )k * ldy + o0 + r ]= acc [r ][k ]; 314} 315 316template < int B > 317void launch_rows (const float * x ,int64_t ldx ,const uint16_t * w ,float * y , 318int64_t ldy ,int n_in ,int n_out ,int n_tok , 319 dpct::queue_ptr st ,const uint16_t * w_aux = nullptr , 320float * y_aux = nullptr ,int64_t ldy_aux = 0 ) { 321constexpr int RPB = 4 ; 322const unsigned nb = (unsigned ) ((n_out + RPB - 1 ) /RPB ); 323static const bool ts = [] {const char * v = std::getenv ("STRATA_TSUM" );return v && v [0 ]== '1' ; }(); 324if (w_aux != nullptr ) {// S26 STRATA_LFUSE: + one aux row block 325/* 326DPCT1049: The work-group size passed to the SYCL kernel may exceed the 327limit. To get the device limit, query info::device::max_work_group_size. Adjust 328the work-group size if needed. 329*/ 330/* 331DPCT1049: The work-group size passed to the SYCL kernel may exceed the 332limit. To get the device limit, query info::device::max_work_group_size. Adjust 333the work-group size if needed. 334*/ 335#define S26_AUX (TSV ) \ 336 if (n_tok <= 4) { \ 337 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 338 sycl::ext::oneapi::experimental::use_root_sync}; \ 339 \ 340 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 341 auto x_ct0 = x; \ 342 auto ldx_ct1 = ldx; \ 343 auto w_ct2 = w; \ 344 auto y_ct3 = y; \ 345 auto ldy_ct4 = ldy; \ 346 auto n_in_ct5 = n_in; \ 347 auto n_out_ct6 = n_out; \ 348 auto n_tok_ct7 = n_tok; \ 349 auto w_aux_ct8 = w_aux; \ 350 auto y_aux_ct9 = y_aux; \ 351 auto ldy_aux_ct10 = ldy_aux; \ 352 \ 353 cgh.parallel_for<dpct_kernel_name< \ 354 class bf16_f32_mmvf_rows_kernel_7c05e5, dpct_kernel_scalar<B>, \ 355 dpct_kernel_scalar<4>, dpct_kernel_scalar<RPB>, \ 356 dpct_kernel_scalar<TSV>, dpct_kernel_scalar<true>>>( \ 357 sycl::nd_range<3>(sycl::range(1, 1, nb + 1) * \ 358 sycl::range(1, 1, B), \ 359 sycl::range(1, 1, B)), \ 360 exp_props, \ 361 [=](sycl::nd_item<3> item_ct1) \ 362 [[sycl::reqd_sub_group_size(32)]] { \ 363 bf16_f32_mmvf_rows_kernel<B, 4, RPB, TSV, true>( \ 364 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, n_in_ct5, \ 365 n_out_ct6, n_tok_ct7, w_aux_ct8, y_aux_ct9, \ 366 ldy_aux_ct10); \ 367 }); \ 368 }); \ 369 } else { \ 370 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 371 sycl::ext::oneapi::experimental::use_root_sync}; \ 372 \ 373 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 374 auto x_ct0 = x; \ 375 auto ldx_ct1 = ldx; \ 376 auto w_ct2 = w; \ 377 auto y_ct3 = y; \ 378 auto ldy_ct4 = ldy; \ 379 auto n_in_ct5 = n_in; \ 380 auto n_out_ct6 = n_out; \ 381 auto n_tok_ct7 = n_tok; \ 382 auto w_aux_ct8 = w_aux; \ 383 auto y_aux_ct9 = y_aux; \ 384 auto ldy_aux_ct10 = ldy_aux; \ 385 \ 386 cgh.parallel_for<dpct_kernel_name< \ 387 class bf16_f32_mmvf_rows_kernel_681929, dpct_kernel_scalar<B>, \ 388 dpct_kernel_scalar<8>, dpct_kernel_scalar<RPB>, \ 389 dpct_kernel_scalar<TSV>, dpct_kernel_scalar<true>>>( \ 390 sycl::nd_range<3>(sycl::range(1, 1, nb + 1) * \ 391 sycl::range(1, 1, B), \ 392 sycl::range(1, 1, B)), \ 393 exp_props, \ 394 [=](sycl::nd_item<3> item_ct1) \ 395 [[sycl::reqd_sub_group_size(32)]] { \ 396 bf16_f32_mmvf_rows_kernel<B, 8, RPB, TSV, true>( \ 397 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, n_in_ct5, \ 398 n_out_ct6, n_tok_ct7, w_aux_ct8, y_aux_ct9, \ 399 ldy_aux_ct10); \ 400 }); \ 401 }); \ 402 } 403if (ts ) {S26_AUX (true) }else {S26_AUX (false) } 404#undef S26_AUX 405return ; 406 } 407if (ts ) { 408/* 409DPCT1049: The work-group size passed to the SYCL kernel may exceed 410the limit. To get the device limit, query 411info::device::max_work_group_size. Adjust the work-group size if needed. 412*/ 413if (n_tok <=4 ) { 414auto exp_props = sycl::ext::oneapi::experimental::properties { 415 sycl::ext::oneapi::experimental::use_root_sync }; 416 417st -> /* 418DPCT1050: The template argument of the dpct_kernel_name could not be 419deduced. You need to update this code. 420*/ 421parallel_for < dpct_kernel_name < 422class bf16_f32_mmvf_rows_kernel_ff3610 , 423dpct_kernel_scalar < B > ,dpct_kernel_scalar < 4 > , 424dpct_kernel_scalar < RPB > ,dpct_kernel_scalar < true> , 425dpct_kernel_scalar < false>>> ( 426 sycl::nd_range < 3 > (sycl::range (1 ,1 ,nb )* 427 sycl::range (1 ,1 ,B ), 428 sycl::range (1 ,1 ,B )), 429exp_props , 430 [= ](sycl::nd_item < 3 > item_ct1 ) 431 [[sycl ::reqd_sub_group_size (32 )]] { 432bf16_f32_mmvf_rows_kernel < B ,4 ,RPB , true> ( 433x ,ldx ,w ,y ,ldy ,n_in ,n_out ,n_tok ); 434 }); 435 } 436/* 437DPCT1049: The work-group size passed to the SYCL kernel may exceed 438the limit. To get the device limit, query 439info::device::max_work_group_size. Adjust the work-group size if needed. 440*/ 441else { 442auto exp_props = sycl::ext::oneapi::experimental::properties { 443 sycl::ext::oneapi::experimental::use_root_sync }; 444 445st -> /* 446DPCT1050: The template argument of the dpct_kernel_name could not be 447deduced. You need to update this code. 448*/ 449parallel_for < dpct_kernel_name < 450class bf16_f32_mmvf_rows_kernel_1b1bb5 , 451dpct_kernel_scalar < B > ,dpct_kernel_scalar < 8 > , 452dpct_kernel_scalar < RPB > ,dpct_kernel_scalar < true> , 453dpct_kernel_scalar < false>>> ( 454 sycl::nd_range < 3 > (sycl::range (1 ,1 ,nb )* 455 sycl::range (1 ,1 ,B ), 456 sycl::range (1 ,1 ,B )), 457exp_props , 458 [= ](sycl::nd_item < 3 > item_ct1 ) 459 [[sycl ::reqd_sub_group_size (32 )]] { 460bf16_f32_mmvf_rows_kernel < B ,8 ,RPB , true> ( 461x ,ldx ,w ,y ,ldy ,n_in ,n_out ,n_tok ); 462 }); 463 } 464return ; 465 } 466/* 467DPCT1049: The work-group size passed to the SYCL kernel may exceed the 468limit. To get the device limit, query info::device::max_work_group_size. 469Adjust the work-group size if needed. 470*/ 471if (n_tok <=4 ) { 472auto exp_props = sycl::ext::oneapi::experimental::properties { 473 sycl::ext::oneapi::experimental::use_root_sync }; 474 475st -> /* 476DPCT1050: The template argument of the dpct_kernel_name could not be 477deduced. You need to update this code. 478*/ 479parallel_for < dpct_kernel_name < 480class bf16_f32_mmvf_rows_kernel_7ff80d ,dpct_kernel_scalar < B > , 481dpct_kernel_scalar < 4 > ,dpct_kernel_scalar < RPB > , 482dpct_kernel_scalar < false> , 483dpct_kernel_scalar < false>>> ( 484 sycl::nd_range < 3 > (sycl::range (1 ,1 ,nb )* sycl::range (1 ,1 ,B ), 485 sycl::range (1 ,1 ,B )), 486exp_props , 487 [= ](sycl::nd_item < 3 > item_ct1 ) 488 [[sycl ::reqd_sub_group_size (32 )]] { 489bf16_f32_mmvf_rows_kernel < B ,4 ,RPB > ( 490x ,ldx ,w ,y ,ldy ,n_in ,n_out ,n_tok ); 491 }); 492 } 493/* 494DPCT1049: The work-group size passed to the SYCL kernel may exceed the 495limit. To get the device limit, query info::device::max_work_group_size. 496Adjust the work-group size if needed. 497*/ 498else { 499auto exp_props = sycl::ext::oneapi::experimental::properties { 500 sycl::ext::oneapi::experimental::use_root_sync }; 501 502st -> /* 503DPCT1050: The template argument of the dpct_kernel_name could not be 504deduced. You need to update this code. 505*/ 506parallel_for < dpct_kernel_name < 507class bf16_f32_mmvf_rows_kernel_13db68 ,dpct_kernel_scalar < B > , 508dpct_kernel_scalar < 8 > ,dpct_kernel_scalar < RPB > , 509dpct_kernel_scalar < false> , 510dpct_kernel_scalar < false>>> ( 511 sycl::nd_range < 3 > (sycl::range (1 ,1 ,nb )* sycl::range (1 ,1 ,B ), 512 sycl::range (1 ,1 ,B )), 513exp_props , 514 [= ](sycl::nd_item < 3 > item_ct1 ) 515 [[sycl ::reqd_sub_group_size (32 )]] { 516bf16_f32_mmvf_rows_kernel < B ,8 ,RPB > ( 517x ,ldx ,w ,y ,ldy ,n_in ,n_out ,n_tok ); 518 }); 519 } 520} 521 522int mmvf_block_size (int64_t n_in ) { 523int best = 32 ; 524int64_t best_iterations = (n_in + 63 ) /64 ; 525for (int candidate = 64 ;candidate <=256 ;candidate += 32 ) { 526const int64_t iterations = (n_in + 2 * candidate - 1 ) / (2 * candidate ); 527if (iterations < best_iterations ) { 528best_iterations = iterations ; 529best = candidate ; 530 } 531 } 532return best ; 533} 534 535}// namespace 536 537bool bf16_gemv_fp32_mmvf_multi_aux (const float * x ,int64_t ldx ,const uint16_t * w ,float * y ,int64_t ldy , 538int64_t n_in ,int64_t n_out ,int n_tok ,const uint16_t * w_aux ,float * y_aux , 539int64_t ldy_aux ,void * stream ) { 540static const bool rows = [] {const char * v = std::getenv ("STRATA_MMVF_ROWS" );return v && v [0 ]== '1' ; }(); 541// exactly the conditions under which both calls would take the rows / multi kernels at the same block size 542if (!rows || n_out < 64 || n_tok < 2 || n_tok > 8 || n_in <=0 || (n_in & 1 )!= 0 || (ldx & 1 )!= 0 || x == nullptr || 543w == nullptr || y == nullptr || w_aux == nullptr || y_aux == nullptr || (reinterpret_cast < uintptr_t > (x )& 7u )!= 0 ) 544return false; 545const dpct::queue_ptr st = strata::q_of (stream ); 546const int ni = (int )n_in ,no = (int )n_out ; 547switch (mmvf_block_size (n_in )) { 548case 32 :launch_rows < 32 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 549case 64 :launch_rows < 64 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 550case 96 :launch_rows < 96 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 551case 128 :launch_rows < 128 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 552case 160 :launch_rows < 160 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 553case 192 :launch_rows < 192 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 554case 224 :launch_rows < 224 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 555default :launch_rows < 256 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st ,w_aux ,y_aux ,ldy_aux );break ; 556 } 557/* 558DPCT1010: SYCL uses exceptions to report errors and does not use the 559error codes. The cudaGetLastError function call was replaced with 0. You 560need to rewrite this code. 561*/ 562const dpct::err0 result = 0 ; 563/* 564DPCT1000: Error handling if-stmt was detected but could not be 565rewritten. 566*/ 567if (result != 0 ) 568/* 569DPCT1009: SYCL reports errors using exceptions and does not use 570error codes. Please replace the "get_error_string_dummy(...)" with a 571real error-handling function. 572*/ 573/* 574DPCT1001: The statement could not be removed. 575*/ 576throw std::runtime_error ( 577 std::string ("bf16_gemv_fp32_mmvf_multi_aux launch: " )+ 578 dpct::get_error_string_dummy (result )); 579return true; 580} 581 582void bf16_gemv_fp32_mmvf_multi (const float * x ,int64_t ldx ,const uint16_t * w ,float * y ,int64_t ldy , 583int64_t n_in ,int64_t n_out ,int n_tok ,void * stream ) { 584if (n_tok == 1 && ldy >=n_out ) {bf16_gemv_fp32_mmvf (x ,w ,y ,n_in ,n_out ,stream );return ; } 585if (n_tok < 1 || n_tok > 8 || n_in <=0 || (n_in & 1 )!= 0 || n_out <=0 || (ldx & 1 )!= 0 || x == nullptr || 586w == nullptr || y == nullptr || (reinterpret_cast < uintptr_t > (x )& 7u )!= 0 ) 587throw std::invalid_argument ("bf16_gemv_fp32_mmvf_multi: 1..8 rows, even n_in/ldx, aligned pointers" ); 588const dpct::queue_ptr st = strata::q_of (stream ); 589static const bool rows = [] {const char * v = std::getenv ("STRATA_MMVF_ROWS" );return v && v [0 ]== '1' ; }(); 590if (rows && n_out >=64 ) { 591const int ni = (int )n_in ,no = (int )n_out ; 592switch (mmvf_block_size (n_in )) { 593case 32 :launch_rows < 32 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 594case 64 :launch_rows < 64 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 595case 96 :launch_rows < 96 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 596case 128 :launch_rows < 128 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 597case 160 :launch_rows < 160 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 598case 192 :launch_rows < 192 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 599case 224 :launch_rows < 224 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 600default :launch_rows < 256 > (x ,ldx ,w ,y ,ldy ,ni ,no ,n_tok ,st );break ; 601 } 602/* 603DPCT1010: SYCL uses exceptions to report errors and does not use 604the error codes. The cudaGetLastError function call was replaced with 0. 605You need to rewrite this code. 606*/ 607const dpct::err0 result = 0 ; 608/* 609DPCT1000: Error handling if-stmt was detected but could not be 610rewritten. 611*/ 612if (result != 0 ) 613/* 614DPCT1009: SYCL reports errors using exceptions and does not use 615error codes. Please replace the "get_error_string_dummy(...)" with a 616real error-handling function. 617*/ 618/* 619DPCT1001: The statement could not be removed. 620*/ 621throw std::runtime_error ( 622 std::string ("bf16_gemv_fp32_mmvf_multi launch: " )+ 623 dpct::get_error_string_dummy (result )); 624return ; 625 } 626#define STRATA_MMVF_M (N ) \ 627 case N: \ 628 switch (n_tok) { \ 629 case 1: { \ 630 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 631 sycl::ext::oneapi::experimental::use_root_sync}; \ 632 \ 633 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 634 auto x_ct0 = x; \ 635 auto ldx_ct1 = ldx; \ 636 auto w_ct2 = w; \ 637 auto y_ct3 = y; \ 638 auto ldy_ct4 = ldy; \ 639 auto n_in_ct5 = (int)n_in; \ 640 auto n_tok_ct6 = n_tok; \ 641 \ 642 cgh.parallel_for<dpct_kernel_name< \ 643 class bf16_f32_mmvf_multi_kernel_27194f, \ 644 dpct_kernel_scalar<N>, dpct_kernel_scalar<1>, \ 645 dpct_kernel_scalar<true>>>( \ 646 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 647 sycl::range(1, 1, N), \ 648 sycl::range(1, 1, N)), \ 649 exp_props, \ 650 [=](sycl::nd_item<3> item_ct1) \ 651 [[sycl::reqd_sub_group_size(32)]] { \ 652 bf16_f32_mmvf_multi_kernel<N, 1, true>( \ 653 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 654 n_in_ct5, n_tok_ct6); \ 655 }); \ 656 }); \ 657 } break; \ 658 case 2: { \ 659 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 660 sycl::ext::oneapi::experimental::use_root_sync}; \ 661 \ 662 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 663 auto x_ct0 = x; \ 664 auto ldx_ct1 = ldx; \ 665 auto w_ct2 = w; \ 666 auto y_ct3 = y; \ 667 auto ldy_ct4 = ldy; \ 668 auto n_in_ct5 = (int)n_in; \ 669 auto n_tok_ct6 = n_tok; \ 670 \ 671 cgh.parallel_for<dpct_kernel_name< \ 672 class bf16_f32_mmvf_multi_kernel_ded48c, \ 673 dpct_kernel_scalar<N>, dpct_kernel_scalar<2>, \ 674 dpct_kernel_scalar<true>>>( \ 675 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 676 sycl::range(1, 1, N), \ 677 sycl::range(1, 1, N)), \ 678 exp_props, \ 679 [=](sycl::nd_item<3> item_ct1) \ 680 [[sycl::reqd_sub_group_size(32)]] { \ 681 bf16_f32_mmvf_multi_kernel<N, 2, true>( \ 682 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 683 n_in_ct5, n_tok_ct6); \ 684 }); \ 685 }); \ 686 } break; \ 687 case 3: { \ 688 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 689 sycl::ext::oneapi::experimental::use_root_sync}; \ 690 \ 691 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 692 auto x_ct0 = x; \ 693 auto ldx_ct1 = ldx; \ 694 auto w_ct2 = w; \ 695 auto y_ct3 = y; \ 696 auto ldy_ct4 = ldy; \ 697 auto n_in_ct5 = (int)n_in; \ 698 auto n_tok_ct6 = n_tok; \ 699 \ 700 cgh.parallel_for<dpct_kernel_name< \ 701 class bf16_f32_mmvf_multi_kernel_a6c94f, \ 702 dpct_kernel_scalar<N>, dpct_kernel_scalar<3>, \ 703 dpct_kernel_scalar<true>>>( \ 704 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 705 sycl::range(1, 1, N), \ 706 sycl::range(1, 1, N)), \ 707 exp_props, \ 708 [=](sycl::nd_item<3> item_ct1) \ 709 [[sycl::reqd_sub_group_size(32)]] { \ 710 bf16_f32_mmvf_multi_kernel<N, 3, true>( \ 711 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 712 n_in_ct5, n_tok_ct6); \ 713 }); \ 714 }); \ 715 } break; \ 716 case 4: { \ 717 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 718 sycl::ext::oneapi::experimental::use_root_sync}; \ 719 \ 720 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 721 auto x_ct0 = x; \ 722 auto ldx_ct1 = ldx; \ 723 auto w_ct2 = w; \ 724 auto y_ct3 = y; \ 725 auto ldy_ct4 = ldy; \ 726 auto n_in_ct5 = (int)n_in; \ 727 auto n_tok_ct6 = n_tok; \ 728 \ 729 cgh.parallel_for<dpct_kernel_name< \ 730 class bf16_f32_mmvf_multi_kernel_eba2ed, \ 731 dpct_kernel_scalar<N>, dpct_kernel_scalar<4>, \ 732 dpct_kernel_scalar<true>>>( \ 733 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 734 sycl::range(1, 1, N), \ 735 sycl::range(1, 1, N)), \ 736 exp_props, \ 737 [=](sycl::nd_item<3> item_ct1) \ 738 [[sycl::reqd_sub_group_size(32)]] { \ 739 bf16_f32_mmvf_multi_kernel<N, 4, true>( \ 740 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 741 n_in_ct5, n_tok_ct6); \ 742 }); \ 743 }); \ 744 } break; \ 745 case 5: { \ 746 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 747 sycl::ext::oneapi::experimental::use_root_sync}; \ 748 \ 749 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 750 auto x_ct0 = x; \ 751 auto ldx_ct1 = ldx; \ 752 auto w_ct2 = w; \ 753 auto y_ct3 = y; \ 754 auto ldy_ct4 = ldy; \ 755 auto n_in_ct5 = (int)n_in; \ 756 auto n_tok_ct6 = n_tok; \ 757 \ 758 cgh.parallel_for<dpct_kernel_name< \ 759 class bf16_f32_mmvf_multi_kernel_3318a1, \ 760 dpct_kernel_scalar<N>, dpct_kernel_scalar<5>, \ 761 dpct_kernel_scalar<true>>>( \ 762 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 763 sycl::range(1, 1, N), \ 764 sycl::range(1, 1, N)), \ 765 exp_props, \ 766 [=](sycl::nd_item<3> item_ct1) \ 767 [[sycl::reqd_sub_group_size(32)]] { \ 768 bf16_f32_mmvf_multi_kernel<N, 5, true>( \ 769 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 770 n_in_ct5, n_tok_ct6); \ 771 }); \ 772 }); \ 773 } break; \ 774 case 6: { \ 775 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 776 sycl::ext::oneapi::experimental::use_root_sync}; \ 777 \ 778 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 779 auto x_ct0 = x; \ 780 auto ldx_ct1 = ldx; \ 781 auto w_ct2 = w; \ 782 auto y_ct3 = y; \ 783 auto ldy_ct4 = ldy; \ 784 auto n_in_ct5 = (int)n_in; \ 785 auto n_tok_ct6 = n_tok; \ 786 \ 787 cgh.parallel_for<dpct_kernel_name< \ 788 class bf16_f32_mmvf_multi_kernel_eddebc, \ 789 dpct_kernel_scalar<N>, dpct_kernel_scalar<6>, \ 790 dpct_kernel_scalar<true>>>( \ 791 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 792 sycl::range(1, 1, N), \ 793 sycl::range(1, 1, N)), \ 794 exp_props, \ 795 [=](sycl::nd_item<3> item_ct1) \ 796 [[sycl::reqd_sub_group_size(32)]] { \ 797 bf16_f32_mmvf_multi_kernel<N, 6, true>( \ 798 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 799 n_in_ct5, n_tok_ct6); \ 800 }); \ 801 }); \ 802 } break; \ 803 default: { \ 804 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 805 sycl::ext::oneapi::experimental::use_root_sync}; \ 806 \ 807 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 808 auto x_ct0 = x; \ 809 auto ldx_ct1 = ldx; \ 810 auto w_ct2 = w; \ 811 auto y_ct3 = y; \ 812 auto ldy_ct4 = ldy; \ 813 auto n_in_ct5 = (int)n_in; \ 814 auto n_tok_ct6 = n_tok; \ 815 \ 816 cgh.parallel_for<dpct_kernel_name< \ 817 class bf16_f32_mmvf_multi_kernel_b73f0b, \ 818 dpct_kernel_scalar<N>, dpct_kernel_scalar<8>, \ 819 dpct_kernel_scalar<false>>>( \ 820 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 821 sycl::range(1, 1, N), \ 822 sycl::range(1, 1, N)), \ 823 exp_props, \ 824 [=](sycl::nd_item<3> item_ct1) \ 825 [[sycl::reqd_sub_group_size(32)]] { \ 826 bf16_f32_mmvf_multi_kernel<N, 8, false>( \ 827 x_ct0, ldx_ct1, w_ct2, y_ct3, ldy_ct4, \ 828 n_in_ct5, n_tok_ct6); \ 829 }); \ 830 }); \ 831 } break; \ 832 } break 833switch (mmvf_block_size (n_in )) { 834STRATA_MMVF_M (32 );STRATA_MMVF_M (64 );STRATA_MMVF_M (96 );STRATA_MMVF_M (128 ); 835STRATA_MMVF_M (160 );STRATA_MMVF_M (192 );STRATA_MMVF_M (224 );STRATA_MMVF_M (256 ); 836 } 837#undef STRATA_MMVF_M 838/* 839DPCT1010: SYCL uses exceptions to report errors and does not use the 840error codes. The cudaGetLastError function call was replaced with 0. You 841need to rewrite this code. 842*/ 843const dpct::err0 result = 0 ; 844/* 845DPCT1000: Error handling if-stmt was detected but could not be 846rewritten. 847*/ 848if (result != 0 ) 849/* 850DPCT1009: SYCL reports errors using exceptions and does not use 851error codes. Please replace the "get_error_string_dummy(...)" with a 852real error-handling function. 853*/ 854/* 855DPCT1001: The statement could not be removed. 856*/ 857throw std::runtime_error ( 858 std::string ("bf16_gemv_fp32_mmvf_multi launch: " )+ 859 dpct::get_error_string_dummy (result )); 860} 861 862void bf16_gemv_fp32_mmvf (const float * x ,const uint16_t * w ,float * y , 863int64_t n_in ,int64_t n_out ,void * stream ) { 864if (n_in <=0 || (n_in & 1 )!= 0 || n_in > std::numeric_limits < int > ::max ()|| 865n_out <=0 || n_out > std::numeric_limits < int > ::max ()) 866throw std::invalid_argument ("bf16_gemv_fp32_mmvf: require positive even n_in and positive n_out <= INT_MAX" ); 867if (x == nullptr || w == nullptr || y == nullptr || 868 (reinterpret_cast < uintptr_t > (x )& 7u )!= 0 || 869 (reinterpret_cast < uintptr_t > (w )& 3u )!= 0 || 870 (reinterpret_cast < uintptr_t > (y )& 3u )!= 0 ) 871throw std::invalid_argument ("bf16_gemv_fp32_mmvf: null or misaligned pointer" ); 872const dpct::queue_ptr st = strata::q_of (stream ); 873#define STRATA_MMVF_CASE (N ) \ 874 case N: { \ 875 auto exp_props = sycl::ext::oneapi::experimental::properties{ \ 876 sycl::ext::oneapi::experimental::use_root_sync}; \ 877 \ 878 strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) { \ 879 auto x_ct0 = x; \ 880 auto w_ct1 = w; \ 881 auto y_ct2 = y; \ 882 auto n_in_ct3 = (int)n_in; \ 883 \ 884 cgh.parallel_for<dpct_kernel_name< \ 885 class bf16_f32_mmvf_kernel_2903a5, dpct_kernel_scalar<N>>>( \ 886 sycl::nd_range<3>(sycl::range(1, 1, (unsigned)n_out) * \ 887 sycl::range(1, 1, N), \ 888 sycl::range(1, 1, N)), \ 889 exp_props, \ 890 [=](sycl::nd_item<3> item_ct1) \ 891 [[sycl::reqd_sub_group_size(32)]] { \ 892 bf16_f32_mmvf_kernel<N>(x_ct0, w_ct1, y_ct2, \ 893 n_in_ct3); \ 894 }); \ 895 }); \ 896 } break 897switch (mmvf_block_size (n_in )) { 898STRATA_MMVF_CASE (32 ); 899STRATA_MMVF_CASE (64 ); 900STRATA_MMVF_CASE (96 ); 901STRATA_MMVF_CASE (128 ); 902STRATA_MMVF_CASE (160 ); 903STRATA_MMVF_CASE (192 ); 904STRATA_MMVF_CASE (224 ); 905STRATA_MMVF_CASE (256 ); 906 } 907#undef STRATA_MMVF_CASE 908/* 909DPCT1010: SYCL uses exceptions to report errors and does not use the 910error codes. The cudaGetLastError function call was replaced with 0. You 911need to rewrite this code. 912*/ 913const dpct::err0 result = 0 ; 914/* 915DPCT1000: Error handling if-stmt was detected but could not be 916rewritten. 917*/ 918if (result != 0 ) 919/* 920DPCT1009: SYCL reports errors using exceptions and does not use 921error codes. Please replace the "get_error_string_dummy(...)" with a 922real error-handling function. 923*/ 924/* 925DPCT1001: The statement could not be removed. 926*/ 927throw std::runtime_error (std::string ("bf16_gemv_fp32_mmvf launch: " )+ 928 dpct::get_error_string_dummy (result )); 929} 930 931 932 933void bf16_gemv_fp32_mmvf_cols (const float * x ,const uint16_t * w ,float * y ,int64_t n_in ,int64_t n_out ,int ncols , 934void * stream ) { 935// columns contiguous: the existing multi-row kernel (weight read once, each output bitwise its one-row call), 936// up to 8 rows per launch 937for (int c0 = 0 ;c0 < ncols ;c0 += 8 ) { 938const int nc = ncols - c0 < 8 ?ncols - c0 :8 ; 939if (nc == 1 )bf16_gemv_fp32_mmvf (x + (size_t )c0 * n_in ,w ,y + (size_t )c0 * n_out ,n_in ,n_out ,stream ); 940else bf16_gemv_fp32_mmvf_multi (x + (size_t )c0 * n_in ,n_in ,w ,y + (size_t )c0 * n_out ,n_out ,n_in ,n_out ,nc , 941stream ); 942 } 943} 944 945}// namespace strata::kernels