multiformat_conversion_codelets.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011,2012 Inria
  4. * Copyright (C) 2011-2013,2015,2017 CNRS
  5. * Copyright (C) 2011-2014,2017 Université de Bordeaux
  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. #include <starpu.h>
  19. #include "multiformat_types.h"
  20. #include "../../../helper.h"
  21. #ifdef STARPU_USE_CUDA
  22. void cuda_to_cpu(void *buffers[], void *arg)
  23. {
  24. (void)arg;
  25. STARPU_SKIP_IF_VALGRIND;
  26. FPRINTF(stderr, "Entering %s\n", __starpu_func__);
  27. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_CUDA_PTR(buffers[0]);
  28. struct point *dst = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  29. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  30. int i;
  31. for (i = 0; i < n; i++)
  32. {
  33. dst[i].x = src->x[i];
  34. dst[i].y = src->y[i];
  35. }
  36. }
  37. extern void cpu_to_cuda_cuda_func(void *buffers[], void *args); struct starpu_codelet cpu_to_cuda_cl =
  38. {
  39. .cuda_funcs = {cpu_to_cuda_cuda_func},
  40. .cuda_flags = {STARPU_CUDA_ASYNC},
  41. .nbuffers = 1
  42. };
  43. struct starpu_codelet cuda_to_cpu_cl =
  44. {
  45. .cpu_funcs = {cuda_to_cpu},
  46. .nbuffers = 1
  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. };
  70. struct starpu_codelet opencl_to_cpu_cl =
  71. {
  72. .cpu_funcs = {opencl_to_cpu},
  73. .nbuffers = 1
  74. };
  75. #endif
  76. #ifdef STARPU_USE_MIC
  77. void mic_to_cpu(void *buffers[], void *arg)
  78. {
  79. (void)arg;
  80. STARPU_SKIP_IF_VALGRIND;
  81. FPRINTF(stderr, "Entering %s\n", __func__);
  82. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_MIC_PTR(buffers[0]);
  83. struct point *dst = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  84. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  85. int i;
  86. for (i = 0; i < n; i++)
  87. {
  88. dst[i].x = src->x[i];
  89. dst[i].y = src->y[i];
  90. }
  91. }
  92. void cpu_to_mic(void *buffers[], void *arg)
  93. {
  94. (void)arg;
  95. STARPU_SKIP_IF_VALGRIND;
  96. FPRINTF(stderr, "Entering %s\n", __func__);
  97. struct point *src = STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);
  98. struct struct_of_arrays *dst = STARPU_MULTIFORMAT_GET_MIC_PTR(buffers[0]);
  99. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  100. int i;
  101. for (i = 0; i < n; i++)
  102. {
  103. dst->x[i] = src[i].x;
  104. dst->y[i] = src[i].y;
  105. }
  106. }
  107. struct starpu_codelet cpu_to_mic_cl =
  108. {
  109. .where = STARPU_MIC,
  110. .cpu_funcs_name = {"cpu_to_mic"},
  111. .nbuffers = 1
  112. };
  113. struct starpu_codelet mic_to_cpu_cl =
  114. {
  115. .where = STARPU_CPU,
  116. .cpu_funcs = {mic_to_cpu},
  117. .nbuffers = 1
  118. };
  119. #endif