12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include <starpu.h>
- #include "multiformat_types.h"
- static __global__ void multiformat_cuda(struct struct_of_arrays *soa, unsigned n)
- {
- unsigned i = blockIdx.x*blockDim.x + threadIdx.x;
- if (i < n)
- soa->x[i] *= soa->y[i];
- }
- extern "C" void multiformat_scal_cuda_func(void *buffers[], void *_args)
- {
- (void) _args;
- FPRINTF(stderr, "Running the cuda kernel (%s)\n", __func__);
- unsigned int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
- struct struct_of_arrays *soa;
- soa = (struct struct_of_arrays *) STARPU_MULTIFORMAT_GET_CUDA_PTR(buffers[0]);
- unsigned threads_per_block = 64;
- unsigned nblocks = (n + threads_per_block-1) / threads_per_block;
- multiformat_cuda<<<nblocks,threads_per_block,2,starpu_cuda_get_local_stream()>>>(soa, n);
- cudaStreamSynchronize(starpu_cuda_get_local_stream());
- }
|