[Openmp-commits] [PATCH] D109511: [libomptarget][amdgpu] Destruct HSA queues
Jon Chesterfield via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Sun Sep 26 07:34:58 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8cf93a35d4b8: [libomptarget][amdgpu] Destruct HSA queues (authored by JonChesterfield).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109511/new/
https://reviews.llvm.org/D109511
Files:
openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.h
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -451,6 +451,17 @@
HSALifetime HSA; // First field => constructed first and destructed last
std::vector<std::list<FuncOrGblEntryTy>> FuncGblEntries;
+ struct QueueDeleter {
+ void operator()(hsa_queue_t *Q) {
+ if (Q) {
+ hsa_status_t Err = hsa_queue_destroy(Q);
+ if (Err != HSA_STATUS_SUCCESS) {
+ DP("Error destroying hsa queue: %s\n", get_error_string(Err));
+ }
+ }
+ }
+ };
+
public:
// load binary populates symbol tables and mutates various global state
// run uses those symbol tables
@@ -460,7 +471,8 @@
// GPU devices
std::vector<hsa_agent_t> HSAAgents;
- std::vector<hsa_queue_t *> HSAQueues; // one per gpu
+ std::vector<std::unique_ptr<hsa_queue_t, QueueDeleter>>
+ HSAQueues; // one per gpu
// CPUs
std::vector<hsa_agent_t> CPUAgents;
@@ -773,10 +785,6 @@
return;
}
- for (int i = 0; i < NumberOfDevices; i++) {
- HSAQueues[i] = nullptr;
- }
-
for (int i = 0; i < NumberOfDevices; i++) {
uint32_t queue_size = 0;
{
@@ -792,12 +800,16 @@
}
}
- hsa_status_t rc = hsa_queue_create(
- HSAAgents[i], queue_size, HSA_QUEUE_TYPE_MULTI, callbackQueue, NULL,
- UINT32_MAX, UINT32_MAX, &HSAQueues[i]);
- if (rc != HSA_STATUS_SUCCESS) {
- DP("Failed to create HSA queue %d\n", i);
- return;
+ {
+ hsa_queue_t *Q = nullptr;
+ hsa_status_t rc =
+ hsa_queue_create(HSAAgents[i], queue_size, HSA_QUEUE_TYPE_MULTI,
+ callbackQueue, NULL, UINT32_MAX, UINT32_MAX, &Q);
+ if (rc != HSA_STATUS_SUCCESS) {
+ DP("Failed to create HSA queue %d\n", i);
+ return;
+ }
+ HSAQueues[i].reset(Q);
}
deviceStateStore[i] = {nullptr, 0};
@@ -2149,7 +2161,7 @@
// Run on the device.
{
- hsa_queue_t *queue = DeviceInfo.HSAQueues[device_id];
+ hsa_queue_t *queue = DeviceInfo.HSAQueues[device_id].get();
if (!queue) {
return OFFLOAD_FAIL;
}
Index: openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.h
===================================================================
--- openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.h
+++ openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.h
@@ -142,6 +142,8 @@
void *data, uint32_t private_segment_size,
uint32_t group_segment_size, hsa_queue_t **queue);
+hsa_status_t hsa_queue_destroy(hsa_queue_t *queue);
+
uint64_t hsa_queue_load_read_index_scacquire(const hsa_queue_t *queue);
uint64_t hsa_queue_add_write_index_relaxed(const hsa_queue_t *queue,
Index: openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
+++ openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
@@ -29,6 +29,7 @@
DLWRAP(hsa_signal_store_screlease, 2);
DLWRAP(hsa_signal_wait_scacquire, 5);
DLWRAP(hsa_queue_create, 8);
+DLWRAP(hsa_queue_destroy, 1);
DLWRAP(hsa_queue_load_read_index_scacquire, 1);
DLWRAP(hsa_queue_add_write_index_relaxed, 2);
DLWRAP(hsa_memory_copy, 3);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109511.375104.patch
Type: text/x-patch
Size: 3433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210926/72d1fd04/attachment.bin>
More information about the Openmp-commits
mailing list