multiformat_conversion_codelets.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2020 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. };
  41. struct starpu_codelet cuda_to_cpu_cl =
  42. {
  43. .cpu_funcs = {cuda_to_cpu},
  44. .nbuffers = 1
  45. };
  46. #endif
  47. #ifdef STARPU_USE_OPENCL
  48. void opencl_to_cpu(void *buffers[], void *arg)
  49. {
  50. (void)arg;
  51. STARPU_SKIP_IF_VALGRIND;
  52. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_OPENCL_PTR(buffers[0]);
  53. struct point *dst = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  54. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  55. int i;
  56. for (i = 0; i < n; i++)
  57. {
  58. dst[i].x = src->x[i];
  59. dst[i].y = src->y[i];
  60. }
  61. }
  62. extern void cpu_to_opencl_opencl_func(void *buffers[], void *args);
  63. struct starpu_codelet cpu_to_opencl_cl =
  64. {
  65. .opencl_funcs = {cpu_to_opencl_opencl_func},
  66. .nbuffers = 1
  67. };
  68. struct starpu_codelet opencl_to_cpu_cl =
  69. {
  70. .cpu_funcs = {opencl_to_cpu},
  71. .nbuffers = 1
  72. };
  73. #endif
  74. #ifdef STARPU_USE_MIC
  75. void mic_to_cpu(void *buffers[], void *arg)
  76. {
  77. (void)arg;
  78. STARPU_SKIP_IF_VALGRIND;
  79. FPRINTF(stderr, "Entering %s\n", __func__);
  80. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_MIC_PTR(buffers[0]);
  81. struct point *dst = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  82. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  83. int i;
  84. for (i = 0; i < n; i++)
  85. {
  86. dst[i].x = src->x[i];
  87. dst[i].y = src->y[i];
  88. }
  89. }
  90. void cpu_to_mic(void *buffers[], void *arg)
  91. {
  92. (void)arg;
  93. STARPU_SKIP_IF_VALGRIND;
  94. FPRINTF(stderr, "Entering %s\n", __func__);
  95. struct point *src = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  96. struct struct_of_arrays *dst = STARPU_MULTIFORMAT_GET_MIC_PTR(buffers[0]);
  97. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  98. int i;
  99. for (i = 0; i < n; i++)
  100. {
  101. dst->x[i] = src[i].x;
  102. dst->y[i] = src[i].y;
  103. }
  104. }
  105. struct starpu_codelet cpu_to_mic_cl =
  106. {
  107. .where = STARPU_MIC,
  108. .cpu_funcs_name = {"cpu_to_mic"},
  109. .nbuffers = 1
  110. };
  111. struct starpu_codelet mic_to_cpu_cl =
  112. {
  113. .where = STARPU_CPU,
  114. .cpu_funcs = {mic_to_cpu},
  115. .nbuffers = 1
  116. };
  117. #endif