assertOpenCL
September 19, 2018
|
Simple C++ example to show how run a kernel with assert*() and PRINT*() macros and test them. More...
#include "opencl_errors_map.hpp"
Go to the source code of this file.
Functions | |
std::string | dirname (std::string path) |
Return the directory part of path. More... | |
std::string | error_name (cl_int code) |
Return the error name corresponding to the error code. More... | |
std::string | file_to_string (std::string filename) |
Read the file and return its content to a string. If failed then print a error message and exit. More... | |
cl::Device | get_device (unsigned int platform_i, unsigned int device_i) |
Return the given device of the given platform OpenCL, or exit if doesn't exists. More... | |
void | print_error (cl_int code, std::string 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 device, bool debug, const std::string &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... | |
Variables | |
const std::map< int32_t, std::string > | errors_map |
List of all error codes and names extracted from /usr/include/CL/cl.h. 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.cpp.
std::string dirname | ( | std::string | path | ) |
Return the directory part of path.
Definition at line 224 of file example.cpp.
std::string error_name | ( | cl_int | code | ) |
Return the error name corresponding to the error code.
Definition at line 177 of file example.cpp.
std::string file_to_string | ( | std::string | filename | ) |
Read the file and return its content to a string. If failed then print a error message and exit.
Definition at line 187 of file example.cpp.
cl::Device get_device | ( | unsigned int | platform_i, |
unsigned int | device_i | ||
) |
Return the given device of the given platform OpenCL, or exit if doesn't exists.
platform_i | |
device_i |
Definition at line 204 of file example.cpp.
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 398 of file example.cpp.
void print_error | ( | cl_int | code, |
std::string | message = "" |
||
) |
If code != 0 then print an error message corresponding to the error code.
Definition at line 241 of file example.cpp.
void run_example | ( | unsigned int | nb_work_group, |
unsigned int | nb_work_items_by_work_group, | ||
cl::Device | device, | ||
bool | debug, | ||
const std::string & | 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 257 of file example.cpp.
const std::map<int32_t, std::string> errors_map |
List of all error codes and names extracted from /usr/include/CL/cl.h.
Definition at line 35 of file example.cpp.