multiformat_conversion_codelets.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <starpu.h>
  17. #include "multiformat_types.h"
  18. #ifdef STARPU_USE_CUDA
  19. void cuda_to_cpu(void *buffers[], void *arg)
  20. {
  21. fprintf(stderr, "Entering %s\n", __func__);
  22. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_CUDA_PTR(buffers[0]);
  23. struct point *dst = STARPU_MULTIFORMAT_GET_PTR(buffers[0]);
  24. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  25. int i;
  26. for (i = 0; i < n; i++)
  27. {
  28. dst[i].x = src->x[i];
  29. dst[i].y = src->y[i];
  30. }
  31. }
  32. extern void cpu_to_cuda_cuda_func(void *buffers[], void *args); struct starpu_codelet cpu_to_cuda_cl = {
  33. .where = STARPU_CUDA,
  34. .cuda_func = cpu_to_cuda_cuda_func,
  35. .nbuffers = 1
  36. };
  37. struct starpu_codelet cuda_to_cpu_cl = {
  38. .where = STARPU_CPU,
  39. .cpu_func = cuda_to_cpu,
  40. .nbuffers = 1
  41. };
  42. #endif
  43. #ifdef STARPU_USE_OPENCL
  44. void opencl_to_cpu(void *buffers[], void *arg)
  45. {
  46. struct struct_of_arrays *src = STARPU_MULTIFORMAT_GET_OPENCL_PTR(buffers[0]);
  47. struct point *dst = STARPU_MULTIFORMAT_GET_PTR(buffers[0]);
  48. int n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);
  49. int i;
  50. for (i = 0; i < n; i++)
  51. {
  52. dst[i].x = src->x[i];
  53. dst[i].y = src->y[i];
  54. }
  55. }
  56. extern void cpu_to_opencl_opencl_func(void *buffers[], void *args);
  57. struct starpu_codelet cpu_to_opencl_cl = {
  58. .where = STARPU_OPENCL,
  59. .opencl_func = cpu_to_opencl_opencl_func,
  60. .nbuffers = 1
  61. };
  62. struct starpu_codelet opencl_to_cpu_cl = {
  63. .where = STARPU_CPU,
  64. .cpu_func = opencl_to_cpu,
  65. .nbuffers = 1
  66. };
  67. #endif