interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / gemv / kernel.cl

22 lines · 830 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2// One work-item per row; x is staged through __local memory in chunks of 64 shared by the work-group.
3// global is M rounded up to 64, local 64; every work-item reaches every barrier.
4#define TS 64
5__kernel void gemv(__global const float *A, __global const float *x, __global float *y, const int M, const int N)
6{
7 __local float xs[TS];
8 int i = get_global_id(0), lid = get_local_id(0);
9 float acc = 0.0f;
10 for (int j0 = 0; j0 < N; j0 += TS) {
11 xs[lid] = (j0 + lid < N) ? x[j0 + lid] : 0.0f;
12 barrier(CLK_LOCAL_MEM_FENCE);
13 if (i < M) {
14 int jn = min(TS, N - j0);
15 for (int j = 0; j < jn; ++j)
16 acc += A[i * N + j0 + j] * xs[j];
17 }
18 barrier(CLK_LOCAL_MEM_FENCE);
19 }
20 if (i < M)
21 y[i] = acc;
22}