Skip to content

Commit

Permalink
[UR] Add CUDA-specific queue flags
Browse files Browse the repository at this point in the history
  • Loading branch information
callumfare committed Jun 20, 2023
1 parent cfa949f commit 325f95f
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 @@ -1632,6 +1632,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 @@ -4355,13 +4355,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 @@ -7749,6 +7749,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 @@ -7859,6 +7867,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 325f95f

Please sign in to comment.