Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::OclFilter Class Referenceabstract

Superclass for all OpenCL based filter. More...

#include <mitkOclFilter.h>

Inheritance diagram for mitk::OclFilter:
Collaboration diagram for mitk::OclFilter:

Public Member Functions

void AddSourceFile (const char *filename)
 Add a source file from the resource files to the OpenCL shader file list. Multiple files can be added to the list. More...
 
void SetCompilerFlags (const char *flags)
 Set specific compilerflags to compile the CL source. Default is set to NULL; example: "-cl-fast-relaxed-math -cl-mad-enable -cl-strict-aliasing". More...
 
virtual bool IsInitialized ()
 Returns true if the initialization was successfull. More...
 
virtual ~OclFilter ()
 Destructor. More...
 

Protected Types

typedef std::vector< const char * > CStringList
 
typedef std::vector< vcl_size_t > ClSizeList
 

Protected Member Functions

 OclFilter ()
 Constructor. More...
 
 OclFilter (const char *filename)
 Constructor ( overloaded ) More...
 
void SetWorkingSize (unsigned int locx, unsigned int dimx, unsigned int locy=1, unsigned int dimy=1, unsigned int locz=1, unsigned int dimz=1)
 Set the working size for the following OpenCL kernel call. More...
 
bool ExecuteKernel (cl_kernel kernel, unsigned int workSizeDim)
 Execute the given kernel on the OpenCL Index-Space defined by the local and global work sizes. More...
 
bool Initialize ()
 Initialize all necessary parts of the filter. More...
 
void CompileSource ()
 Compile the program source. More...
 
void SetSourcePreambel (const char *preambel)
 Add some source code on the beginning of the loaded source. More...
 
virtual us::ModuleGetModule ()=0
 Get the Module of the filter. Needs to be implemented by every subclass. The filter will load the OpenCL sourcefiles from this module context. More...
 
void LoadSourceFiles (CStringList &SourceCodeList, ClSizeList &SourceCodeSizeList)
 Helper functions that load sourcefiles from the module context in the Initialize function. More...
 

Protected Attributes

const char * m_ClCompilerFlags
 String that contains the compiler flags. More...
 
cl_program m_ClProgram
 The compiled OpenCL program. More...
 
cl_command_queue m_CommandQue
 Command queue for the filter. More...
 
std::string m_FilterID
 Unique ID of the filter, needs to be specified in the constructor of the derived class. More...
 
const char * m_Preambel
 source preambel for e.g. #define commands to be inserted into the OpenCL source More...
 
CStringList m_ClFiles
 List of sourcefiles that will be compiled for this filter. More...
 
bool m_Initialized
 status of the filter More...
 
vcl_size_t m_LocalWorkSize [3]
 The local work size fo the filter. More...
 
vcl_size_t m_GlobalWorkSize [3]
 The global work size of the filter. More...
 

Detailed Description

Superclass for all OpenCL based filter.

This class takes care of loading and compiling the external GPU program code.

Definition at line 37 of file mitkOclFilter.h.

Member Typedef Documentation

typedef std::vector<vcl_size_t> mitk::OclFilter::ClSizeList
protected

Definition at line 67 of file mitkOclFilter.h.

typedef std::vector<const char*> mitk::OclFilter::CStringList
protected

Definition at line 66 of file mitkOclFilter.h.

Constructor & Destructor Documentation

mitk::OclFilter::~OclFilter ( )
virtual
mitk::OclFilter::OclFilter ( )
protected

Constructor.

Definition at line 35 of file mitkOclFilter.cpp.

mitk::OclFilter::OclFilter ( const char *  filename)
protected

Constructor ( overloaded )

Definition at line 45 of file mitkOclFilter.cpp.

References m_ClFiles.

Member Function Documentation

void mitk::OclFilter::AddSourceFile ( const char *  filename)

Add a source file from the resource files to the OpenCL shader file list. Multiple files can be added to the list.

Parameters
nameof the file in the resource system

Definition at line 234 of file mitkOclFilter.cpp.

Referenced by mitk::OclBinaryThresholdImageFilter::OclBinaryThresholdImageFilter().

void mitk::OclFilter::CompileSource ( )
protected

Compile the program source.

Parameters
preambele.g. defines for the shader code

Definition at line 147 of file mitkOclFilter.cpp.

References CHECK_OCL_ERR, OclResourceService::GetContext(), us::GetModuleContext(), ModuleContext::GetService(), ModuleContext::GetServiceReference(), MITK_DEBUG, MITK_ERROR, oclLogBinary(), and oclLogBuildInfo().

