Medical Imaging Interaction Toolkit  2018.4.99-e1268d66
Medical Imaging Interaction Toolkit
mitkOclUtils.cpp File Reference
#include "mitkOclUtils.h"
#include "mitkLogMacros.h"
#include <cstdio>
#include <cstring>

Go to the source code of this file.

Functions

unsigned int iDivUp (unsigned int dividend, unsigned int divisor)
 Method to estimate an integer quotient C from given dividend and divisor higher or equal to the corresponding floating quotient. More...
 
cl_int oclGetPlatformID (cl_platform_id *selectedPlatform)
 Returns a platform ID of an OpenCL-capable GPU, or throws an exception. More...
 
void oclPrintMemObjectInfo (cl_mem memobj)
 Prints the available memory info about the given object to std::cout. More...
 
void oclPrintDeviceInfo (cl_device_id device)
 Prints out the essential support information about current device. More...
 
cl_ulong oclGetGlobalMemSize (cl_device_id device)
 Returns the Global memory size of the current device. More...
 
std::string GetOclErrorAsString (int _clErr)
 Returns the name of an OpenCL Error as a string. More...
 
void GetOclError (int _clErr)
 Checks whether the given value corresponds to an OpenCL Error value and prints this message out as MITK_ERROR if yes. More...
 
bool oclCheckError (int _err, const char *filepath, int lineno)
 Checks the given code for errors and produces a std::cout output if the _err does not equal CL_SUCCESS. The output includes also the filename and the line number of the method call. More...
 
void GetSupportedImageFormats (cl_context _context, cl_mem_object_type _type)
 Print out all supported image formats for given image type. More...
 
std::string GetImageTypeAsString (const unsigned int _in)
 Translates the internal image type identifier to a human readable description string. More...
 
void oclLogBinary (cl_program clProg, cl_device_id clDev)
 Logs the GPU Program binary code. More...
 
void oclLogBuildInfo (cl_program clProg, cl_device_id clDev)
 Shows the OpenCL-Program build info, called if clBuildProgram != CL_SUCCES. More...
 

Function Documentation

◆ GetImageTypeAsString()

std::string GetImageTypeAsString ( const unsigned int  _in)

Translates the internal image type identifier to a human readable description string.

Definition at line 440 of file mitkOclUtils.cpp.

Referenced by GetSupportedImageFormats().

◆ GetOclError()

void GetOclError ( int  _clErr)

Checks whether the given value corresponds to an OpenCL Error value and prints this message out as MITK_ERROR if yes.

Definition at line 372 of file mitkOclUtils.cpp.

References GetOclErrorAsString(), MITK_ERROR, and MITK_WARN.

Referenced by oclCheckError().

◆ GetOclErrorAsString()

std::string GetOclErrorAsString ( int  _clErr)

Returns the name of an OpenCL Error as a string.

Most of the OpenCL Methods ( cl<NAME> ) return an integer error code. This method translates the error value given as parameter to the corresponding error name. For example the value -30 will be translated to CL_INVALID_VALUE

Definition at line 221 of file mitkOclUtils.cpp.

Referenced by GetOclError(), mitk::OclDataSetToDataSetFilter::InitExec(), mitk::OclImageToImageFilter::InitExec(), and mitk::OclDataSetToDataSetFilter::InitExecNoInput().

◆ GetSupportedImageFormats()

void GetSupportedImageFormats ( cl_context  _context,
cl_mem_object_type  _type 
)

Print out all supported image formats for given image type.

Parameters
_typethe image type ( CL_MEM_OBJECT_2D or CL_MEM_OBJECT_3D )
_contextthe OpenCL context to be examined

Definition at line 393 of file mitkOclUtils.cpp.

References CHECK_OCL_ERR, GetImageTypeAsString(), and MITK_INFO.

◆ iDivUp()

unsigned int iDivUp ( unsigned int  dividend,
unsigned int  divisor 
)

Method to estimate an integer quotient C from given dividend and divisor higher or equal to the corresponding floating quotient.

If the divisor is a factor of the dividend, the dividend/divisor is an integer value and is returned. If not, the nearest higher integer is returned. So it holds for the return value C that C * divisor is equal or greater then the dividend. In OpenCL context useful for estimating the local/global working dimension of a NDRange so that all image data is covered by the parallelisation scheme.

Definition at line 19 of file mitkOclUtils.cpp.

Referenced by mitk::OclFilter::SetWorkingSize().

◆ oclCheckError()

bool oclCheckError ( int  _err,
const char *  filepath,
int  lineno 
)

Checks the given code for errors and produces a std::cout output if the _err does not equal CL_SUCCESS. The output includes also the filename and the line number of the method call.

Definition at line 380 of file mitkOclUtils.cpp.

References GetOclError(), and MITK_ERROR.

◆ oclGetGlobalMemSize()

cl_ulong oclGetGlobalMemSize ( cl_device_id  device)

Returns the Global memory size of the current device.

Definition at line 214 of file mitkOclUtils.cpp.

Referenced by mitk::OclFilter::GetDeviceMemory().

◆ oclGetPlatformID()

cl_int oclGetPlatformID ( cl_platform_id *  selectedPlatform)

Returns a platform ID of an OpenCL-capable GPU, or throws an exception.

Definition at line 23 of file mitkOclUtils.cpp.

References MITK_ERROR.

◆ oclLogBinary()

void oclLogBinary ( cl_program  clProg,
cl_device_id  clDev 
)

Logs the GPU Program binary code.

Parameters
clProgthe OpenCL Program to log
clDevthe OpenCL-capable device the program was tried to be compiled for

Definition at line 527 of file mitkOclUtils.cpp.

References MITK_INFO.

Referenced by mitk::OclFilter::CompileSource().

◆ oclLogBuildInfo()

void oclLogBuildInfo ( cl_program  clProg,
cl_device_id  clDev 
)

Shows the OpenCL-Program build info, called if clBuildProgram != CL_SUCCES.

Parameters
clProgthe OpenCL Program to log
clDevthe OpenCL-capable device the program was tried to be compiled for

Definition at line 572 of file mitkOclUtils.cpp.

References MITK_INFO.

Referenced by mitk::OclFilter::CompileSource().

◆ oclPrintDeviceInfo()

void oclPrintDeviceInfo ( cl_device_id  device)

Prints out the essential support information about current device.

Definition at line 130 of file mitkOclUtils.cpp.

References MITK_INFO.

◆ oclPrintMemObjectInfo()

void oclPrintMemObjectInfo ( cl_mem  memobj)

Prints the available memory info about the given object to std::cout.

Definition at line 50 of file mitkOclUtils.cpp.

References CHECK_OCL_ERR, and MITK_INFO.

Referenced by mitk::OclDataSet::TransferDataToCPU(), and mitk::OclImage::TransferDataToCPU().