123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include <starpu.h>
- #include "multiformat_types.h"
- #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
- 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", __starpu_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());
- }
|