multiformat_conversion_codelets.c 3.1 KB

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