diff options
author | Zack Rusin <zack@kde.org> | 2009-08-30 15:03:08 -0400 |
---|---|---|
committer | Zack Rusin <zack@kde.org> | 2009-08-30 15:03:08 -0400 |
commit | fe552119577560a7d842d852f1c37844b14a2e2f (patch) | |
tree | a8a8ebecce27f9dc891627115de10558ee3ad14d /src/api | |
parent | f9b2a85968d82b938842606d5765348a3f9cd9d7 (diff) |
reorganize the directory structure a bit
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/api_command.cpp | 42 | ||||
-rw-r--r-- | src/api/api_context.cpp | 47 | ||||
-rw-r--r-- | src/api/api_device.cpp | 132 | ||||
-rw-r--r-- | src/api/api_enqueue.cpp | 221 | ||||
-rw-r--r-- | src/api/api_event.cpp | 31 | ||||
-rw-r--r-- | src/api/api_flush.cpp | 14 | ||||
-rw-r--r-- | src/api/api_gl.cpp | 86 | ||||
-rw-r--r-- | src/api/api_kernel.cpp | 61 | ||||
-rw-r--r-- | src/api/api_memory.cpp | 84 | ||||
-rw-r--r-- | src/api/api_platform.cpp | 34 | ||||
-rw-r--r-- | src/api/api_profiling.cpp | 13 | ||||
-rw-r--r-- | src/api/api_program.cpp | 74 | ||||
-rw-r--r-- | src/api/api_sampler.cpp | 34 |
13 files changed, 873 insertions, 0 deletions
diff --git a/src/api/api_command.cpp b/src/api/api_command.cpp new file mode 100644 index 0000000..4f1c417 --- /dev/null +++ b/src/api/api_command.cpp @@ -0,0 +1,42 @@ +#include <OpenCL/cl.h> + +// Command Queue APIs +cl_command_queue +clCreateCommandQueue(cl_context context, + cl_device_id device, + cl_command_queue_properties properties, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clRetainCommandQueue(cl_command_queue command_queue) +{ + return 0; +} + +cl_int +clReleaseCommandQueue(cl_command_queue command_queue) +{ + return 0; +} + +cl_int +clGetCommandQueueInfo(cl_command_queue command_queue, + cl_command_queue_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + +cl_int +clSetCommandQueueProperty(cl_command_queue command_queue, + cl_command_queue_properties properties, + cl_bool enable, + cl_command_queue_properties * old_properties) +{ + return 0; +} diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp new file mode 100644 index 0000000..fbf3af9 --- /dev/null +++ b/src/api/api_context.cpp @@ -0,0 +1,47 @@ +#include <OpenCL/cl.h> + + +// Context APIs + +cl_context +clCreateContext(cl_context_properties properties, + cl_uint num_devices, + const cl_device_id * devices, + logging_fn pfn_notify, + void * user_data, + cl_int * errcode_ret) +{ + return 0; +} + +cl_context +clCreateContextFromType(cl_context_properties properties, + cl_device_type device_type, + logging_fn pfn_notify, + void * user_data, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clRetainContext(cl_context context) +{ + return 0; +} + +cl_int +clReleaseContext(cl_context context) +{ + return 0; +} + +cl_int +clGetContextInfo(cl_context context, + cl_context_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} diff --git a/src/api/api_device.cpp b/src/api/api_device.cpp new file mode 100644 index 0000000..f91ad29 --- /dev/null +++ b/src/api/api_device.cpp @@ -0,0 +1,132 @@ +#include "OpenCL/cl.h" +#include "OpenCL/cl_platform.h" + +#include "core/device.h" + +#include "pipe/p_screen.h" +#include "pipe/p_format.h" +#include "util/u_memory.h" + +#include <string> + +// Device APIs + +struct CLConstValue { + CLConstValue(int _id) + : id(_id) + {} + + virtual void param(size_t param_value_size, + void * param_value, + size_t *param_value_size_ret) + {} + + int id; +}; +template <class T> +struct CLConstValueTemplate : public CLConstValue { + CLConstValueTemplate(int _id, T _value) + : CLConstValue(id), value(_value) + {} + T value; +}; + +const CLConstValue values[] = { + CLConstValueTemplate<std::string>(CL_DEVICE_NAME, std::string("hello")), + CLConstValueTemplate<int>(CL_DEVICE_TYPE, (int)3) +}; + +static void +create_gpu_device(cl_device_id * devices, + cl_uint * num_devices, + cl_uint num_entries) +{ +} + +static void +create_cpu_device(cl_device_id * devices, + cl_uint * num_devices, + cl_uint num_entries) +{ + Device *device = Device::create(CL_DEVICE_TYPE_CPU); + + devices[0] = (cl_device_id)device; + *num_devices = 1; +} + +static void +create_accel_device(cl_device_id * devices, + cl_uint * num_devices, + cl_uint num_entries) +{ +} + + +cl_int +clGetDeviceIDs(cl_device_type device_type, + cl_uint num_entries, + cl_device_id * devices, + cl_uint * num_devices) +{ + cl_bool gpu, cpu, accelerator; + cl_uint original_num_entries = num_entries; + + gpu = (device_type & CL_DEVICE_TYPE_DEFAULT) || + (device_type & CL_DEVICE_TYPE_GPU) || + (device_type & CL_DEVICE_TYPE_ALL); + + cpu = (device_type & CL_DEVICE_TYPE_CPU) || + (device_type & CL_DEVICE_TYPE_ALL); + + accelerator = (device_type & CL_DEVICE_TYPE_ACCELERATOR) || + (device_type & CL_DEVICE_TYPE_ALL); + + if (!gpu && !cpu && !accelerator) + return CL_INVALID_DEVICE_TYPE; + + if ((!num_entries && devices) || (!num_devices && !devices)) + return CL_INVALID_VALUE; + + if (gpu && num_entries > 0) { + cl_uint num_gpus = 0; + create_gpu_device(devices, &num_gpus, num_entries); + num_entries -= num_gpus; + if (num_devices) + *num_devices += num_gpus; + } + + if (cpu && num_entries > 0) { + cl_uint num_cpus = 0; + create_cpu_device(devices, &num_cpus, num_entries); + num_entries -= num_cpus; + if (num_devices) + *num_devices += num_cpus; + } + + if (accelerator && num_entries) { + cl_uint num_accels = 0; + create_accel_device(devices, &num_accels, num_entries); + num_entries -= num_accels; + if (num_devices) + *num_devices += num_accels; + } + + if (original_num_entries == num_entries) + return CL_DEVICE_NOT_FOUND; + + return CL_SUCCESS; +} + +cl_int +clGetDeviceInfo(cl_device_id device, + cl_device_info opcode, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + if (!device) + return CL_INVALID_DEVICE; + + return device->info(opcode, param_value_size, param_value, + param_value_size_ret); +} diff --git a/src/api/api_enqueue.cpp b/src/api/api_enqueue.cpp new file mode 100644 index 0000000..15091b4 --- /dev/null +++ b/src/api/api_enqueue.cpp @@ -0,0 +1,221 @@ +#include <OpenCL/cl.h> + +// Enqueued Commands APIs +cl_int +clEnqueueReadBuffer(cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_read, + size_t offset, + size_t cb, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueWriteBuffer(cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_write, + size_t offset, + size_t cb, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueCopyBuffer(cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueReadImage(cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_read, + const size_t * origin, + const size_t * region, + size_t row_pitch, + size_t slice_pitch, + void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueWriteImage(cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_write, + const size_t * origin, + const size_t * region, + size_t row_pitch, + size_t slice_pitch, + const void * ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueCopyImage(cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t * src_origin, + const size_t * dst_origin, + const size_t * region, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueCopyImageToBuffer(cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t * src_origin, + const size_t * region, + size_t dst_offset, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueCopyBufferToImage(cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t * dst_origin, + const size_t * region, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +void * +clEnqueueMapBuffer(cl_command_queue command_queue, + cl_mem buffer, + cl_bool blocking_map, + cl_map_flags map_flags, + size_t offset, + size_t cb, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event, + cl_int * errcode_ret) +{ + return 0; +} + +void * +clEnqueueMapImage(cl_command_queue command_queue, + cl_mem image, + cl_bool blocking_map, + cl_map_flags map_flags, + const size_t * origin, + const size_t * region, + size_t * image_row_pitch, + size_t * image_slice_pitch, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clEnqueueUnmapMemObject(cl_command_queue command_queue, + cl_mem memobj, + void * mapped_ptr, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueNDRangeKernel(cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t * global_work_offset, + const size_t * global_work_size, + const size_t * local_work_size, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueTask(cl_command_queue command_queue, + cl_kernel kernel, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueNativeFnAsKernel(cl_command_queue command_queue, + void (*user_func)(void *), + void * args, + size_t cb_args, + cl_uint num_mem_objects, + const cl_mem * mem_list, + const void ** args_mem_loc, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueMarker(cl_command_queue command_queue, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueWaitForEvents(cl_command_queue command_queue, + cl_uint num_events, + const cl_event * event_list) +{ + return 0; +} + +cl_int +clEnqueueBarrier(cl_command_queue command_queue) +{ + return 0; +} diff --git a/src/api/api_event.cpp b/src/api/api_event.cpp new file mode 100644 index 0000000..9c08011 --- /dev/null +++ b/src/api/api_event.cpp @@ -0,0 +1,31 @@ +#include <OpenCL/cl.h> + +// Event Object APIs +cl_int +clWaitForEvents(cl_uint num_events, + const cl_event * event_list) +{ + return 0; +} + +cl_int +clGetEventInfo(cl_event event, + cl_event_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + +cl_int +clRetainEvent(cl_event event) +{ + return 0; +} + +cl_int +clReleaseEvent(cl_event event) +{ + return 0; +} diff --git a/src/api/api_flush.cpp b/src/api/api_flush.cpp new file mode 100644 index 0000000..34afab0 --- /dev/null +++ b/src/api/api_flush.cpp @@ -0,0 +1,14 @@ +#include <OpenCL/cl.h> + +// Flush and Finish APIs +cl_int +clFlush(cl_command_queue command_queue) +{ + return 0; +} + +cl_int +clFinish(cl_command_queue command_queue) +{ + return 0; +} diff --git a/src/api/api_gl.cpp b/src/api/api_gl.cpp new file mode 100644 index 0000000..757df6a --- /dev/null +++ b/src/api/api_gl.cpp @@ -0,0 +1,86 @@ +#define GL_GLEXT_PROTOTYPES +#include "GL/gl.h" +#include "GL/glext.h" + +#include "OpenCL/cl.h" +#include "OpenCL/cl_gl.h" + +cl_mem +clCreateFromGLBuffer(cl_context context, + cl_mem_flags flags, + GLuint bufobj, + int * errcode_ret) +{ + return 0; +} + +cl_mem +clCreateFromGLTexture2D(cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + int * errcode_ret) +{ + return 0; +} + +cl_mem +clCreateFromGLTexture3D(cl_context context, + cl_mem_flags flags, + GLenum target, + GLint miplevel, + GLuint texture, + int * errcode_ret) +{ + return 0; +} + +cl_mem +clCreateFromGLRenderbuffer(cl_context context, + cl_mem_flags flags, + GLuint renderbuffer, + int * errcode_ret) +{ + return 0; +} + +cl_int +clGetGLObjectInfo(cl_mem memobj, + cl_gl_object_type * gl_object_type, + GLuint * gl_object_name) +{ + return 0; +} + +cl_int +clGetGLTextureInfo(cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + +cl_int +clEnqueueAcquireGLObjects(cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} + +cl_int +clEnqueueReleaseGLObjects(cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem * mem_objects, + cl_uint num_events_in_wait_list, + const cl_event * event_wait_list, + cl_event * event) +{ + return 0; +} diff --git a/src/api/api_kernel.cpp b/src/api/api_kernel.cpp new file mode 100644 index 0000000..27d7c81 --- /dev/null +++ b/src/api/api_kernel.cpp @@ -0,0 +1,61 @@ +#include <OpenCL/cl.h> + +// Kernel Object APIs +cl_kernel +clCreateKernel(cl_program program, + const char * kernel_name, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clCreateKernelsInProgram(cl_program program, + cl_uint num_kernels, + cl_kernel * kernels, + cl_uint * num_kernels_ret) +{ + return 0; +} + +cl_int +clRetainKernel(cl_kernel kernel) +{ + return 0; +} + +cl_int +clReleaseKernel(cl_kernel kernel) +{ + return 0; +} + +cl_int +clSetKernelArg(cl_kernel kernel, + cl_uint arg_indx, + size_t arg_size, + const void * arg_value) +{ + return 0; +} + +cl_int +clGetKernelInfo(cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + +cl_int +clGetKernelWorkGroupInfo(cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} diff --git a/src/api/api_memory.cpp b/src/api/api_memory.cpp new file mode 100644 index 0000000..19d4095 --- /dev/null +++ b/src/api/api_memory.cpp @@ -0,0 +1,84 @@ +#include <OpenCL/cl.h> + + +// Memory Object APIs +cl_mem +clCreateBuffer(cl_context context, + cl_mem_flags flags, + size_t size, + void * host_ptr, + cl_int * errcode_ret) +{ + return 0; +} + +cl_mem +clCreateImage2D(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height, + size_t image_row_pitch, + void * host_ptr, + cl_int * errcode_ret) +{ + return 0; +} + +cl_mem +clCreateImage3D(cl_context context, + cl_mem_flags flags, + const cl_image_format * image_format, + size_t image_width, + size_t image_height, + size_t image_depth, + size_t image_row_pitch, + size_t image_slice_pitch, + void * host_ptr, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clRetainMemObject(cl_mem memobj) +{ + return 0; +} + +cl_int +clReleaseMemObject(cl_mem memobj) +{ + return 0; +} + +cl_int +clGetSupportedImageFormats(cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_image_format * image_formats, + cl_uint * num_image_formats) +{ + return 0; +} + +cl_int +clGetMemObjectInfo(cl_mem memobj, + cl_mem_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + +cl_int +clGetImageInfo(cl_mem image, + cl_image_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} diff --git a/src/api/api_platform.cpp b/src/api/api_platform.cpp new file mode 100644 index 0000000..b6429e7 --- /dev/null +++ b/src/api/api_platform.cpp @@ -0,0 +1,34 @@ +#include <OpenCL/cl.h> + +#include <string.h> + +#define PROFILE_STR "FULL_PROFILE" +#define PROFILE_STR_LEN 12 + +#define VERSION_STR "OpenCL 1.0" +#define VERSION_STR_LEN 10 + +// Platform API +cl_int +clGetPlatformInfo(cl_platform_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + switch(param_name) { + case CL_PLATFORM_PROFILE: + strcpy((char*)param_value, PROFILE_STR); + *param_value_size_ret = PROFILE_STR_LEN; + break; + + case CL_PLATFORM_VERSION: + strcpy((char*)param_value, VERSION_STR); + *param_value_size_ret = VERSION_STR_LEN; + break; + + default: + return CL_INVALID_VALUE; + } + + return CL_SUCCESS; +} diff --git a/src/api/api_profiling.cpp b/src/api/api_profiling.cpp new file mode 100644 index 0000000..5980dee --- /dev/null +++ b/src/api/api_profiling.cpp @@ -0,0 +1,13 @@ +#include <OpenCL/cl.h> + +// Profiling APIs +cl_int +clGetEventProfilingInfo(cl_event event, + cl_profiling_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + diff --git a/src/api/api_program.cpp b/src/api/api_program.cpp new file mode 100644 index 0000000..98999fa --- /dev/null +++ b/src/api/api_program.cpp @@ -0,0 +1,74 @@ +#include <OpenCL/cl.h> + +// Program Object APIs +cl_program +clCreateProgramWithSource(cl_context context, + cl_uint count, + const char ** strings, + const size_t * lengths, + cl_int * errcode_ret) +{ + return 0; +} + +cl_program +clCreateProgramWithBinary(cl_context context, + cl_uint num_devices, + const cl_device_id * device_list, + const size_t * lengths, + const void ** binaries, + cl_int * binary_status, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clRetainProgram(cl_program program) +{ + return 0; +} + +cl_int +clReleaseProgram(cl_program program) +{ + return 0; +} + +cl_int +clBuildProgram(cl_program program, + cl_uint num_devices, + const cl_device_id * device_list, + const char * options, + void (*pfn_notify)(cl_program program, void * user_data), + void * user_data) +{ + return 0; +} + +cl_int +clUnloadCompiler(void) +{ + return 0; +} + +cl_int +clGetProgramInfo(cl_program program, + cl_program_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} + +cl_int +clGetProgramBuildInfo(cl_program program, + cl_device_id device, + cl_program_build_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} diff --git a/src/api/api_sampler.cpp b/src/api/api_sampler.cpp new file mode 100644 index 0000000..8c4d74a --- /dev/null +++ b/src/api/api_sampler.cpp @@ -0,0 +1,34 @@ +#include <OpenCL/cl.h> + +// Sampler APIs +cl_sampler +clCreateSampler(cl_context context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int * errcode_ret) +{ + return 0; +} + +cl_int +clRetainSampler(cl_sampler sampler) +{ + return 0; +} + +cl_int +clReleaseSampler(cl_sampler sampler) +{ + return 0; +} + +cl_int +clGetSamplerInfo(cl_sampler sampler, + cl_sampler_info param_name, + size_t param_value_size, + void * param_value, + size_t * param_value_size_ret) +{ + return 0; +} |