Skip to content

Commit

Permalink
Merge pull request #372 from igchor/usm_rename
Browse files Browse the repository at this point in the history
[ur] unify usm_advice naming
  • Loading branch information
pbalcer authored Mar 30, 2023
2 parents a5e5b8f + 89d5832 commit cdca7c1
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 164 deletions.
28 changes: 14 additions & 14 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,20 +988,20 @@ def __str__(self):

###############################################################################
## @brief USM memory advice
class ur_mem_advice_v(IntEnum):
class ur_usm_advice_v(IntEnum):
DEFAULT = 0 ## The USM memory advice is default
SET_READ_MOSTLY = 1 ## Hint that memory will be read from frequently and written to rarely
CLEAR_READ_MOSTLY = 2 ## Removes the affect of ::::UR_MEM_ADVICE_SET_READ_MOSTLY
CLEAR_READ_MOSTLY = 2 ## Removes the affect of ::::UR_USM_ADVICE_SET_READ_MOSTLY
SET_PREFERRED_LOCATION = 3 ## Hint that the preferred memory location is the specified device
CLEAR_PREFERRED_LOCATION = 4 ## Removes the affect of ::::UR_MEM_ADVICE_SET_PREFERRED_LOCATION
CLEAR_PREFERRED_LOCATION = 4 ## Removes the affect of ::::UR_USM_ADVICE_SET_PREFERRED_LOCATION
SET_NON_ATOMIC_MOSTLY = 5 ## Hints that memory will mostly be accessed non-atomically
CLEAR_NON_ATOMIC_MOSTLY = 6 ## Removes the affect of ::::UR_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY
CLEAR_NON_ATOMIC_MOSTLY = 6 ## Removes the affect of ::::UR_USM_ADVICE_SET_NON_ATOMIC_MOSTLY
BIAS_CACHED = 7 ## Hints that memory should be cached
BIAS_UNCACHED = 8 ## Hints that memory should be not be cached

class ur_mem_advice_t(c_int):
class ur_usm_advice_t(c_int):
def __str__(self):
return str(ur_mem_advice_v(self.value))
return str(ur_usm_advice_v(self.value))


###############################################################################
Expand All @@ -1016,7 +1016,7 @@ class ur_usm_desc_t(Structure):
("stype", ur_structure_type_t), ## [in] type of this structure, must be ::UR_STRUCTURE_TYPE_USM_DESC
("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure
("flags", ur_usm_flags_t), ## [in] memory allocation flags.
("hints", ur_mem_advice_t), ## [in] Memory advice hints
("hints", ur_usm_advice_t), ## [in] Memory advice hints
("align", c_ulong) ## [in] memory advice hints.
]

Expand Down Expand Up @@ -1316,7 +1316,7 @@ class ur_command_v(IntEnum):
USM_FILL = 17 ## Event created by ::urEnqueueUSMFill
USM_MEMCPY = 18 ## Event created by ::urEnqueueUSMMemcpy
USM_PREFETCH = 19 ## Event created by ::urEnqueueUSMPrefetch
USM_MEM_ADVISE = 20 ## Event created by ::urEnqueueUSMMemAdvise
USM_ADVISE = 20 ## Event created by ::urEnqueueUSMAdvise
USM_FILL_2D = 21 ## Event created by ::urEnqueueUSMFill2D
USM_MEMCPY_2D = 22 ## Event created by ::urEnqueueUSMMemcpy2D
DEVICE_GLOBAL_VARIABLE_WRITE = 23 ## Event created by ::urEnqueueDeviceGlobalVariableWrite
Expand Down Expand Up @@ -1433,7 +1433,7 @@ class ur_function_v(IntEnum):
ENQUEUE_USM_FILL = 32 ## Enumerator for ::urEnqueueUSMFill
ENQUEUE_USM_MEMCPY = 33 ## Enumerator for ::urEnqueueUSMMemcpy
ENQUEUE_USM_PREFETCH = 34 ## Enumerator for ::urEnqueueUSMPrefetch
ENQUEUE_USM_MEM_ADVISE = 35 ## Enumerator for ::urEnqueueUSMMemAdvise
ENQUEUE_USM_ADVISE = 35 ## Enumerator for ::urEnqueueUSMAdvise
ENQUEUE_USM_FILL2_D = 36 ## Enumerator for ::urEnqueueUSMFill2D
ENQUEUE_USM_MEMCPY2_D = 37 ## Enumerator for ::urEnqueueUSMMemcpy2D
ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38 ## Enumerator for ::urEnqueueDeviceGlobalVariableWrite
Expand Down Expand Up @@ -2222,11 +2222,11 @@ class ur_mem_dditable_t(Structure):
_urEnqueueUSMPrefetch_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_size_t, ur_usm_migration_flags_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) )

