COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Macros | Enumerations | Functions
cutil.h File Reference
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for cutil.h:

Go to the source code of this file.

Macros

#define DLL_MAPPING
 
#define CUTIL_API
 
#define CUT_DEVICE_SYNCHRONIZE()   cudaThreadSynchronize();
 Macros. More...
 
#define CUT_DEVICE_RESET()   cudaThreadExit();
 
#define CUT_BANK_CHECKER(array, index)   array[index]
 
#define CU_SAFE_CALL_NO_SYNC(call)
 
#define CU_SAFE_CALL(call)   CU_SAFE_CALL_NO_SYNC(call);
 
#define CU_SAFE_CTX_SYNC()
 
#define CUDA_SAFE_CALL_NO_SYNC(call)
 
#define CUDA_SAFE_CALL(call)   CUDA_SAFE_CALL_NO_SYNC(call);
 
#define CUDA_SAFE_THREAD_SYNC()
 
#define CUFFT_SAFE_CALL(call)
 
#define CUT_SAFE_CALL(call)
 
#define CUT_CHECK_ERROR(errorMessage)
 Check for CUDA error. More...
 
#define CUT_SAFE_MALLOC(mallocCall)
 Check for malloc error. More...
 
#define CUT_CONDITION(val)
 Check if conditon is true (flexible assert) More...
 
#define CUT_DEVICE_INIT(ARGC, ARGV)
 
#define CUDA_CHECK_CTX_LOST(errorMessage)
 Check for CUDA context lost. More...
 
#define CU_CHECK_CTX_LOST(errorMessage)
 Check for CUDA context lost. More...
 
#define CUT_DEVICE_INIT_DRV(cuDevice, ARGC, ARGV)
 
#define CUT_EXIT(argc, argv)
 

Enumerations

enum  CUTBoolean { CUTFalse = 0, CUTTrue = 1 }
 CUT bool type. More...
 

Functions

DLL_MAPPING void CUTIL_API cutFree (void *ptr)
 
DLL_MAPPING void CUTIL_API cutCheckBankAccess (unsigned int tidx, unsigned int tidy, unsigned int tidz, unsigned int bdimx, unsigned int bdimy, unsigned int bdimz, const char *file, const int line, const char *aname, const int index)
 
DLL_MAPPING char *CUTIL_API cutFindFilePath (const char *filename, const char *executablePath)
 
