-
Notifications
You must be signed in to change notification settings - Fork 75
SWDEV-561708 Initial shared queue pool apis #1614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
328e9b1
1466415
afd4ed1
a499fac
9a8e1b6
4fc2af0
0cfa2e3
75c64ac
0b6a91c
eb47ff2
bde9d18
c9980ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Copyright © Advanced Micro Devices, Inc., or its affiliates. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| #ifndef ROCRTST_SUITES_FUNCTIONAL_COUNTED_QUEUES_H | ||
| #define ROCRTST_SUITES_FUNCTIONAL_COUNTED_QUEUES_H | ||
|
|
||
|
|
||
| #include "suites/test_common/test_base.h" | ||
|
|
||
| class CountedQueuesTest : public TestBase { | ||
| public: | ||
| explicit CountedQueuesTest(); | ||
|
|
||
| // @Brief: Destructor for test case of CountedQueuesTest | ||
| virtual ~CountedQueuesTest(); | ||
|
|
||
| // @Brief: Setup the environment for measurement | ||
| virtual void SetUp(); | ||
|
|
||
| // @Brief: Core measurement execution | ||
| virtual void Run(); | ||
|
|
||
| // @Brief: Clean up and retrive the resource | ||
| virtual void Close(); | ||
|
|
||
| // @Brief: Display results | ||
| virtual void DisplayResults() const; | ||
|
|
||
| // @Brief: Display information about what this test does | ||
| virtual void DisplayTestInfo(void); | ||
|
|
||
| void CountedQueueBasicApiTest(); | ||
| void CountedQueues_SamePriority_MaxLimitTest(); | ||
| void InvalidArgsTest(); | ||
| void CountedQueuesAllPrioritiesLimitTest(); | ||
| void CountedQueuesSetPriorityNackTest(); | ||
| void CountedQueuesSetCUMaskNackTest(); | ||
| void CountedQueuesDispatchTest(); | ||
| void CountedQueuesMultithreadedDispatchTest(); | ||
|
|
||
| private: | ||
| void* src_buffer_; | ||
| void* dst_buffer_; | ||
| }; | ||
|
|
||
| #endif // ROCRTST_SUITES_FUNCTIONAL_COUNTED_QUEUES_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,5 @@ | |
| test; \ | ||
| } | ||
|
|
||
|
|
||
| #endif // ROCRTST_SUITES_TEST_COMMON_MAIN_H_ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright © Advanced Micro Devices, Inc., or its affiliates. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| #ifndef HSA_RUNTME_CORE_INC_COUNTED_QUEUE_MANAGER_H_ | ||
| #define HSA_RUNTME_CORE_INC_COUNTED_QUEUE_MANAGER_H_ | ||
|
|
||
|
|
||
| #include "hsa.h" | ||
| #include "hsa_ext_amd.h" | ||
| #include "core/inc/agent.h" | ||
| #include "core/inc/runtime.h" | ||
| #include <map> | ||
| #include <mutex> | ||
| #include <vector> | ||
| #include <memory> | ||
|
|
||
| namespace rocr { | ||
| namespace core { | ||
|
|
||
| // Wrapper for a logical counted queue (unique handle + callback) | ||
| struct CountedQueue { | ||
| core::Queue* hw_queue; // this will store the public handle of HW Queue (hsa_queue_t) | ||
| void (*callback)(hsa_status_t, hsa_queue_t*, void*); | ||
| void* callback_data; | ||
|
|
||
| CountedQueue(core::Queue* hw, void (*cb)(hsa_status_t, hsa_queue_t*, void*), void* data) | ||
| : hw_queue(hw), callback(cb), callback_data(data) {} | ||
| }; | ||
|
|
||
| // Manages the pool of counted queues for a single GPU agent | ||
| class CountedQueuePoolManager { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would make the CountedQueuePoolManager a member of the GpuAgent class and initialize it in the GpuAgent constructor. That way we do not have to make it a singleton and check for IsInstanceCreated() each time. Then inside hsa_amd_counted_queue_acquire implementation, we would call: status = agent->CountedQueueCreate(....); Which will invoke the CountedQueuePoolManager for the GpuAgent. For CPU agents, hsa_amd_counted_queue_acquire can return error. |
||
| public: | ||
| explicit CountedQueuePoolManager(core::Agent*); | ||
| ~CountedQueuePoolManager(); | ||
|
|
||
| // Acquire a queue (either reuse or create new) | ||
| hsa_status_t AcquireQueue(hsa_queue_type_t type, hsa_amd_queue_priority_t priority, | ||
| void (*callback)(hsa_status_t, hsa_queue_t*, void*), void* data, | ||
| uint64_t flags, hsa_queue_t** out_queue); | ||
|
|
||
| // Release a logical queue | ||
| hsa_status_t ReleaseQueue(hsa_queue_t* queue); | ||
|
|
||
| // Query info (use count, hw id) | ||
| hsa_status_t GetQueueInfo(hsa_queue_t* queue, hsa_queue_info_attribute_t attribute, | ||
| void* value); | ||
|
|
||
| private: | ||
| core::Queue* FindOrCreateHardwareQueue(hsa_queue_type_t type, hsa_amd_queue_priority_t priority, | ||
| void (*callback)(hsa_status_t, hsa_queue_t*, void*), | ||
| void* data, uint64_t flags); | ||
|
|
||
| core::Agent* agent_; // pointer to the gpu agent that owns this pool | ||
| uint32_t max_hw_queues_; | ||
| std::mutex mutex_; | ||
|
|
||
| // Pool of hw queues by priority on the agent | ||
| std::map<hsa_amd_queue_priority_t, std::vector<core::Queue*>> hw_queue_pools_; | ||
|
|
||
| // Map from unique handle to CountedQueue (hw queue, metadata per acquire request) | ||
| std::map<hsa_queue_t*, CountedQueue*> counted_queues_; | ||
| }; | ||
|
|
||
| } // namespace core | ||
| } // namespace rocr | ||
|
|
||
| #endif // HSA_RUNTME_CORE_INC_COUNTED_QUEUE_MANAGER_H_ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to fork.
TEST(rocrtstFunc, Counted_Queue_Basic_Test) {
CountedQueuesTest cq;
RunCustomTestProlog(&cq);
cq.testFunc();
RunCustomTestEpilog(&cq);
}
Same for the other tests below