SWDEV-301667 - Add cache state for a device
- Add a global cache state for a device to indicate scopes of submitted AQL packets - Remove scopes for TS marker if hipEventReleaseToDevice is passed. Set env ROC_EVENT_NO_FLUSH=1 to use NOP AQL for event records. It would flush caches by default with system scope release. - Calling finish() should ensure if caches are flushed, if not queue a marker Change-Id: Ibbbdbb1cd7ac61cb35649169212142545be159e0
This commit is contained in:
@@ -55,8 +55,14 @@ Event::Event(HostQueue& queue)
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
Event::Event() : callbacks_(NULL), status_(CL_SUBMITTED),
|
||||
hw_event_(nullptr), notify_event_(nullptr), device_(nullptr) { notified_.clear(); }
|
||||
Event::Event()
|
||||
: callbacks_(NULL),
|
||||
status_(CL_SUBMITTED),
|
||||
hw_event_(nullptr),
|
||||
notify_event_(nullptr),
|
||||
device_(nullptr) {
|
||||
notified_.clear();
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
Event::~Event() {
|
||||
@@ -241,7 +247,7 @@ bool Event::awaitCompletion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
ClPrint(LOG_DEBUG, LOG_WAIT, "waiting for event %p to complete, current status %d",
|
||||
ClPrint(LOG_DEBUG, LOG_WAIT, "Waiting for event %p to complete, current status %d",
|
||||
this, status());
|
||||
auto* queue = command().queue();
|
||||
if ((queue != nullptr) && queue->vdev()->ActiveWait()) {
|
||||
@@ -256,7 +262,7 @@ bool Event::awaitCompletion() {
|
||||
lock_.wait();
|
||||
}
|
||||
}
|
||||
ClPrint(LOG_DEBUG, LOG_WAIT, "event %p wait completed", this);
|
||||
ClPrint(LOG_DEBUG, LOG_WAIT, "Event %p wait completed", this);
|
||||
}
|
||||
|
||||
return status() == CL_COMPLETE;
|
||||
@@ -277,7 +283,7 @@ bool Event::notifyCmdQueue(bool cpu_wait) {
|
||||
notified_.clear();
|
||||
return false;
|
||||
}
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "queue marker to command queue: %p", queue);
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "Queue marker to command queue: %p", queue);
|
||||
command->enqueue();
|
||||
// Save notification, associated with the current event
|
||||
notify_event_ = command;
|
||||
@@ -290,7 +296,7 @@ bool Event::notifyCmdQueue(bool cpu_wait) {
|
||||
notified_.clear();
|
||||
return false;
|
||||
}
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "queue marker to command queue: %p", queue);
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "Queue marker to command queue: %p", queue);
|
||||
command->enqueue();
|
||||
command->release();
|
||||
}
|
||||
@@ -336,7 +342,7 @@ void Command::enqueue() {
|
||||
Agent::postEventCreate(as_cl(static_cast<Event*>(this)), type_);
|
||||
}
|
||||
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "command is enqueued: %p", this);
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "Command enqueued: %p", this);
|
||||
|
||||
// Direct dispatch logic below will submit the command immediately, but the command status
|
||||
// update will occur later after flush() with a wait
|
||||
@@ -360,7 +366,7 @@ void Command::enqueue() {
|
||||
EnableProfiling();
|
||||
}
|
||||
|
||||
if (isMarker && !profilingInfo().marker_ts_) {
|
||||
if (isMarker && (profilingInfo().marker_ts_ == 0)) {
|
||||
// Update batch head for the current marker. Hence the status of all commands can be
|
||||
// updated upon the marker completion
|
||||
SetBatchHead(queue_->GetSubmittionBatch());
|
||||
@@ -414,6 +420,7 @@ NDRangeKernelCommand::NDRangeKernelCommand(HostQueue& queue, const EventWaitList
|
||||
profilingInfo_.enabled_ = true;
|
||||
profilingInfo_.clear();
|
||||
profilingInfo_.callback_ = nullptr;
|
||||
profilingInfo_.marker_ts_ = 1;
|
||||
}
|
||||
kernel_.retain();
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class Event : public RuntimeObject {
|
||||
static const EventWaitList nullWaitList;
|
||||
|
||||
struct ProfilingInfo {
|
||||
ProfilingInfo(bool enabled = false) : enabled_(enabled), waves_(0), marker_ts_(false) {
|
||||
ProfilingInfo(bool enabled = false) : enabled_(enabled), waves_(0), marker_ts_(0) {
|
||||
if (enabled) {
|
||||
clear();
|
||||
callback_ = nullptr;
|
||||
@@ -113,10 +113,11 @@ class Event : public RuntimeObject {
|
||||
uint64_t submitted_;
|
||||
uint64_t start_;
|
||||
uint64_t end_;
|
||||
bool enabled_; //!< Profiling enabled for the wave limiter
|
||||
uint32_t waves_; //!< The number of waves used in a dispatch
|
||||
bool enabled_; //!< Profiling enabled for the wave limiter
|
||||
uint32_t waves_; //!< The number of waves used in a dispatch
|
||||
ProfilingCallback* callback_;
|
||||
bool marker_ts_;
|
||||
uint32_t marker_ts_; //!< Marker with release scope
|
||||
//!< 5 - system scope, 3 - device scope, 1 - no scopes
|
||||
void clear() {
|
||||
queued_ = 0ULL;
|
||||
submitted_ = 0ULL;
|
||||
|
||||
@@ -106,20 +106,20 @@ bool HostQueue::terminate() {
|
||||
|
||||
void HostQueue::finish() {
|
||||
Command* command = nullptr;
|
||||
bool isCacheFlushed = device().IsCacheFlushed(Device::CacheState::kCacheStateSystem);
|
||||
if (IS_HIP) {
|
||||
command = getLastQueuedCommand(true);
|
||||
// Check if the queue has nothing to process and return
|
||||
if (AMD_DIRECT_DISPATCH && command == nullptr) {
|
||||
if (AMD_DIRECT_DISPATCH && isCacheFlushed && command == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (nullptr == command) {
|
||||
if (nullptr == command || !isCacheFlushed) {
|
||||
// Send a finish to make sure we finished all commands
|
||||
command = new Marker(*this, false);
|
||||
if (command == NULL) {
|
||||
return;
|
||||
}
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "marker is queued");
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "Marker queued, Cache Flushed = %d", isCacheFlushed);
|
||||
command->enqueue();
|
||||
}
|
||||
// Check HW status of the ROCcrl event. Note: not all ROCclr modes support HW status
|
||||
@@ -194,7 +194,7 @@ void HostQueue::loop(device::VirtualDevice* virtualDevice) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "command (%s) is submitted: %p", getOclCommandKindString(command->type()), command);
|
||||
ClPrint(LOG_DEBUG, LOG_CMD, "Command (%s) submitted: %p", getOclCommandKindString(command->type()), command);
|
||||
|
||||
command->setStatus(CL_SUBMITTED);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user