starpu_opencl.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2011 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011 Centre National de la Recherche Scientifique
  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. #ifndef __STARPU_OPENCL_H__
  18. #define __STARPU_OPENCL_H__
  19. #ifdef STARPU_USE_OPENCL
  20. #ifdef __APPLE__
  21. #include <OpenCL/cl.h>
  22. #else
  23. #include <CL/cl.h>
  24. #endif
  25. #include <starpu_config.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. void starpu_opencl_display_error(const char *func, const char *msg, cl_int status);
  30. #define STARPU_OPENCL_DISPLAY_ERROR(status) \
  31. starpu_opencl_display_error(__starpu_func__, NULL, status)
  32. static inline void starpu_opencl_report_error(const char *func, const char *msg, cl_int status)
  33. {
  34. starpu_opencl_display_error(func, msg, status);
  35. assert(0);
  36. }
  37. #define STARPU_OPENCL_REPORT_ERROR(status) \
  38. starpu_opencl_display_error(__starpu_func__, NULL, status)
  39. #define STARPU_OPENCL_REPORT_ERROR_WITH_MSG(msg, status) \
  40. starpu_opencl_display_error(__starpu_func__, msg, status)
  41. struct starpu_opencl_program {
  42. cl_program programs[STARPU_MAXOPENCLDEVS];
  43. };
  44. void starpu_opencl_get_context(int devid, cl_context *context);
  45. void starpu_opencl_get_device(int devid, cl_device_id *device);
  46. void starpu_opencl_get_queue(int devid, cl_command_queue *queue);
  47. void starpu_opencl_get_current_context(cl_context *context);
  48. void starpu_opencl_get_current_queue(cl_command_queue *queue);
  49. int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct starpu_opencl_program *opencl_programs,
  50. const char* build_options);
  51. int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, struct starpu_opencl_program *opencl_programs,
  52. const char* build_options);
  53. int starpu_opencl_unload_opencl(struct starpu_opencl_program *opencl_programs);
  54. int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, const char *kernel_name, int devid);
  55. int starpu_opencl_release_kernel(cl_kernel kernel);
  56. int starpu_opencl_collect_stats(cl_event event);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif /* STARPU_USE_OPENCL */
  61. #endif /* __STARPU_OPENCL_H__ */