Defines | Functions
generic.h File Reference

Generic (General support functionalities) More...

#include "host.h"
#include "random.h"
#include <stdlib.h>
#include <stddef.h>
#include <time.h>
#include <assert.h>
Include dependency graph for generic.h:

Go to the source code of this file.

Defines

#define VL_ERR_MSG_LEN   1024
 Maximum length (in characters) of an error message.
#define VL_VERSION_STRING   "0.9.20"
 Library version string.
Common operations

------------------------------------------------------------------

#define VL_MIN(x, y)   (((x)<(y))?(x):(y))
 Compute the minimum between two values.
#define VL_MAX(x, y)   (((x)>(y))?(x):(y))
 Compute the maximum between two values.
#define VL_SHIFT_LEFT(x, n)   (((n)>=0)?((x)<<(n)):((x)>>-(n)))
 Signed left shift operation.

Functions

VL_EXPORT char * vl_configuration_to_string_copy (void)
 Get VLFeat configuration string.
VL_EXPORT vl_bool vl_cpu_has_avx (void)
 Check for AVX instruction set.
VL_EXPORT vl_bool vl_cpu_has_sse2 (void)
 Check for SSE2 instruction set.
VL_EXPORT vl_bool vl_cpu_has_sse3 (void)
 Check for SSE3 instruction set.
VL_EXPORT vl_size vl_get_num_cpus (void)
 Get the number of CPU cores of the host.
VL_EXPORT VlRandvl_get_rand (void)
 Get the default random number generator.
VL_EXPORT vl_bool vl_get_simd_enabled (void)
 Are SIMD instructons enabled?
VL_EXPORT char const * vl_get_version_string (void)
 Get VLFeat version string.
VL_EXPORT void vl_set_simd_enabled (vl_bool x)
 Toggle usage of SIMD instructions.
Multi-thread computations
VL_EXPORT vl_size vl_get_max_threads (void)
 Get the maximum number of computational threads used by VLFeat.
VL_EXPORT void vl_set_num_threads (vl_size n)
VL_EXPORT vl_size vl_get_thread_limit (void)
 Get the number of computational threads available to the application.
Memory allocation

------------------------------------------------------------------

VL_EXPORT void vl_set_alloc_func (void *(*malloc_func)(size_t), void *(*realloc_func)(void *, size_t), void *(*calloc_func)(size_t, size_t), void(*free_func)(void *))
 Set memory allocation functions.
VL_EXPORT voidvl_malloc (size_t n)
 Allocate a memory block.
VL_EXPORT voidvl_realloc (void *ptr, size_t n)
 Reallocate a memory block.
VL_EXPORT voidvl_calloc (size_t n, size_t size)
 Free and clear a memory block.
VL_EXPORT voidvl_memalign (size_t n, size_t size)
VL_EXPORT void vl_free (void *ptr)
 Free a memory block.
Measuring time

------------------------------------------------------------------

VL_EXPORT void vl_tic (void)
 Reset processor time reference The function resets VLFeat TIC/TOC time reference. There is one such reference per thread.
VL_EXPORT double vl_toc (void)
 Get elapsed time since tic.
VL_EXPORT double vl_get_cpu_time (void)
 Get processor time.

Type identifiers for atomic data types

#define VL_TYPE_FLOAT   1
#define VL_TYPE_DOUBLE   2
#define VL_TYPE_INT8   3
#define VL_TYPE_UINT8   4
#define VL_TYPE_INT16   5
#define VL_TYPE_UINT16   6
#define VL_TYPE_INT32   7
#define VL_TYPE_UINT32   8
#define VL_TYPE_INT64   9
#define VL_TYPE_UINT64   10
typedef vl_uint32 vl_type
VL_INLINE char const * vl_get_type_name (vl_type type)
 Get the name of a data type.
VL_INLINE vl_size vl_get_type_size (vl_type type)
 Get data type size.

Error handling

------------------------------------------------------------------

#define VL_ERR_OK   0
#define VL_ERR_OVERFLOW   1
#define VL_ERR_ALLOC   2
#define VL_ERR_BAD_ARG   3
#define VL_ERR_IO   4
#define VL_ERR_EOF   5
#define VL_ERR_NO_MORE   5
VL_EXPORT int vl_get_last_error (void)
 Get the code of the last error.
