Interface class for the scan kernel.
More...
#include <algorithms.hpp>

Public Types | |
| enum | Memory : uint8_t { Memory::H_IN, Memory::H_OUT, Memory::D_IN, Memory::D_SUMS, Memory::D_OUT } |
| Enumerates the memory objects handled by the class. More... | |
Public Member Functions | |
| Scan (clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info) | |
Configures an OpenCL environment as specified by _info. More... | |
| cl::Memory & | get (Scan::Memory mem) |
| Returns a reference to an internal memory object. More... | |
| void | init (unsigned int _cols, unsigned int _rows, Staging _staging=Staging::IO) |
| Configures kernel execution parameters. More... | |
| void | write (Scan::Memory mem=Scan::Memory::D_IN, 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 (Scan::Memory mem=Scan::Memory::H_OUT, 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... | |
| template<> | |
| Scan (clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info) | |
| template<> | |
| Scan (clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info) | |
Public Attributes | |
| T * | hPtrIn |
| T * | hPtrOut |
Interface class for the scan kernel.
scan performs a scan operation on each row in an array. For more details, look at the kernel's documentation.
scan kernel is available in kernels/scan_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 Scan instance:
| Name | Type | Placement | I/O | Use | Properties | Size |
|---|---|---|---|---|---|---|
| H_IN | Buffer | Host | I | Staging | CL_MEM_READ_WRITE | \(width*height*sizeof\ (cl\_int)\) |
| H_OUT | Buffer | Host | O | Staging | CL_MEM_READ_WRITE | \(width*height*sizeof\ (cl\_int)\) |
| D_IN | Buffer | Device | I | Processing | CL_MEM_READ_ONLY | \(width*height*sizeof\ (cl\_int)\) |
| D_OUT | Buffer | Device | O | Processing | CL_MEM_READ_WRITE | \(width*height*sizeof\ (cl\_int)\) |
| C | configures the class to perform either inclusive or exclusive scan. |
| T | configures the class to work with different types of data. |
|
strong |
| cl_algo::RBC::Scan< C, T >::Scan | ( | clutils::CLEnv & | _env, |
| clutils::CLEnvInfo< 1 > | _info | ||
| ) |
Configures an OpenCL environment as specified by _info.
| cl_algo::RBC::Scan< ScanConfig::INCLUSIVE, cl_int >::Scan | ( | clutils::CLEnv & | _env, |
| clutils::CLEnvInfo< 1 > | _info | ||
| ) |
| [in] | _env | opencl environment. |
| [in] | _info | opencl configuration. Specifies the context, queue, etc, to be used. |
| cl_algo::RBC::Scan< ScanConfig::EXCLUSIVE, cl_int >::Scan | ( | clutils::CLEnv & | _env, |
| clutils::CLEnvInfo< 1 > | _info | ||
| ) |
| [in] | _env | opencl environment. |
| [in] | _info | opencl configuration. Specifies the context, queue, etc, to be used. |
| cl::Memory & cl_algo::RBC::Scan< C, T >::get | ( | Scan< C, T >::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::Scan< C, T >::init | ( | unsigned int | _cols, |
| unsigned int | _rows, | ||
| 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. float elements and having large summations can be problematic. It is advised that a scaling is applied on the elements for better accuracy.| [in] | _cols | number of columns in the input array. |
| [in] | _rows | number of rows in the input array. |
| [in] | _staging | flag to indicate whether or not to instantiate the staging buffers. |
| void * cl_algo::RBC::Scan< C, T >::read | ( | Scan< C, T >::Memory | mem = Scan< C, T >::Memory::H_OUT, |
| 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::Scan< C, T >::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 last 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::Scan< C, T >::write | ( | Scan< C, T >::Memory | mem = Scan< C, T >::Memory::D_IN, |
| 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. |
| T* cl_algo::RBC::Scan< C, T >::hPtrIn |
Mapping of the input staging buffer.
| T* cl_algo::RBC::Scan< C, T >::hPtrOut |
Mapping of the output staging buffer.
1.8.9.1