DLPrimitives
|
This class is used to pass cl::Events that the kernel should wait for and/or signal event completion. More...
#include <include/dlprim/context.hpp>
Public Member Functions | |
ExecutionContext () | |
default constructor - can be used for CPU context | |
ExecutionContext (cl::CommandQueue const &q) | |
Create context from cl::CommandQueue, note no events will be waited/signaled. | |
ExecutionContext (cl::CommandQueue const &q, cl::Event *event) | |
Create a context with a request to signal completion event. | |
ExecutionContext (cl::CommandQueue const &q, std::vector< cl::Event > *events) | |
Create a context with a request to wait for events. | |
ExecutionContext (cl::CommandQueue const &q, std::vector< cl::Event > *events, cl::Event *event) | |
Create a context with a request to signal completion event and wait for events. | |
bool | is_cpu_context () const |
ExecutionContext (ExecutionContext const &)=default | |
ExecutionContext & | operator= (ExecutionContext const &)=default |
bool | timing_enabled () const |
void | enable_timing (std::shared_ptr< TimingData > p) |
Add benchmarking/traceing object data. | |
ExecutionContext | generate_series_context (size_t id, size_t total) const |
Create contexts for multiple enqueues. More... | |
void | enter (char const *name) const |
Profiling scope enter called by ExecGuard::ExecGuard() | |
void | leave () const |
Profiling scope leave, called by ExecGuard::~ExecGuard() | |
void | finish () |
cl::CommandQueue & | queue () const |
Get the command queue. Never call it in non-OpenCL context. | |
cl::Event * | event (char const *name="unknown", int id=-1) const |
Get event to signal. Note: name is used for profiling. Such that profiling is enabled profiling conters will be written the TimingData with the name of the kernel you call. Optional id allows to distinguish between multiple similar calls. | |
std::vector< cl::Event > * | events () const |
Get events to wait for. | |
ExecutionContext | first_context () const |
Create context that waits for event if needed - use only if you know that more kernels are followed. | |
ExecutionContext | middle_context () const |
Create context does not wait or signals use only if you know that more kernels run before and after. | |
ExecutionContext | last_context () const |
Create context that signals for completion event if needed - use only if you know that more kernels run before. | |
Friends | |
class | Context |
This class is used to pass cl::Events that the kernel should wait for and/or signal event completion.
It is also used to pass cl::CommandQueue over API
Use it as following:
If you need to run several kernels use generate_series_context(#,total)
For example:
|
inline |
Create contexts for multiple enqueues.
The idea is simple if we have events to signal and wait for and multiple kernels to execute, the first execution id == 0 should provide list of events to wait if id == total - 1, give event to signal