VL_EXPORT char const * vl_get_last_error_message (void)
 Get the last error message.
VL_EXPORT int vl_set_last_error (int error, char const *errorMessage,...)
 Set last VLFeat error.

Logging

------------------------------------------------------------------

#define VL_PRINTF   (*vl_get_printf_func())
 Call user-customizable printf function.
#define VL_PRINT   (*vl_get_printf_func())
 Same as VL_PRINTF (legacy code)
typedef int(* printf_func_t )(char const *format,...)
 Customizable printf function pointer type.
VL_EXPORT void vl_set_printf_func (printf_func_t printf_func)
 Set the printf function.
VL_EXPORT printf_func_t vl_get_printf_func (void)
 Get the printf function.

Detailed Description

Generic (General support functionalities)

Author:
Andrea Vedaldi

Definition in file generic.h.


Define Documentation

#define VL_ERR_ALLOC   2

Resource allocation error

Definition at line 124 of file generic.h.

#define VL_ERR_BAD_ARG   3

Bad argument or illegal data error

Definition at line 125 of file generic.h.

#define VL_ERR_EOF   5

End-of-file or end-of-sequence error

Definition at line 127 of file generic.h.

#define VL_ERR_IO   4

Input/output error

Definition at line 126 of file generic.h.

#define VL_ERR_MSG_LEN   1024

Maximum length (in characters) of an error message.

Definition at line 30 of file generic.h.

#define VL_ERR_NO_MORE   5

End-of-sequence

Deprecated:

Definition at line 128 of file generic.h.

#define VL_ERR_OK   0

No error

Definition at line 122 of file generic.h.

#define VL_ERR_OVERFLOW   1

Buffer overflow error

Definition at line 123 of file generic.h.

#define VL_MAX (   x,
 
)    (((x)>(y))?(x):(y))

Compute the maximum between two values.

Parameters:
xvalue.
yvalue.
Returns:
the maximum of x and y.

Definition at line 188 of file generic.h.

#define VL_MIN (   x,
 
)    (((x)<(y))?(x):(y))

Compute the minimum between two values.

Parameters:
xvalue
yvalue
Returns:
the minimum of x and y.

Definition at line 181 of file generic.h.

#define VL_PRINT   (*vl_get_printf_func())

Same as VL_PRINTF (legacy code)

Definition at line 169 of file generic.h.

#define VL_PRINTF   (*vl_get_printf_func())

Call user-customizable printf function.

The function calls the user customizable printf.

Definition at line 168 of file generic.h.

#define VL_SHIFT_LEFT (   x,
 
)    (((n)>=0)?((x)<<(n)):((x)>>-(n)))

Signed left shift operation.

Parameters:
xvalue.
nnumber of shift positions.
Returns:
x << n . The macro is equivalent to the builtin << operator, but it supports negative shifts too.

Definition at line 197 of file generic.h.

#define VL_TYPE_DOUBLE   2

double type

Definition at line 36 of file generic.h.

#define VL_TYPE_FLOAT   1

float type

Definition at line 35 of file generic.h.

#define VL_TYPE_INT16   5

vl_int16 type

Definition at line 39 of file generic.h.

#define VL_TYPE_INT32   7

vl_int32 type

Definition at line 41 of file generic.h.

#define VL_TYPE_INT64   9

vl_int64 type

Definition at line 43 of file generic.h.

#define VL_TYPE_INT8   3

vl_int8 type

Definition at line 37 of file generic.h.

#define VL_TYPE_UINT16   6

vl_uint16 type

Definition at line 40 of file generic.h.

#define VL_TYPE_UINT32   8

vl_uint32 type

Definition at line 42 of file generic.h.

#define VL_TYPE_UINT64   10

vl_uint64 type

Definition at line 44 of file generic.h.

#define VL_TYPE_UINT8   4

vl_uint8 type

Definition at line 38 of file generic.h.

#define VL_VERSION_STRING   "0.9.20"

Library version string.

Definition at line 27 of file generic.h.


Typedef Documentation

typedef int(* printf_func_t)(char const *format,...)

Customizable printf function pointer type.

