bufferkdtree (C sources)
C source code for the Python bufferkdtree implementation
 All Classes Files Functions Variables Typedefs Macros
Classes | Macros | Functions
opencl.h File Reference
#include <CL/cl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for opencl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DEVICE_INFOS
 

Macros

#define STR_HELPER(x)   #x
 
#define STR(x)   STR_HELPER(x)
 
#define MAX_KERNEL_SOURCE_LENGTH   100000
 
#define MAX_KERNEL_CONSTANTS_LENGTH   1000
 
#define ERROR_NO_PLATFORMS   -1
 
#define ERROR_INVALID_PLATFORMS   -2
 
#define ERROR_NO_DEVICES   -3
 
#define ERROR_INVALID_DEVICE   -4
 

Functions

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)
 

Macro Definition Documentation

#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 (   x)    STR_HELPER(x)
#define STR_HELPER (   x)    #x

Function Documentation

void check_cl_error ( cl_int  err,
const char *  file,
int  line 
)

Helper function that checks for an OpenCL error

Parameters
errThe OpenCL error code (int)
*fileThe source code file
lineThe 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_numberThe OpenCL platform number
*device_numberThe 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_queueThe OpenCL command queue
*deviceThe OpenCL device
*contextThe 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_numberThe OpenCL platform number
*platformPointer to platform that shall be initialized
device_numberThe OpenCL device id/number that shall be used
*devicePointer to corresponding device
*contextThe OpenCL context
*command_queueThe OpenCL command queue
verboseThe 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
contextThe OpenCL context
deviceThe OpenCL device
*kernel_constantsPointer to string that contains kernel constants that shall be added to the compiled kernel
*kernel_filenamePointer to string containing the kernel code
*kernel_namePointer 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
programThe OpenCL program to be built
deviceThe 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
*filenamePointer to string containing the filename
**textPointer to char* that shall contain the parsed text
*sizeNumber of bytes that shall be parsed