24 m_Data(nullptr), m_BpE(1)
39 MITK_DEBUG <<
"InitializeGPUBuffer call with: BPE=" << m_BpE;
49 m_gpuBuffer = clCreateBuffer(m_context, CL_MEM_READ_WRITE, m_bufferSize * (
size_t)m_BpE,
nullptr, &clErr);
52 MITK_INFO <<
"Created GPU Buffer Object of size: " << (size_t)m_BpE * m_bufferSize <<
" Bytes";
57 if (clErr != CL_SUCCESS)
58 mitkThrow() <<
"openCL Error when creating Buffer";
65 if (_type)
return m_cpuModified;
66 else return m_gpuModified;
72 m_cpuModified = _type;
73 m_gpuModified = !_type;
81 if (m_Data ==
nullptr){
82 MITK_ERROR(
"ocl.DataSet") <<
"(mitk) No data present!\n";
97 clErr = clEnqueueWriteBuffer(gpuComQueue,
m_gpuBuffer, CL_TRUE, 0, m_bufferSize * (
size_t)m_BpE, m_Data, 0, NULL, NULL);
98 MITK_DEBUG <<
"Wrote Data to GPU Buffer Object.";
101 m_gpuModified =
true;
103 if (clErr != CL_SUCCESS)
104 mitkThrow() <<
"openCL Error when writing Buffer";
123 cl_mem_object_type memInfo;
124 clErr = clGetMemObjectInfo(this->
m_gpuBuffer, CL_MEM_TYPE,
sizeof(cl_mem_object_type), &memInfo,
nullptr );
126 MITK_DEBUG <<
"Querying info for object, recieving: " << memInfo;
139 MITK_ERROR(
"ocl.DataSet") <<
"(mitk) No buffer present!\n";
144 char* data =
new char[m_bufferSize * (size_t)m_BpE];
151 clErr = clEnqueueReadBuffer( gpuComQueue,
m_gpuBuffer, CL_TRUE, 0, m_bufferSize * (
size_t)m_BpE, data ,0,
nullptr,
nullptr);
154 if(clErr != CL_SUCCESS)
155 mitkThrow() <<
"openCL Error when reading Output Buffer";
157 clFlush( gpuComQueue );
159 this->m_gpuModified =
false;
#define CHECK_OCL_ERR(_er)
void Modified(int _type)
Set the modified flag for one of the buffers.
ServiceReferenceU GetServiceReference(const std::string &clazz)
void * GetService(const ServiceReferenceBase &reference)
void SetBufferSize(vcl_size_t size)
Set the amount of elements in buffer.
virtual int TransferDataToGPU(cl_command_queue)
Copies the RAM-stored data to GMEM.
bool IsModified(int _type)
Returns the status of the image buffer.
void SetBpE(unsigned short BpE)
Set the DataSet memory Size per Element in Bytes.
virtual void * TransferDataToCPU(cl_command_queue)
Copies the in GMEM stored data to RAM.
virtual ~OclDataSet()
Destructor.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void oclPrintMemObjectInfo(cl_mem memobj)
Prints the available memory info about the given object to std::cout.
Declaration of the OpenCL Resources micro-service.