ocl.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This file is part of oclkit.
  3. *
  4. * oclkit is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * oclkit is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef OCL_H
  18. #define OCL_H
  19. #include <CL/cl.h>
  20. #include <stdio.h>
  21. typedef struct OclPlatform OclPlatform;
  22. #define OCL_CHECK_ERROR(error) { \
  23. if ((error) != CL_SUCCESS) fprintf (stderr, "OpenCL error <%s:%i>: %s\n", __FILE__, __LINE__, ocl_strerr((error))); }
  24. int ocl_read_args (int argc,
  25. const char **argv,
  26. unsigned int *platform,
  27. cl_device_type *type);
  28. OclPlatform * ocl_new (unsigned platform,
  29. cl_device_type type);
  30. OclPlatform * ocl_new_with_queues (unsigned platform,
  31. cl_device_type type,
  32. cl_command_queue_properties
  33. queue_properties);
  34. OclPlatform * ocl_new_from_args (int argc,
  35. const char ** argv,
  36. cl_command_queue_properties
  37. queue_properties);
  38. void ocl_print_usage (void);
  39. void ocl_free (OclPlatform *ocl);
  40. char * ocl_get_platform_info
  41. (OclPlatform *ocl,
  42. cl_platform_info param);
  43. cl_context ocl_get_context (OclPlatform *ocl);
  44. cl_program ocl_create_program_from_file
  45. (OclPlatform *ocl,
  46. const char *filename,
  47. const char *options,
  48. cl_int *errcode);
  49. cl_program ocl_create_program_from_source
  50. (OclPlatform *ocl,
  51. const char *source,
  52. const char *options,
  53. cl_int *errcode);
  54. int ocl_get_num_devices (OclPlatform *ocl);
  55. cl_device_id * ocl_get_devices (OclPlatform *ocl);
  56. cl_command_queue * ocl_get_cmd_queues (OclPlatform *ocl);
  57. const char* ocl_strerr (int error);
  58. char* ocl_read_program (const char *filename);
  59. void ocl_get_event_times (cl_event event,
  60. cl_ulong *start,
  61. cl_ulong *end,
  62. cl_ulong *queued,
  63. cl_ulong *submitted);
  64. #endif