DLL_MAPPING CUTBoolean CUTIL_API cutReadFilef (const char *filename, float **data, unsigned int *len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutReadFiled (const char *filename, double **data, unsigned int *len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutReadFilei (const char *filename, int **data, unsigned int *len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutReadFileui (const char *filename, unsigned int **data, unsigned int *len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutReadFileb (const char *filename, char **data, unsigned int *len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutReadFileub (const char *filename, unsigned char **data, unsigned int *len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFilef (const char *filename, const float *data, unsigned int len, const float epsilon, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFiled (const char *filename, const float *data, unsigned int len, const double epsilon, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFilei (const char *filename, const int *data, unsigned int len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFileui (const char *filename, const unsigned int *data, unsigned int len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFileb (const char *filename, const char *data, unsigned int len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFileub (const char *filename, const unsigned char *data, unsigned int len, bool verbose=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMub (const char *file, unsigned char **data, unsigned int *w, unsigned int *h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPPMub (const char *file, unsigned char **data, unsigned int *w, unsigned int *h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPPM4ub (const char *file, unsigned char **data, unsigned int *w, unsigned int *h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMi (const char *file, unsigned int **data, unsigned int *w, unsigned int *h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMs (const char *file, unsigned short **data, unsigned int *w, unsigned int *h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMf (const char *file, float **data, unsigned int *w, unsigned int *h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMub (const char *file, unsigned char *data, unsigned int w, unsigned int h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutSavePPMub (const char *file, unsigned char *data, unsigned int w, unsigned int h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutSavePPM4ub (const char *file, unsigned char *data, unsigned int w, unsigned int h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMi (const char *file, unsigned int *data, unsigned int w, unsigned int h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMs (const char *file, unsigned short *data, unsigned int w, unsigned int h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMf (const char *file, float *data, unsigned int w, unsigned int h)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCmdLineFlag (const int argc, const char **argv, const char *flag_name)
 
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumenti (const int argc, const char **argv, const char *arg_name, int *val)
 
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumentf (const int argc, const char **argv, const char *arg_name, float *val)
 
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumentstr (const int argc, const char **argv, const char *arg_name, char **val)
 
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumentListstr (const int argc, const char **argv, const char *arg_name, char **val, unsigned int *len)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCondition (int val, const char *file, const int line)
 
DLL_MAPPING CUTBoolean CUTIL_API cutComparef (const float *reference, const float *data, const unsigned int len)
 
DLL_MAPPING CUTBoolean CUTIL_API cutComparei (const int *reference, const int *data, const unsigned int len)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCompareuit (const unsigned int *reference, const unsigned int *data, const unsigned int len, const float epsilon, const float threshold)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCompareub (const unsigned char *reference, const unsigned char *data, const unsigned int len)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCompareubt (const unsigned char *reference, const unsigned char *data, const unsigned int len, const float epsilon, const float threshold)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCompareube (const unsigned char *reference, const unsigned char *data, const unsigned int len, const float epsilon)
 
DLL_MAPPING CUTBoolean CUTIL_API cutComparefe (const float *reference, const float *data, const unsigned int len, const float epsilon)
 
DLL_MAPPING CUTBoolean CUTIL_API cutComparefet (const float *reference, const float *data, const unsigned int len, const float epsilon, const float threshold)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCompareL2fe (const float *reference, const float *data, const unsigned int len, const float epsilon)
 
DLL_MAPPING CUTBoolean CUTIL_API cutComparePPM (const char *src_file, const char *ref_file, const float epsilon, const float threshold, bool verboseErrors=false)
 
DLL_MAPPING CUTBoolean CUTIL_API cutCreateTimer (unsigned int *name)
 Timer functionality. More...
 
DLL_MAPPING CUTBoolean CUTIL_API cutDeleteTimer (unsigned int name)
 
DLL_MAPPING CUTBoolean CUTIL_API cutStartTimer (const unsigned int name)
 
DLL_MAPPING CUTBoolean CUTIL_API cutStopTimer (const unsigned int name)
 
DLL_MAPPING CUTBoolean CUTIL_API cutResetTimer (const unsigned int name)
 
DLL_MAPPING float CUTIL_API cutGetTimerValue (const unsigned int name)
 
DLL_MAPPING float CUTIL_API cutGetAverageTimerValue (const unsigned int name)
 

Macro Definition Documentation

#define CU_CHECK_CTX_LOST (   errorMessage)
Value:
{ \
cudaError_t err = cudaGetLastError(); \
if (CUDA_ERROR_INVALID_CONTEXT != err) \
{ \
fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", errorMessage, __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
if (cudaSuccess != err) \
{ \
fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", errorMessage, __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
}
#define CUT_DEVICE_SYNCHRONIZE()
Macros.
Definition: cutil.h:747

Check for CUDA context lost.

#define CU_SAFE_CALL (   call)    CU_SAFE_CALL_NO_SYNC(call);
#define CU_SAFE_CALL_NO_SYNC (   call)
Value:
{ \
CUresult err = call; \
if (CUDA_SUCCESS != err) \
{ \
fprintf(stderr, "Cuda driver error %x in file '%s' in line %i.\n", err, __FILE__, __LINE__); \
#define CU_SAFE_CTX_SYNC ( )
Value:
{ \
CUresult err = cuCtxSynchronize(); \
if (CUDA_SUCCESS != err) \
{ \
fprintf(stderr, "Cuda driver error %x in file '%s' in line %i.\n", err, __FILE__, __LINE__); \
#define CUDA_CHECK_CTX_LOST (   errorMessage)
Value:
{ \
cudaError_t err = cudaGetLastError(); \
if (cudaSuccess != err) \
{ \
fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", errorMessage, __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
if (cudaSuccess != err) \
{ \
fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", errorMessage, __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
}
#define CUT_DEVICE_SYNCHRONIZE()
Macros.
Definition: cutil.h:747

Check for CUDA context lost.

#define CUDA_SAFE_CALL (   call)    CUDA_SAFE_CALL_NO_SYNC(call);
#define CUDA_SAFE_CALL_NO_SYNC (   call)
Value:
{ \
cudaError err = call; \
if (cudaSuccess != err) \
{ \
fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
}
#define CUDA_SAFE_THREAD_SYNC ( )
Value:
{ \
cudaError err = CUT_DEVICE_SYNCHRONIZE(); \
if (cudaSuccess != err) \
{ \
fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", __FILE__, __LINE__, cudaGetErrorString(err)); \
} \
}
#define CUT_DEVICE_SYNCHRONIZE()
Macros.
Definition: cutil.h:747
#define CUFFT_SAFE_CALL (   call)
Value:
{ \
cufftResult err = call; \
if (CUFFT_SUCCESS != err) \
{ \
fprintf(stderr, "CUFFT error in file '%s' in line %i.\n", __FILE__, __LINE__); \
exit(EXIT_FAILURE); \
} \
}
#define CUT_BANK_CHECKER (   array,
  index 
)    array[index]
#define CUT_CHECK_ERROR (   errorMessage)
Value:
{ \
cudaError_t err = cudaGetLastError(); \
if (cudaSuccess != err) \
{ \
fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", errorMessage, __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
}

Check for CUDA error.

#define CUT_CONDITION (   val)
Value:
if (CUTFalse == cutCheckCondition(val, __FILE__, __LINE__)) \
{ \
exit(EXIT_FAILURE); \
}
Definition: cutil.h:68
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCondition(int val, const char *file, const int line)
GLuint GLfloat * val
Definition: khronos-glext.h:7898

Check if conditon is true (flexible assert)

#define CUT_DEVICE_INIT (   ARGC,
  ARGV 
)
Value:
{ \
int deviceCount; \
CUDA_SAFE_CALL_NO_SYNC(cudaGetDeviceCount(&deviceCount)); \
if (deviceCount == 0) \
{ \
fprintf(stderr, "cutil error: no devices supporting CUDA.\n"); \
exit(EXIT_FAILURE); \
} \
int dev = 0; \
cutGetCmdLineArgumenti(ARGC, (const char **)ARGV, "device", &dev); \
if (dev < 0) \
dev = 0; \
if (dev > deviceCount - 1) \
dev = deviceCount - 1; \
cudaDeviceProp deviceProp; \
CUDA_SAFE_CALL_NO_SYNC(cudaGetDeviceProperties(&deviceProp, dev)); \
if (deviceProp.major < 1) \
{ \
fprintf(stderr, "cutil error: device does not support CUDA.\n"); \
exit(EXIT_FAILURE); \
} \
if (cutCheckCmdLineFlag(ARGC, (const char **)ARGV, "quiet") == CUTFalse) \
fprintf(stderr, "Using device %d: %s\n", dev, deviceProp.name); \
CUDA_SAFE_CALL(cudaSetDevice(dev)); \
}
Definition: cutil.h:68
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumenti(const int argc, const char **argv, const char *arg_name, int *val)
#define CUDA_SAFE_CALL_NO_SYNC(call)
Definition: cutil.h:792
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCmdLineFlag(const int argc, const char **argv, const char *flag_name)
#define CUDA_SAFE_CALL(call)
Definition: cutil.h:802
#define CUT_DEVICE_INIT_DRV (   cuDevice,
  ARGC,
  ARGV 
)
Value:
{ \
cuDevice = 0; \
int deviceCount = 0; \
CUresult err = cuInit(0); \
if (CUDA_SUCCESS == err) \
CU_SAFE_CALL_NO_SYNC(cuDeviceGetCount(&deviceCount)); \
if (deviceCount == 0) \
{ \
fprintf(stderr, "cutil error: no devices supporting CUDA\n"); \
exit(EXIT_FAILURE); \
} \
int dev = 0; \
cutGetCmdLineArgumenti(ARGC, (const char **)ARGV, "device", &dev); \
if (dev < 0) \
dev = 0; \
if (dev > deviceCount - 1) \
dev = deviceCount - 1; \
CU_SAFE_CALL_NO_SYNC(cuDeviceGet(&cuDevice, dev)); \
char name[100]; \
cuDeviceGetName(name, 100, cuDevice); \
if (cutCheckCmdLineFlag(ARGC, (const char **)ARGV, "quiet") == CUTFalse) \
fprintf(stderr, "Using device %d: %s\n", dev, name); \
}
Definition: cutil.h:68
GLuint const GLchar * name
Definition: khronos-glext.h:6722
#define CU_SAFE_CALL_NO_SYNC(call)
Definition: cutil.h:772
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumenti(const int argc, const char **argv, const char *arg_name, int *val)
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCmdLineFlag(const int argc, const char **argv, const char *flag_name)
#define CUT_DEVICE_RESET ( )    cudaThreadExit();
#define CUT_DEVICE_SYNCHRONIZE ( )    cudaThreadSynchronize();

Macros.

#define CUT_EXIT (   argc,
  argv 
)
Value:
if (!cutCheckCmdLineFlag(argc, (const char **)argv, "noprompt")) \
{ \
printf("\nPress ENTER to exit...\n"); \
fflush(stdout); \
fflush(stderr); \
getchar(); \
} \
exit(EXIT_SUCCESS);
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCmdLineFlag(const int argc, const char **argv, const char *flag_name)
#define CUT_SAFE_CALL (   call)
Value:
if (CUTTrue != call) \
{ \
fprintf(stderr, "Cut error in file '%s' in line %i.\n", __FILE__, __LINE__); \
exit(EXIT_FAILURE); \
}
Definition: cutil.h:69
#define CUT_SAFE_MALLOC (   mallocCall)
Value:
{ \
if (!(mallocCall)) \
{ \
fprintf(stderr, "Host malloc failure in file '%s' in line %i\n", __FILE__, __LINE__); \
exit(EXIT_FAILURE); \
} \
} \
while (0) \
;

Check for malloc error.

#define CUTIL_API
#define DLL_MAPPING

Enumeration Type Documentation

enum CUTBoolean

CUT bool type.

Enumerator
CUTFalse 
CUTTrue 

Function Documentation

DLL_MAPPING void CUTIL_API cutCheckBankAccess ( unsigned int  tidx,
unsigned int  tidy,
unsigned int  tidz,
unsigned int  bdimx,
unsigned int  bdimy,
unsigned int  bdimz,
const char *  file,
const int  line,
const char *  aname,
const int  index 
)

Helper for bank conflict checking (should only be used with the CUT_BANK_CHECKER macro)

Parameters
tidxthread id in x dimension of block
tidythread id in y dimension of block
tidzthread id in z dimension of block
bdimxblock size in x dimension
bdimyblock size in y dimension
bdimzblock size in z dimension
filename of the source file where the access takes place
lineline in the source file where the access takes place
anamename of the array which is accessed
indexindex into the array
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCmdLineFlag ( const int  argc,
const char **  argv,
const char *  flag_name 
)

Check if command line argument flag-name is given

Returns
CUTTrue if command line argument flag_name has been given, otherwise 0
Parameters
argcargc as passed to main()
argvargv as passed to main()
flag_namename of command line flag
DLL_MAPPING CUTBoolean CUTIL_API cutCheckCondition ( int  val,
const char *  file,
const int  line 
)

Extended assert

Returns
CUTTrue if the condition val holds, otherwise CUTFalse
Parameters
valcondition to test
fileFILE macro
lineLINE macro
Note
This function should be used via the CONDITION(val) macro
DLL_MAPPING CUTBoolean CUTIL_API cutComparef ( const float *  reference,
const float *  data,
const unsigned int  len 
)

Compare two float arrays

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
DLL_MAPPING CUTBoolean CUTIL_API cutComparefe ( const float *  reference,
const float *  data,
const unsigned int  len,
const float  epsilon 
)

Compare two float arrays with an epsilon tolerance for equality

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
epsilonepsilon to use for the comparison
DLL_MAPPING CUTBoolean CUTIL_API cutComparefet ( const float *  reference,
const float *  data,
const unsigned int  len,
const float  epsilon,
const float  threshold 
)

Compare two float arrays with an epsilon tolerance for equality and a threshold for # pixel errors

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
epsilonepsilon to use for the comparison
DLL_MAPPING CUTBoolean CUTIL_API cutComparei ( const int *  reference,
const int *  data,
const unsigned int  len 
)

Compare two integer arrays

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
DLL_MAPPING CUTBoolean CUTIL_API cutCompareL2fe ( const float *  reference,
const float *  data,
const unsigned int  len,
const float  epsilon 
)

Compare two float arrays using L2-norm with an epsilon tolerance for equality

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
epsilonepsilon to use for the comparison
DLL_MAPPING CUTBoolean CUTIL_API cutComparePPM ( const char *  src_file,
const char *  ref_file,
const float  epsilon,
const float  threshold,
bool  verboseErrors = false 
)

Compare two PPM image files with an epsilon tolerance for equality

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
src_filefilename for the image to be compared
datafilename for the reference data / gold image
epsilonepsilon to use for the comparison
thresholdthreshold of pixels that can still mismatch to pass (i.e. 0.15f = 15% must pass) $param verboseErrors output details of image mismatch to std::err
DLL_MAPPING CUTBoolean CUTIL_API cutCompareub ( const unsigned char *  reference,
const unsigned char *  data,
const unsigned int  len 
)

Compare two unsigned char arrays

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
DLL_MAPPING CUTBoolean CUTIL_API cutCompareube ( const unsigned char *  reference,
const unsigned char *  data,
const unsigned int  len,
const float  epsilon 
)

Compare two integer arrays witha n epsilon tolerance for equality

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
epsilonepsilon to use for the comparison
DLL_MAPPING CUTBoolean CUTIL_API cutCompareubt ( const unsigned char *  reference,
const unsigned char *  data,
const unsigned int  len,
const float  epsilon,
const float  threshold 
)

Compare two integers with a tolernance for # of byte errors

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
epsilonepsilon to use for the comparison
thresholdtolerance % # of comparison errors (0.15f = 15%)
DLL_MAPPING CUTBoolean CUTIL_API cutCompareuit ( const unsigned int *  reference,
const unsigned int *  data,
const unsigned int  len,
const float  epsilon,
const float  threshold 
)

Compare two unsigned integer arrays, with epsilon and threshold

Returns
CUTTrue if reference and data are identical, otherwise CUTFalse
Parameters
referencehandle to the reference data / gold image
datahandle to the computed data
lennumber of elements in reference and data
thresholdtolerance % # of comparison errors (0.15f = 15%)
DLL_MAPPING CUTBoolean CUTIL_API cutCreateTimer ( unsigned int *  name)

Timer functionality.

Create a new timer

Returns
CUTTrue if a time has been created, otherwise false
Parameters
nameof the new timer, 0 if the creation failed
DLL_MAPPING CUTBoolean CUTIL_API cutDeleteTimer ( unsigned int  name)

Delete a timer

Returns
CUTTrue if a time has been deleted, otherwise false
Parameters
nameof the timer to delete
DLL_MAPPING char* CUTIL_API cutFindFilePath ( const char *  filename,
const char *  executablePath 
)

Find the path for a filename

Returns
the path if succeeded, otherwise 0
Parameters
filenamename of the file
executablePathoptional absolute path of the executable
DLL_MAPPING void CUTIL_API cutFree ( void ptr)

Deallocate memory allocated within Cutil

Parameters
pointerto memory
DLL_MAPPING float CUTIL_API cutGetAverageTimerValue ( const unsigned int  name)

Return the average time in milliseconds for timer execution as the total time for the timer dividied by the number of completed (stopped) runs the timer has made. Excludes the current running time if the timer is currently running.

Parameters
namename of the timer to return the time of
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumentf ( const int  argc,
const char **  argv,
const char *  arg_name,
float *  val 
)

Get the value of a command line argument of type float

Returns
CUTTrue if command line argument arg_name has been given and is of the requested type, otherwise CUTFalse
Parameters
argcargc as passed to main()
argvargv as passed to main()
arg_namename of the command line argument
valvalue of the command line argument
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumenti ( const int  argc,
const char **  argv,
const char *  arg_name,
int *  val 
)

Get the value of a command line argument of type int

Returns
CUTTrue if command line argument arg_name has been given and is of the requested type, otherwise CUTFalse
Parameters
argcargc as passed to main()
argvargv as passed to main()
arg_namename of the command line argument
valvalue of the command line argument
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumentListstr ( const int  argc,
const char **  argv,
const char *  arg_name,
char **  val,
unsigned int *  len 
)

Get the value of a command line argument list those element are strings

Returns
CUTTrue if command line argument arg_name has been given and is of the requested type, otherwise CUTFalse
Parameters
argcargc as passed to main()
argvargv as passed to main()
arg_namename of the command line argument
valcommand line argument list
lenlength of the list / number of elements
DLL_MAPPING CUTBoolean CUTIL_API cutGetCmdLineArgumentstr ( const int  argc,
const char **  argv,
const char *  arg_name,
char **  val 
)

Get the value of a command line argument of type string

Returns
CUTTrue if command line argument arg_name has been given and is of the requested type, otherwise CUTFalse
Parameters
argcargc as passed to main()
argvargv as passed to main()
arg_namename of the command line argument
valvalue of the command line argument
DLL_MAPPING float CUTIL_API cutGetTimerValue ( const unsigned int  name)

Returns total execution time in milliseconds for the timer over all runs since the last reset or timer creation.

Parameters
namename of the timer to return the time of
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMf ( const char *  file,
float **  data,
unsigned int *  w,
unsigned int *  h 
)

Load PGM image file (with float as data element type)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
Note
If a NULL pointer is passed to this function and it is initialized withing Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMi ( const char *  file,
unsigned int **  data,
unsigned int *  w,
unsigned int *  h 
)

Load PGM image file (with unsigned int as data element type)

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMs ( const char *  file,
unsigned short **  data,
unsigned int *  w,
unsigned int *  h 
)

Load PGM image file (with unsigned short as data element type)

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
Note
If a NULL pointer is passed to this function and it is initialized withing Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPGMub ( const char *  file,
unsigned char **  data,
unsigned int *  w,
unsigned int *  h 
)

Load PGM image file (with unsigned char as data element type)

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPPM4ub ( const char *  file,
unsigned char **  data,
unsigned int *  w,
unsigned int *  h 
)

Load PPM image file (with unsigned char as data element type), padding 4th component

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutLoadPPMub ( const char *  file,
unsigned char **  data,
unsigned int *  w,
unsigned int *  h 
)

Load PPM image file (with unsigned char as data element type)

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutReadFileb ( const char *  filename,
char **  data,
unsigned int *  len,
bool  verbose = false 
)

Read file containing char / byte data

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filenamename of the source file
datauninitialized pointer, returned initialized and pointing to the data read
lennumber of data elements in data, -1 on error
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutReadFiled ( const char *  filename,
double **  data,
unsigned int *  len,
bool  verbose = false 
)

Read file containing double precision floating point data

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filenamename of the source file
datauninitialized pointer, returned initialized and pointing to the data read
lennumber of data elements in data, -1 on error
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutReadFilef ( const char *  filename,
float **  data,
unsigned int *  len,
bool  verbose = false 
)

Read file containing single precision floating point data

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filenamename of the source file
datauninitialized pointer, returned initialized and pointing to the data read
lennumber of data elements in data, -1 on error
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutReadFilei ( const char *  filename,
int **  data,
unsigned int *  len,
bool  verbose = false 
)

Read file containing integer data

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filenamename of the source file
datauninitialized pointer, returned initialized and pointing to the data read
lennumber of data elements in data, -1 on error
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutReadFileub ( const char *  filename,
unsigned char **  data,
unsigned int *  len,
bool  verbose = false 
)

Read file containing unsigned char / byte data

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filenamename of the source file
datauninitialized pointer, returned initialized and pointing to the data read
lennumber of data elements in data, -1 on error
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutReadFileui ( const char *  filename,
unsigned int **  data,
unsigned int *  len,
bool  verbose = false 
)

Read file containing unsigned integer data

Returns
CUTTrue if reading the file succeeded, otherwise false
Parameters
filenamename of the source file
datauninitialized pointer, returned initialized and pointing to the data read
lennumber of data elements in data, -1 on error
Note
If a NULL pointer is passed to this function and it is initialized within Cutil then cutFree() has to be used to deallocate the memory
DLL_MAPPING CUTBoolean CUTIL_API cutResetTimer ( const unsigned int  name)

Resets the timer's counter.

Parameters
namename of the timer to reset.
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMf ( const char *  file,
float *  data,
unsigned int  w,
unsigned int  h 
)

Save PGM image file (with float as data element type)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMi ( const char *  file,
unsigned int *  data,
unsigned int  w,
unsigned int  h 
)

Save PGM image file (with unsigned int as data element type)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMs ( const char *  file,
unsigned short *  data,
unsigned int  w,
unsigned int  h 
)

Save PGM image file (with unsigned short as data element type)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutSavePGMub ( const char *  file,
unsigned char *  data,
unsigned int  w,
unsigned int  h 
)

Save PGM image file (with unsigned char as data element type)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutSavePPM4ub ( const char *  file,
unsigned char *  data,
unsigned int  w,
unsigned int  h 
)

Save PPM image file (with unsigned char as data element type, padded to 4 bytes)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutSavePPMub ( const char *  file,
unsigned char *  data,
unsigned int  w,
unsigned int  h 
)

Save PPM image file (with unsigned char as data element type)

Parameters
filename of the image file
datahandle to the data read
wwidth of the image
hheight of the image
DLL_MAPPING CUTBoolean CUTIL_API cutStartTimer ( const unsigned int  name)

Start the time with name name

Parameters
namename of the timer to start
DLL_MAPPING CUTBoolean CUTIL_API cutStopTimer ( const unsigned int  name)

Stop the time with name name. Does not reset.

Parameters
namename of the timer to stop
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFileb ( const char *  filename,
const char *  data,
unsigned int  len,
bool  verbose = false 
)

Write a data file containing char / byte data

Returns
CUTTrue if writing the file succeeded, otherwise false
Parameters
filenamename of the file to write
datapointer to data to write
lennumber of data elements in data, -1 on error
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFiled ( const char *  filename,
const float *  data,
unsigned int  len,
const double  epsilon,
bool  verbose = false 
)

Write a data file containing double precision floating point data

Returns
CUTTrue if writing the file succeeded, otherwise false
Parameters
filenamename of the file to write
datapointer to data to write
lennumber of data elements in data, -1 on error
epsilonepsilon for comparison
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFilef ( const char *  filename,
const float *  data,
unsigned int  len,
const float  epsilon,
bool  verbose = false 
)

Write a data file containing single precision floating point data

Returns
CUTTrue if writing the file succeeded, otherwise false
Parameters
filenamename of the file to write
datapointer to data to write
lennumber of data elements in data, -1 on error
epsilonepsilon for comparison
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFilei ( const char *  filename,
const int *  data,
unsigned int  len,
bool  verbose = false 
)

Write a data file containing integer data

Returns
CUTTrue if writing the file succeeded, otherwise false
Parameters
filenamename of the file to write
datapointer to data to write
lennumber of data elements in data, -1 on error
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFileub ( const char *  filename,
const unsigned char *  data,
unsigned int  len,
bool  verbose = false 
)

Write a data file containing unsigned char / byte data

Returns
CUTTrue if writing the file succeeded, otherwise false
Parameters
filenamename of the file to write
datapointer to data to write
lennumber of data elements in data, -1 on error
DLL_MAPPING CUTBoolean CUTIL_API cutWriteFileui ( const char *  filename,
const unsigned int *  data,
unsigned int  len,
bool  verbose = false 
)

Write a data file containing unsigned integer data

Returns
CUTTrue if writing the file succeeded, otherwise false
Parameters
filenamename of the file to write
datapointer to data to write
lennumber of data elements in data, -1 on error