Simple C example to show how run a kernel with assert*() and PRINT*() macros and test them.
More...
Go to the source code of this file.
|
char * | dirname_alloc (const char *path) |
| Return the directory part of path in a (new allocated) string. More...
|
|
const char * | error_name (cl_int code) |
| Return the error name corresponding to the error code. More...
|
|
char * | file_to_alloc_string (const char *filename) |
| Read the file and return its content to a (new allocated) string. If failed then print a error message and exit. More...
|
|
cl_device_id | get_device_id (unsigned int platform_i, unsigned int device_i) |
| Return the given id device of the given platform OpenCL, or exit if doesn't exists. More...
|
|
char * | get_device_info_alloc_string (cl_device_id device_id, cl_device_info param_name) |
| Return a (new allocated) string corresponding to device info parameter. More...
|
|
void | print_error (cl_int code, const char *message) |
| If code != 0 then print an error message corresponding to the error code. More...
|
|
void | run_example (unsigned int nb_work_group, unsigned int nb_work_items_by_work_group, cl_device_id device_id, bool debug, const char *path) |
| Run the kernel ../kernel/example.cl. More...
|
|
int | main (int argc, const char *const argv[]) |
| Get the optional parameter –device platform:device and run the kernel ../kernel/example.cl. More...
|
|
Simple C example to show how run a kernel with assert*() and PRINT*() macros and test them.
Piece of assertOpenCL — GPLv3 — Copyright (C) 2018 Olivier Pirson — http://www.opimedia.be/ — September 19, 2018
Definition in file example.c.
◆ dirname_alloc()
char * dirname_alloc |
( |
const char * |
path | ) |
|
Return the directory part of path in a (new allocated) string.
Definition at line 127 of file example.c.
◆ error_name()
std::string error_name |
( |
cl_int |
code | ) |
|
Return the error name corresponding to the error code.
Definition at line 167 of file example.c.
◆ file_to_alloc_string()
char * file_to_alloc_string |
( |
const char * |
filename | ) |
|
Read the file and return its content to a (new allocated) string. If failed then print a error message and exit.
Definition at line 179 of file example.c.
◆ get_device_id()
cl_device_id get_device_id |
( |
unsigned int |
platform_i, |
|
|
unsigned int |
device_i |
|
) |
| |
Return the given id device of the given platform OpenCL, or exit if doesn't exists.
- Parameters
-
- Returns
- OpenCL device id
Definition at line 209 of file example.c.
◆ get_device_info_alloc_string()
char * get_device_info_alloc_string |
( |
cl_device_id |
device_id, |
|
|
cl_device_info |
param_name |
|
) |
| |
Return a (new allocated) string corresponding to device info parameter.
Definition at line 255 of file example.c.
◆ main()
int main |
( |
int |
argc, |
|
|
const char *const |
argv[] |
|
) |
| |
Get the optional parameter –device platform:device and run the kernel ../kernel/example.cl.
Definition at line 486 of file example.c.
◆ print_error()
void print_error |
( |
cl_int |
code, |
|
|
const char * |
message |
|
) |
| |
If code != 0 then print an error message corresponding to the error code.
Definition at line 274 of file example.c.
◆ run_example()
void run_example |
( |
unsigned int |
nb_work_group, |
|
|
unsigned int |
nb_work_items_by_work_group, |
|
|
cl_device_id |
device_id, |
|
|
bool |
debug, |
|
|
const char * |
path |
|
) |
| |
Run the kernel ../kernel/example.cl.
If debug then run the kernel in debug mode, else run the kernel with the macro NDEBUG defined.
Definition at line 288 of file example.c.
◆ errors_map
List of all error codes and names extracted from /usr/include/CL/cl.h.
Definition at line 43 of file example.c.
◆ errors_map_size
const unsigned int errors_map_size = 61 |
Number of elements in errors_map.
Definition at line 51 of file example.c.