dot_product_kernels.cu 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011,2012,2015,2017 CNRS
  4. * Copyright (C) 2014,2015 Université de Bordeaux
  5. * Copyright (C) 2011,2012 Inria
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. /* Trivial dot reduction CUDA kernel */
  19. #include <starpu.h>
  20. #define DOT_TYPE double
  21. static __global__ void cuda_redux(DOT_TYPE *dota, DOT_TYPE *dotb)
  22. {
  23. *dota = *dota + *dotb;
  24. return;
  25. }
  26. extern "C" void redux_cuda_func(void *descr[], void *_args)
  27. {
  28. (void)_args;
  29. DOT_TYPE *dota = (DOT_TYPE *)STARPU_VARIABLE_GET_PTR(descr[0]);
  30. DOT_TYPE *dotb = (DOT_TYPE *)STARPU_VARIABLE_GET_PTR(descr[1]);
  31. cuda_redux<<<1,1, 0, starpu_cuda_get_local_stream()>>>(dota, dotb);
  32. }