Generic (General support functionalities) More...
#include "host.h"
#include "random.h"
#include <stdlib.h>
#include <stddef.h>
#include <time.h>
#include <assert.h>
Macros
Functions
Type identifiers for atomic data types
Error handling
Logging
Detailed Description
- Author
- Andrea Vedaldi
Macro Definition Documentation
◆ VL_ERR_ALLOC
Resource allocation error
◆ VL_ERR_BAD_ARG
Bad argument or illegal data error
◆ VL_ERR_EOF
End-of-file or end-of-sequence error
◆ VL_ERR_IO
Input/output error
◆ VL_ERR_NO_MORE
End-of-sequence
◆ VL_ERR_OK
No error
◆ VL_ERR_OVERFLOW
Buffer overflow error
◆ VL_MAX
- Parameters
-
x value.y value.
- Returns
- the maximum of x and y.
◆ VL_MIN
- Parameters
-
x valuey value
- Returns
- the minimum of x and y.
◆ VL_PRINTF
The function calls the user customizable printf
.
◆ VL_SHIFT_LEFT
- Parameters
-
x value.n number of shift positions.
- Returns
x
<< n . The macro is equivalent to the builtin<<
operator, but it supports negative shifts too.
◆ VL_TYPE_DOUBLE
double
type
◆ VL_TYPE_FLOAT
float
type
◆ VL_TYPE_INT16
vl_int16
type
◆ VL_TYPE_INT32
vl_int32
type
◆ VL_TYPE_INT64
vl_int64
type
◆ VL_TYPE_INT8
vl_int8
type
◆ VL_TYPE_UINT16
vl_uint16
type
◆ VL_TYPE_UINT32
vl_uint32
type
◆ VL_TYPE_UINT64
vl_uint64
type
◆ VL_TYPE_UINT8
vl_uint8
type
Function Documentation
◆ vl_calloc()
- Parameters
-
n number of items to allocate.size size 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.
◆ vl_configuration_to_string_copy()
- Returns
- a new configuration string.
The function returns a new string containing a human readable description of the library configuration.
◆ vl_cpu_has_avx()
- Returns
true
if AVX is present.
◆ vl_cpu_has_sse2()
- Returns
true
if SSE2 is present.
◆ vl_cpu_has_sse3()
- Returns
true
if SSE3 is present.
◆ vl_free()
- Parameters
-
ptr pointer 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.
◆ vl_get_cpu_time()
◆ vl_get_last_error()
- Returns
- error code.
- See also
- vl_get_last_error_message.
◆ vl_get_last_error_message()
- Returns
- pointer to the error message.
- See also
- vl_get_last_error.
◆ vl_get_max_threads()
- 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.
◆ vl_get_num_cpus()
- Returns
- number of CPU cores.
◆ vl_get_printf_func()
- Returns
- printf_func pointer to the
printf
implementation.
- See also
- vl_set_printf_func.
◆ vl_get_rand()
- Returns
- random number generator.
The function returns a pointer to the default random number generator. There is one such generator per thread.
◆ vl_get_simd_enabled()
- Returns
true
if SIMD instructions are enabled.
◆ vl_get_thread_limit()
- 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
◆ vl_get_type_name()
- Parameters
-
type data 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.
◆ vl_get_type_size()
- Parameters
-
type data 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.
◆ vl_get_version_string()
- Returns
- the library version string.
◆ vl_malloc()
- Parameters
-
n size 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.
◆ vl_realloc()
- Parameters
-
ptr pointer to a memory block previously allocated.n size 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.
◆ vl_set_alloc_func()
- Parameters
-
malloc_func pointer to
malloc
.realloc_func pointer torealloc
.calloc_func pointer tocalloc
.free_func pointer tofree
.
◆ vl_set_last_error()
- Parameters
-
error error code.errorMessage error 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.
◆ vl_set_num_threads()
- Parameters
-
numThreads number of threads to use.
This function sets the maximum number of computational threads that will be used by VLFeat. VLFeat may in practice use fewer threads (for example because numThreads is larger than the number of computational cores in the host, or because the number of threads exceeds the limit available to the application).
If numThreads
is set to 0, then VLFeat sets the number of threads to the OpenMP current maximum, obtained by calling omp_get_max_threads()
.
This function is similar to omp_set_num_threads()
but changes a parameter internal to VLFeat rather than affecting OpenMP global state.
If VLFeat was compiled without, this function does nothing.
◆ vl_set_printf_func()
- Parameters
-
printf_func pointer to a
printf
implementation. Setprint_func
to NULL to disable printf.
◆ vl_set_simd_enabled()
- Parameters
-
x
true
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.
◆ vl_tic()
- See also
- vl_get_cpu_time, vl_toc.
◆ vl_toc()
- 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 theQueryPerformanceCounter()
system call, which is more accurate thanclock()
on this platform.