2
0

SWDEV-334150 - Force callback to cycle commands

Enqueue a handler callback for hipEventRecords(aka marker_ts_) for every
64 submits, This recycles the memory if we dont end up calling
synchronize for the longest time.

Change-Id: I3d39fe76d52a5d81387927edd85b5663b563682c
Este cometimento está contido em:
Saleel Kudchadker
2022-04-27 11:13:41 -07:00
ascendente 934149ff0a
cometimento fa76f03654
3 ficheiros modificados com 23 adições e 2 eliminações
+10 -1
Ver ficheiro
@@ -336,6 +336,7 @@ void Command::releaseResources() {
}
}
static constexpr uint32_t kMarkerTsCount = 64;
// ================================================================================================
void Command::enqueue() {
assert(queue_ != NULL && "Cannot be enqueued");
@@ -368,7 +369,15 @@ void Command::enqueue() {
EnableProfiling();
}
if (isMarker && (!profilingInfo().marker_ts_)) {
bool submitBatch = !profilingInfo().marker_ts_;
// Flush the batch if ther marker_ts have been continuously submitted until a threashold
// is reached. This helps recycling the commands and frees memory.
if (queue_->GetMarkerTsCount() > kMarkerTsCount) {
submitBatch = true;
queue_->ResetMarkerTsCount();
}
if (isMarker && submitBatch) {
// Update batch head for the current marker. Hence the status of all commands can be
// updated upon the marker completion
SetBatchHead(queue_->GetSubmittionBatch());
+2 -1
Ver ficheiro
@@ -40,7 +40,8 @@ HostQueue::HostQueue(Context& context, Device& device, cl_command_queue_properti
lastEnqueueCommand_(nullptr),
head_(nullptr),
tail_(nullptr),
isActive_(false) {
isActive_(false),
markerTsCount_(0) {
if (AMD_DIRECT_DISPATCH) {
// Initialize the queue
thread_.Init(this);
+11
Ver ficheiro
@@ -264,6 +264,9 @@ class HostQueue : public CommandQueue {
// an invalid access
command->retain();
if (command->profilingInfo().marker_ts_) {
markerTsCount_++;
}
// Release the last command in the batch
if (lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->release();
@@ -284,12 +287,20 @@ class HostQueue : public CommandQueue {
//! Get queue status
bool GetQueueStatus() { return isActive_; }
//! Get markerTsCount
uint32_t GetMarkerTsCount() const { return markerTsCount_; }
//! Reset counter
void ResetMarkerTsCount() { markerTsCount_ = 0; }
private:
Command* head_; //!< Head of the batch list
Command* tail_; //!< Tail of the batch list
//! True if this command queue is active
bool isActive_;
uint32_t markerTsCount_; //!< Count of TS markers
};