multiformat_conversion_codelets.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
  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. #if STARPU_HAVE_VALGRIND_H
  18. #include <valgrind/valgrind.h>
  19. #endif
  20. #include <starpu.h>
  21. #include "multiformat_types.h"
  22. #include "../../../helper.h"
  23. #ifdef STARPU_USE_CUDA
  24. void cuda_to_cpu(void *buffers[], void *arg)
  25. {
  26. STARPU_SKIP_IF_VALGRIND;
  27. FPRINTF(stderr, "Entering %s\n", __func__);
  28. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_CUDA_PTR(buffers[0]);
  29. struct point *dst = STARPU_MULTIFORMAT_GET_PTR(buffers[0]);
  30. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  31. int i;
  32. for (i = 0; i < n; i++)
  33. {
  34. dst[i].x = src->x[i];
  35. dst[i].y = src->y[i];
  36. }
  37. }
  38. extern void cpu_to_cuda_cuda_func(void *buffers[], void *args); struct starpu_codelet cpu_to_cuda_cl =
  39. {
  40. .where = STARPU_CUDA,
  41. .cuda_funcs = {cpu_to_cuda_cuda_func, NULL},
  42. .nbuffers = 1
  43. };
  44. struct starpu_codelet cuda_to_cpu_cl =
  45. {
  46. .where = STARPU_CPU,
  47. .cpu_funcs = {cuda_to_cpu, NULL},
  48. .nbuffers = 1
  49. };
  50. #endif
  51. #ifdef STARPU_USE_OPENCL
  52. void opencl_to_cpu(void *buffers[], void *arg)
  53. {
  54. STARPU_SKIP_IF_VALGRIND;
  55. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_OPENCL_PTR(buffers[0]);
  56. struct point *dst = STARPU_MULTIFORMAT_GET_PTR(buffers[0]);
  57. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  58. int i;
  59. for (i = 0; i < n; i++)
  60. {
  61. dst[i].x = src->x[i];
  62. dst[i].y = src->y[i];
  63. }
  64. }
  65. extern void cpu_to_opencl_opencl_func(void *buffers[], void *args);
  66. struct starpu_codelet cpu_to_opencl_cl =
  67. {
  68. .where = STARPU_OPENCL,
  69. .opencl_funcs = {cpu_to_opencl_opencl_func, NULL},
  70. .nbuffers = 1
  71. };
  72. struct starpu_codelet opencl_to_cpu_cl =
  73. {
  74. .where = STARPU_CPU,
  75. .cpu_funcs = {opencl_to_cpu, NULL},
  76. .nbuffers = 1
  77. };
  78. #endif