Code quality: removed dependencies on the C++ OpenCL wrapper

This commit is contained in:
Philippe Tillet
2015-07-25 21:00:18 -07:00
parent 9e91a35d05
commit 0ef6654c5f
40 changed files with 577 additions and 161 deletions

View File

@@ -1,3 +1,5 @@
#include <iostream>
#include "isaac/driver/command_queue.h"
#include "isaac/driver/common.h"
#include "isaac/driver/context.h"
@@ -6,14 +8,16 @@
#include "isaac/driver/kernel.h"
#include "isaac/driver/ndrange.h"
#include "isaac/driver/buffer.h"
#include <iostream>
#include "helpers/ocl/infos.hpp"
namespace isaac
{
namespace driver
{
CommandQueue::CommandQueue(cl::CommandQueue const & queue) : backend_(OPENCL), context_(queue.getInfo<CL_QUEUE_CONTEXT>()), device_(queue.getInfo<CL_QUEUE_DEVICE>()), h_(backend_)
CommandQueue::CommandQueue(cl_command_queue const & queue) : backend_(OPENCL), context_(ocl::info<CL_QUEUE_CONTEXT>(queue)), device_(ocl::info<CL_QUEUE_DEVICE>(queue)), h_(backend_)
{
h_.cl() = queue;
}
@@ -28,10 +32,12 @@ CommandQueue::CommandQueue(Context const & context, Device const & device, cl_co
break;
#endif
case OPENCL:
{
cl_int err;
h_.cl() = cl::CommandQueue(context.h_.cl(), device.h_.cl(), properties, &err);
h_.cl() = clCreateCommandQueue(context.h_.cl(), device.h_.cl(), properties, &err);
ocl::check(err);
break;
}
default: throw;
}
}
@@ -49,7 +55,7 @@ void CommandQueue::synchronize()
#ifdef ISAAC_WITH_CUDA
case CUDA: cuda::check(cuStreamSynchronize(*h_.cu)); break;
#endif
case OPENCL: h_.cl().finish(); break;
case OPENCL: ocl::check(clFinish(h_.cl())); break;
default: throw;
}
}
@@ -68,7 +74,7 @@ Event CommandQueue::enqueue(Kernel const & kernel, NDRange global, driver::NDRan
break;
#endif
case OPENCL:
ocl::check(h_.cl().enqueueNDRangeKernel(kernel.h_.cl(), cl::NullRange, (cl::NDRange)global, (cl::NDRange)local, NULL, &event.h_.cl()));
ocl::check(clEnqueueNDRangeKernel(h_.cl(), kernel.h_.cl(), global.dimension(), NULL, (const size_t *)global, (const size_t *) local, 0, NULL, &event.h_.cl()));
break;
default: throw;
}
@@ -88,7 +94,7 @@ void CommandQueue::write(Buffer const & buffer, bool blocking, std::size_t offse
break;
#endif
case OPENCL:
h_.cl().enqueueWriteBuffer(buffer.h_.cl(), blocking, offset, size, ptr);
clEnqueueWriteBuffer(h_.cl(), buffer.h_.cl(), blocking, offset, size, ptr, 0, NULL, NULL);
break;
default: throw;
}
@@ -107,7 +113,7 @@ void CommandQueue::read(Buffer const & buffer, bool blocking, std::size_t offset
break;
#endif
case OPENCL:
h_.cl().enqueueReadBuffer(buffer.h_.cl(), blocking, offset, size, ptr);
clEnqueueReadBuffer(h_.cl(), buffer.h_.cl(), blocking, offset, size, ptr, 0, NULL, NULL);
break;
default: throw;
}
@@ -119,7 +125,7 @@ bool CommandQueue::operator==(CommandQueue const & other) const
bool CommandQueue::operator<(CommandQueue const & other) const
{ return h_ < other.h_; }
HANDLE_TYPE(cl::CommandQueue, CUstream) & CommandQueue::handle()
HANDLE_TYPE(cl_command_queue, CUstream) & CommandQueue::handle()
{ return h_; }
}