#include <sycl/sycl.hpp>
#include <sycl/sycl.hpp>
#define N 1024
float kCoefficients[8];
void increment_atomic(int* counter, int delta) {
int prev = atomicAdd(counter, delta);
if (item.get_local_id() == 0) {
atomicCAS(counter, prev, prev + 1);
}
}
void warp_scan(const int* in, int* out) {
__shared__ int buf[32];
int lane = item.get_sub_group().get_local_id()();
int wid = item.get_local_id() / 32;
buf[lane] = in[item.get_local_id()];
item.barrier() ;
if (lane == 0) {
int s = 0;
for (int i = 0; i < 32; ++i) s += buf[i];
out[wid] = s;
}
item.barrier(sycl::access::fence_space::global_space);
}
void matmul(const float* a, const float* b, float* c,
int m, int n, int k) {
int row = item.get_group(0) * item.get_local_range() + item.get_local_id();
int col = item.get_group(0) * item.get_local_range() + item.get_local_id();
if (row < m && col < n) {
float s = kCoefficients[0] * a[row * k] * b[col];
c[row * n + col] = s;
}
}
void launch_examples(int* counter, float* a, float* b, float* c) {
dim3 grid(N / 32, N / 16);
dim3 block(32, 16);
{ }); }); smem=none stream=default args=counter, 1 };
{ }); }); smem=none stream=default args=counter, a };
{ }); }); smem=none stream=default args=a, b, c, N, N, N };
}