Graph Processor provides interfaces for enqueueing commands and their dependencies to the underlying runtime. More...
#include <detail/scheduler/scheduler.hpp>
Static Public Member Functions | |
static void | waitForEvent (EventImplPtr Event, ReadLockT &GraphReadLock, std::vector< Command * > &ToCleanUp, bool LockTheLock=true) |
Waits for the command, associated with Event passed, is completed. More... | |
static bool | enqueueCommand (Command *Cmd, EnqueueResultT &EnqueueResult, std::vector< Command * > &ToCleanUp, BlockingT Blocking=NON_BLOCKING) |
Enqueues the command and all its dependencies. More... | |
Graph Processor provides interfaces for enqueueing commands and their dependencies to the underlying runtime.
Member functions of this class do not modify the graph.
Commands are enqueued whenever they come to the Scheduler. Each command has enqueue method which takes vector of events that represents dependencies and returns event which represents the command. GraphProcessor performs topological sort to get the order in which commands have to be enqueued. Then it enqueues each command, passing a vector of events that this command needs to wait on. If an error happens during command enqueue, the whole process is stopped, the faulty command is propagated back to the Scheduler.
The command with dependencies that belong to a context different from its own can't be enqueued directly (limitation of OpenCL runtime). Instead, for each dependency, a proxy event is created in the target context and linked using OpenCL callback mechanism with original one. For example, the following SYCL code:
is translated to the following OCL API calls:
The alternative approach that has been considered is to have separate dispatcher thread that would wait for all events from the Context other then target Context to complete and then enqueue command with dependencies from target Context only. Alternative approach makes code significantly more complex and can hurt performance on CPU device vs chosen approach with callbacks.
Definition at line 731 of file scheduler.hpp.
|
static |
Enqueues the command and all its dependencies.
EnqueueResult | is set to specific status if enqueue failed. |
ToCleanUp | container for commands that can be cleaned up. |
The function may unlock and lock GraphReadLock as needed. Upon return the lock is left in locked state.
Definition at line 49 of file graph_processor.cpp.
References cl::sycl::detail::Command::enqueue(), cl::sycl::detail::Command::getPreparedHostDepsEvents(), cl::sycl::detail::Command::isEnqueueBlocked(), cl::sycl::detail::Command::isSuccessfullyEnqueued(), cl::sycl::detail::DepDesc::MDepCommand, and cl::sycl::detail::Command::MDeps.
|
static |
Waits for the command, associated with Event passed, is completed.
GraphReadLock | read-lock which is already acquired for reading |
ToCleanUp | container for commands that can be cleaned up. |
LockTheLock | selects if graph lock should be locked upon return |
The function may unlock and lock GraphReadLock as needed. Upon return the lock is left in locked state if and only if LockTheLock is true.
Definition at line 24 of file graph_processor.cpp.
References cl::sycl::detail::BLOCKING, cl::sycl::detail::getCommand(), cl::sycl::detail::Command::getEvent(), and cl::sycl::detail::EnqueueResultT::MResult.