bufferkdtree (C sources)
C source code for the Python bufferkdtree implementation
 All Classes Files Functions Variables Typedefs Macros
Functions
cpu.h File Reference
#include <stdlib.h>
#include <string.h>
#include "base.h"
#include "types.h"
#include "util.h"
Include dependency graph for cpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void init_arrays_cpu (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void brute_force_leaf_cpu (INT_TYPE fr_idx, INT_TYPE to_idx, FLOAT_TYPE *test_patterns, INT_TYPE ntest_patterns, FLOAT_TYPE *d_min, INT_TYPE *idx_min, TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void process_all_buffers_cpu (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void do_bruteforce_all_leaves_cpu (INT_TYPE *test_indices_removed_from_all_buffers, INT_TYPE total_number_test_indices_removed, INT_TYPE *fr_indices, INT_TYPE *to_indices, TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void process_queue_via_brute_force_cpu (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void find_leaf_idx_batch_cpu (INT_TYPE *all_next_indices, INT_TYPE num_all_next_indices, INT_TYPE *ret_vals, TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void get_distances_and_indices_cpu (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 
void write_sorted_training_patterns_cpu (TREE_RECORD *tree_record, TREE_PARAMETERS *params)
 

Function Documentation

void brute_force_leaf_cpu ( INT_TYPE  fr_idx,
INT_TYPE  to_idx,
FLOAT_TYPE test_patterns,
INT_TYPE  ntest_patterns,
FLOAT_TYPE d_min,
INT_TYPE idx_min,
TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Brute-force nearest neigbhor search in a leaf of the tree (determined by fr_idx, to_idx, and XI).

Parameters
fr_idxThe "from" index w.r.t. the training indices
to_idxThe "to" index w.r.t. the training indices
*test_patternsArray of test patterns
ntest_patternsNumber of test patterns
*d_minArray of distance values that can be updated
*idx_minArray of indices that can be updated
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void do_bruteforce_all_leaves_cpu ( INT_TYPE test_indices_removed_from_all_buffers,
INT_TYPE  total_number_test_indices_removed,
INT_TYPE fr_indices,
INT_TYPE to_indices,
TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Performs a brute-force in the leaves.

Parameters
*test_indices_removed_from_all_buffersArray of indices that were removed from all buffers
total_number_test_indices_removedNumber of removed indices
*fr_indicesArray of "from" indices (see paper)
*to_indicesArray of "to" indices (see paper)
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void find_leaf_idx_batch_cpu ( INT_TYPE all_next_indices,
INT_TYPE  num_all_next_indices,
INT_TYPE ret_vals,
TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Finds the next leaf indices for all test patterns indixed by all_next_indices.

Parameters
all_next_indicesArray containing indices to be processed
num_all_next_indicesNumber of indices
*ret_valsFor each index, the next leaf buffer that needs to be processed
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void get_distances_and_indices_cpu ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Copies the arrays dist_min_global and idx_min_global from GPU to CPU Updates the distances and indices (w.r.t the original indices)

Parameters
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void init_arrays_cpu ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Initializes all arrays.

Parameters
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void process_all_buffers_cpu ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Processes all buffers on the CPU.

Parameters
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void process_queue_via_brute_force_cpu ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

If only few elements are left in the queues after the buffers have been emptied, we do a simple brute force step to compute the nearest neighbors.

Parameters
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters
void write_sorted_training_patterns_cpu ( TREE_RECORD tree_record,
TREE_PARAMETERS params 
)

Writes the training patterns in a specific ordering.

Parameters
*tree_recordPointer to struct instance storing the model
*paramsPointer to struct instance storing all model parameters