Skip to content
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

[ur] Add NONE to virtual mem access flags #638

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,9 @@ def __str__(self):
###############################################################################
## @brief Virtual memory access mode flags.
class ur_virtual_mem_access_flags_v(IntEnum):
READ_WRITE = UR_BIT(0) ## Virtual memory both read and write accessible
READ_ONLY = UR_BIT(1) ##
NONE = UR_BIT(0) ## Virtual memory has no access.
READ_WRITE = UR_BIT(1) ## Virtual memory has both read and write access.
READ_ONLY = UR_BIT(2) ## Virtual memory has read only access.

class ur_virtual_mem_access_flags_t(c_int):
def __str__(self):
Expand Down
7 changes: 4 additions & 3 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -3055,15 +3055,16 @@ urVirtualMemFree(
/// @brief Virtual memory access mode flags.
typedef uint32_t ur_virtual_mem_access_flags_t;
typedef enum ur_virtual_mem_access_flag_t {
UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE = UR_BIT(0), ///< Virtual memory both read and write accessible
UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY = UR_BIT(1), ///<
UR_VIRTUAL_MEM_ACCESS_FLAG_NONE = UR_BIT(0), ///< Virtual memory has no access.
UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE = UR_BIT(1), ///< Virtual memory has both read and write access.
UR_VIRTUAL_MEM_ACCESS_FLAG_READ_ONLY = UR_BIT(2), ///< Virtual memory has read only access.
/// @cond
UR_VIRTUAL_MEM_ACCESS_FLAG_FORCE_UINT32 = 0x7fffffff
/// @endcond

} ur_virtual_mem_access_flag_t;
/// @brief Bit Mask for validating ur_virtual_mem_access_flags_t
#define UR_VIRTUAL_MEM_ACCESS_FLAGS_MASK 0xfffffffc
#define UR_VIRTUAL_MEM_ACCESS_FLAGS_MASK 0xfffffff8

///////////////////////////////////////////////////////////////////////////////
/// @brief Map a virtual memory range to a physical memory handle.
Expand Down
11 changes: 7 additions & 4 deletions scripts/core/virtual_memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ desc: "Virtual memory access mode flags."
class: $xVirtualMem
name: $x_virtual_mem_access_flags_t
etors:
- name: READ_WRITE
- name: NONE
value: $X_BIT(0)
desc: "Virtual memory both read and write accessible"
- name: READ_ONLY
desc: "Virtual memory has no access."
- name: READ_WRITE
value: $X_BIT(1)
desc: ""
desc: "Virtual memory has both read and write access."
- name: READ_ONLY
value: $X_BIT(2)
desc: "Virtual memory has read only access."

--- #--------------------------------------------------------------------------
type: function
Expand Down
15 changes: 15 additions & 0 deletions source/common/ur_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6437,6 +6437,10 @@ inline std::ostream &operator<<(std::ostream &os,
enum ur_virtual_mem_access_flag_t value) {
switch (value) {

case UR_VIRTUAL_MEM_ACCESS_FLAG_NONE:
os << "UR_VIRTUAL_MEM_ACCESS_FLAG_NONE";
break;

case UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE:
os << "UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE";
break;
Expand All @@ -6458,6 +6462,17 @@ inline void serializeFlag<ur_virtual_mem_access_flag_t>(std::ostream &os,
uint32_t val = flag;
bool first = true;

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

if ((val & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) ==
(uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) {
val ^= (uint32_t)UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE;
Expand Down