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/gemv/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 / gemv / kernel.cu` 31 lines ยท 1006 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 #include 3 4 #define TS 64 5 6 // One thread per row; x is staged through static shared memory in chunks of 64 shared by the block. 7 // Every thread reaches every __syncthreads(). 8 __global__ void gemv(const float *A, const float *x, float *y, int M, int N) 9 { 10 __shared__ float xs[TS]; 11 int i = blockIdx.x * TS + threadIdx.x, lid = threadIdx.x; 12 float acc = 0.0f; 13 for (int j0 = 0; j0 < N; j0 += TS) { 14 xs[lid] = (j0 + lid < N) ? x[j0 + lid] : 0.0f; 15 __syncthreads(); 16 if (i < M) { 17 int jn = N - j0 < TS ? N - j0 : TS; 18 for (int j = 0; j < jn; ++j) 19 acc += A[(long long)i * N + j0 + j] * xs[j]; 20 } 21 __syncthreads(); 22 } 23 if (i < M) 24 y[i] = acc; 25 } 26 27 void oal_launch(const long long *p, void *const *buf) 28 { 29 int M = (int)p[0], N = (int)p[1]; 30 gemv<<<(unsigned)((M + TS - 1) / TS), TS>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], M, N); 31 }