bufferkdtree (C sources)
C source code for the Python bufferkdtree implementation
 All Classes Files Functions Variables Typedefs Macros
Functions
base.c File Reference
#include "include/base.h"
Include dependency graph for base.c:

Functions

void init_extern (int n_neighbors, int tree_depth, int num_threads, int num_nXtrain_chunks, int platform_id, int device_id, double allowed_train_mem_percent_chunk, double allowed_test_mem_percent, int splitting_type, char *kernels_source_directory, int verbosity_level, TREE_PARAMETERS *params)
 
void build_bufferkdtree (FLOAT_TYPE *Xtrain, INT_TYPE nXtrain, INT_TYPE dXtrain, TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void neighbors_extern (FLOAT_TYPE *Xtest, INT_TYPE nXtest, INT_TYPE dXtest, FLOAT_TYPE *distances, INT_TYPE ndistances, INT_TYPE ddistances, INT_TYPE *indices, INT_TYPE nindices, INT_TYPE dindices, TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void extern_free_resources (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void extern_free_query_buffers (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
long get_max_nXtest_extern (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
int extern_check_platform_device (int platform_id, int device_id)
 

Function Documentation

void build_bufferkdtree ( FLOAT_TYPE Xtrain,
INT_TYPE  nXtrain,
INT_TYPE  dXtrain,
TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Builds a buffer k-d-tree

Parameters
*XtrainPointer to array of type "FLOAT_TYPE" (either "float" or "double")
nXtrainNumber of rows in *X (i.e., points/patterns)
dXtrainNumber of columns in *X (one column per point/pattern)
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
int extern_check_platform_device ( int  platform_id,
int  device_id 
)

Checks if platform and device are valid

Parameters
platform_idThe OpenCL platform id to be used
device_idThe OpenCL device id to be used
void extern_free_query_buffers ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Frees opencl test buffers

Parameters
*tree_recordPointer to struct storing all relevant information for model
*paramsPointer to struct containing all relevant parameters
void extern_free_resources ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Frees resources (e.g., on the GPU)

Parameters
*tree_recordPointer to struct storing all relevant information for model
*paramsPointer to struct containing all relevant parameters
long get_max_nXtest_extern ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Returns maximum number of test queries that can be processed.

Parameters
*tree_recordPointer to struct storing all relevant information for model
*paramsPointer to struct containing all relevant parameters
Returns
Maximum number of test instances that can be processed
void init_extern ( int  n_neighbors,
int  tree_depth,
int  num_threads,
int  num_nXtrain_chunks,
int  platform_id,
int  device_id,
double  allowed_train_mem_percent_chunk,
double  allowed_test_mem_percent,
int  splitting_type,
char *  kernels_source_directory,
int  verbosity_level,
TREE_PARAMETERS params 
)

Initializes the *params struct with the parameters provided.

Parameters
n_neighborsThe number of nearest neighbors to be found
tree_depthThe tree depth of the tree to be built
num_threadsThe number of threads that should be used
num_nXtrain_chunksThe number of chunks the training data should be split into
platform_idThe OpenCL platform that should be used
device_idThe id of the OpenCL device that should be used
allowed_train_mem_percent_chunkThe amount of memory (percentage) that the training data may occupy
allowed_test_mem_percentThe amount of memory (percentage) that the test data may occupy
splitting_typeThe splitting type that can be used during the construction of the tree
*kernels_source_directoryPointer to string that contains the path to the OpenCL kernels
verbosity_levelThe verbosity level (0==no output, 1==more output, 2==...)
*paramsPointer to struct that is used to store all parameters
void neighbors_extern ( FLOAT_TYPE Xtest,
INT_TYPE  nXtest,
INT_TYPE  dXtest,
FLOAT_TYPE distances,
INT_TYPE  ndistances,
INT_TYPE  ddistances,
INT_TYPE indices,
INT_TYPE  nindices,
INT_TYPE  dindices,
TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Interface (extern): Computes the k nearest neighbors for a given set of test points stored in *Xtest and stores the results in two arrays *distances and *indices.

Parameters
*XtestPointer to the set of query/test points (stored as FLOAT_TYPE)
nXtestThe number of query points
dXtestThe dimension of each query point
*distancesThe distances array (FLOAT_TYPE) used to store the computed distances
ndistancesThe number of query points
ddistancesThe number of distance values for each query point
*indicesPointer to arrray storing the indices of the k nearest neighbors for each query point
nindicesThe number of query points
dindicesThe number of indices comptued for each query point
*tree_recordPointer to struct storing all relevant information for model
*paramsPointer to struct containing all relevant parameters