okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-sycl-prs e106b4c86 into the batch 16 candidate (SYCL pull requests 4185 and 3153)a8a51b280

main
18.2 KiB344 linesraw
1#include "b60_layout_state.hpp"
2// Private phase-boundary adapter for the measured same-payload layouts.
3#include <sycl/sycl.hpp>
4#include <cstdint>
5#include <cstdio>
6#include <stdexcept>
7namespace strata::kernels {
8template<int B> inline int raw_to_packed(int i,int blocks){
9 const int row=i/(blocks*B),kb=(i/B)%blocks,x=i%B,base=kb*16*B;
10 if constexpr(B==56){
11  const int r=row%8,b=(row/8)*8*blocks*56+kb*448;
12  if(x<32)return b+(r*8+x/4)*4+x%4;
13  if(x<48)return b+256+(r*8+(x-32)/2)*2+(x-32)%2;
14  return b+384+r*8+x-48;
15 }
16 if constexpr(B==66){
17  const int r=row%8,b=(row/8)*8*blocks*66+kb*528;
18  if(x<2)return b+512+r*2+x;
19  const int p=(x-2)/8,z=(x-2)%8;
20  return b+(z<4?0:256)+(r*8+p)*4+z%4;
21 }
22 if constexpr(B==136)return base+(x/4)*64+row*4+x%4;
23 if constexpr(B==82){
24  if(x<2)return base+1280+row*2+x;
25  if(x<34)return base+((x-2)/4)*160+row*4+(x-2)%4;
26  if(x<66)return base+((x-34)/4)*160+64+row*4+(x-34)%4;
27  if(x<74)return base+(x-66)*160+128+row*2;
28  return base+(x-74)*160+129+row*2;
29 }
30 if constexpr(B==18){
31  if(x<2)return base+256+row*2+x;
32  const int z=x-2;return base+(z/8)*128+((z%8)/4)*64+row*4+z%4;
33 }
34}
35template<int B> inline int packed_to_raw(int i,int blocks){
36 if constexpr(B==56){
37  const int sub=i/(8*blocks*56),rem=i%(8*blocks*56),kb=rem/448,z=rem%448;
38  int r,x;
39  if(z<256){const int cell=z/4;r=cell/8;x=(cell%8)*4+z%4;}
40  else if(z<384){const int cell=(z-256)/2;r=cell/8;x=32+(cell%8)*2+(z-256)%2;}
41  else {r=(z-384)/8;x=48+(z-384)%8;}
42  return ((sub*8+r)*blocks+kb)*56+x;
43 }
44 if constexpr(B==66){
45  const int sub=i/(8*blocks*66),rem=i%(8*blocks*66),kb=rem/528,z=rem%528;
46  int r,x;
47  if(z>=512){r=(z-512)/2;x=(z-512)%2;}
48  else {const int cell=(z%256)/4;r=cell/8;x=2+(cell%8)*8+(z>=256?4:0)+z%4;}
49  return ((sub*8+r)*blocks+kb)*66+x;
50 }
51 const int kb=i/(16*B),z=i%(16*B);int row,x;
52 if constexpr(B==136){row=(z%64)/4;x=(z/64)*4+z%4;}
53 if constexpr(B==82){
54  if(z>=1280){row=(z-1280)/2;x=(z-1280)%2;}
55  else {const int p=z/160,r=z%160;
56   if(r<64){row=r/4;x=2+p*4+r%4;}
57   else if(r<128){row=(r-64)/4;x=34+p*4+(r-64)%4;}
58   else {row=(r-128)/2;x=((r-128)%2?74:66)+p;}
59  }
60 }
61 if constexpr(B==18){
62  if(z>=256){row=(z-256)/2;x=(z-256)%2;}
63  else {const int p=z/128,r=z%128;row=(r%64)/4;x=2+p*8+(r/64)*4+r%4;}
64 }
65 return (row*blocks+kb)*B+x;
66}
67template<int B,int Blocks> class B60WeightPermute;
68template<int B,int Blocks> void launch_permute(void* const* matrices,int count,int rows,bool inverse,sycl::queue& q){
69 constexpr int blocks=Blocks,words=16*Blocks*B/4;
70 if(size_t(words)*4>q.get_device().get_info<sycl::info::device::local_mem_size>())throw std::invalid_argument("weight tile exceeds local memory");
71 q.submit([&](sycl::handler& h){
72  sycl::local_accessor<uint32_t,1> tile(words,h);
73  h.parallel_for<B60WeightPermute<B,Blocks>>(sycl::nd_range<3>(sycl::range<3>(1,count,(rows/16)*256),sycl::range<3>(1,1,256)),[=](sycl::nd_item<3> it){
74   auto* p=static_cast<uint32_t*>(matrices[it.get_group(1)]);
75   const int t=it.get_local_id(2);const size_t base=it.get_group(2)*size_t(words);
76   for(int w=t;w<words;w+=256)tile[w]=p[base+w];
77   it.barrier(sycl::access::fence_space::local_space);
78   for(int w=t;w<words;w+=256){
79    uint32_t out=0;
80    for(int byte=0;byte<4;++byte){const int j=inverse?raw_to_packed<B>(w*4+byte,blocks):packed_to_raw<B>(w*4+byte,blocks);
81     out|=((tile[j/4]>>(8*(j%4)))&255u)<<(8*byte);
82    }
83    p[base+w]=out;
84   }
85  });
86 });
87}
88void b60_weight_permute_many(void* const* matrices,int count,int rows,int blocks,int type,bool inverse,void* stream){
89 if(!matrices||count<=0||rows<=0||rows%16||blocks<=0||!stream)throw std::invalid_argument("weight permutation geometry");
90 auto& q=*static_cast<sycl::queue*>(stream);if(!q.is_in_order())throw std::invalid_argument("weight permutation needs ordered phase boundary");
91 if(type==29&&blocks==10)launch_permute<56,10>(matrices,count,rows,inverse,q);
92 else if(type==16&&blocks==10)launch_permute<66,10>(matrices,count,rows,inverse,q);
93 else if(type==22&&blocks==10)launch_permute<82,10>(matrices,count,rows,inverse,q);
94 else if(type==42&&blocks==10)launch_permute<18,10>(matrices,count,rows,inverse,q);
95 else if(type==23&&blocks==10)launch_permute<136,10>(matrices,count,rows,inverse,q);
96 else if(type==23&&blocks==24)launch_permute<136,24>(matrices,count,rows,inverse,q);
97 else throw std::invalid_argument("unsupported packed weight type");
98}
99}
100
101#include <atomic>
102namespace strata::kernels {
103namespace {std::atomic<bool> b60_packed_state{false};thread_local bool b60_main_actor_state=false;}
104bool b60_weights_packed(){return b60_packed_state.load(std::memory_order_acquire);}
105void b60_set_weights_packed(bool v){b60_packed_state.store(v,std::memory_order_release);}
106bool b60_main_actor(){return b60_main_actor_state;}
107void b60_set_main_actor(bool v){b60_main_actor_state=v;}
108}
109
110// Exact out-of-place caches. Original raw pointers remain valid for every other consumer.
111#include "b60_weight_cache.hpp"
112#include <map>
113#include <mutex>
114#include <utility>
115namespace strata::kernels {
116namespace {
117struct B60CachedWeight {void* allocation;void* packed;int rows,cols,device;};
118std::mutex b60_cache_mutex;
119std::map<std::pair<uintptr_t,int>,B60CachedWeight> b60_weight_caches;
120inline size_t b60_iq3_cache_byte(size_t i,int blocks){
121 const size_t row=i/(blocks*110),kb=(i/110)%blocks,x=i%110;
122 const size_t r=row%16,base=(row/16)*16*blocks*110+kb*1760;
123 if(x<2)return base+1728+r*2+x;
124 if(x<66){const size_t p=(x-2)/8,z=(x-2)%8;return base+p*208+(z<4?0:64)+r*4+z%4;}
125 if(x<74)return base+(x-66)*208+192+r;
126 if(x<106)return base+((x-74)/4)*208+128+r*4+(x-74)%4;
127 return base+1664+r*4+x-106;
128}
129template<int Kind>class B60SeparateWeightCache;
130}
131const void* b60_cached_weight(const void* original,int kind){
132 std::lock_guard<std::mutex> lock(b60_cache_mutex);
133 auto it=b60_weight_caches.find({reinterpret_cast<uintptr_t>(original),kind});
134 return it==b60_weight_caches.end()?nullptr:it->second.packed;
135}
136void b60_make_weight_cache(const void* original,int rows,int cols,int kind,int device,void* stream){
137 if(!original||!stream||rows<=0||(rows%16&&kind!=24)||cols<=0)throw std::invalid_argument("B60 cache geometry/pointer");
138 const bool iq3=kind==21&&((cols==2560&&rows==6144)||(cols==6144&&rows==2560));
139 const bool iq4=kind==23&&cols==2560&&(rows==6144||rows==12288);
140 const bool head=kind==24&&cols==2560&&(rows==248320||rows==106299);
141 const bool gr=kind==30&&((rows==320&&cols==10240)||(rows==10240&&cols==320));
142 if(!iq3&&!iq4&&!head&&!gr)throw std::invalid_argument("B60 unsupported cache shape/kind");
143 auto& q=*static_cast<sycl::queue*>(stream);
144 if(!q.is_in_order())throw std::invalid_argument("B60 cache preparation requires ordered queue");
145 const size_t raw_bytes=gr?size_t(rows)*cols*2:size_t(rows)*(cols/256)*(iq3?110:136);
146 const size_t bytes=head?size_t((rows+15)/16*16)*(cols/256)*136:raw_bytes;
147 constexpr size_t guard=kB60WeightCacheGuard;
148 void* allocation=sycl::malloc_device(bytes+2*guard,q);if(!allocation)throw std::bad_alloc();
149 void* result=static_cast<uint8_t*>(allocation)+guard;
150 try{
151  q.fill(static_cast<uint8_t*>(allocation),uint8_t(0xa7),bytes+2*guard);
152  if(iq3){
153   const auto* src=static_cast<const uint8_t*>(original);auto* dst=static_cast<uint8_t*>(result);const int blocks=cols/256;
154   q.parallel_for<B60SeparateWeightCache<21>>(sycl::nd_range<1>(((bytes+255)/256)*256,256),[=](sycl::nd_item<1> it){
155    const size_t i=it.get_global_id(0);if(i<bytes)dst[b60_iq3_cache_byte(i,blocks)]=src[i];
156   });
157  }else if(iq4||head){
158   const auto* src=static_cast<const uint8_t*>(original);auto* dst=static_cast<uint8_t*>(result);const int blocks=cols/256;const size_t tile=16*blocks*136;
159   if(head)q.fill(dst,uint8_t(0),bytes);
160   q.parallel_for<B60SeparateWeightCache<23>>(sycl::nd_range<1>(((bytes+255)/256)*256,256),[=](sycl::nd_item<1> it){
161    const size_t i=it.get_global_id(0);if(i<raw_bytes){const size_t base=(i/tile)*tile;dst[base+raw_to_packed<136>(int(i%tile),blocks)]=src[i];}
162   });
163  }else{
164   const auto* src=static_cast<const uint32_t*>(original);auto* dst=static_cast<uint32_t*>(result);const size_t words=bytes/4;const int cw=cols/2;
165   q.parallel_for<B60SeparateWeightCache<30>>(sycl::nd_range<1>(((words+255)/256)*256,256),[=](sycl::nd_item<1> it){
166    const size_t i=it.get_global_id(0);if(i<words){const size_t row=i/cw,k=i%cw;dst[(row/16)*16*cw+k*16+row%16]=src[i];}
167   });
168  }
169  q.wait_and_throw();
170  std::lock_guard<std::mutex> lock(b60_cache_mutex);
171  auto [it,inserted]=b60_weight_caches.emplace(std::make_pair(reinterpret_cast<uintptr_t>(original),kind),B60CachedWeight{allocation,result,rows,cols,device});
172  if(!inserted)throw std::logic_error("B60 cache duplicate raw address/kind, including cross-device aliases");
173 }catch(...){sycl::free(allocation,q);throw;}
174}
175void b60_release_weight_cache(const void* original,int kind,int device,void* stream){
176 void* allocation=nullptr;
177 {
178  std::lock_guard<std::mutex> lock(b60_cache_mutex);
179  auto it=b60_weight_caches.find({reinterpret_cast<uintptr_t>(original),kind});
180  if(it==b60_weight_caches.end()||it->second.device!=device)throw std::logic_error("B60 cache release ownership");
181  allocation=it->second.allocation;b60_weight_caches.erase(it);
182 }
183 sycl::free(allocation,*static_cast<sycl::queue*>(stream));
184}
185}
186
187// Independent registry: existing cache APIs, raw pointers and object ABI stay intact.
188#include "b60_mtp_q8_cache.hpp"
189namespace strata::kernels {
190namespace {
191struct B60MtpQ8Cache {void* allocation;void* packed;int rows,cols,device;unsigned token_mask;};
192std::mutex b60_mtp_q8_mutex;
193std::map<uintptr_t,B60MtpQ8Cache> b60_mtp_q8_caches;
194class B60MtpQ8ByteCache;
195}
196bool b60_has_mtp_q8_cache(const void* raw){
197 std::lock_guard<std::mutex> lock(b60_mtp_q8_mutex);
198 return b60_mtp_q8_caches.count(reinterpret_cast<uintptr_t>(raw))!=0;
199}
200const void* b60_cached_mtp_q8_weight(const void* raw,int rows,int cols,int tokens,int device){
201 std::lock_guard<std::mutex> lock(b60_mtp_q8_mutex);
202 auto it=b60_mtp_q8_caches.find(reinterpret_cast<uintptr_t>(raw));
203 if(it==b60_mtp_q8_caches.end())return nullptr;
204 const auto& c=it->second;
205 if(c.rows!=rows||c.cols!=cols||c.device!=device)throw std::logic_error("B60 MTP Q8 cached pointer geometry/device");
206 return tokens>=1&&tokens<=8&&(c.token_mask&(1u<<tokens))?c.packed:nullptr;
207}
208void b60_make_mtp_q8_cache(const void* raw,int rows,int cols,unsigned mask,int device,void* stream){
209 const bool shape=(cols==2560&&(rows==2560||rows==12288||rows==512||rows==640))||
210                  (rows==2560&&(cols==6144||cols==640));
211 if(!raw||!stream||!shape||!mask||(mask&~((1u<<1)|(1u<<4)|(1u<<8))))throw std::invalid_argument("B60 MTP Q8 cache shape/mask");
212 auto& q=*static_cast<sycl::queue*>(stream);
213 if(!q.is_in_order()||device<0||
214    sycl::get_pointer_type(raw,q.get_context())!=sycl::usm::alloc::device||sycl::get_pointer_device(raw,q.get_context())!=q.get_device())
215  throw std::invalid_argument("B60 MTP Q8 cache ownership/queue");
216 const size_t bytes=size_t(rows)*(cols/32)*34;constexpr size_t guard=128;
217 void* allocation=sycl::malloc_device(bytes+2*guard,q);if(!allocation)throw std::bad_alloc();
218 auto* result=static_cast<uint8_t*>(allocation)+guard;
219 try{
220  q.fill(static_cast<uint8_t*>(allocation),uint8_t(0xa7),bytes+2*guard);
221  const auto* src=static_cast<const uint8_t*>(raw);const int blocks=cols/32;
222  q.parallel_for<B60MtpQ8ByteCache>(sycl::nd_range<1>(((bytes+255)/256)*256,256),[=](sycl::nd_item<1> it){
223   const size_t i=it.get_global_id(0);
224   if(i<bytes){
225    const size_t row=i/(size_t(blocks)*34),kb=(i/34)%blocks,x=i%34,r=row%16;
226    const size_t base=(row/16)*size_t(blocks)*544+kb*544;
227    const size_t dst=x<2?base+r*2+x:base+32+((x-2)/4)*64+r*4+(x-2)%4;
228    result[dst]=src[i];
229   }
230  });
231  q.wait_and_throw();
232  std::lock_guard<std::mutex> lock(b60_mtp_q8_mutex);
233  auto [it,inserted]=b60_mtp_q8_caches.emplace(reinterpret_cast<uintptr_t>(raw),B60MtpQ8Cache{allocation,result,rows,cols,device,mask});
234  if(!inserted)throw std::logic_error("B60 duplicate MTP Q8 cache raw pointer");
235 }catch(...){sycl::free(allocation,q);throw;}
236}
237void b60_release_mtp_q8_cache(const void* raw,int device,void* stream){
238 void* allocation;
239 {
240  std::lock_guard<std::mutex> lock(b60_mtp_q8_mutex);
241  auto it=b60_mtp_q8_caches.find(reinterpret_cast<uintptr_t>(raw));
242  if(it==b60_mtp_q8_caches.end()||it->second.device!=device)throw std::logic_error("B60 MTP Q8 cache release ownership");
243  allocation=it->second.allocation;b60_mtp_q8_caches.erase(it);
244 }
245 sycl::free(allocation,*static_cast<sycl::queue*>(stream));
246}
247}
248
249// Single-device decode: a device-built plan mixes packed resident slots with raw
250// pinned mirrors. Convert only mirror groups into one reusable device arena.
251// Neither the host mirror nor the model file is modified. The two ordered nodes
252// finish every copy before publishing new pointers to the unchanged FP readers.
253namespace strata::kernels {
254namespace {
255struct SingleExpertStage {uint8_t* data=nullptr;sycl::queue* queue=nullptr;size_t stride=0;int cap=0;uintptr_t begin=0,end=0;};
256SingleExpertStage single_stage;
257class B60SingleExpertStageCopy;
258class B60SingleExpertStagePublish;
259class B60SingleExpertMirrorExchangeCoalesced;
260inline size_t single_source_byte(size_t i,int gu,size_t up,size_t down,bool pack16,bool pack29){
261 const size_t base=i<up?0:i<down?up:down;
262 const size_t z=i-base;
263 const int B=i>=down?18:gu==22?82:gu==16&&pack16?66:gu==29&&pack29?56:0;
264 if(!B)return i;
265 const size_t tile=size_t(16)*10*B,b=(z/tile)*tile;const int j=int(z%tile);
266 if(B==18)return base+b+packed_to_raw<18>(j,10);
267 if(B==82)return base+b+packed_to_raw<82>(j,10);
268 if(B==66)return base+b+packed_to_raw<66>(j,10);
269 return base+b+packed_to_raw<56>(j,10);
270}
271inline size_t single_destination_byte(size_t i,int gu,size_t up,size_t down,bool pack16,bool pack29){
272 const size_t base=i<up?0:i<down?up:down,z=i-base;
273 const int B=i>=down?18:gu==22?82:gu==16&&pack16?66:gu==29&&pack29?56:0;
274 if(!B)return i;
275 const size_t tile=size_t(16)*10*B,b=(z/tile)*tile;const int j=int(z%tile);
276 if(B==18)return base+b+raw_to_packed<18>(j,10);
277 if(B==82)return base+b+raw_to_packed<82>(j,10);
278 if(B==66)return base+b+raw_to_packed<66>(j,10);
279 return base+b+raw_to_packed<56>(j,10);
280}
281}
282void b60_single_staging_open(int cap,size_t blob,void* stream){
283 if(single_stage.data||cap<=0||!blob||blob%64||!stream)throw std::invalid_argument("B60 single staging ownership/geometry");
284 auto* q=static_cast<sycl::queue*>(stream);auto* p=sycl::malloc_device<uint8_t>(size_t(cap)*blob,*q);if(!p)throw std::bad_alloc();
285 single_stage={p,q,blob,cap,0,0};q->fill(p,uint8_t(0),size_t(cap)*blob).wait_and_throw();
286 std::fprintf(stderr,"B60_SINGLE_STAGE cap=%d stride=%zu bytes=%zu device=0\n",cap,blob,size_t(cap)*blob);
287}
288void b60_single_staging_bind(const void* base,size_t bytes){
289 if(!single_stage.data||!base||!bytes||single_stage.begin)throw std::invalid_argument("B60 single staging cache range");
290 single_stage.begin=reinterpret_cast<uintptr_t>(base);single_stage.end=single_stage.begin+bytes;
291}
292void b60_single_staging_close(){
293 if(single_stage.data){single_stage.queue->wait_and_throw();sycl::free(single_stage.data,*single_stage.queue);single_stage={};}
294}
295void b60_exchange_single_expert(uint8_t* device,uint8_t* mirror,int gu,size_t up,size_t down,size_t bytes,void* stream){
296 const size_t expected_up=gu==22?524800:gu==16?422400:358400;
297 if(!device||!mirror||!stream||bytes%4||up!=expected_up||up*2!=down||down+460800!=bytes||
298    !(gu==22||gu==16||gu==29)||(reinterpret_cast<uintptr_t>(device)&63)||
299    (reinterpret_cast<uintptr_t>(mirror)&63))
300  throw std::invalid_argument("B60 packed mirror exchange geometry");
301 auto& q=*static_cast<sycl::queue*>(stream);
302 if(!q.is_in_order()||sycl::get_pointer_type(device,q.get_context())!=sycl::usm::alloc::device||
303    sycl::get_pointer_type(mirror,q.get_context())!=sycl::usm::alloc::host||
304    sycl::get_pointer_device(device,q.get_context())!=q.get_device())
305  throw std::invalid_argument("B60 packed mirror exchange ownership");
306 const bool pack16=[] {const char* p=std::getenv("STRATA_PRIVATE_GU_XXS_PACKED");return p&&p[0]=='1';}();
307 const bool pack29=[] {const char* p=std::getenv("STRATA_PRIVATE_GU_IQ1_PACKED");return p&&p[0]=='1';}();
308 // Own a contiguous raw mirror word: all PCIe accesses coalesce. The four
309 // scattered resident bytes are in VRAM and belong only to this work-item.
310 // The bijection permits in-place exchange without a temporary expert blob.
311 auto* host_words=reinterpret_cast<uint32_t*>(mirror);
312 q.parallel_for<B60SingleExpertMirrorExchangeCoalesced>(
313  sycl::nd_range<1>(((bytes/4+255)/256)*256,256),
314  [=](sycl::nd_item<1> it) [[sycl::reqd_sub_group_size(32)]] {
315   const size_t w=it.get_global_id(0);if(w>=bytes/4)return;
316   const uint32_t incoming=host_words[w];uint32_t outgoing=0;
317   for(int b=0;b<4;++b){
318    const size_t packed=single_destination_byte(w*4+b,gu,up,down,pack16,pack29);
319    outgoing|=uint32_t(device[packed])<<(8*b);
320    device[packed]=uint8_t(incoming>>(8*b));
321   }
322   host_words[w]=outgoing;
323  });
324 q.wait_and_throw();
325}
326void b60_stage_single_experts(unsigned long long* ptrs,const int32_t* count,int cap,int gu,size_t up,size_t down,size_t bytes,void* stream){
327 const auto s=single_stage;auto& q=*static_cast<sycl::queue*>(stream);
328 if(!s.data||!s.begin||!q.is_in_order()||q.get_device()!=s.queue->get_device()||cap<1||cap>s.cap||bytes>s.stride||bytes%4||down+460800!=bytes||up*2!=down||!(gu==22||gu==16||gu==29))throw std::invalid_argument("B60 single staging plan/geometry");
329 const bool pack16=[] {const char* p=std::getenv("STRATA_PRIVATE_GU_XXS_PACKED");return p&&p[0]=='1';}();
330 const bool pack29=[] {const char* p=std::getenv("STRATA_PRIVATE_GU_IQ1_PACKED");return p&&p[0]=='1';}();
331 // Each 16 KiB stripe owns disjoint words. All stripes see the original ptrs.
332 const size_t stripes=(bytes+16383)/16384;
333 q.parallel_for<B60SingleExpertStageCopy>(sycl::nd_range<2>(sycl::range<2>(size_t(cap),stripes*256),sycl::range<2>(1,256)),[=](sycl::nd_item<2> it){
334  const int g=int(it.get_group(0));if(g>=*count)return;const uintptr_t src=ptrs[g];if(src>=s.begin&&src<s.end)return;
335  const auto* p=reinterpret_cast<const uint8_t*>(src);auto* dst=reinterpret_cast<uint32_t*>(s.data+size_t(g)*s.stride);
336  const size_t lo=it.get_group(1)*4096,hi=sycl::min(lo+4096,bytes/4);
337  for(size_t w=lo+it.get_local_id(1);w<hi;w+=256){uint32_t out=0;
338   for(int b=0;b<4;++b)out|=uint32_t(p[single_source_byte(w*4+b,gu,up,down,pack16,pack29)])<<(8*b);
339   dst[w]=out;
340  }
341 });
342 q.parallel_for<B60SingleExpertStagePublish>(sycl::range<1>(size_t(cap)),[=](sycl::id<1> it){const int g=int(it[0]);if(g<*count){const uintptr_t src=ptrs[g];if(src<s.begin||src>=s.end)ptrs[g]=reinterpret_cast<uintptr_t>(s.data+size_t(g)*s.stride);}});
343}
344}