multiformat.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013 CNRS
  4. * Copyright (C) 2010-2013 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. //! [To be included. You should update doxygen if you see this text.]
  18. #define NX 1024
  19. struct point array_of_structs[NX];
  20. starpu_data_handle_t handle;
  21. /*
  22. * The conversion of a piece of data is itself a task, though it is created,
  23. * submitted and destroyed by StarPU internals and not by the user. Therefore,
  24. * we have to define two codelets.
  25. * Note that for now the conversion from the CPU format to the GPU format has to
  26. * be executed on the GPU, and the conversion from the GPU to the CPU has to be
  27. * executed on the CPU.
  28. */
  29. #ifdef STARPU_USE_OPENCL
  30. void cpu_to_opencl_opencl_func(void *buffers[], void *args);
  31. struct starpu_codelet cpu_to_opencl_cl =
  32. {
  33. .where = STARPU_OPENCL,
  34. .opencl_funcs = { cpu_to_opencl_opencl_func },
  35. .nbuffers = 1,
  36. .modes = { STARPU_RW }
  37. };
  38. void opencl_to_cpu_func(void *buffers[], void *args);
  39. struct starpu_codelet opencl_to_cpu_cl =
  40. {
  41. .where = STARPU_CPU,
  42. .cpu_funcs = { opencl_to_cpu_func },
  43. .cpu_funcs_name = { "opencl_to_cpu_func" },
  44. .nbuffers = 1,
  45. .modes = { STARPU_RW }
  46. };
  47. #endif
  48. struct starpu_multiformat_data_interface_ops format_ops =
  49. {
  50. #ifdef STARPU_USE_OPENCL
  51. .opencl_elemsize = 2 * sizeof(float),
  52. .cpu_to_opencl_cl = &cpu_to_opencl_cl,
  53. .opencl_to_cpu_cl = &opencl_to_cpu_cl,
  54. #endif
  55. .cpu_elemsize = 2 * sizeof(float),
  56. ...
  57. };
  58. starpu_multiformat_data_register(handle, STARPU_MAIN_RAM, &array_of_structs, NX, &format_ops);
  59. //! [To be included. You should update doxygen if you see this text.]