Loading...
Searching...
No Matches
itkOpenCLKernelManager.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
/*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkOpenCLKernelManager_h
#define itkOpenCLKernelManager_h
#include <itkLightObject.h>
#include <itkObjectFactory.h>
#include "itkGPUDataManager.h"
#include "itkOpenCLContext.h"
#include "itkOpenCLKernel.h"
#include <vector>
namespace itk
{
class OpenCLContext;
class ITKOpenCL_EXPORT OpenCLKernelManager : public LightObject
{
public:
ITK_DISALLOW_COPY_AND_MOVE(OpenCLKernelManager);
using Self = OpenCLKernelManager;
using Superclass = LightObject;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(OpenCLKernelManager, LightObject);
OpenCLContext *
GetContext() const
{
return this->m_Context;
}
OpenCLKernel &
GetKernel(const std::size_t kernelId);
OpenCLEvent
LaunchKernel(const std::size_t kernelId);
OpenCLEvent
LaunchKernel(const std::size_t kernelId,
const OpenCLSize & global_work_size,
const OpenCLSize & local_work_size = OpenCLSize::null,
const OpenCLSize & global_work_offset = OpenCLSize::null);
OpenCLEvent
LaunchKernel(const std::size_t kernelId, const OpenCLEventList & event_list);
OpenCLEvent
LaunchKernel(const std::size_t kernelId,
const OpenCLEventList & event_list,
const OpenCLSize & global_work_size,
const OpenCLSize & local_work_size = OpenCLSize::null,
const OpenCLSize & global_work_offset = OpenCLSize::null);
std::size_t
CreateKernel(const OpenCLProgram & program, const std::string & name);
OpenCLProgram
BuildProgramFromSourceCode(const std::string & sourceCode,
const std::string & prefixSourceCode = std::string(),
const std::string & postfixSourceCode = std::string(),
const std::string & extraBuildOptions = std::string());
OpenCLProgram
BuildProgramFromSourceFile(const std::string & fileName,
const std::string & prefixSourceCode = std::string(),
const std::string & postfixSourceCode = std::string(),
const std::string & extraBuildOptions = std::string());
void
SetGlobalWorkSizeForAllKernels(const OpenCLSize & size);
void
SetLocalWorkSizeForAllKernels(const OpenCLSize & size);
void
SetGlobalWorkOffsetForAllKernels(const OpenCLSize & offset);
bool
SetKernelArg(const std::size_t kernelId, const cl_uint argId, const std::size_t argSize, const void * argVal);
bool
SetKernelArgForAllKernels(const cl_uint argId, const std::size_t argSize, const void * argVal);
bool
SetKernelArgWithImage(const std::size_t kernelId, cl_uint argId, const GPUDataManager::Pointer manager);
protected:
OpenCLKernelManager();
~OpenCLKernelManager() override;
bool
CheckArgumentReady(const std::size_t kernelId);
void
ResetArguments(const std::size_t kernelIdx);
private:
OpenCLContext * m_Context{};
struct KernelArgumentList
{
bool m_IsReady;
GPUDataManager::Pointer m_GPUDataManager;
};
std::vector<OpenCLKernel> m_Kernels{};
std::vector<std::vector<KernelArgumentList>> m_KernelArgumentReady{};
};
} // end namespace itk
#endif /* itkOpenCLKernelManager_h */
itk::GPUDataManager::Pointer
SmartPointer< Self > Pointer
Definition itkGPUDataManager.h:74
itk::OpenCLContext
The OpenCLContext class represents an OpenCL context.
Definition itkOpenCLContext.h:77
itk::OpenCLEventList
OpenCLEventList class represents a list of OpenCLEvent objects.
Definition itkOpenCLEventList.h:33
itk::OpenCLEvent
OpenCLEvent class represents an OpenCL event object.
Definition itkOpenCLEvent.h:93
itk::OpenCLKernelManager::LaunchKernel
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId, const OpenCLEventList &event_list, const OpenCLSize &global_work_size, const OpenCLSize &local_work_size=OpenCLSize::null, const OpenCLSize &global_work_offset=OpenCLSize::null)
itk::OpenCLKernelManager::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkOpenCLKernelManager.h:76
itk::OpenCLKernelManager::Superclass
LightObject Superclass
Definition itkOpenCLKernelManager.h:74
itk::OpenCLKernelManager::LaunchKernel
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId)
itk::OpenCLKernelManager::GetContext
OpenCLContext * GetContext() const
Definition itkOpenCLKernelManager.h:86
itk::OpenCLKernelManager::m_Context
OpenCLContext * m_Context
Definition itkOpenCLKernelManager.h:164
itk::OpenCLKernelManager::ResetArguments
void ResetArguments(const std::vcl_size_t kernelIdx)
itk::OpenCLKernelManager::CheckArgumentReady
bool CheckArgumentReady(const std::vcl_size_t kernelId)
itk::OpenCLKernelManager::m_KernelArgumentReady
std::vector< std::vector< KernelArgumentList > > m_KernelArgumentReady
Definition itkOpenCLKernelManager.h:173
itk::OpenCLKernelManager::GetKernel
OpenCLKernel & GetKernel(const std::vcl_size_t kernelId)
itk::OpenCLKernelManager::Self
OpenCLKernelManager Self
Definition itkOpenCLKernelManager.h:73
itk::OpenCLKernelManager::SetKernelArgForAllKernels
bool SetKernelArgForAllKernels(const cl_uint argId, const std::vcl_size_t argSize, const void *argVal)
itk::OpenCLKernelManager::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(OpenCLKernelManager)
itk::OpenCLKernelManager::BuildProgramFromSourceFile
OpenCLProgram BuildProgramFromSourceFile(const std::string &fileName, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string(), const std::string &extraBuildOptions=std::string())
itk::OpenCLKernelManager::SetLocalWorkSizeForAllKernels
void SetLocalWorkSizeForAllKernels(const OpenCLSize &size)
itk::OpenCLKernelManager::BuildProgramFromSourceCode
OpenCLProgram BuildProgramFromSourceCode(const std::string &sourceCode, const std::string &prefixSourceCode=std::string(), const std::string &postfixSourceCode=std::string(), const std::string &extraBuildOptions=std::string())
itk::OpenCLKernelManager::LaunchKernel
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId, const OpenCLEventList &event_list)
itk::OpenCLKernelManager::m_Kernels
std::vector< OpenCLKernel > m_Kernels
Definition itkOpenCLKernelManager.h:172
itk::OpenCLKernelManager::~OpenCLKernelManager
~OpenCLKernelManager() override
itk::OpenCLKernelManager::CreateKernel
std::vcl_size_t CreateKernel(const OpenCLProgram &program, const std::string &name)
itk::OpenCLKernelManager::LaunchKernel
OpenCLEvent LaunchKernel(const std::vcl_size_t kernelId, const OpenCLSize &global_work_size, const OpenCLSize &local_work_size=OpenCLSize::null, const OpenCLSize &global_work_offset=OpenCLSize::null)
itk::OpenCLKernelManager::SetKernelArgWithImage
bool SetKernelArgWithImage(const std::vcl_size_t kernelId, cl_uint argId, const GPUDataManager::Pointer manager)
itk::OpenCLKernelManager::SetKernelArg
bool SetKernelArg(const std::vcl_size_t kernelId, const cl_uint argId, const std::vcl_size_t argSize, const void *argVal)
itk::OpenCLKernelManager::Pointer
SmartPointer< Self > Pointer
Definition itkOpenCLKernelManager.h:75
itk::OpenCLKernelManager::OpenCLKernelManager
OpenCLKernelManager()
itk::OpenCLKernelManager::SetGlobalWorkOffsetForAllKernels
void SetGlobalWorkOffsetForAllKernels(const OpenCLSize &offset)
itk::OpenCLKernelManager::SetGlobalWorkSizeForAllKernels
void SetGlobalWorkSizeForAllKernels(const OpenCLSize &size)
itk::OpenCLKernel
The OpenCLKernel class represents an executable entry point function in an OpenCL program.
Definition itkOpenCLKernel.h:136
itk::OpenCLProgram
The OpenCLProgram class represents an OpenCL program object.
Definition itkOpenCLProgram.h:38
itk::OpenCLSize
The OpenCLSize class defines the size of an item of work for an OpenCL kernel.
Definition itkOpenCLSize.h:50
itk::OpenCLSize::null
static const Null null
Definition itkOpenCLSize.h:62
itkGPUDataManager.h
itkOpenCLContext.h
ITKOpenCL_EXPORT
#define ITKOpenCL_EXPORT
Definition itkOpenCLExport.h:33
itkOpenCLKernel.h
itk
Definition itkAdvancedImageToImageMetric.h:43
itk::OpenCLKernelManager::KernelArgumentList
Definition itkOpenCLKernelManager.h:167
itk::OpenCLKernelManager::KernelArgumentList::m_IsReady
bool m_IsReady
Definition itkOpenCLKernelManager.h:168
itk::OpenCLKernelManager::KernelArgumentList::m_GPUDataManager
GPUDataManager::Pointer m_GPUDataManager
Definition itkOpenCLKernelManager.h:169

Generated on 1768596610 for elastix by 1.15.0 |