Interface class for the rbcMinDists
kernel.
More...
#include <algorithms.hpp>
Public Types | |
enum | Memory : uint8_t { Memory::H_IN_D, Memory::H_OUT_ID, Memory::H_OUT_RNK, Memory::H_OUT_N, Memory::D_IN_D, Memory::D_MINS, Memory::D_OUT_ID, Memory::D_OUT_RNK, Memory::D_OUT_N } |
Enumerates the memory objects handled by the class. More... | |
Public Member Functions | |
RBCMin (clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info) | |
Configures an OpenCL environment as specified by _info . More... | |
cl::Memory & | get (RBCMin::Memory mem) |
Returns a reference to an internal memory object. More... | |
void | init (unsigned int _cols, unsigned int _rows, int _accCounters=1, Staging _staging=Staging::IO) |
Configures kernel execution parameters. More... | |
void | write (RBCMin::Memory mem=RBCMin::Memory::D_IN_D, 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 (RBCMin::Memory mem=RBCMin::Memory::H_OUT_ID, 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 * | hPtrInD |
rbc_dist_id * | hPtrOutID |
cl_uint * | hPtrOutRnk |
cl_uint * | hPtrOutN |
Interface class for the rbcMinDists
kernel.
rbcMinDists
computes the minimum element, and its corresponding column id, of each row in an array. It also builds a histogram of the id values. And lastly, it stores the rank (order of insert) of each minimum element within its corresponding histogram bin. For more details, look at the kernel's documentation.
rbcMinDists
kernel is available in kernels/rbc_kernels.cl
. 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 RBCMin
instance:
Name | Type | Placement | I/O | Use | Properties | Size |
---|---|---|---|---|---|---|
H_IN_D | Buffer | Host | I | Staging | CL_MEM_READ_WRITE | \(columns*rows*sizeof\ (cl\_float)\) |
H_OUT_ID | Buffer | Host | O | Staging | CL_MEM_READ_WRITE | \(rows *sizeof\ (rbc\_dist\_id)\) |
H_OUT_RNK | Buffer | Host | O | Staging | CL_MEM_READ_WRITE | \(rows *sizeof\ (cl\_uint)\) |
H_OUT_N | Buffer | Host | O | Staging | CL_MEM_READ_WRITE | \(columns *sizeof\ (cl\_uint)\) |
D_IN_D | Buffer | Device | I | Processing | CL_MEM_READ_ONLY | \(columns*rows*sizeof\ (cl\_float)\) |
D_OUT_ID | Buffer | Device | O | Processing | CL_MEM_WRITE_ONLY | \(rows *sizeof\ (rbc\_dist\_id)\) |
D_OUT_RNK | Buffer | Device | O | Processing | CL_MEM_WRITE_ONLY | \(rows *sizeof\ (cl\_uint)\) |
D_OUT_N | Buffer | Device | O | Processing | CL_MEM_READ_WRITE | \(columns *sizeof\ (cl\_uint)\) |
rbc_dist_id
is documented in rbcDataTypes.hpp
.
|
strong |
Enumerates the memory objects handled by the class.
H_*
names refer to staging buffers on the host. D_*
names refer to buffers on the device. cl_algo::RBC::RBCMin::RBCMin | ( | clutils::CLEnv & | _env, |
clutils::CLEnvInfo< 1 > | _info | ||
) |
Configures an OpenCL environment as specified by _info
.
[in] | _env | opencl environment. |
[in] | _info | opencl configuration. Specifies the context, queue, etc, to be used. |
cl::Memory & cl_algo::RBC::RBCMin::get | ( | RBCMin::Memory | mem | ) |
Returns a reference to an internal memory object.
This interface exists to allow CL memory sharing between different kernels.
[in] | mem | enumeration value specifying the requested memory object. |
void cl_algo::RBC::RBCMin::init | ( | unsigned int | _cols, |
unsigned int | _rows, | ||
int | _accCounters = 1 , |
||
Staging | _staging = Staging::IO |
||
) |
Configures kernel execution parameters.
Sets up memory objects as necessary, and defines the kernel workspaces.
init
, then that memory will be maintained. Otherwise, a new memory object will be created.[in] | _cols | number of columns in the input array. |
[in] | _rows | number of rows in the input array. |
[in] | _accCounters | flag to indicate whether or not to involve in the computation the list element counters, N , and element ranks, Rnk . |
[in] | _staging | flag to indicate whether or not to instantiate the staging buffers. |
void * cl_algo::RBC::RBCMin::read | ( | RBCMin::Memory | mem = RBCMin::Memory::H_OUT_ID , |
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.
[in] | mem | enumeration value specifying an output staging buffer. |
[in] | block | a flag to indicate whether to perform a blocking or a non-blocking operation. |
[in] | events | a wait-list of events. |
[out] | event | event associated with the read operation to the staging buffer. |
void cl_algo::RBC::RBCMin::run | ( | const std::vector< cl::Event > * | events = nullptr , |
cl::Event * | event = nullptr |
||
) |
Executes the necessary kernels.
The function call is non-blocking.
[in] | events | a wait-list of events. |
[out] | event | event associated with the kernel execution. |
|
inline |
Executes the necessary kernels.
This run
instance is used for profiling.
[in] | timer | GPUTimer that does the profiling of the kernel executions. |
[in] | events | a wait-list of events. |
void cl_algo::RBC::RBCMin::write | ( | RBCMin::Memory | mem = RBCMin::Memory::D_IN_D , |
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.
[in] | mem | enumeration value specifying an input device buffer. |
[in] | ptr | a pointer to an array holding input data. If not NULL, the data from ptr will be copied to the associated staging buffer. |
[in] | block | a flag to indicate whether to perform a blocking or a non-blocking operation. |
[in] | events | a wait-list of events. |
[out] | event | event associated with the write operation to the device buffer. |
cl_float* cl_algo::RBC::RBCMin::hPtrInD |
Mapping of the input staging buffer.
rbc_dist_id* cl_algo::RBC::RBCMin::hPtrOutID |
Mapping of the output staging buffer with the minimum elements and id values.
cl_uint* cl_algo::RBC::RBCMin::hPtrOutN |
Mapping of the output staging buffer with the number of elements per representative list.
cl_uint* cl_algo::RBC::RBCMin::hPtrOutRnk |
Mapping of the output staging buffer with the indices of each database point within the associated list.