Make HSA_QUEUE_TYPE_COOPERATIVE a queue type value

- Correct defintion of HSA_QUEUE_TYPE_COOPERATIVE to be a queue type
  and not a bit mask.
- Correct implementation of hsa_queue_type_t to treat is as an
  enumeration type and not a bit mask. In particular
  HSA_QUEUE_TYPE_COOPERATIVE is a distinct queue type that uses the
  multi producer protocol, and is not a bit set value.

Change-Id: I9415be8853671e5511e16e306caf16020e8c84af


[ROCm/ROCR-Runtime commit: bccb25fc33]
This commit is contained in:
Tony
2020-05-07 19:15:42 -04:00
parent b5f6574895
commit fbb4e4c2c3
4 changed files with 26 additions and 30 deletions
@@ -309,7 +309,7 @@ AqlQueue::~AqlQueue() {
} }
void AqlQueue::Destroy() { void AqlQueue::Destroy() {
if (amd_queue_.hsa_queue.type & HSA_QUEUE_TYPE_COOPERATIVE) { if (amd_queue_.hsa_queue.type == HSA_QUEUE_TYPE_COOPERATIVE) {
agent_->GWSRelease(); agent_->GWSRelease();
return; return;
} }
@@ -598,7 +598,7 @@ void GpuAgent::InitGWS() {
if (status != HSAKMT_STATUS_SUCCESS) if (status != HSAKMT_STATUS_SUCCESS)
throw AMD::hsa_exception(HSA_STATUS_ERROR_OUT_OF_RESOURCES, "GWS allocation failed."); throw AMD::hsa_exception(HSA_STATUS_ERROR_OUT_OF_RESOURCES, "GWS allocation failed.");
queue->amd_queue_.hsa_queue.type = HSA_QUEUE_TYPE_COOPERATIVE | HSA_QUEUE_TYPE_MULTI; queue->amd_queue_.hsa_queue.type = HSA_QUEUE_TYPE_COOPERATIVE;
gws_queue_.ref_ct_ = 0; gws_queue_.ref_ct_ = 0;
return queue.release(); return queue.release();
}); });
@@ -933,7 +933,7 @@ hsa_status_t GpuAgent::QueueCreate(size_t size, hsa_queue_type32_t queue_type,
uint32_t group_segment_size, uint32_t group_segment_size,
core::Queue** queue) { core::Queue** queue) {
// Handle GWS queues. // Handle GWS queues.
if (queue_type & HSA_QUEUE_TYPE_COOPERATIVE) { if (queue_type == HSA_QUEUE_TYPE_COOPERATIVE) {
ScopedAcquire<KernelMutex> lock(&gws_queue_.lock_); ScopedAcquire<KernelMutex> lock(&gws_queue_.lock_);
auto ret = (*gws_queue_.queue_).get(); auto ret = (*gws_queue_.queue_).get();
if (ret != nullptr) { if (ret != nullptr) {
@@ -700,13 +700,8 @@ hsa_status_t hsa_queue_create(
agent->GetInfo(HSA_AGENT_INFO_QUEUE_TYPE, &agent_queue_type); agent->GetInfo(HSA_AGENT_INFO_QUEUE_TYPE, &agent_queue_type);
assert(HSA_STATUS_SUCCESS == status); assert(HSA_STATUS_SUCCESS == status);
if (agent_queue_type == HSA_QUEUE_TYPE_SINGLE && if ((agent_queue_type == HSA_QUEUE_TYPE_SINGLE) &&
((type & HSA_QUEUE_TYPE_SINGLE) != HSA_QUEUE_TYPE_SINGLE)) { (type != HSA_QUEUE_TYPE_SINGLE)) {
return HSA_STATUS_ERROR_INVALID_QUEUE_CREATION;
}
if ((type & HSA_QUEUE_TYPE_COOPERATIVE) &&
((type & HSA_QUEUE_TYPE_SINGLE) != HSA_QUEUE_TYPE_MULTI)) {
return HSA_STATUS_ERROR_INVALID_QUEUE_CREATION; return HSA_STATUS_ERROR_INVALID_QUEUE_CREATION;
} }
@@ -2184,24 +2184,25 @@ typedef struct hsa_region_s {
*/ */
typedef enum { typedef enum {
/** /**
* Queue supports multiple producers. * Queue supports multiple producers. Use of multiproducer queue mechanics is
* required.
*/ */
HSA_QUEUE_TYPE_MULTI = 0, HSA_QUEUE_TYPE_MULTI = 0,
/** /**
* Queue only supports a single producer. In some scenarios, the application * Queue only supports a single producer. In some scenarios, the application
* may want to limit the submission of AQL packets to a single agent. Queues * may want to limit the submission of AQL packets to a single agent. Queues
* that support a single producer may be more efficient than queues supporting * that support a single producer may be more efficient than queues supporting
* multiple producers. * multiple producers. Use of multiproducer queue mechanics is not supported.
*/ */
HSA_QUEUE_TYPE_SINGLE = 1, HSA_QUEUE_TYPE_SINGLE = 1,
/** /**
* Queue supports cooperative dispatches able to use GWS synchronization. * Queue supports multiple producers and cooperative dispatches. Cooperative
* Queues of this type must also be of type HSA_QUEUE_TYPE_MULTI and * dispatches are able to use GWS synchronization. Queues of this type may be
* may be limited in number. The runtime may return the same queue to serve * limited in number. The runtime may return the same queue to serve multiple
* multiple hsa_queue_create calls when this type is given. Callers must * ::hsa_queue_create calls when this type is given. Callers must inspect the
* inspect the returned queue to discover queue size. Queues of this type * returned queue to discover queue size. Queues of this type are reference
* are reference counted and require a matching number of hsa_queue_destroy * counted and require a matching number of ::hsa_queue_destroy calls to
* calls to release. Use of multiproducer queue mechanics is required. See * release. Use of multiproducer queue mechanics is required. See
* ::HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES to query agent support for this * ::HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES to query agent support for this
* type. * type.
*/ */