RandomBallCover  1.2.1
 Hosted by GitHub
Public Types | Public Member Functions | Public Attributes | List of all members
cl_algo::RBC::RBCPermute< C > Class Template Reference

Interface class for the rbcPermute kernel. More...

#include <algorithms.hpp>

Collaboration diagram for cl_algo::RBC::RBCPermute< C >:
Collaboration graph
[legend]

Public Types

enum  Memory : uint8_t {
  Memory::H_IN_X, Memory::H_IN_ID, Memory::H_IN_RNK, Memory::H_IN_O,
  Memory::H_OUT_X_P, Memory::H_OUT_ID_P, Memory::D_IN_X, Memory::D_IN_ID,
  Memory::D_IN_RNK, Memory::D_IN_O, Memory::D_OUT_X_P, Memory::D_OUT_ID_P
}
 Enumerates the memory objects handled by the class. More...
 

Public Member Functions

 RBCPermute (clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
 Configures an OpenCL environment as specified by _info. More...
 
cl::Memory & get (RBCPermute::Memory mem)
 Returns a reference to an internal memory object. More...
 
void init (unsigned int _nx, unsigned int _nr, unsigned int _d=8, int _permID=0, Staging _staging=Staging::IO)
 Configures kernel execution parameters. More...
 
void write (RBCPermute::Memory mem=RBCPermute::Memory::D_IN_X, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
 Performs a data transfer to a device buffer. More...
 
void * read (RBCPermute::Memory mem=RBCPermute::Memory::H_OUT_X_P, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
 Performs a data transfer to a staging buffer. More...
 
void run (const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
 Executes the necessary kernels. More...
 
template<typename period >
double run (clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
 Executes the necessary kernels. More...
 

Public Attributes

cl_float * hPtrInX
 
rbc_dist_idhPtrInID
 
cl_uint * hPtrInRnk
 
cl_uint * hPtrInO
 
cl_float * hPtrOutXp
 
rbc_dist_idhPtrOutIDp
 

Detailed Description

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
class cl_algo::RBC::RBCPermute< C >

Interface class for the rbcPermute kernel.

rbcPermute permutes the database points to form the representative lists and allow for coalesced access pattern during the search operation. For more details, look at the kernel's documentation.

Note
The rbcPermute kernel is available in kernels/rbc_kernels.cl.
The class creates its own buffers. If you would like to provide your own buffers, call get to get references to the placeholders within the class and assign them to your buffers. You will have to do this strictly before the call to init. You can also call get (after the call to init) to get a reference to a buffer within the class and assign it to another kernel class instance further down in your task pipeline.

The following input/output OpenCL memory objects are created by a RBCPermute instance:

Name Type Placement I/O Use Properties Size
H_IN_X Buffer Host I Staging CL_MEM_READ_WRITE \(n_x*d *sizeof\ (cl\_float)\)
H_IN_ID Buffer Host I Staging CL_MEM_READ_WRITE \(n_x*sizeof\ (rbc\_dist\_id)\)
H_IN_RNK Buffer Host I Staging CL_MEM_READ_WRITE \(n_x *sizeof\ (cl\_uint)\)
H_IN_O Buffer Host I Staging CL_MEM_READ_WRITE \(n_r *sizeof\ (cl\_uint)\)
H_OUT_X_P Buffer Host O Staging CL_MEM_READ_WRITE \(n_x*d *sizeof\ (cl\_float)\)
H_OUT_ID_PBuffer Host O Staging CL_MEM_READ_WRITE \(n_x*sizeof\ (rbc\_dist\_id)\)
D_IN_X Buffer Device I Processing CL_MEM_READ_ONLY \(n_x*d *sizeof\ (cl\_float)\)
D_IN_ID Buffer Device I Processing CL_MEM_READ_ONLY \(n_x*sizeof\ (rbc\_dist\_id)\)
D_IN_RNK Buffer Device I Processing CL_MEM_READ_ONLY \(n_x *sizeof\ (cl\_uint)\)
D_IN_O Buffer Device I Processing CL_MEM_READ_ONLY \(n_r *sizeof\ (cl\_uint)\)
D_OUT_X_P Buffer Device O Processing CL_MEM_WRITE_ONLY \(n_x*d *sizeof\ (cl\_float)\)
D_OUT_ID_PBuffer Device O Processing CL_MEM_WRITE_ONLY \(n_x*sizeof\ (rbc\_dist\_id)\)
Template Parameters
Cconfigures the class either for Generic or Kinect data.

Member Enumeration Documentation

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
enum cl_algo::RBC::RBCPermute::Memory : uint8_t
strong

Enumerates the memory objects handled by the class.

Note
H_* names refer to staging buffers on the host.
D_* names refer to buffers on the device.
Enumerator
H_IN_X 

Input staging buffer for the database.

H_IN_ID 

Input staging buffer with the representative ids for each point.

H_IN_RNK 

Input staging buffer with the indices of the points within each rep. list.

H_IN_O 

Input staging buffer with the offsets of the representative lists within the db.

H_OUT_X_P 

Output staging buffer for the permuted database.

H_OUT_ID_P 

Output staging buffer with the representative ids for each point in the permuted db.

D_IN_X 

Input buffer for the database.

D_IN_ID 

Input buffer with the representative ids for each point.

D_IN_RNK 

Input buffer with the indices of the points within each rep. list.

D_IN_O 

Input buffer with the offsets of the representative lists within the db.

D_OUT_X_P 

Output buffer for the permuted database.

D_OUT_ID_P 

Output buffer with the representative ids for each point in the permuted db.

Constructor & Destructor Documentation

template<RBCPermuteConfig C>
cl_algo::RBC::RBCPermute< C >::RBCPermute ( clutils::CLEnv &  _env,
clutils::CLEnvInfo< 1 >  _info 
)

Configures an OpenCL environment as specified by _info.

Parameters
[in]_envopencl environment.
[in]_infoopencl configuration. Specifies the context, queue, etc, to be used.

Member Function Documentation

template<RBCPermuteConfig C>
cl::Memory & cl_algo::RBC::RBCPermute< C >::get ( RBCPermute< C >::Memory  mem)

Returns a reference to an internal memory object.

This interface exists to allow CL memory sharing between different kernels.

Parameters
[in]memenumeration value specifying the requested memory object.
Returns
A reference to the requested memory object.
template<RBCPermuteConfig C>
void cl_algo::RBC::RBCPermute< C >::init ( unsigned int  _nx,
unsigned int  _nr,
unsigned int  _d = 8,
int  _permID = 0,
Staging  _staging = Staging::IO 
)

Configures kernel execution parameters.

Sets up memory objects as necessary, and defines the kernel workspaces.

Note
If you have assigned a memory object to one member variable of the class before the call to init, then that memory will be maintained. Otherwise, a new memory object will be created.
Parameters
[in]_nxnumber of database points.
[in]_nrnumber of representative points.
[in]_ddimensionality of the associated points.
[in]_permIDflag to indicate whether or not to also permute the ID array.
[in]_stagingflag to indicate whether or not to instantiate the staging buffers.
template<RBCPermuteConfig C>
void * cl_algo::RBC::RBCPermute< C >::read ( RBCPermute< C >::Memory  mem = RBCPermute< C >::Memory::H_OUT_X_P,
bool  block = CL_TRUE,
const std::vector< cl::Event > *  events = nullptr,
cl::Event *  event = nullptr 
)

Performs a data transfer to a staging buffer.

The transfer happens from a device buffer to the associated (specified) staging buffer on the host.

Parameters
[in]memenumeration value specifying an output staging buffer.
[in]blocka flag to indicate whether to perform a blocking or a non-blocking operation.
[in]eventsa wait-list of events.
[out]eventevent associated with the read operation to the staging buffer.
template<RBCPermuteConfig C>
void cl_algo::RBC::RBCPermute< C >::run ( const std::vector< cl::Event > *  events = nullptr,
cl::Event *  event = nullptr 
)

Executes the necessary kernels.

The function call is non-blocking.

Parameters
[in]eventsa wait-list of events.
[out]eventevent associated with the last kernel execution.
template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
template<typename period >
double cl_algo::RBC::RBCPermute< C >::run ( clutils::GPUTimer< period > &  timer,
const std::vector< cl::Event > *  events = nullptr 
)
inline

Executes the necessary kernels.

This run instance is used for profiling.

Parameters
[in]timerGPUTimer that does the profiling of the kernel executions.
[in]eventsa wait-list of events.
Returns
Τhe total execution time measured by the timer.
template<RBCPermuteConfig C>
void cl_algo::RBC::RBCPermute< C >::write ( RBCPermute< C >::Memory  mem = RBCPermute< C >::Memory::D_IN_X,
void *  ptr = nullptr,
bool  block = CL_FALSE,
const std::vector< cl::Event > *  events = nullptr,
cl::Event *  event = nullptr 
)

Performs a data transfer to a device buffer.

The transfer happens from a staging buffer on the host to the associated (specified) device buffer.

Parameters
[in]memenumeration value specifying an input device buffer.
[in]ptra pointer to an array holding input data. If not NULL, the data from ptr will be copied to the associated staging buffer.
[in]blocka flag to indicate whether to perform a blocking or a non-blocking operation.
[in]eventsa wait-list of events.
[out]eventevent associated with the write operation to the device buffer.

Member Data Documentation

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
rbc_dist_id* cl_algo::RBC::RBCPermute< C >::hPtrInID

Mapping of the input staging buffer with the representative ids for each point.

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
cl_uint* cl_algo::RBC::RBCPermute< C >::hPtrInO

Mapping of the input staging buffer with the offsets of the representative lists within the db.

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
cl_uint* cl_algo::RBC::RBCPermute< C >::hPtrInRnk

Mapping of the input staging buffer with the indices of the points within each rep. list.

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
cl_float* cl_algo::RBC::RBCPermute< C >::hPtrInX

Mapping of the input staging buffer for the database.

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
rbc_dist_id* cl_algo::RBC::RBCPermute< C >::hPtrOutIDp

Mapping of the output staging buffer with the representative ids for each point in the permuted db.

template<RBCPermuteConfig C = RBCPermuteConfig::GENERIC>
cl_float* cl_algo::RBC::RBCPermute< C >::hPtrOutXp

Mapping of the output staging buffer for the permuted database.


The documentation for this class was generated from the following files: