multiformat.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #define NX 1024
  2. struct point array_of_structs[NX];
  3. starpu_data_handle_t handle;
  4. /*
  5. * The conversion of a piece of data is itself a task, though it is created,
  6. * submitted and destroyed by StarPU internals and not by the user. Therefore,
  7. * we have to define two codelets.
  8. * Note that for now the conversion from the CPU format to the GPU format has to
  9. * be executed on the GPU, and the conversion from the GPU to the CPU has to be
  10. * executed on the CPU.
  11. */
  12. #ifdef STARPU_USE_OPENCL
  13. void cpu_to_opencl_opencl_func(void *buffers[], void *args);
  14. struct starpu_codelet cpu_to_opencl_cl = {
  15. .where = STARPU_OPENCL,
  16. .opencl_funcs = { cpu_to_opencl_opencl_func, NULL },
  17. .nbuffers = 1,
  18. .modes = { STARPU_RW }
  19. };
  20. void opencl_to_cpu_func(void *buffers[], void *args);
  21. struct starpu_codelet opencl_to_cpu_cl = {
  22. .where = STARPU_CPU,
  23. .cpu_funcs = { opencl_to_cpu_func, NULL },
  24. .nbuffers = 1,
  25. .modes = { STARPU_RW }
  26. };
  27. #endif
  28. struct starpu_multiformat_data_interface_ops format_ops = {
  29. #ifdef STARPU_USE_OPENCL
  30. .opencl_elemsize = 2 * sizeof(float),
  31. .cpu_to_opencl_cl = &cpu_to_opencl_cl,
  32. .opencl_to_cpu_cl = &opencl_to_cpu_cl,
  33. #endif
  34. .cpu_elemsize = 2 * sizeof(float),
  35. ...
  36. };
  37. starpu_multiformat_data_register(handle, 0, &array_of_structs, NX, &format_ops);