ocl.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. cl_platform_id ocl_get_platform (OclPlatform *ocl);
  41. char * ocl_get_platform_info
  42. (OclPlatform *ocl,
  43. cl_platform_info param);
  44. cl_context ocl_get_context (OclPlatform *ocl);
  45. cl_program ocl_create_program_from_file
  46. (OclPlatform *ocl,
  47. const char *filename,
  48. const char *options,
  49. cl_int *errcode);
  50. cl_program ocl_create_program_from_source
  51. (OclPlatform *ocl,
  52. const char *source,
  53. const char *options,
  54. cl_int *errcode);
  55. int ocl_get_num_devices (OclPlatform *ocl);
  56. cl_device_id * ocl_get_devices (OclPlatform *ocl);
  57. cl_command_queue * ocl_get_cmd_queues (OclPlatform *ocl);
  58. const char* ocl_strerr (int error);
  59. char* ocl_read_program (const char *filename);
  60. void ocl_get_event_times (cl_event event,
  61. cl_ulong *start,
  62. cl_ulong *end,
  63. cl_ulong *queued,
  64. cl_ulong *submitted);
  65. #endif