openaccel-lab
aien-dev/openaccel-lab
Brought by drakestapleton
openaccel-lab / workloads / saxpy / kernel.cu
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | #include <cuda_runtime.h> |
| 3 | |
| 4 | __global__ void saxpy(const float *alpha, const float *x, const float *y_in, float *y, long long n) |
| 5 | { |
| 6 | long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; |
| 7 | if (i < n) |
| 8 | y[i] = alpha[0] * x[i] + y_in[i]; |
| 9 | } |
| 10 | |
| 11 | void oal_launch(const long long *p, void *const *buf) |
| 12 | { |
| 13 | long long n = p[0]; |
| 14 | saxpy<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (const float *)buf[1], |
| 15 | (const float *)buf[2], (float *)buf[3], n); |
| 16 | } |