multiformat_conversion_codelets.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu.h>
  17. #include "multiformat_types.h"
  18. #include "../../../helper.h"
  19. #ifdef STARPU_USE_CUDA
  20. void cuda_to_cpu(void *buffers[], void *arg)
  21. {
  22. (void)arg;
  23. STARPU_SKIP_IF_VALGRIND;
  24. FPRINTF(stderr, "Entering %s\n", __starpu_func__);
  25. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_CUDA_PTR(buffers[0]);
  26. struct point *dst = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  27. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  28. int i;
  29. for (i = 0; i < n; i++)
  30. {
  31. dst[i].x = src->x[i];
  32. dst[i].y = src->y[i];
  33. }
  34. }
  35. extern void cpu_to_cuda_cuda_func(void *buffers[], void *args); struct starpu_codelet cpu_to_cuda_cl =
  36. {
  37. .cuda_funcs = {cpu_to_cuda_cuda_func},
  38. .cuda_flags = {STARPU_CUDA_ASYNC},
  39. .nbuffers = 1,
  40. .modes = { STARPU_RW },
  41. };
  42. struct starpu_codelet cuda_to_cpu_cl =
  43. {
  44. .cpu_funcs = {cuda_to_cpu},
  45. .nbuffers = 1,
  46. .modes = { STARPU_RW },
  47. };
  48. #endif
  49. #ifdef STARPU_USE_OPENCL
  50. void opencl_to_cpu(void *buffers[], void *arg)
  51. {
  52. (void)arg;
  53. STARPU_SKIP_IF_VALGRIND;
  54. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_OPENCL_PTR(buffers[0]);
  55. struct point *dst = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  56. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  57. int i;
  58. for (i = 0; i < n; i++)
  59. {
  60. dst[i].x = src->x[i];
  61. dst[i].y = src->y[i];
  62. }
  63. }
  64. extern void cpu_to_opencl_opencl_func(void *buffers[], void *args);
  65. struct starpu_codelet cpu_to_opencl_cl =
  66. {
  67. .opencl_funcs = {cpu_to_opencl_opencl_func},
  68. .nbuffers = 1,
  69. .modes = { STARPU_RW },
  70. };
  71. struct starpu_codelet opencl_to_cpu_cl =
  72. {
  73. .cpu_funcs = {opencl_to_cpu},
  74. .nbuffers = 1,
  75. .modes = { STARPU_RW },
  76. };
  77. #endif