multiformat_conversion_codelets.c 2.2 KB

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