Skip to content

Commit 6558e56

Browse files
authored
[libc] Update HSA queues to use the maximum size and set the barrier bit (#110034)
Summary: It's safer to use the maximum size, as this prevents the runtime from oversubscribing with multiple producers. Additionally we should set the barrier bit to ensure that the queue entries block if multiple are submitted (Which shouldn't happen for this tool).
1 parent e7621f4 commit 6558e56

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libc/utils/gpu/loader/amdgpu/amdhsa-loader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ hsa_status_t launch_kernel(hsa_agent_t dev_agent, hsa_executable_t executable,
281281
// Initialize the packet header and set the doorbell signal to begin execution
282282
// by the HSA runtime.
283283
uint16_t header =
284+
1u << HSA_PACKET_HEADER_BARRIER |
284285
(HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) |
285286
(HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE) |
286287
(HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE);
@@ -540,11 +541,11 @@ int load(int argc, const char **argv, const char **envp, void *image,
540541
}
541542
}
542543

543-
// Obtain a queue with the minimum (power of two) size, used to send commands
544+
// Obtain a queue with the maximum (power of two) size, used to send commands
544545
// to the HSA runtime and launch execution on the device.
545546
uint64_t queue_size;
546547
if (hsa_status_t err = hsa_agent_get_info(
547-
dev_agent, HSA_AGENT_INFO_QUEUE_MIN_SIZE, &queue_size))
548+
dev_agent, HSA_AGENT_INFO_QUEUE_MAX_SIZE, &queue_size))
548549
handle_error(err);
549550
hsa_queue_t *queue = nullptr;
550551
if (hsa_status_t err =

0 commit comments

Comments
 (0)