Generic - Definition. More...
#include "generic.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
Go to the source code of this file.
Classes | |
struct | _VlState |
struct | _VlThreadState |
Typedefs | |
typedef struct _VlState | VlState |
typedef struct _VlThreadState | VlThreadState |
Functions | |
static int | do_nothing_printf (char const *format VL_UNUSED,...) |
void * | vl_calloc (size_t n, size_t size) |
Free and clear a memory block. | |
char * | vl_configuration_to_string_copy () |
Get VLFeat configuration string. | |
static void | vl_constructor (void) |
vl_bool | vl_cpu_has_avx (void) |
Check for AVX instruction set. | |
vl_bool | vl_cpu_has_sse2 (void) |
Check for SSE2 instruction set. | |
vl_bool | vl_cpu_has_sse3 (void) |
Check for SSE3 instruction set. | |
static void | vl_destructor () |
void | vl_free (void *ptr) |
Free a memory block. | |
double | vl_get_cpu_time () |
Get processor time. | |
int | vl_get_last_error (void) |
Get the code of the last error. | |
char const * | vl_get_last_error_message (void) |
Get the last error message. | |
vl_size | vl_get_max_threads (void) |
Get the maximum number of computational threads used by VLFeat. | |
vl_size | vl_get_num_cpus (void) |
Get the number of CPU cores of the host. | |
printf_func_t | vl_get_printf_func (void) |
Get the printf function. | |
VL_EXPORT VlRand * | vl_get_rand (void) |
Get the default random number generator. | |
vl_bool | vl_get_simd_enabled (void) |
Are SIMD instructons enabled? | |
VL_INLINE VlState * | vl_get_state () |
vl_size | vl_get_thread_limit (void) |
Get the number of computational threads available to the application. | |
VL_INLINE VlThreadState * | vl_get_thread_specific_state () |
char const * | vl_get_version_string () |
Get VLFeat version string. | |
static void | vl_lock_state (void) |
void * | vl_malloc (size_t n) |
Allocate a memory block. | |
void * | vl_realloc (void *ptr, size_t n) |
Reallocate a memory block. | |
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. | |
int | vl_set_last_error (int error, char const *errorMessage,...) |
Set last VLFeat error. | |
void | vl_set_num_threads (vl_size numThreads VL_UNUSED) |
Set the maximum number of threads used by VLFeat. | |
void | vl_set_printf_func (printf_func_t printf_func) |
Set the printf function. | |
void | vl_set_simd_enabled (vl_bool x) |
Toggle usage of SIMD instructions. | |
static void | vl_thread_specific_state_delete (VlThreadState *self) |
static VlThreadState * | vl_thread_specific_state_new (void) |
void | vl_tic (void) |
Reset processor time reference The function resets VLFeat TIC/TOC time reference. There is one such reference per thread. | |
double | vl_toc (void) |
Get elapsed time since tic. | |
static void | vl_unlock_state (void) |
Variables | |
VlState | _vl_state |
Generic - Definition.
Definition in file generic.c.
typedef struct _VlThreadState VlThreadState |
static int do_nothing_printf | ( | char const *format | VL_UNUSED, |
... | |||
) | [static] |
char* vl_configuration_to_string_copy | ( | void | ) |
static void vl_constructor | ( | void | ) | [static] |
static void vl_destructor | ( | ) | [static] |
Free a memory block.
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.
double vl_get_cpu_time | ( | void | ) |
int vl_get_last_error | ( | void | ) |
char const* vl_get_last_error_message | ( | void | ) |
Get the maximum number of computational threads used by VLFeat.
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.
Get the printf function.
printf
implementation. VL_EXPORT VlRand* vl_get_rand | ( | void | ) |
VL_INLINE VlState * vl_get_state | ( | void | ) |
Get the number of computational threads available to the application.
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.
VL_INLINE VlThreadState * vl_get_thread_specific_state | ( | void | ) |
char const* vl_get_version_string | ( | void | ) |
static void vl_lock_state | ( | void | ) | [static] |
void* vl_realloc | ( | void * | ptr, |
size_t | n | ||
) |
Reallocate a memory block.
ptr | pointer to a memory block previously allocated. |
n | size in bytes of the new block. |
This function reallocates a memory block to change its size. The synopsis is the same as the POSIX realloc
function.
int vl_set_last_error | ( | int | error, |
char const * | errorMessage, | ||
... | |||
) |
Set last VLFeat error.
error | error code. |
errorMessage | error message format string. |
... | format string arguments. |
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.
void vl_set_num_threads | ( | vl_size numThreads | VL_UNUSED | ) |
Set the maximum number of threads used by VLFeat.
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.
void vl_set_printf_func | ( | printf_func_t | printf_func | ) |
Toggle usage of SIMD instructions.
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.
static void vl_thread_specific_state_delete | ( | VlThreadState * | self | ) | [static] |
static VlThreadState * vl_thread_specific_state_new | ( | void | ) | [static] |
Reset processor time reference The function resets VLFeat TIC/TOC time reference. There is one such reference per thread.
Get elapsed time since tic.
The function returns the processor time elapsed since vl_tic was called last.
clock()
system call. On Windows, it uses the QueryPerformanceCounter()
system call, which is more accurate than clock()
on this platform. static void vl_unlock_state | ( | void | ) | [static] |