Definition at line 154 of file generic.h.

typedef vl_uint32 vl_type

Definition at line 46 of file generic.h.


Function Documentation

VL_EXPORT void* vl_calloc ( size_t  n,
size_t  size 
)

Free and clear a memory block.

Parameters:
nnumber of items to allocate.
sizesize in bytes of an item.
Returns:
pointer to the new block.

This function allocates and clears a memory block. The synopsis is the same as the POSIX calloc function.

Definition at line 1345 of file generic.c.

VL_EXPORT char* vl_configuration_to_string_copy ( void  )

Get VLFeat configuration string.

Returns:
a new configuration string.

The function returns a new string containing a human readable description of the library configuration.

Definition at line 881 of file generic.c.

VL_EXPORT vl_bool vl_cpu_has_avx ( void  )

Check for AVX instruction set.

Returns:
true if AVX is present.

Definition at line 1092 of file generic.c.

VL_EXPORT vl_bool vl_cpu_has_sse2 ( void  )

Check for SSE2 instruction set.

Returns:
true if SSE2 is present.

Definition at line 1120 of file generic.c.

VL_EXPORT vl_bool vl_cpu_has_sse3 ( void  )

Check for SSE3 instruction set.

Returns:
true if SSE3 is present.

Definition at line 1106 of file generic.c.

VL_EXPORT void vl_free ( void ptr)

Free a memory block.

Parameters:
ptrpointer to the memory block.

This function frees a memory block allocated by vl_malloc, vl_calloc, or vl_realloc. The synopsis is the same as the POSIX malloc function.

Definition at line 1359 of file generic.c.

VL_EXPORT double vl_get_cpu_time ( void  )

Get processor time.

Returns:
processor time in seconds.
See also:
vl_tic, vl_toc

Definition at line 1394 of file generic.c.

VL_EXPORT int vl_get_last_error ( void  )

Get the code of the last error.

Returns:
error code.
See also:
vl_get_last_error_message.

Definition at line 1265 of file generic.c.

VL_EXPORT char const* vl_get_last_error_message ( void  )

Get the last error message.

Returns:
pointer to the error message.
See also:
vl_get_last_error.

Definition at line 1275 of file generic.c.

VL_EXPORT vl_size vl_get_max_threads ( void  )

Get the maximum number of computational threads used by VLFeat.

Returns:
number of threads.

This function returns the maximum number of thread used by VLFeat. VLFeat will try to use this number of computational threads and never exceed it.

This is similar to the OpenMP function omp_get_max_threads(); however, it reads a parameter private to VLFeat which is independent of the value used by the OpenMP library.

If VLFeat was compiled without OpenMP support, this function returns 1.

See also:
vl_set_num_threads(), Parallel computations

Definition at line 1175 of file generic.c.

VL_EXPORT vl_size vl_get_num_cpus ( void  )

Get the number of CPU cores of the host.

Returns:
number of CPU cores.

Definition at line 1055 of file generic.c.

Get the printf function.

Returns:
printf_func pointer to the printf implementation.
See also:
vl_set_printf_func.

Definition at line 1383 of file generic.c.

VL_EXPORT VlRand* vl_get_rand ( void  )

Get the default random number generator.

Returns:
random number generator.

The function returns a pointer to the default random number generator. There is one such generator per thread.

Definition at line 1461 of file generic.c.

VL_EXPORT vl_bool vl_get_simd_enabled ( void  )

Are SIMD instructons enabled?

Returns:
true if SIMD instructions are enabled.

Definition at line 1082 of file generic.c.

VL_EXPORT vl_size vl_get_thread_limit ( void  )

Get the number of computational threads available to the application.

Returns:
number of threads.

This function wraps the OpenMP function omp_get_thread_limit(). If VLFeat was compiled without OpenMP support, this function returns 1. If VLFeat was compiled with OpenMP prior to version 3.0 (2008/05), it returns 0.

See also:
Parallel computations

Definition at line 1143 of file generic.c.

VL_INLINE char const* vl_get_type_name ( vl_type  type)

Get the name of a data type.

Parameters:
typedata type.
Returns:
data name of the data type.

