okami.mom/strata

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

Niko1221Merge f-037-arc (5eaee81a4)86bed1c92

main
21.8 KiB503 linesraw
1// src/kernels/cuda/kv_stream.cu - see include/strata/kernels/kv_stream.hpp.
2#define DPCT_PROFILING_ENABLED
3#include <sycl/sycl.hpp>
4#include "strata/kprof.hpp"
5#include <dpct/dpct.hpp>
6#include "strata/sycl_queue.hpp"
7#include "strata/kernels/kv_stream.hpp"
8#include "strata/kernels/kv_q4.hpp"
9#include "strata/kernels/kv_q8.hpp"
10
11#include <algorithm>
12#include <cstdio>
13#include <cstdlib>
14#include <cmath>
15
16namespace strata::kernels {
17namespace {
18
19void check(const char* what) {
20    /*
21    DPCT1010: SYCL uses exceptions to report errors and does not use the
22    error codes. The cudaGetLastError function call was replaced with 0. You
23    need to rewrite this code.
24    */
25    const dpct::err0 e = 0;
26}
27
28constexpr int RT = 1024;   // the resolve block
29
30// The per-block byte runs of the (up to four) pool arrays: block b of array i is bytes [b * len, (b + 1) * len).
31struct Runs {
32    const uint8_t* src[4];
33    uint8_t* dst[4];
34    int len[4];
35    int n;
36};
37
38Runs runs_of(const QsaAttnPools& slots, const KvHostPools& host, int fmt, const QsaShapes& s) {
39    const int rows = (int) (s.n_head_kv * s.page_size);
40    Runs r{};
41    if (fmt == kKvHybrid) {   // K8V4: int8 K codes, their scales, rotated q4_0 V
42        const int codes = rows * (int) s.head_dim, scales = rows * (int) (s.head_dim / KV_Q8_GROUP) * 2;
43        const int v = rows * (int) kv_q4_bytes_per_head((int) s.head_dim);
44        r.src[0] = (const uint8_t*) host.k_q;     r.dst[0] = (uint8_t*) slots.k_q;     r.len[0] = codes;
45        r.src[1] = (const uint8_t*) host.k_scale; r.dst[1] = (uint8_t*) slots.k_scale; r.len[1] = scales;
46        r.src[2] = (const uint8_t*) host.v_q4;    r.dst[2] = (uint8_t*) slots.v_q4;    r.len[2] = v;
47        r.n = 3;
48    } else if (fmt == kKvQ4) {
49        const int bytes = rows * (int) kv_q4_bytes_per_head((int) s.head_dim);
50        r.src[0] = (const uint8_t*) host.k_q4; r.dst[0] = (uint8_t*) slots.k_q4; r.len[0] = bytes;
51        r.src[1] = (const uint8_t*) host.v_q4; r.dst[1] = (uint8_t*) slots.v_q4; r.len[1] = bytes;
52        r.n = 2;
53    } else if (fmt == kKvInt8) {
54        const int codes = rows * (int) s.head_dim, scales = rows * (int) (s.head_dim / KV_Q8_GROUP) * 2;
55        r.src[0] = (const uint8_t*) host.k_q;     r.dst[0] = (uint8_t*) slots.k_q;     r.len[0] = codes;
56        r.src[1] = (const uint8_t*) host.v_q;     r.dst[1] = (uint8_t*) slots.v_q;     r.len[1] = codes;
57        r.src[2] = (const uint8_t*) host.k_scale; r.dst[2] = (uint8_t*) slots.k_scale; r.len[2] = scales;
58        r.src[3] = (const uint8_t*) host.v_scale; r.dst[3] = (uint8_t*) slots.v_scale; r.len[3] = scales;
59        r.n = 4;
60    } else {
61        const int bytes = rows * (int) s.head_dim * 2;
62        r.src[0] = (const uint8_t*) host.k_pool; r.dst[0] = (uint8_t*) slots.k_pool; r.len[0] = bytes;
63        r.src[1] = (const uint8_t*) host.v_pool; r.dst[1] = (uint8_t*) slots.v_pool; r.len[1] = bytes;
64        r.n = 2;
65    }
66    return r;
67}
68
69// Block-wide exclusive prefix sum of one int per thread (RT threads); `total` is the sum over the block.
70inline int block_scan(int v, int *warp_sums, int &total) {
71    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
72    const int lane = item_ct1.get_local_id(2) & 31,
73              w = item_ct1.get_local_id(2) >> 5;
74    int x = v;
75    for (int o = 1; o < 32; o <<= 1) {
76        /*
77        DPCT1108: '__shfl_up_sync' was migrated with the experimental feature
78        masked sub_group function which may not be supported by all compilers or
79        runtimes. You may need to adjust the code.
80        */
81        const int y = dpct::experimental::shift_sub_group_right(
82            0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(), x,
83            o);
84        if (lane >= o) x += y;
85    }
86    if (lane == 31) warp_sums[w] = x;
87    /*
88    DPCT1065: Consider replacing sycl::nd_item::barrier() with
89    sycl::nd_item::barrier(sycl::access::fence_space::local_space) for better
90    performance if there is no access to global memory.
91    */
92    item_ct1.barrier();
93    if (w == 0) {
94        int t = warp_sums[lane];
95        for (int o = 1; o < 32; o <<= 1) {
96            /*
97            DPCT1108: '__shfl_up_sync' was migrated with the experimental
98            feature masked sub_group function which may not be supported by all
99            compilers or runtimes. You may need to adjust the code.
100            */
101            const int y = dpct::experimental::shift_sub_group_right(
102                0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),
103                t, o);
104            if (lane >= o) t += y;
105        }
106        warp_sums[lane] = t;
107    }
108    /*
109    DPCT1065: Consider replacing sycl::nd_item::barrier() with
110    sycl::nd_item::barrier(sycl::access::fence_space::local_space) for better
111    performance if there is no access to global memory.
112    */
113    item_ct1.barrier();
114    total = warp_sums[31];
115    const int excl = x - v + (w > 0 ? warp_sums[w - 1] : 0);
116    /*
117    DPCT1065: Consider replacing sycl::nd_item::barrier() with
118    sycl::nd_item::barrier(sycl::access::fence_space::local_space) for better
119    performance if there is no access to global memory.
120    */
121    item_ct1.barrier();
122    return excl;
123}
124
125__dpct_inline__ void resolve_kernel(KvStreamMap m,
126                                    const int32_t *__restrict__ ids,
127                                    const int32_t *__restrict__ steps, int n_q,
128                                    int cap, int page_size) {
129    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
130auto &s_nmiss = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(
131    sycl::ext::oneapi::this_work_item::get_work_group<3>());
132    auto &s_lookups = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(
133        sycl::ext::oneapi::this_work_item::get_work_group<3>());
134    auto &s_cut = *sycl::ext::oneapi::group_local_memory_for_overwrite<int>(
135        sycl::ext::oneapi::this_work_item::get_work_group<3>());
136    auto &warp_sums =
137        *sycl::ext::oneapi::group_local_memory_for_overwrite<int[32]>(
138            sycl::ext::oneapi::this_work_item::get_work_group<3>());
139    const int epoch = m.ctl[0] + 1;
140    if (item_ct1.get_local_id(2) == 0) { s_nmiss = 0; s_lookups = 0; }
141    /*
142    DPCT1065: Consider replacing sycl::nd_item::barrier() with
143    sycl::nd_item::barrier(sycl::access::fence_space::local_space) for better
144    performance if there is no access to global memory.
145    */
146    item_ct1.barrier();
147    // 1. hits take this epoch and their reference bit; a missing block is claimed exactly once (-1 -> -2)
148    int lookups = 0;
149    for (int q = 0; q < n_q; ++q) {
150        const int width = steps[q * kStepCount + kStepWidth];
151        const int32_t* qi = ids + (long long) q * cap;
152        for (int i = item_ct1.get_local_id(2); i < width; i += RT) {
153            const int b = qi[i] / page_size;
154            if (i > 0 && qi[i - 1] / page_size == b) continue;   // ids are ascending: one lookup per block
155            ++lookups;
156            const int sl = m.page_table[b];
157            if (sl >= 0) {
158                m.slot_stamp[sl] = epoch;
159                m.slot_ref[sl] = 1;
160            } else if (sl == -1 &&
161                       dpct::atomic_compare_exchange_strong<
162                           sycl::access::address_space::generic_space>(
163                           &m.page_table[b], -1, -2) == -1) {
164                m.miss_block[dpct::atomic_fetch_add<
165                    sycl::access::address_space::generic_space>(&s_nmiss, 1)] =
166                    b;
167            }
168        }
169    }
170    if (lookups > 0)
171        dpct::atomic_fetch_add<sycl::access::address_space::generic_space>(
172            &s_lookups, lookups); // (#783, stuchapin909) most threads see none:
173                                  // skip the shared atomic
174    /*
175    DPCT1065: Consider replacing sycl::nd_item::barrier() with
176    sycl::nd_item::barrier(sycl::access::fence_space::local_space) for better
177    performance if there is no access to global memory.
178    */
179    item_ct1.barrier();
180    // 2. one victim per miss: a clock sweep from the hand. A slot this call uses (stamp == epoch) is never taken;
181    //    a referenced one loses its bit as the hand passes it and is taken on the next pass.
182    const int need = s_nmiss, n = (int) m.n_slots;
183    int hand = m.ctl[1], got = 0;
184    for (int scanned = 0; got < need && scanned < 3 * n; scanned += RT) {
185        const int j = (int)(((long long)hand + item_ct1.get_local_id(2)) % n);
186        const bool mine = m.slot_stamp[j] == epoch;
187        const bool cand = !mine && (m.slot_block[j] < 0 || m.slot_ref[j] == 0);
188        int total = 0;
189        const int rank = block_scan(cand ? 1 : 0, warp_sums, total);
190        const int want = need - got;
191        if (item_ct1.get_local_id(2) == 0) s_cut = RT;
192        /*
193        DPCT1118: SYCL group functions and algorithms must be encountered in
194        converged control flow. You may need to adjust the code.
195        */
196        /*
197        DPCT1065: Consider replacing sycl::nd_item::barrier() with
198        sycl::nd_item::barrier(sycl::access::fence_space::local_space) for
199        better performance if there is no access to global memory.
200        */
201        item_ct1.barrier();
202        if (cand && rank == want - 1) s_cut =
203            item_ct1.get_local_id(2) +
204            1; // the hand stops just past the last slot taken
205        /*
206        DPCT1118: SYCL group functions and algorithms must be encountered in
207        converged control flow. You may need to adjust the code.
208        */
209        /*
210        DPCT1065: Consider replacing sycl::nd_item::barrier() with
211        sycl::nd_item::barrier(sycl::access::fence_space::local_space) for
212        better performance if there is no access to global memory.
213        */
214        item_ct1.barrier();
215        const int cut = s_cut;
216        if (cand && rank < want) {
217            m.miss_slot[got + rank] = j;
218            m.slot_stamp[j] = epoch;   // taken: a sweep that wraps around must not take it twice
219        } else if (item_ct1.get_local_id(2) < cut && !mine) {
220            m.slot_ref[j] = 0;
221        }
222        got += total < want ? total : want;
223        hand = (int) (((long long) hand + cut) % n);
224        /*
225        DPCT1118: SYCL group functions and algorithms must be encountered in
226        converged control flow. You may need to adjust the code.
227        */
228        /*
229        DPCT1065: Consider replacing sycl::nd_item::barrier() with
230        sycl::nd_item::barrier(sycl::access::fence_space::local_space) for
231        better performance if there is no access to global memory.
232        */
233        item_ct1.barrier();
234    }
235    // 3. re-point the table; the copy kernel fills the slots
236    const int placed = got < need ? got : need;
237    for (int k = item_ct1.get_local_id(2); k < need; k += RT) {
238        const int b = m.miss_block[k];
239        if (k >= placed) { m.page_table[b] = -1; continue; }   // overflow: never happens with a legal n_slots
240        const int sl = m.miss_slot[k];
241        const int old = m.slot_block[sl];
242        if (old >= 0) m.page_table[old] = -1;
243        m.slot_block[sl] = b;
244        m.slot_stamp[sl] = epoch;
245        m.slot_ref[sl] = 1;
246        m.page_table[b] = sl;
247    }
248    if (item_ct1.get_local_id(2) == 0) {
249        m.ctl[0] = epoch;
250        m.ctl[1] = hand;
251        m.ctl[2] = placed;
252        if (placed < need) m.ctl[3] = 1;
253        unsigned long long* c = reinterpret_cast<unsigned long long*>(m.ctl + 4);
254        c[0] += (unsigned long long) placed;
255        c[1] += (unsigned long long) s_lookups;
256        c[2] += 1ull;
257    }
258}
259
260// One block per missed block (grid-stride): copy its runs from the host copy into its slot, 16 B per thread.
261__dpct_inline__ void copy_kernel(KvStreamMap m, Runs r) {
262    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
263    const int need = m.ctl[2];
264    for (int k = item_ct1.get_group(2); k < need;
265         k += item_ct1.get_group_range(2)) {
266        const long long b = m.miss_block[k], sl = m.miss_slot[k];
267        for (int a = 0; a < r.n; ++a) {
268            const sycl::uint4 *src =
269                reinterpret_cast<const sycl::uint4 *>(r.src[a] + b * r.len[a]);
270            sycl::uint4 *dst =
271                reinterpret_cast<sycl::uint4 *>(r.dst[a] + sl * r.len[a]);
272#pragma unroll
273            for (int i = item_ct1.get_local_id(2); i < r.len[a] / 16;
274                 i += item_ct1.get_local_range(2)) dst[i] = src[i];
275        }
276    }
277}
278
279__dpct_inline__ void reset_kernel(KvStreamMap m) {
280    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
281    const long long i0 = (long long)item_ct1.get_group(2) *
282                             item_ct1.get_local_range(2) +
283                         item_ct1.get_local_id(2),
284                    st = (long long)item_ct1.get_group_range(2) *
285                         item_ct1.get_local_range(2);
286#pragma unroll
287    for (long long i = i0; i < m.n_blocks; i += st) m.page_table[i] = -1;
288#pragma unroll
289    for (long long i = i0; i < m.n_slots; i += st) {
290        m.slot_block[i] = -1;
291        m.slot_stamp[i] = -1;
292        m.slot_ref[i] = 0;
293    }
294    if (i0 < kKvCtlInts) m.ctl[i0] = 0;
295}
296
297__dpct_inline__ void ring_kernel(int32_t *table, long long n_blocks,
298                                 long long n_slots) {
299    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
300#pragma unroll
301    for (long long i =
302             (long long)item_ct1.get_group(2) * item_ct1.get_local_range(2) +
303             item_ct1.get_local_id(2);
304         i < n_blocks; i += (long long)item_ct1.get_group_range(2) *
305                            item_ct1.get_local_range(2))
306        table[i] = (int32_t) (i % n_slots);
307}
308
309}  // namespace
310
311uint64_t kv_block_bytes(const QsaShapes& s, int fmt) {
312    const uint64_t rows = (uint64_t) (s.n_head_kv * s.page_size);
313    if (fmt == kKvHybrid)
314        return rows * (uint64_t) s.head_dim + rows * (uint64_t) (s.head_dim / KV_Q8_GROUP) * 2 +
315               rows * kv_q4_bytes_per_head((int) s.head_dim);
316    if (fmt == kKvQ4) return rows * kv_q4_bytes_per_head((int) s.head_dim) * 2;
317    return fmt == kKvInt8 ? rows * (uint64_t) s.head_dim * 2 + rows * (uint64_t) (s.head_dim / KV_Q8_GROUP) * 2 * 2
318                : rows * (uint64_t) s.head_dim * 2 * 2;
319}
320
321void kv_stream_reset(const KvStreamMap& m, void* stream) {
322    {
323        auto exp_props = sycl::ext::oneapi::experimental::properties{
324            sycl::ext::oneapi::experimental::use_root_sync};
325
326        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
327            ->template parallel_for<dpct_kernel_name<class reset_kernel_f02a82>>(
328                sycl::nd_range<3>(sycl::range(1, 1, 128) *
329                                      sycl::range(1, 1, 256),
330                                  sycl::range(1, 1, 256)),
331                exp_props, [=](sycl::nd_item<3> item_ct1) {
332                    reset_kernel(m);
333                });
334    }
335    check("reset");
336}
337
338void kv_stream_resolve(const KvStreamMap& m, const QsaAttnPools& slots, const KvHostPools& host, int fmt,
339                       const int32_t* ids, const int32_t* steps, int64_t n_q, int64_t cap, const QsaShapes& s,
340                       void* stream) {
341    if (n_q <= 0) return;
342    if (s.n_head_kv * s.page_size * (s.head_dim / KV_Q8_GROUP) * 2 % 16 != 0) {
343        std::fprintf(stderr, "kv_stream: a block's scale run must be a multiple of 16 bytes\n");
344        std::exit(1);
345    }
346    // one sweep step looks at RT consecutive slots `(hand + thread) % n_slots`; with fewer slots than RT two
347    // threads see the same slot and may both take it for two different misses.  The engine never streams with fewer
348    // than qsa_kv_resident_min() / page_size = 5,120 slots, so this is a guard, not a limit.
349    if (m.n_slots < RT) {
350        std::fprintf(stderr, "kv_stream: %lld slots is fewer than the resolve block (%d): the clock sweep would take a "
351                             "slot twice\n", (long long) m.n_slots, RT);
352        std::exit(1);
353    }
354    /*
355    DPCT1049: The work-group size passed to the SYCL kernel may exceed the
356    limit. To get the device limit, query info::device::max_work_group_size.
357    Adjust the work-group size if needed.
358    */
359    {
360        auto exp_props = sycl::ext::oneapi::experimental::properties{
361            sycl::ext::oneapi::experimental::use_root_sync};
362
363        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
364            ->template parallel_for<dpct_kernel_name<class resolve_kernel_148a81>>(
365                sycl::nd_range<3>(sycl::range(1, 1, RT), sycl::range(1, 1, RT)),
366                exp_props,
367                [=](sycl::nd_item<3> item_ct1)
368                    [[sycl::reqd_sub_group_size(32)]] {
369                        resolve_kernel(m, ids, steps, (int)n_q, (int)cap,
370                                       (int)s.page_size);
371                    });
372    }
373    check("resolve");
374    {
375        auto exp_props = sycl::ext::oneapi::experimental::properties{
376            sycl::ext::oneapi::experimental::use_root_sync};
377
378        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
379            ->submit([&](sycl::handler &cgh) {
380                auto runs_of_slots_host_fmt_s_ct1 =
381                    runs_of(slots, host, fmt, s);
382
383                cgh.parallel_for<dpct_kernel_name<class copy_kernel_4bb253>>(
384                    sycl::nd_range<3>(sycl::range(1, 1, 96) *
385                                          sycl::range(1, 1, 128),
386                                      sycl::range(1, 1, 128)),
387                    exp_props, [=](sycl::nd_item<3> item_ct1) {
388                        copy_kernel(m, runs_of_slots_host_fmt_s_ct1);
389                    });
390            });
391    }
392    check("copy");
393}
394
395void kv_ring_table(int32_t* page_table, int64_t n_blocks, int64_t n_slots, void* stream) {
396    {
397        auto exp_props = sycl::ext::oneapi::experimental::properties{
398            sycl::ext::oneapi::experimental::use_root_sync};
399
400        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
401            ->template parallel_for<dpct_kernel_name<class ring_kernel_f9df1d>>(
402                sycl::nd_range<3>(sycl::range(1, 1, 64) *
403                                      sycl::range(1, 1, 256),
404                                  sycl::range(1, 1, 256)),
405                exp_props, [=](sycl::nd_item<3> item_ct1) {
406                    ring_kernel(page_table, n_blocks, n_slots);
407                });
408    }
409    check("ring table");
410}
411
412void kv_ring_restore(const QsaAttnPools &slots, const KvHostPools &host,
413                     int fmt, int64_t b0, int64_t b1, int64_t n_slots,
414                     const QsaShapes &s, void *stream) try {
415    const Runs r = runs_of(slots, host, fmt, s);
416    for (int64_t b = b0; b < b1;) {
417        const int64_t sl = b % n_slots, run = std::min<int64_t>(b1 - b, n_slots - sl);   // up to the ring's end
418        for (int a = 0; a < r.n; ++a)
419            /*
420            DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy
421            API. While the origin API might be synchronous, it depends on the
422            type of operand memory, so you may need to call wait() on event
423            return by memcpy API to ensure synchronization behavior.
424            */
425            if (DPCT_CHECK_ERROR(strata::q_of(stream)->memcpy(
426                    r.dst[a] + sl * r.len[a], r.src[a] + b * r.len[a],
427                    (size_t)(run * r.len[a]))) != 0)
428                check("ring restore");
429        b += run;
430    }
431}
432catch (sycl::exception const &exc) {
433  std::cerr << exc.what() << "Exception caught at file:" << __FILE__
434            << ", line:" << __LINE__ << std::endl;
435  std::exit(1);
436}
437
438void kv_stage_from_host(const QsaAttnPools &stage, const KvHostPools &host,
439                        int fmt, int64_t n_blocks, const QsaShapes &s,
440                        void *stream) try {
441    if (n_blocks <= 0) return;
442    const Runs r = runs_of(stage, host, fmt, s);
443    for (int a = 0; a < r.n; ++a)
444        /*
445        DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.
446        While the origin API might be synchronous, it depends on the type of
447        operand memory, so you may need to call wait() on event return by memcpy
448        API to ensure synchronization behavior.
449        */
450        if (DPCT_CHECK_ERROR(strata::q_of(stream)->memcpy(
451                r.dst[a], r.src[a], (size_t)(n_blocks * r.len[a]))) != 0)
452            check("stage");
453}
454catch (sycl::exception const &exc) {
455  std::cerr << exc.what() << "Exception caught at file:" << __FILE__
456            << ", line:" << __LINE__ << std::endl;
457  std::exit(1);
458}
459
460void kv_unstage_to_host(const QsaAttnPools &stage, const KvHostPools &host,
461                        int fmt, int64_t b0, int64_t b1, const QsaShapes &s,
462                        void *stream) try {
463    if (b1 <= b0) return;
464    const Runs r = runs_of(stage, host, fmt, s);   // src: the host copy, dst: the staging pool (identity layout both)
465    for (int a = 0; a < r.n; ++a)
466        /*
467        DPCT1124: cudaMemcpyAsync is migrated to asynchronous memcpy API.
468        While the origin API might be synchronous, it depends on the type of
469        operand memory, so you may need to call wait() on event return by memcpy
470        API to ensure synchronization behavior.
471        */
472        if (DPCT_CHECK_ERROR(strata::q_of(stream)->memcpy(
473                (void *)(r.src[a] + b0 * r.len[a]), r.dst[a] + b0 * r.len[a],
474                (size_t)((b1 - b0) * r.len[a]))) != 0)
475            check("unstage");
476}
477catch (sycl::exception const &exc) {
478  std::cerr << exc.what() << "Exception caught at file:" << __FILE__
479            << ", line:" << __LINE__ << std::endl;
480  std::exit(1);
481}
482
483KvStreamCounters kv_stream_counters(const KvStreamMap &m) try {
484    int32_t c[kKvCtlInts] = {};
485    KvStreamCounters r;
486    if (m.ctl == nullptr ||
487        DPCT_CHECK_ERROR(
488            dpct::get_in_order_queue().memcpy(c, m.ctl, sizeof(c)).wait()) !=
489            0) return r;
490    const unsigned long long* u = reinterpret_cast<const unsigned long long*>(c + 4);
491    r.misses = u[0];
492    r.lookups = u[1];
493    r.calls = u[2];
494    r.overflow = c[3] != 0;
495    return r;
496}
497catch (sycl::exception const &exc) {
498  std::cerr << exc.what() << "Exception caught at file:" << __FILE__
499            << ", line:" << __LINE__ << std::endl;
500  std::exit(1);
501}
502
503}  // namespace strata::kernels