2020-12-11 20:05:32 +08:00
|
|
|
#pragma once
|
2020-01-17 11:01:02 -08:00
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
#include <OpenCL/cl.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <CL/cl.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-04 23:19:25 +08:00
|
|
|
#include <string>
|
|
|
|
|
|
2020-11-30 19:04:49 +08:00
|
|
|
#define CL_CHECK(_expr) \
|
|
|
|
|
do { \
|
2021-08-18 16:56:37 +08:00
|
|
|
assert(CL_SUCCESS == (_expr)); \
|
2020-11-30 19:04:49 +08:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define CL_CHECK_ERR(_expr) \
|
|
|
|
|
({ \
|
|
|
|
|
cl_int err = CL_INVALID_VALUE; \
|
|
|
|
|
__typeof__(_expr) _ret = _expr; \
|
|
|
|
|
assert(_ret&& err == CL_SUCCESS); \
|
|
|
|
|
_ret; \
|
|
|
|
|
})
|
|
|
|
|
|
2020-08-17 17:24:39 +08:00
|
|
|
cl_device_id cl_get_device_id(cl_device_type device_type);
|
2023-08-21 19:32:48 -07:00
|
|
|
cl_context cl_create_context(cl_device_id device_id);
|
2025-01-13 02:15:26 +08:00
|
|
|
void cl_release_context(cl_context context);
|
2021-11-04 23:19:25 +08:00
|
|
|
cl_program cl_program_from_source(cl_context ctx, cl_device_id device_id, const std::string& src, const char* args = nullptr);
|
2020-12-11 20:05:32 +08:00
|
|
|
cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args);
|