Medical Imaging Interaction Toolkit  2016.11.0
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...
 
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

std::string GetImageTypeAsString ( const unsigned int  _in)

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

Definition at line 430 of file mitkOclUtils.cpp.

Referenced by GetSupportedImageFormats().

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 362 of file mitkOclUtils.cpp.

References GetOclErrorAsString(), MITK_ERROR, and MITK_WARN.

Referenced by oclCheckError().

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 214 of file mitkOclUtils.cpp.

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

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 383 of file mitkOclUtils.cpp.

References CHECK_OCL_ERR, GetImageTypeAsString(), and MITK_INFO.

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 23 of file mitkOclUtils.cpp.

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

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 370 of file mitkOclUtils.cpp.

References GetOclError(), and MITK_ERROR.

cl_int oclGetPlatformID ( cl_platform_id *  selectedPlatform)

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

Definition at line 27 of file mitkOclUtils.cpp.

References MITK_ERROR.

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 517 of file mitkOclUtils.cpp.

References MITK_INFO.

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

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 562 of file mitkOclUtils.cpp.

References MITK_INFO.

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

void oclPrintDeviceInfo ( cl_device_id  device)

Prints out the essential support information about current device.

Definition at line 134 of file mitkOclUtils.cpp.

References MITK_INFO.

void oclPrintMemObjectInfo ( cl_mem  memobj)

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

Definition at line 54 of file mitkOclUtils.cpp.

References CHECK_OCL_ERR, and MITK_INFO.

Referenced by mitk::OclImage::TransferDataToCPU().