type is one of VL_TYPE_FLOAT, VL_TYPE_DOUBLE, VL_TYPE_INT8, VL_TYPE_INT16, VL_TYPE_INT32, VL_TYPE_INT64, VL_TYPE_UINT8, VL_TYPE_UINT16, VL_TYPE_UINT32, VL_TYPE_UINT64.

Definition at line 58 of file generic.h.

VL_INLINE vl_size vl_get_type_size ( vl_type  type)

Get data type size.

Parameters:
typedata type.
Returns:
size (in byte)

type is one of VL_TYPE_FLOAT, VL_TYPE_DOUBLE, VL_TYPE_INT8, VL_TYPE_INT16, VL_TYPE_INT32, VL_TYPE_INT64, VL_TYPE_UINT8, VL_TYPE_UINT16, VL_TYPE_UINT32, VL_TYPE_UINT64.

Definition at line 85 of file generic.h.

VL_EXPORT char const* vl_get_version_string ( void  )

Get VLFeat version string.

Returns:
the library version string.

Definition at line 868 of file generic.c.

VL_EXPORT void* vl_malloc ( size_t  n)

Allocate a memory block.

Parameters:
nsize in bytes of the new block.
Returns:
pointer to the allocated block.

This function allocates a memory block of the specified size. The synopsis is the same as the POSIX malloc function.

Definition at line 1313 of file generic.c.

VL_EXPORT void* vl_memalign ( size_t  n,
size_t  size 
)
VL_EXPORT void* vl_realloc ( void ptr,
size_t  n 
)

Reallocate a memory block.

Parameters:
ptrpointer to a memory block previously allocated.
nsize in bytes of the new block.
Returns:
pointer to the new block.

This function reallocates a memory block to change its size. The synopsis is the same as the POSIX realloc function.

Definition at line 1330 of file generic.c.

VL_EXPORT void vl_set_alloc_func ( void *(*)(size_t)  malloc_func,
void *(*)(void *, size_t)  realloc_func,
void *(*)(size_t, size_t)  calloc_func,
void(*)(void *)  free_func 
)

Set memory allocation functions.

Parameters:
malloc_funcpointer to malloc.
realloc_funcpointer to realloc.
calloc_funcpointer to calloc.
free_funcpointer to free.

Definition at line 1289 of file generic.c.

VL_EXPORT int vl_set_last_error ( int  error,
char const *  errorMessage,
  ... 
)

Set last VLFeat error.

Parameters:
errorerror code.
errorMessageerror message format string.
...format string arguments.
Returns:
error code.

The function sets the code and optionally the error message of the last encountered error. errorMessage is the message format. It uses the printf convention and is followed by the format arguments. The maximum length of the error message is given by VL_ERR_MSG_LEN (longer messages are truncated).

Passing NULL as errorMessage sets the error message to the empty string.

Definition at line 1238 of file generic.c.

VL_EXPORT void vl_set_num_threads ( vl_size  n)
VL_EXPORT void vl_set_printf_func ( printf_func_t  printf_func)

Set the printf function.

Parameters:
printf_funcpointer to a printf implementation. Set print_func to NULL to disable printf.

Definition at line 1372 of file generic.c.

VL_EXPORT void vl_set_simd_enabled ( vl_bool  x)

Toggle usage of SIMD instructions.

Parameters:
xtrue if SIMD instructions are used.

Notice that SIMD instructions are used only if the CPU model supports them. Note also that data alignment may restrict the use of such instructions.

See also:
vl_cpu_has_sse2(), vl_cpu_has_sse3(), etc.

Definition at line 1072 of file generic.c.

VL_EXPORT void vl_tic ( void  )

Reset processor time reference The function resets VLFeat TIC/TOC time reference. There is one such reference per thread.

See also:
vl_get_cpu_time, vl_toc.

Definition at line 1413 of file generic.c.

VL_EXPORT double vl_toc ( void  )

Get elapsed time since tic.

Returns:
elapsed time in seconds.

The function returns the processor time elapsed since vl_tic was called last.

Remarks:
In multi-threaded applications, there is an independent timer for each execution thread.
On UNIX, this function uses the clock() system call. On Windows, it uses the QueryPerformanceCounter() system call, which is more accurate than clock() on this platform.

Definition at line 1438 of file generic.c.



libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51