Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/openaccel-lab/blob/main/workloads/rope/kernel.cu # openaccel-lab aien-dev/openaccel-lab Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 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 21 void 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 }