bool mitk::OclFilter::ExecuteKernel ( cl_kernel  kernel,
unsigned int  workSizeDim 
)
protected

Execute the given kernel on the OpenCL Index-Space defined by the local and global work sizes.

Definition at line 71 of file mitkOclFilter.cpp.

References CHECK_OCL_ERR.

virtual us::Module* mitk::OclFilter::GetModule ( )
protectedpure virtual

Get the Module of the filter. Needs to be implemented by every subclass. The filter will load the OpenCL sourcefiles from this module context.

Implemented in mitk::OclBinaryThresholdImageFilter.

bool mitk::OclFilter::Initialize ( )
protected

Initialize all necessary parts of the filter.

The Initialize() method creates the command queue and the m_clProgram. The program is either compiled from the given source or taken from the OclResourceManager if the program was compiled already.

Definition at line 84 of file mitkOclFilter.cpp.

References CHECK_OCL_ERR, OclResourceService::GetCommandQueue(), us::GetModuleContext(), ModuleContext::GetService(), ModuleContext::GetServiceReference(), MITK_ERROR, and MITK_INFO.

Referenced by mitk::OclBinaryThresholdImageFilter::Initialize().

bool mitk::OclFilter::IsInitialized ( )
virtual

Returns true if the initialization was successfull.

Definition at line 245 of file mitkOclFilter.cpp.

Referenced by mitk::OclBinaryThresholdImageFilter::Initialize().

void mitk::OclFilter::LoadSourceFiles ( CStringList SourceCodeList,
ClSizeList SourceCodeSizeList 
)
protected

Helper functions that load sourcefiles from the module context in the Initialize function.

Parameters
SourceCodeListholds the sourcecode for every file as string, the SourceCodeSizeList holst the size of every file in bytes.

Definition at line 116 of file mitkOclFilter.cpp.

References us::ModuleResource::GetName(), us::ModuleResource::IsValid(), MITK_DEBUG, and MITK_WARN.

void mitk::OclFilter::SetCompilerFlags ( const char *  flags)

Set specific compilerflags to compile the CL source. Default is set to NULL; example: "-cl-fast-relaxed-math -cl-mad-enable -cl-strict-aliasing".

Parameters
flagsto the modulefolder that contains the gpuSource

Definition at line 239 of file mitkOclFilter.cpp.

void mitk::OclFilter::SetSourcePreambel ( const char *  preambel)
protected

Add some source code on the beginning of the loaded source.

In this way, some preprocessor flags for the CL compiler can at the beginning of the filter

Parameters
preambelSource preambel for e.g. #define commands to be inserted into the OpenCL source

Definition at line 229 of file mitkOclFilter.cpp.

void mitk::OclFilter::SetWorkingSize ( unsigned int  locx,
unsigned int  dimx,
unsigned int  locy = 1,
unsigned int  dimy = 1,
unsigned int  locz = 1,
unsigned int  dimz = 1 
)
protected

Set the working size for the following OpenCL kernel call.

Definition at line 209 of file mitkOclFilter.cpp.

References iDivUp().

Member Data Documentation

const char* mitk::OclFilter::m_ClCompilerFlags
protected

String that contains the compiler flags.

Definition at line 76 of file mitkOclFilter.h.

CStringList mitk::OclFilter::m_ClFiles
protected

List of sourcefiles that will be compiled for this filter.

Definition at line 91 of file mitkOclFilter.h.

Referenced by OclFilter().

cl_program mitk::OclFilter::m_ClProgram
protected

The compiled OpenCL program.

Definition at line 79 of file mitkOclFilter.h.

cl_command_queue mitk::OclFilter::m_CommandQue
protected

Command queue for the filter.

Definition at line 82 of file mitkOclFilter.h.

std::string mitk::OclFilter::m_FilterID
protected

Unique ID of the filter, needs to be specified in the constructor of the derived class.

Definition at line 85 of file mitkOclFilter.h.

Referenced by mitk::OclBinaryThresholdImageFilter::OclBinaryThresholdImageFilter().

vcl_size_t mitk::OclFilter::m_GlobalWorkSize[3]
protected

The global work size of the filter.

Definition at line 100 of file mitkOclFilter.h.

bool mitk::OclFilter::m_Initialized
protected

status of the filter

Definition at line 94 of file mitkOclFilter.h.

vcl_size_t mitk::OclFilter::m_LocalWorkSize[3]
protected

The local work size fo the filter.

Definition at line 97 of file mitkOclFilter.h.

const char* mitk::OclFilter::m_Preambel
protected

source preambel for e.g. #define commands to be inserted into the OpenCL source

Definition at line 88 of file mitkOclFilter.h.


The documentation for this class was generated from the following files: