Skip to content

Commit 5beab76

Browse files
author
Jaime Arteaga
authored
Add API to set atomic properties of a shared allocation (#173)
Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 30a1671 commit 5beab76

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

scripts/core/memory.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,3 +540,102 @@ type: class
540540
desc: "C++ wrapper for memory allocation"
541541
name: $xMem
542542
owner: $xContext
543+
--- #--------------------------------------------------------------------------
544+
type: enum
545+
desc: "atomic access attribute flags"
546+
class: $xMem
547+
name: $x_memory_atomic_attr_exp_flags_t
548+
version: "1.7"
549+
etors:
550+
- name: NO_ATOMICS
551+
desc: "Atomics on the pointer are not allowed"
552+
- name: NO_HOST_ATOMICS
553+
desc: "Host atomics on the pointer are not allowed"
554+
- name: HOST_ATOMICS
555+
desc: "Host atomics on the pointer are allowed. Requires $X_MEMORY_ACCESS_CAP_FLAG_ATOMIC returned by $xDeviceGetMemoryAccessProperties."
556+
- name: NO_DEVICE_ATOMICS
557+
desc: "Device atomics on the pointer are not allowed"
558+
- name: DEVICE_ATOMICS
559+
desc: "Device atomics on the pointer are allowed. Requires $X_MEMORY_ACCESS_CAP_FLAG_ATOMIC returned by $xDeviceGetMemoryAccessProperties."
560+
- name: NO_SYSTEM_ATOMICS
561+
desc: "Concurrent atomics on the pointer from both host and device are not allowed"
562+
- name: SYSTEM_ATOMICS
563+
desc: "Concurrent atomics on the pointer from both host and device are allowed. Requires $X_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC returned by $xDeviceGetMemoryAccessProperties."
564+
--- #--------------------------------------------------------------------------
565+
type: function
566+
desc: "Sets atomic access attributes for a shared allocation"
567+
class: $xMem
568+
name: SetAtomicAccessAttributeExp
569+
version: "1.7"
570+
details:
571+
- |
572+
If the shared-allocation is owned by multiple devices (i.e. nullptr
573+
was passed to $xMemAllocShared when creating it), then hDevice may be
574+
passed to set the attributes in that specific device. If nullptr is
575+
passed in hDevice, then the atomic attributes are set in all devices
576+
associated with the allocation.
577+
- |
578+
If the atomic access attribute select is not supported by the driver,
579+
$X_RESULT_INVALID_ARGUMENT is returned.
580+
- |
581+
The atomic access attribute may be only supported at a device-specific
582+
granularity, such as at a page boundary. In this case, the memory range
583+
may be expanded such that the start and end of the range satisfy granularity
584+
requirements.
585+
- |
586+
When calling this function multiple times with different flags, only the
587+
attributes from last call are honored.
588+
- |
589+
The application must not call this function for shared-allocations currently
590+
being used by the device.
591+
- |
592+
The application must **not** call this function from simultaneous threads
593+
with the same pointer.
594+
- |
595+
The implementation of this function should be lock-free.
596+
params:
597+
- type: $x_context_handle_t
598+
name: hContext
599+
desc: "[in] handle of context"
600+
- type: "$x_device_handle_t"
601+
name: hDevice
602+
desc: "[in] device associated with the memory advice"
603+
- type: "const void*"
604+
name: ptr
605+
desc: "[in] Pointer to the start of the memory range"
606+
- type: size_t
607+
name: size
608+
desc: "[in] Size in bytes of the memory range"
609+
- type: $x_memory_atomic_attr_exp_flags_t
610+
name: attr
611+
desc: |
612+
[in] Atomic access attributes to set for the specified range.
613+
Must be 0 (default) or a valid combination of $x_memory_atomic_attr_exp_flag_t.
614+
--- #--------------------------------------------------------------------------
615+
type: function
616+
desc: "Retrieves the atomic access attributes previously set for a shared allocation"
617+
class: $xMem
618+
name: GetAtomicAccessAttributeExp
619+
version: "1.7"
620+
details:
621+
- |
622+
The application may call this function from simultaneous threads
623+
with the same pointer.
624+
- |
625+
The implementation of this function should be lock-free.
626+
params:
627+
- type: $x_context_handle_t
628+
name: hContext
629+
desc: "[in] handle of context"
630+
- type: "$x_device_handle_t"
631+
name: hDevice
632+
desc: "[in] device associated with the memory advice"
633+
- type: "const void*"
634+
name: ptr
635+
desc: "[in] Pointer to the start of the memory range"
636+
- type: size_t
637+
name: size
638+
desc: "[in] Size in bytes of the memory range"
639+
- type: "$x_memory_atomic_attr_exp_flags_t*"
640+
name: pAttr
641+
desc: "[out] Atomic access attributes for the specified range"

0 commit comments

Comments
 (0)