interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / rope / kernel.cu

27 lines · 959 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2#include <cuda_runtime.h>
3
4// one thread per rotated pair; n = T*H*h pairs
5__global__ void rope(const float *x, const float *cs, const float *sn, float *y, long long n, long long h,
6 long long H)
7{
8 long long g = (long long)blockIdx.x * blockDim.x + threadIdx.x;
9 if (g < n) {
10 long long i = g % h;
11 long long th = g / h;
12 long long t = th / H;
13 long long o = th * 2 * h + i;
14 float c = cs[t * h + i], s = sn[t * h + i];
15 float x1 = x[o], x2 = x[o + h];
16 y[o] = x1 * c - x2 * s;
17 y[o + h] = x1 * s + x2 * c;
18 }
19}
20
21void oal_launch(const long long *p, void *const *buf)
22{
23 long long T = p[0], H = p[1], h = p[3];
24 long long n = T * H * h;
25 rope<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (const float *)buf[1],
26 (const float *)buf[2], (float *)buf[3], n, h, H);
27}