Skip to content

Commit

Permalink
Merge pull request #637 from callumfare/callum/cuda_queue_flags
Browse files Browse the repository at this point in the history
[UR] Add CUDA-specific queue flags
  • Loading branch information
callumfare authored Jun 21, 2023
2 parents c34c827 + 325f95f commit 87cf158
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,10 @@ class ur_queue_flags_v(IntEnum):
## semantics. Implementation chooses submission mode.
SUBMISSION_IMMEDIATE = UR_BIT(8) ## Hint: enqueue and submit immediately. No change in queue semantics.
## Implementation chooses submission mode.
USE_DEFAULT_STREAM = UR_BIT(9) ## Use the default stream. Only meaningful for CUDA. Other platforms may
## ignore this flag.
SYNC_WITH_DEFAULT_STREAM = UR_BIT(10) ## Synchronize with the default stream. Only meaningful for CUDA. Other
## platforms may ignore this flag.

class ur_queue_flags_t(c_int):
def __str__(self):
Expand Down
6 changes: 5 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -4356,13 +4356,17 @@ typedef enum ur_queue_flag_t {
///< semantics. Implementation chooses submission mode.
UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE = UR_BIT(8), ///< Hint: enqueue and submit immediately. No change in queue semantics.
///< Implementation chooses submission mode.
UR_QUEUE_FLAG_USE_DEFAULT_STREAM = UR_BIT(9), ///< Use the default stream. Only meaningful for CUDA. Other platforms may
///< ignore this flag.
UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM = UR_BIT(10), ///< Synchronize with the default stream. Only meaningful for CUDA. Other
///< platforms may ignore this flag.
/// @cond
UR_QUEUE_FLAG_FORCE_UINT32 = 0x7fffffff
/// @endcond

} ur_queue_flag_t;
/// @brief Bit Mask for validating ur_queue_flags_t
#define UR_QUEUE_FLAGS_MASK 0xfffffe00
#define UR_QUEUE_FLAGS_MASK 0xfffff800

///////////////////////////////////////////////////////////////////////////////
/// @brief Query information about a command queue
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ etors:
- name: SUBMISSION_IMMEDIATE
value: "$X_BIT(8)"
desc: "Hint: enqueue and submit immediately. No change in queue semantics. Implementation chooses submission mode."
- name: USE_DEFAULT_STREAM
desc: "Use the default stream. Only meaningful for CUDA. Other platforms may ignore this flag."
value: "$X_BIT(9)"
- name: SYNC_WITH_DEFAULT_STREAM
desc: "Synchronize with the default stream. Only meaningful for CUDA. Other platforms may ignore this flag."
value: "$X_BIT(10)"
--- #--------------------------------------------------------------------------
type: function
desc: "Query information about a command queue"
Expand Down
30 changes: 30 additions & 0 deletions source/common/ur_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7764,6 +7764,14 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_queue_flag_t value) {
case UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE:
os << "UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE";
break;

case UR_QUEUE_FLAG_USE_DEFAULT_STREAM:
os << "UR_QUEUE_FLAG_USE_DEFAULT_STREAM";
break;

case UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM:
os << "UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -7874,6 +7882,28 @@ inline void serializeFlag<ur_queue_flag_t>(std::ostream &os, uint32_t flag) {
}
os << UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE;
}

if ((val & UR_QUEUE_FLAG_USE_DEFAULT_STREAM) ==
(uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM) {
val ^= (uint32_t)UR_QUEUE_FLAG_USE_DEFAULT_STREAM;
if (!first) {
os << " | ";
} else {
first = false;
}
os << UR_QUEUE_FLAG_USE_DEFAULT_STREAM;
}

if ((val & UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) ==
(uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM) {
val ^= (uint32_t)UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM;
if (!first) {
os << " | ";
} else {
first = false;
}
os << UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM;
}
if (val != 0) {
std::bitset<32> bits(val);
if (!first) {
Expand Down

0 comments on commit 87cf158

Please sign in to comment.