Add HSA_CU_MASK

New environment variable HSA_CU_MASK allows users to
specify a cu mask to every queue allocated from any
GPU.  hsa_amd_queue_cu_set_mask is restricted from
escaping this mask.

A new API hsa_amd_queue_cu_get_mask is added to query
the current cu mask.

Change-Id: I846c03a5faaca9b95067c31db84b59cc9fce2f03


[ROCm/ROCR-Runtime commit: 4455250be1]
This commit is contained in:
Sean Keely
2021-06-29 18:03:05 -05:00
rodzic c7606d1dfc
commit 4c6ea88cf5
19 zmienionych plików z 430 dodań i 30 usunięć
@@ -185,7 +185,16 @@ class AqlQueue : public core::Queue, private core::LocalSignal, public core::Doo
/// @param cu_mask pointer to cu mask
///
/// @return hsa_status_t
hsa_status_t SetCUMasking(const uint32_t num_cu_mask_count, const uint32_t* cu_mask) override;
hsa_status_t SetCUMasking(uint32_t num_cu_mask_count, const uint32_t* cu_mask) override;
/// @brief Get CU Masking
///
/// @param num_cu_mask_count size of mask bit array
///
/// @param cu_mask pointer to cu mask
///
/// @return hsa_status_t
hsa_status_t GetCUMasking(uint32_t num_cu_mask_count, uint32_t* cu_mask) override;
// @brief Submits a block of PM4 and waits until it has been executed.
void ExecutePM4(uint32_t* cmd_data, size_t cmd_size_b) override;
@@ -277,6 +286,12 @@ class AqlQueue : public core::Queue, private core::LocalSignal, public core::Doo
// Exception notification signal
Signal* exception_signal_;
// CU mask lock
KernelMutex mask_lock_;
// Current CU mask
std::vector<uint32_t> cu_mask_;
// Shared event used for queue errors
static HsaEvent* queue_event_;
@@ -174,7 +174,7 @@ class GpuAgent : public GpuAgentInt {
// id.
// @param [in] node_props Node property.
// @param [in] xnack_mode XNACK mode of device.
GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xnack_mode);
GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xnack_mode, uint32_t index);
// @brief GPU agent destructor.
~GpuAgent();
@@ -322,6 +322,10 @@ class GpuAgent : public GpuAgentInt {
return memory_max_frequency_;
}
// @brief Order the device is surfaced in hsa_iterate_agents counting only
// GPU devices.
__forceinline uint32_t enumeration_index() const { return enum_index_; }
void Trim() override;
protected:
@@ -454,6 +458,9 @@ class GpuAgent : public GpuAgentInt {
// @brief The GPU memory maximum frequency in MHz.
uint32_t memory_max_frequency_;
// @brief Enumeration index
uint32_t enum_index_;
// @brief HDP flush registers
hsa_amd_hdp_flush_t HDP_flush_ = {nullptr, nullptr};
@@ -144,8 +144,12 @@ class HostQueue : public Queue {
std::memory_order_release);
}
hsa_status_t SetCUMasking(const uint32_t num_cu_mask_count, const uint32_t* cu_mask) override {
return HSA_STATUS_ERROR;
hsa_status_t SetCUMasking(uint32_t num_cu_mask_count, const uint32_t* cu_mask) override {
return HSA_STATUS_ERROR_INVALID_QUEUE;
}
hsa_status_t GetCUMasking(uint32_t num_cu_mask_count, uint32_t* cu_mask) override {
return HSA_STATUS_ERROR_INVALID_QUEUE;
}
void ExecutePM4(uint32_t* cmd_data, size_t cmd_size_b) override {
@@ -113,6 +113,10 @@ hsa_status_t hsa_amd_queue_cu_set_mask(const hsa_queue_t* queue,
uint32_t num_cu_mask_count,
const uint32_t* cu_mask);
// Mirrors Amd Extension Apis
hsa_status_t HSA_API hsa_amd_queue_cu_get_mask(const hsa_queue_t* queue, uint32_t num_cu_mask_count,
uint32_t* cu_mask);
// Mirrors Amd Extension Apis
hsa_status_t
hsa_amd_memory_pool_get_info(hsa_amd_memory_pool_t memory_pool,
@@ -114,9 +114,12 @@ class QueueWrapper : public Queue {
uint64_t AddWriteIndexRelease(uint64_t value) override {
return wrapped->AddWriteIndexRelease(value);
}
hsa_status_t SetCUMasking(const uint32_t num_cu_mask_count, const uint32_t* cu_mask) override {
hsa_status_t SetCUMasking(uint32_t num_cu_mask_count, const uint32_t* cu_mask) override {
return wrapped->SetCUMasking(num_cu_mask_count, cu_mask);
}
hsa_status_t GetCUMasking(uint32_t num_cu_mask_count, uint32_t* cu_mask) override {
return wrapped->GetCUMasking(num_cu_mask_count, cu_mask);
}
void ExecutePM4(uint32_t* cmd_data, size_t cmd_size_b) override {
wrapped->ExecutePM4(cmd_data, cmd_size_b);
}
@@ -295,8 +295,16 @@ class Queue : public Checked<0xFA3906A679F9DB49>, private LocalQueue {
/// @param cu_mask pointer to cu mask
///
/// @return hsa_status_t
virtual hsa_status_t SetCUMasking(const uint32_t num_cu_mask_count,
const uint32_t* cu_mask) = 0;
virtual hsa_status_t SetCUMasking(uint32_t num_cu_mask_count, const uint32_t* cu_mask) = 0;
/// @brief Get CU Masking
///
/// @param num_cu_mask_count size of mask bit array
///
/// @param cu_mask pointer to cu mask
///
/// @return hsa_status_t
virtual hsa_status_t GetCUMasking(uint32_t num_cu_mask_count, uint32_t* cu_mask) = 0;
// @brief Submits a block of PM4 and waits until it has been executed.
virtual void ExecutePM4(uint32_t* cmd_data, size_t cmd_size_b) = 0;