###############################################################################
## @brief Function-pointer for urEnqueueUSMMemAdvise
## @brief Function-pointer for urEnqueueUSMAdvise
if __use_win_types:
_urEnqueueUSMMemAdvise_t = WINFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_size_t, ur_mem_advice_t, POINTER(ur_event_handle_t) )
_urEnqueueUSMAdvise_t = WINFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_size_t, ur_usm_advice_t, POINTER(ur_event_handle_t) )
else:
_urEnqueueUSMMemAdvise_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_size_t, ur_mem_advice_t, POINTER(ur_event_handle_t) )
_urEnqueueUSMAdvise_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_size_t, ur_usm_advice_t, POINTER(ur_event_handle_t) )

###############################################################################
## @brief Function-pointer for urEnqueueUSMFill2D
Expand Down Expand Up @@ -2279,7 +2279,7 @@ class ur_enqueue_dditable_t(Structure):
("pfnUSMFill", c_void_p), ## _urEnqueueUSMFill_t
("pfnUSMMemcpy", c_void_p), ## _urEnqueueUSMMemcpy_t
("pfnUSMPrefetch", c_void_p), ## _urEnqueueUSMPrefetch_t
("pfnUSMMemAdvise", c_void_p), ## _urEnqueueUSMMemAdvise_t
("pfnUSMAdvise", c_void_p), ## _urEnqueueUSMAdvise_t
("pfnUSMFill2D", c_void_p), ## _urEnqueueUSMFill2D_t
("pfnUSMMemcpy2D", c_void_p), ## _urEnqueueUSMMemcpy2D_t
("pfnDeviceGlobalVariableWrite", c_void_p), ## _urEnqueueDeviceGlobalVariableWrite_t
Expand Down Expand Up @@ -2715,7 +2715,7 @@ def __init__(self, version : ur_api_version_t):
self.urEnqueueUSMFill = _urEnqueueUSMFill_t(self.__dditable.Enqueue.pfnUSMFill)
self.urEnqueueUSMMemcpy = _urEnqueueUSMMemcpy_t(self.__dditable.Enqueue.pfnUSMMemcpy)
self.urEnqueueUSMPrefetch = _urEnqueueUSMPrefetch_t(self.__dditable.Enqueue.pfnUSMPrefetch)
self.urEnqueueUSMMemAdvise = _urEnqueueUSMMemAdvise_t(self.__dditable.Enqueue.pfnUSMMemAdvise)
self.urEnqueueUSMAdvise = _urEnqueueUSMAdvise_t(self.__dditable.Enqueue.pfnUSMAdvise)
self.urEnqueueUSMFill2D = _urEnqueueUSMFill2D_t(self.__dditable.Enqueue.pfnUSMFill2D)
self.urEnqueueUSMMemcpy2D = _urEnqueueUSMMemcpy2D_t(self.__dditable.Enqueue.pfnUSMMemcpy2D)
self.urEnqueueDeviceGlobalVariableWrite = _urEnqueueDeviceGlobalVariableWrite_t(self.__dditable.Enqueue.pfnDeviceGlobalVariableWrite)
Expand Down
52 changes: 26 additions & 26 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2199,21 +2199,21 @@ typedef enum ur_usm_alloc_info_t {

///////////////////////////////////////////////////////////////////////////////
/// @brief USM memory advice
typedef enum ur_mem_advice_t {
UR_MEM_ADVICE_DEFAULT = 0, ///< The USM memory advice is default
UR_MEM_ADVICE_SET_READ_MOSTLY = 1, ///< Hint that memory will be read from frequently and written to rarely
UR_MEM_ADVICE_CLEAR_READ_MOSTLY = 2, ///< Removes the affect of ::::UR_MEM_ADVICE_SET_READ_MOSTLY
UR_MEM_ADVICE_SET_PREFERRED_LOCATION = 3, ///< Hint that the preferred memory location is the specified device
UR_MEM_ADVICE_CLEAR_PREFERRED_LOCATION = 4, ///< Removes the affect of ::::UR_MEM_ADVICE_SET_PREFERRED_LOCATION
UR_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY = 5, ///< Hints that memory will mostly be accessed non-atomically
UR_MEM_ADVICE_CLEAR_NON_ATOMIC_MOSTLY = 6, ///< Removes the affect of ::::UR_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY
UR_MEM_ADVICE_BIAS_CACHED = 7, ///< Hints that memory should be cached
UR_MEM_ADVICE_BIAS_UNCACHED = 8, ///< Hints that memory should be not be cached
typedef enum ur_usm_advice_t {
UR_USM_ADVICE_DEFAULT = 0, ///< The USM memory advice is default
UR_USM_ADVICE_SET_READ_MOSTLY = 1, ///< Hint that memory will be read from frequently and written to rarely
UR_USM_ADVICE_CLEAR_READ_MOSTLY = 2, ///< Removes the affect of ::::UR_USM_ADVICE_SET_READ_MOSTLY
UR_USM_ADVICE_SET_PREFERRED_LOCATION = 3, ///< Hint that the preferred memory location is the specified device
UR_USM_ADVICE_CLEAR_PREFERRED_LOCATION = 4, ///< Removes the affect of ::::UR_USM_ADVICE_SET_PREFERRED_LOCATION
UR_USM_ADVICE_SET_NON_ATOMIC_MOSTLY = 5, ///< Hints that memory will mostly be accessed non-atomically
UR_USM_ADVICE_CLEAR_NON_ATOMIC_MOSTLY = 6, ///< Removes the affect of ::::UR_USM_ADVICE_SET_NON_ATOMIC_MOSTLY
UR_USM_ADVICE_BIAS_CACHED = 7, ///< Hints that memory should be cached
UR_USM_ADVICE_BIAS_UNCACHED = 8, ///< Hints that memory should be not be cached
/// @cond
UR_MEM_ADVICE_FORCE_UINT32 = 0x7fffffff
UR_USM_ADVICE_FORCE_UINT32 = 0x7fffffff
/// @endcond

} ur_mem_advice_t;
} ur_usm_advice_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Handle of USM pool
Expand All @@ -2225,7 +2225,7 @@ typedef struct ur_usm_desc_t {
ur_structure_type_t stype; ///< [in] type of this structure, must be ::UR_STRUCTURE_TYPE_USM_DESC
const void *pNext; ///< [in][optional] pointer to extension-specific structure
ur_usm_flags_t flags; ///< [in] memory allocation flags.
ur_mem_advice_t hints; ///< [in] Memory advice hints
ur_usm_advice_t hints; ///< [in] Memory advice hints
uint32_t align; ///< [in] memory advice hints.

} ur_usm_desc_t;
Expand Down Expand Up @@ -3788,7 +3788,7 @@ typedef enum ur_command_t {
UR_COMMAND_USM_FILL = 17, ///< Event created by ::urEnqueueUSMFill
UR_COMMAND_USM_MEMCPY = 18, ///< Event created by ::urEnqueueUSMMemcpy
UR_COMMAND_USM_PREFETCH = 19, ///< Event created by ::urEnqueueUSMPrefetch
UR_COMMAND_USM_MEM_ADVISE = 20, ///< Event created by ::urEnqueueUSMMemAdvise
UR_COMMAND_USM_ADVISE = 20, ///< Event created by ::urEnqueueUSMAdvise
UR_COMMAND_USM_FILL_2D = 21, ///< Event created by ::urEnqueueUSMFill2D
UR_COMMAND_USM_MEMCPY_2D = 22, ///< Event created by ::urEnqueueUSMMemcpy2D
UR_COMMAND_DEVICE_GLOBAL_VARIABLE_WRITE = 23, ///< Event created by ::urEnqueueDeviceGlobalVariableWrite
Expand Down Expand Up @@ -4123,7 +4123,7 @@ typedef enum ur_function_t {
UR_FUNCTION_ENQUEUE_USM_FILL = 32, ///< Enumerator for ::urEnqueueUSMFill
UR_FUNCTION_ENQUEUE_USM_MEMCPY = 33, ///< Enumerator for ::urEnqueueUSMMemcpy
UR_FUNCTION_ENQUEUE_USM_PREFETCH = 34, ///< Enumerator for ::urEnqueueUSMPrefetch
UR_FUNCTION_ENQUEUE_USM_MEM_ADVISE = 35, ///< Enumerator for ::urEnqueueUSMMemAdvise
UR_FUNCTION_ENQUEUE_USM_ADVISE = 35, ///< Enumerator for ::urEnqueueUSMAdvise
UR_FUNCTION_ENQUEUE_USM_FILL2_D = 36, ///< Enumerator for ::urEnqueueUSMFill2D
UR_FUNCTION_ENQUEUE_USM_MEMCPY2_D = 37, ///< Enumerator for ::urEnqueueUSMMemcpy2D
UR_FUNCTION_ENQUEUE_DEVICE_GLOBAL_VARIABLE_WRITE = 38, ///< Enumerator for ::urEnqueueDeviceGlobalVariableWrite
Expand Down Expand Up @@ -5125,7 +5125,7 @@ urEnqueueUSMPrefetch(
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == pMem`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_MEM_ADVICE_BIAS_UNCACHED < advice`
/// + `::UR_USM_ADVICE_BIAS_UNCACHED < advice`
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
/// - ::UR_RESULT_ERROR_INVALID_EVENT
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand All @@ -5135,11 +5135,11 @@ urEnqueueUSMPrefetch(
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
UR_APIEXPORT ur_result_t UR_APICALL
urEnqueueUSMMemAdvise(
urEnqueueUSMAdvise(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
const void *pMem, ///< [in] pointer to the USM memory object
size_t size, ///< [in] size in bytes to be advised
ur_mem_advice_t advice, ///< [in] USM memory advice
ur_usm_advice_t advice, ///< [in] USM memory advice
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies this particular
///< command instance.
);
Expand Down Expand Up @@ -7322,25 +7322,25 @@ typedef void(UR_APICALL *ur_pfnEnqueueUSMPrefetchCb_t)(
void **ppTracerInstanceUserData);

///////////////////////////////////////////////////////////////////////////////
/// @brief Callback function parameters for urEnqueueUSMMemAdvise
/// @brief Callback function parameters for urEnqueueUSMAdvise
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_enqueue_usm_mem_advise_params_t {
typedef struct ur_enqueue_usm_advise_params_t {
ur_queue_handle_t *phQueue;
const void **ppMem;
size_t *psize;
ur_mem_advice_t *padvice;
ur_usm_advice_t *padvice;
ur_event_handle_t **pphEvent;
} ur_enqueue_usm_mem_advise_params_t;
} ur_enqueue_usm_advise_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Callback function-pointer for urEnqueueUSMMemAdvise
/// @brief Callback function-pointer for urEnqueueUSMAdvise
/// @param[in] params Parameters passed to this instance
/// @param[in] result Return value
/// @param[in] pTracerUserData Per-Tracer user data
/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data
typedef void(UR_APICALL *ur_pfnEnqueueUSMMemAdviseCb_t)(
ur_enqueue_usm_mem_advise_params_t *params,
typedef void(UR_APICALL *ur_pfnEnqueueUSMAdviseCb_t)(
ur_enqueue_usm_advise_params_t *params,
ur_result_t result,
void *pTracerUserData,
void **ppTracerInstanceUserData);
Expand Down Expand Up @@ -7483,7 +7483,7 @@ typedef struct ur_enqueue_callbacks_t {
ur_pfnEnqueueUSMFillCb_t pfnUSMFillCb;
ur_pfnEnqueueUSMMemcpyCb_t pfnUSMMemcpyCb;
ur_pfnEnqueueUSMPrefetchCb_t pfnUSMPrefetchCb;
ur_pfnEnqueueUSMMemAdviseCb_t pfnUSMMemAdviseCb;
ur_pfnEnqueueUSMAdviseCb_t pfnUSMAdviseCb;
ur_pfnEnqueueUSMFill2DCb_t pfnUSMFill2DCb;
ur_pfnEnqueueUSMMemcpy2DCb_t pfnUSMMemcpy2DCb;
ur_pfnEnqueueDeviceGlobalVariableWriteCb_t pfnDeviceGlobalVariableWriteCb;
Expand Down
8 changes: 4 additions & 4 deletions include/ur_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -953,12 +953,12 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMPrefetch_t)(
ur_event_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urEnqueueUSMMemAdvise
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMMemAdvise_t)(
/// @brief Function-pointer for urEnqueueUSMAdvise
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMAdvise_t)(
ur_queue_handle_t,
const void *,
size_t,
ur_mem_advice_t,
ur_usm_advice_t,
ur_event_handle_t *);

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1039,7 +1039,7 @@ typedef struct ur_enqueue_dditable_t {
ur_pfnEnqueueUSMFill_t pfnUSMFill;
ur_pfnEnqueueUSMMemcpy_t pfnUSMMemcpy;
ur_pfnEnqueueUSMPrefetch_t pfnUSMPrefetch;
ur_pfnEnqueueUSMMemAdvise_t pfnUSMMemAdvise;
ur_pfnEnqueueUSMAdvise_t pfnUSMAdvise;
ur_pfnEnqueueUSMFill2D_t pfnUSMFill2D;
ur_pfnEnqueueUSMMemcpy2D_t pfnUSMMemcpy2D;
ur_pfnEnqueueDeviceGlobalVariableWrite_t pfnDeviceGlobalVariableWrite;
Expand Down
4 changes: 2 additions & 2 deletions scripts/core/enqueue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ returns:
type: function
desc: "Enqueue a command to set USM memory advice"
class: $xEnqueue
name: USMMemAdvise
name: USMAdvise
ordinal: "0"
params:
- type: $x_queue_handle_t
Expand All @@ -1127,7 +1127,7 @@ params:
- type: size_t
name: size
desc: "[in] size in bytes to be advised"
- type: $x_mem_advice_t
- type: $x_usm_advice_t
name: advice
desc: "[in] USM memory advice"
- type: $x_event_handle_t*
Expand Down
4 changes: 2 additions & 2 deletions scripts/core/event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ etors:
desc: Event created by $xEnqueueUSMMemcpy
- name: USM_PREFETCH
desc: Event created by $xEnqueueUSMPrefetch
- name: USM_MEM_ADVISE
desc: Event created by $xEnqueueUSMMemAdvise
- name: USM_ADVISE
desc: Event created by $xEnqueueUSMAdvise
- name: USM_FILL_2D
desc: Event created by $xEnqueueUSMFill2D
- name: USM_MEMCPY_2D
Expand Down
4 changes: 2 additions & 2 deletions scripts/core/registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ etors:
- name: ENQUEUE_USM_PREFETCH
desc: Enumerator for $xEnqueueUSMPrefetch
value: '34'
- name: ENQUEUE_USM_MEM_ADVISE
desc: Enumerator for $xEnqueueUSMMemAdvise
- name: ENQUEUE_USM_ADVISE
desc: Enumerator for $xEnqueueUSMAdvise
value: '35'
- name: ENQUEUE_USM_FILL2_D
desc: Enumerator for $xEnqueueUSMFill2D
Expand Down
10 changes: 5 additions & 5 deletions scripts/core/usm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ etors:
type: enum
desc: "USM memory advice"
class: $xUSM
name: $x_mem_advice_t
name: $x_usm_advice_t
etors:
- name: DEFAULT
desc: "The USM memory advice is default"
- name: SET_READ_MOSTLY
desc: "Hint that memory will be read from frequently and written to rarely"
- name: CLEAR_READ_MOSTLY
desc: "Removes the affect of ::$X_MEM_ADVICE_SET_READ_MOSTLY"
desc: "Removes the affect of ::$X_USM_ADVICE_SET_READ_MOSTLY"
- name: SET_PREFERRED_LOCATION
desc: "Hint that the preferred memory location is the specified device"
- name: CLEAR_PREFERRED_LOCATION
desc: "Removes the affect of ::$X_MEM_ADVICE_SET_PREFERRED_LOCATION"
desc: "Removes the affect of ::$X_USM_ADVICE_SET_PREFERRED_LOCATION"
- name: SET_NON_ATOMIC_MOSTLY
desc: "Hints that memory will mostly be accessed non-atomically"
- name: CLEAR_NON_ATOMIC_MOSTLY
desc: "Removes the affect of ::$X_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY"
desc: "Removes the affect of ::$X_USM_ADVICE_SET_NON_ATOMIC_MOSTLY"
- name: BIAS_CACHED
desc: "Hints that memory should be cached"
- name: BIAS_UNCACHED
Expand All @@ -123,7 +123,7 @@ members:
- type: $x_usm_flags_t
name: flags
desc: "[in] memory allocation flags."
- type: $x_mem_advice_t
- type: $x_usm_advice_t
name: hints
desc: "[in] Memory advice hints"
- type: uint32_t
Expand Down
Loading

0 comments on commit cdca7c1

Please sign in to comment.