diff options
author | Zack Rusin <zack@kde.org> | 2010-11-10 23:17:05 -0500 |
---|---|---|
committer | Zack Rusin <zack@kde.org> | 2010-11-10 23:17:05 -0500 |
commit | d502708bbfdbcf89139c49539cfac58c9e2c56ce (patch) | |
tree | b848c7ea1fcd55d9e01141f12ff14821671ce7c9 | |
parent | 27333d524570f9bced822daa80d233fc21daba24 (diff) |
Implement more of the api stubs
-rw-r--r-- | src/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/api/api_context.cpp | 21 | ||||
-rw-r--r-- | src/api/api_device.cpp | 6 | ||||
-rw-r--r-- | src/core/commandqueue.cpp | 9 | ||||
-rw-r--r-- | src/core/commandqueue.h | 19 | ||||
-rw-r--r-- | src/core/context.cpp | 18 | ||||
-rw-r--r-- | src/core/context.h | 27 | ||||
-rw-r--r-- | src/core/device.cpp | 17 | ||||
-rw-r--r-- | src/core/device.h | 58 | ||||
-rw-r--r-- | src/core/event.cpp | 11 | ||||
-rw-r--r-- | src/core/event.h | 20 | ||||
-rw-r--r-- | src/core/kernel.cpp | 11 | ||||
-rw-r--r-- | src/core/kernel.h | 18 | ||||
-rw-r--r-- | src/core/mem.cpp | 11 | ||||
-rw-r--r-- | src/core/mem.h | 21 | ||||
-rw-r--r-- | src/core/platformid.cpp | 11 | ||||
-rw-r--r-- | src/core/platformid.h | 21 | ||||
-rw-r--r-- | src/core/program.cpp | 11 | ||||
-rw-r--r-- | src/core/program.h | 19 | ||||
-rw-r--r-- | src/core/sampler.cpp | 11 | ||||
-rw-r--r-- | src/core/sampler.h | 20 |
21 files changed, 298 insertions, 70 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0ecf39..e75abf6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,8 +15,14 @@ set(COAL_SRC_FILES api/api_enqueue.cpp api/api_flush.cpp api/api_memory.cpp api/api_profiling.cpp api/api_sampler.cpp api/api_gl.cpp - core/device.cpp core/context.cpp + core/device.cpp + core/event.cpp + core/kernel.cpp + core/mem.cpp + core/platformid.cpp + core/program.cpp + core/sampler.cpp compiler/compiler.cpp) add_library(OpenCL SHARED ${COAL_SRC_FILES}) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index b027d2f..1d828df 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -18,7 +18,8 @@ clCreateContext(const cl_context_properties *properties, cl_device_id device = devices[0]; cl_int device_info; - device_info = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL); + device_info = clGetDeviceInfo(device, CL_DEVICE_TYPE, + sizeof(type), &type, NULL); if (device_info != CL_INVALID_DEVICE) { ret_context = clCreateContextFromType(properties, type, pfn_notify, user_data, errcode_ret); @@ -30,26 +31,24 @@ clCreateContext(const cl_context_properties *properties, cl_context clCreateContextFromType(const cl_context_properties *properties, cl_device_type device_type, - void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, + void (*pfn_notify)(const char *, const void *, size_t, void *), void * user_data, cl_int * errcode_ret) { - struct pipe_context *context = NULL; + struct _cl_context *context = NULL; switch (device_type) { case CL_DEVICE_TYPE_CPU: - context = cl_create_context(); + context = new _cl_context(); break; default: if (errcode_ret) { *errcode_ret = CL_INVALID_DEVICE_TYPE; } - goto fail; } -fail: - return cl_convert_context(context); + return context; } cl_int @@ -58,7 +57,7 @@ clRetainContext(cl_context context) cl_int ret; if (context) { - context->id++; + context->ref(); ret = CL_SUCCESS; } else { ret = CL_INVALID_CONTEXT; @@ -73,11 +72,7 @@ clReleaseContext(cl_context context) cl_uint ret; if (context) { - if( !context->id ) { - context->pipe.destroy(&context->pipe); - } else { - context->id--; - } + context->deref(); ret = CL_SUCCESS; } else { ret = CL_INVALID_CONTEXT; diff --git a/src/api/api_device.cpp b/src/api/api_device.cpp index fd2942a..5c7c32c 100644 --- a/src/api/api_device.cpp +++ b/src/api/api_device.cpp @@ -48,10 +48,10 @@ create_cpu_device(cl_device_id * devices, cl_uint * num_devices, cl_uint num_entries) { - Device *device = Device::create(CL_DEVICE_TYPE_CPU); + Coal::DeviceId *device = Coal::DeviceId::create(CL_DEVICE_TYPE_CPU); - devices[0] = (cl_device_id)device; - *num_devices = 1; + devices[0] = (cl_device_id)device; + *num_devices = 1; } static void diff --git a/src/core/commandqueue.cpp b/src/core/commandqueue.cpp new file mode 100644 index 0000000..feaa3df --- /dev/null +++ b/src/core/commandqueue.cpp @@ -0,0 +1,9 @@ +#include "commandqueue.h" + +CommandQueue::CommandQueue() +{ +} + +CommandQueue::~CommandQueue() +{ +} diff --git a/src/core/commandqueue.h b/src/core/commandqueue.h new file mode 100644 index 0000000..1e86c3f --- /dev/null +++ b/src/core/commandqueue.h @@ -0,0 +1,19 @@ +#ifndef COAL_COMMANDQUEUE_H +#define COAL_COMMANDQUEUE_H + +namespace Coal { + + class CommandQueue + { + public: + CommandQueue(); + ~CommandQueue(); + }; +} + +struct _cl_command_queue : public Coal::CommandQueue +{ +}; + + +#endif diff --git a/src/core/context.cpp b/src/core/context.cpp index 5f2071e..5d25e2e 100644 --- a/src/core/context.cpp +++ b/src/core/context.cpp @@ -1,16 +1,22 @@ #include "context.h" #include "util/u_memory.h" -void cl_destroy_context( struct pipe_context *context ) +using namespace Coal; + +Context::Context() { - struct _cl_context *clcontext = cl_convert_context(context); +} - FREE(clcontext); +Context::~Context() +{ } -struct pipe_context *cl_create_context() +bool Context::ref() { - struct _cl_context *cl_context = CALLOC_STRUCT(_cl_context); + return true; +} - return &cl_context->pipe; +bool Context::deref() +{ + return true; } diff --git a/src/core/context.h b/src/core/context.h index 26256a7..06a18a7 100644 --- a/src/core/context.h +++ b/src/core/context.h @@ -4,20 +4,25 @@ #include "CL/cl.h" #include "pipe/p_context.h" -struct _cl_context { - struct pipe_context pipe; - cl_uint id; -}; +namespace Coal { -void cl_set_current_context( struct _cl_context *ctx); -struct _cl_context *cl_current_context( void); + class Context { + public: + Context(); + ~Context(); -struct pipe_context *cl_create_context(); + bool ref(); + bool deref(); + + private: + struct pipe_context pipe; + cl_uint id; + }; -static INLINE struct _cl_context * -cl_convert_context( struct pipe_context *pipe ) -{ - return (struct _cl_context *)pipe; } +struct _cl_context : public Coal::Context +{ +}; + #endif diff --git a/src/core/device.cpp b/src/core/device.cpp index b1a4872..cbcb72b 100644 --- a/src/core/device.cpp +++ b/src/core/device.cpp @@ -7,14 +7,15 @@ #include "pipe/p_format.h" #include "util/u_memory.h" +using namespace Coal; -Device * Device::create(cl_uint type) +DeviceId * DeviceId::create(cl_uint type) { switch(type) { case CL_DEVICE_TYPE_CPU: { struct pipe_screen *screen = /*softpipe_create_screen(ws);*/ 0; - return new Device(CL_DEVICE_TYPE_CPU, screen); + return new DeviceId(CL_DEVICE_TYPE_CPU, screen); } break; case CL_DEVICE_TYPE_GPU: @@ -42,10 +43,10 @@ static void stringToParam(const std::string &str, *paramValueSizeRet = str.size(); } -cl_int Device::info(cl_device_info opcode, - size_t paramValueSize, - void * paramValue, - size_t * paramValueSizeRet) const +cl_int DeviceId::info(cl_device_info opcode, + size_t paramValueSize, + void * paramValue, + size_t * paramValueSizeRet) const { if (!paramValue) return CL_SUCCESS; @@ -167,13 +168,13 @@ cl_int Device::info(cl_device_info opcode, return CL_SUCCESS; } -Device::Device(cl_uint type, struct pipe_screen *screen) +DeviceId::DeviceId(cl_uint type, struct pipe_screen *screen) : m_screen(screen) { fillInfo(type); } -void Device::fillInfo(cl_uint type) +void DeviceId::fillInfo(cl_uint type) { m_info.type = type; m_info.vendorId = 0;//should be a PCIe ID diff --git a/src/core/device.h b/src/core/device.h index f586652..4d0a8e0 100644 --- a/src/core/device.h +++ b/src/core/device.h @@ -1,5 +1,5 @@ -#ifndef DEVICE_H -#define DEVICE_H +#ifndef COAL_DEVICEID_H +#define COAL_DEVICEID_H #include "deviceinfo.h" @@ -7,41 +7,43 @@ struct pipe_screen; +namespace Coal { -class Device -{ -public: - static Device *create(cl_uint type); -public: - inline cl_uint type() const; - inline struct pipe_screen *screen() const; + class DeviceId + { + public: + static DeviceId *create(cl_uint type); + public: + inline cl_uint type() const; + inline struct pipe_screen *screen() const; - cl_int info(cl_device_info opcode, - size_t paramValueSize, - void * paramValue, - size_t * paramValueSizeRet) const; + cl_int info(cl_device_info opcode, + size_t paramValueSize, + void * paramValue, + size_t * paramValueSizeRet) const; -private: - Device(cl_uint type, struct pipe_screen *screen); - void fillInfo(cl_uint type); + private: + DeviceId(cl_uint type, struct pipe_screen *screen); + void fillInfo(cl_uint type); -private: - DeviceInfo m_info; + private: + DeviceInfo m_info; - struct pipe_screen *m_screen; -}; + struct pipe_screen *m_screen; + }; -inline cl_uint Device::type() const -{ - return m_info.type; -} + inline cl_uint DeviceId::type() const + { + return m_info.type; + } -inline struct pipe_screen *Device::screen() const -{ - return m_screen; + inline struct pipe_screen *DeviceId::screen() const + { + return m_screen; + } } -struct _cl_device_id : public Device +struct _cl_device_id : public Coal::DeviceId {}; #endif diff --git a/src/core/event.cpp b/src/core/event.cpp new file mode 100644 index 0000000..ee23fc4 --- /dev/null +++ b/src/core/event.cpp @@ -0,0 +1,11 @@ +#include "event.h" + +using namespace Coal; + +Event::Event() +{ +} + +Event::~Event() +{ +} diff --git a/src/core/event.h b/src/core/event.h new file mode 100644 index 0000000..4392ec5 --- /dev/null +++ b/src/core/event.h @@ -0,0 +1,20 @@ +#ifndef COAL_EVENT_H +#define COAL_EVENT_H + +#include "CL/cl.h" + +namespace Coal +{ + class Event + { + public: + Event(); + ~Event(); + }; +} + +struct _cl_event : public Coal::Event +{ +}; + +#endif diff --git a/src/core/kernel.cpp b/src/core/kernel.cpp new file mode 100644 index 0000000..554c7d9 --- /dev/null +++ b/src/core/kernel.cpp @@ -0,0 +1,11 @@ +#include "kernel.h" + +using namespace Coal; + +Kernel::Kernel() +{ +} + +Kernel::~Kernel() +{ +} diff --git a/src/core/kernel.h b/src/core/kernel.h new file mode 100644 index 0000000..9501c25 --- /dev/null +++ b/src/core/kernel.h @@ -0,0 +1,18 @@ +#ifndef COAL_KERNEL_H +#define COAL_KERNEL_H + +namespace Coal +{ + class Kernel + { + public: + Kernel(); + ~Kernel(); + }; +} + +struct _cl_kernel : public Coal::Kernel +{ +}; + +#endif diff --git a/src/core/mem.cpp b/src/core/mem.cpp new file mode 100644 index 0000000..7b46ad5 --- /dev/null +++ b/src/core/mem.cpp @@ -0,0 +1,11 @@ +#include "mem.h" + +using namespace Coal; + +Mem::Mem() +{ +} + +Mem::~Mem() +{ +} diff --git a/src/core/mem.h b/src/core/mem.h new file mode 100644 index 0000000..ebf7b55 --- /dev/null +++ b/src/core/mem.h @@ -0,0 +1,21 @@ +#ifndef COAL_MEM_H +#define COAL_MEM_H + +#include "CL/cl.h" + +namespace Coal { + + class Mem + { + public: + Mem(); + ~Mem(); + }; +} + +struct _cl_mem : public Coal::Mem +{ +}; + + +#endif diff --git a/src/core/platformid.cpp b/src/core/platformid.cpp new file mode 100644 index 0000000..1a91c97 --- /dev/null +++ b/src/core/platformid.cpp @@ -0,0 +1,11 @@ +#include "platformid.h" + +using namespace Coal; + +PlatformId::PlatformId() +{ +} + +PlatformId::~PlatformId() +{ +} diff --git a/src/core/platformid.h b/src/core/platformid.h new file mode 100644 index 0000000..41b60a9 --- /dev/null +++ b/src/core/platformid.h @@ -0,0 +1,21 @@ +#ifndef COAL_PLATFORMID_H +#define COAL_PLATFORMID_H + +#include "CL/cl.h" + +namespace Coal { + + class PlatformId + { + public: + PlatformId(); + ~PlatformId(); + }; +} + +struct _cl_platform_id : public Coal::PlatformId +{ +}; + + +#endif diff --git a/src/core/program.cpp b/src/core/program.cpp new file mode 100644 index 0000000..b74d6d9 --- /dev/null +++ b/src/core/program.cpp @@ -0,0 +1,11 @@ +#include "program.h" + +using namespace Coal; + +Program::Program() +{ +} + +Program::~Program() +{ +} diff --git a/src/core/program.h b/src/core/program.h new file mode 100644 index 0000000..df669f1 --- /dev/null +++ b/src/core/program.h @@ -0,0 +1,19 @@ +#ifndef COAL_PROGRAM_H +#define COAL_PROGRAM_H + +namespace Coal { + + class Program + { + public: + Program(); + ~Program(); + }; +} + +struct _cl_program : public Coal::Program +{ +}; + + +#endif diff --git a/src/core/sampler.cpp b/src/core/sampler.cpp new file mode 100644 index 0000000..52aa9a8 --- /dev/null +++ b/src/core/sampler.cpp @@ -0,0 +1,11 @@ +#include "sampler.h" + +using namespace Coal; + +Sampler::Sampler() +{ +} + +Sampler::~Sampler() +{ +} diff --git a/src/core/sampler.h b/src/core/sampler.h new file mode 100644 index 0000000..0b97b27 --- /dev/null +++ b/src/core/sampler.h @@ -0,0 +1,20 @@ +#ifndef COAL_SAMPLER_H +#define COAL_SAMPLER_H + +#include "CL/cl.h" + +namespace Coal +{ + class Sampler + { + public: + Sampler(); + ~Sampler(); + }; +} + +struct _cl_sampler : public Coal::Sampler +{ +}; + +#endif |