Skip to content

Commit

Permalink
#7473: fix wrap logic for Enqueue commands"
Browse files Browse the repository at this point in the history
  • Loading branch information
aliuTT committed Apr 18, 2024
1 parent f09bd15 commit e46e280
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tt_metal/impl/dispatch/command_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void EnqueueReadBufferCommand::process() {
const uint32_t command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}

this->manager.cq_write(command_sequence.data(), fetch_size_bytes, write_ptr);
Expand Down Expand Up @@ -687,6 +688,7 @@ void EnqueueProgramCommand::process() {
uint32_t command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(total_fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}

write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
Expand All @@ -712,6 +714,7 @@ void EnqueueProgramCommand::process() {
uint32_t command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(preamble_fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}

this->manager.cq_write(preamble_command_sequence.data(), preamble_fetch_size_bytes, write_ptr);
Expand All @@ -730,6 +733,7 @@ void EnqueueProgramCommand::process() {
uint32_t command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}

this->manager.cq_write(cmds.data(), fetch_size_bytes, write_ptr);
Expand All @@ -745,6 +749,7 @@ void EnqueueProgramCommand::process() {
command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(program_fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}

this->manager.cq_write(program_command_sequence.data(), program_fetch_size_bytes, write_ptr);
Expand Down Expand Up @@ -866,6 +871,12 @@ void EnqueueWaitForEventCommand::process() {
this->manager.fetch_queue_reserve_back(this->command_queue_id);

uint32_t write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
// Wrap issue queue
const uint32_t command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}
this->manager.cq_write(command_sequence.data(), fetch_size_bytes, write_ptr);
this->manager.issue_queue_push_back(fetch_size_bytes, this->command_queue_id);
this->manager.fetch_queue_write(fetch_size_bytes, this->command_queue_id);
Expand Down Expand Up @@ -915,6 +926,12 @@ void EnqueueTraceCommand::process() {
this->manager.fetch_queue_reserve_back(this->command_queue_id);

uint32_t write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
// Wrap issue queue
const uint32_t command_issue_limit = this->manager.get_issue_queue_limit(this->command_queue_id);
if (write_ptr + align(fetch_size_bytes, 32) > command_issue_limit) {
this->manager.wrap_issue_queue_wr_ptr(this->command_queue_id);
write_ptr = this->manager.get_issue_queue_write_ptr(this->command_queue_id);
}
this->manager.cq_write(command_sequence.data(), fetch_size_bytes, write_ptr);
this->manager.issue_queue_push_back(fetch_size_bytes, this->command_queue_id);
this->manager.fetch_queue_write(fetch_size_bytes, this->command_queue_id);
Expand Down

0 comments on commit e46e280

Please sign in to comment.