mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-25 06:17:38 -04:00
22 lines
666 B
C++
22 lines
666 B
C++
#include <stdint.h>
|
|
#include <vx_intrinsics.h>
|
|
#include <vx_spawn.h>
|
|
#include "common.h"
|
|
|
|
void kernel_body(kernel_arg_t* __UNIFORM__ arg) {
|
|
auto src0_ptr = reinterpret_cast<TYPE*>(arg->src0_addr);
|
|
auto src1_ptr = reinterpret_cast<TYPE*>(arg->src1_addr);
|
|
auto dst_ptr = reinterpret_cast<TYPE*>(arg->dst_addr);
|
|
|
|
uint32_t count = arg->task_size;
|
|
uint32_t offset = blockIdx.x * count;
|
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
|
dst_ptr[offset+i] = src0_ptr[offset+i] + src1_ptr[offset+i];
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
kernel_arg_t* arg = (kernel_arg_t*)csr_read(VX_CSR_MSCRATCH);
|
|
return vx_spawn_threads(1, &arg->num_tasks, nullptr, (vx_kernel_func_cb)kernel_body, arg);
|
|
}
|