#include <CL/cl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
|
void | init_opencl (cl_uint platform_number, cl_platform_id *platform, cl_uint device_number, cl_device_id *device, cl_context *context, cl_command_queue *command_queue, int verbose) |
|
void | init_command_queue (cl_command_queue *command_queue, cl_device_id *device, cl_context *context) |
|
void | print_build_information (cl_program program, cl_device_id device) |
|
int | get_device_infos (cl_uint platform_number, cl_uint device_number, DEVICE_INFOS *device_infos) |
|
void | check_cl_error (cl_int err, const char *file, int line) |
|
cl_kernel | make_kernel_from_file (cl_context context, cl_device_id device, char *kernel_constants, char *kernel_filename, const char *kernel_name) |
|
void | readfile (char *filename, char **text, unsigned long *size) |
|
#define ERROR_INVALID_DEVICE -4 |
#define ERROR_INVALID_PLATFORMS -2 |
#define ERROR_NO_DEVICES -3 |
#define ERROR_NO_PLATFORMS -1 |
#define MAX_KERNEL_CONSTANTS_LENGTH 1000 |
#define MAX_KERNEL_SOURCE_LENGTH 100000 |
#define STR_HELPER |
( |
|
x | ) |
#x |
void check_cl_error |
( |
cl_int |
err, |
|
|
const char * |
file, |
|
|
int |
line |
|
) |
| |
Helper function that checks for an OpenCL error
- Parameters
-
err | The OpenCL error code (int) |
*file | The source code file |
line | The associated line |
int get_device_infos |
( |
cl_uint |
platform_number, |
|
|
cl_uint |
device_number, |
|
|
DEVICE_INFOS * |
device_infos |
|
) |
| |
Returns information about a given OpenCL device/platform
- Parameters
-
platform_number | The OpenCL platform number |
*device_number | The OpenCL device |
- Returns
- A struct containing all device infos
void init_command_queue |
( |
cl_command_queue * |
command_queue, |
|
|
cl_device_id * |
device, |
|
|
cl_context * |
context |
|
) |
| |
Initializes a command queue
- Parameters
-
*command_queue | The OpenCL command queue |
*device | The OpenCL device |
*context | The OpenCL context |
void init_opencl |
( |
cl_uint |
platform_number, |
|
|
cl_platform_id * |
platform, |
|
|
cl_uint |
device_number, |
|
|
cl_device_id * |
device, |
|
|
cl_context * |
context, |
|
|
cl_command_queue * |
command_queue, |
|
|
int |
verbose |
|
) |
| |
Initializes the OpenCL context, command_queue, platform, and device.
- Parameters
-
platform_number | The OpenCL platform number |
*platform | Pointer to platform that shall be initialized |
device_number | The OpenCL device id/number that shall be used |
*device | Pointer to corresponding device |
*context | The OpenCL context |
*command_queue | The OpenCL command queue |
verbose | The verbosity level (0==no output, 1==more output, ...) |
cl_kernel make_kernel_from_file |
( |
cl_context |
context, |
|
|
cl_device_id |
device, |
|
|
char * |
kernel_constants, |
|
|
char * |
kernel_filename, |
|
|
const char * |
kernel_name |
|
) |
| |
Generates an OpenCL kernel from a source string.
- Parameters
-
context | The OpenCL context |
device | The OpenCL device |
*kernel_constants | Pointer to string that contains kernel constants that shall be added to the compiled kernel |
*kernel_filename | Pointer to string containing the kernel code |
*kernel_name | Pointer to string containing the kernel name |
void print_build_information |
( |
cl_program |
program, |
|
|
cl_device_id |
device |
|
) |
| |
Prints the build information that stems from a kernel.
- Parameters
-
program | The OpenCL program to be built |
device | The OpenCL device |
void readfile |
( |
char * |
filename, |
|
|
char ** |
text, |
|
|
unsigned long * |
size |
|
) |
| |
Helper function that can read text from a file and stores everything in a char array.
- Parameters
-
*filename | Pointer to string containing the filename |
**text | Pointer to char* that shall contain the parsed text |
*size | Number of bytes that shall be parsed |