1"""Enum values for HSA from the HSA extension header
2
3Note that Python namespacing could be used to avoid the C-like
4prefixing, but we choose to keep the same names as found in the C
5enums, in order to match the documentation.
6"""
7
8# These enums are a direct translation of those found in:
9# hsa_ext_amd.h from the ROCR-Runtime. For example:
10# https://github.com/RadeonOpenCompute/ROCR-Runtime/blob/master/src/inc/hsa_ext_amd.h
11# Comments relating to the values are largely wholesale copied.
12
13import ctypes
14
15
16#------------------------------------------------------------------------------
17#
18# Anonymous enum expressing that a memory pool is invalid
19#
20HSA_STATUS_ERROR_INVALID_MEMORY_POOL = 40
21#------------------------------------------------------------------------------
22
23
24#------------------------------------------------------------------------------
25#
26# Agent attributes
27#
28# Enums of the type hsa_amd_agent_info_t
29
30# Chip identifier. The type of this attribute is uint32_t.
31HSA_AMD_AGENT_INFO_CHIP_ID = 0xA000
32
33# Size of a cacheline in bytes. The type of this attribute is uint32_t.
34HSA_AMD_AGENT_INFO_CACHELINE_SIZE = 0xA001
35
36# The number of compute unit available in the agent. The type of this
37# attribute is uint32_t.
38HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT = 0xA002
39
40# The maximum clock frequency of the agent in MHz. The type of this
41# attribute is uint32_t.
42HSA_AMD_AGENT_INFO_MAX_CLOCK_FREQUENCY = 0xA003
43
44# Internay driver node identifier. The type of this attribute is uint32_t.
45HSA_AMD_AGENT_INFO_DRIVER_NODE_ID = 0xA004
46
47# Max number of watch points on memory address ranges to generate exception
48# events when the watched addresses are accessed.
49HSA_AMD_AGENT_INFO_MAX_ADDRESS_WATCH_POINTS = 0xA005
50#------------------------------------------------------------------------------
51
52
53#------------------------------------------------------------------------------
54#
55# Region attributes
56#
57# Enums of the type hsa_amd_region_info_t
58
59# Determine if host can access the region. The type of this attribute is bool.
60HSA_AMD_REGION_INFO_HOST_ACCESSIBLE = 0xA000
61
62# Base address of the region in flat address space.
63HSA_AMD_REGION_INFO_BASE = 0xA001
64
65# Memory Interface width, the return value type is uint32_t.
66# This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_WIDTH.
67HSA_AMD_REGION_INFO_BUS_WIDTH = 0xA002
68
69# Max Memory Clock, the return value type is uint32_t.
70# This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY.
71HSA_AMD_REGION_INFO_MAX_CLOCK_FREQUENCY = 0xA003
72#------------------------------------------------------------------------------
73
74
75#------------------------------------------------------------------------------
76#
77# Coherency attributes of a fine grained region
78#
79# Enums of the type hsa_amd_coherency_type_t
80
81# Coherent region.
82HSA_AMD_COHERENCY_TYPE_COHERENT = 0
83
84# Non coherent region.
85HSA_AMD_COHERENCY_TYPE_NONCOHERENT = 1
86#------------------------------------------------------------------------------
87
88
89#------------------------------------------------------------------------------
90#
91# Memory segments associated with a memory pool.
92#
93# Enums of the type hsa_amd_segment_t
94
95# Global segment. Used to hold data that is shared by all agents.
96HSA_AMD_SEGMENT_GLOBAL = 0
97
98# Read-only segment. Used to hold data that remains constant during the
99# execution of a kernel.
100HSA_AMD_SEGMENT_READONLY = 1
101
102# Private segment. Used to hold data that is local to a single work-item.
103HSA_AMD_SEGMENT_PRIVATE = 2
104
105# Group segment. Used to hold data that is shared by the work-items of a
106# work-group.
107HSA_AMD_SEGMENT_GROUP = 3
108#------------------------------------------------------------------------------
109
110
111#------------------------------------------------------------------------------
112#
113# Memory pool global flags.
114#
115# Enums of the type hsa_amd_memory_pool_global_flag_t.
116
117# The application can use allocations in the memory pool to store kernel
118# arguments, and provide the values for the kernarg segment of
119# a kernel dispatch.
120HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT = 1
121
122# Updates to memory in this pool conform to HSA memory consistency model.
123# If this flag is set, then HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED
124# must not be set.
125HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED = 2
126
127# Writes to memory in this pool can be performed by a single agent at a time.
128HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED = 4
129#------------------------------------------------------------------------------
130
131
132#------------------------------------------------------------------------------
133#
134# Memory pool features flags.
135#
136# Enums of the type hsa_amd_memory_pool_info_t.
137
138# Segment where the memory pool resides. The type of this attribute is
139# hsa_amd_segment_t.
140HSA_AMD_MEMORY_POOL_INFO_SEGMENT = 0
141
142# Flag mask. The value of this attribute is undefined if the value of
143# HSA_AMD_MEMORY_POOL_INFO_SEGMENT is not HSA_AMD_SEGMENT_GLOBAL. The type
144# of this attribute is uint32_t, a bit-field of
145# hsa_amd_memory_pool_global_flag_t values.
146HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS = 1
147
148# Size of this pool, in bytes. The type of this attribute is size_t.
149HSA_AMD_MEMORY_POOL_INFO_SIZE = 2
150
151# Indicates whether memory in this pool can be allocated using
152# hsa_amd_memory_pool_allocate. The type of this attribute is bool.
153# The value of this flag is always false for memory pools in the group and
154# private segments.
155HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED = 5
156
157# Allocation granularity of buffers allocated by hsa_amd_memory_pool_allocate
158# in this memory pool. The size of a buffer allocated in this pool is a
159# multiple of the value of this attribute. The value of this attribute is
160# only defined if HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for
161# this pool. The type of this attribute is size_t.
162HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE = 6
163
164# Alignment of buffers allocated by hsa_amd_memory_pool_allocate in this
165# pool. The value of this attribute is only defined if
166# HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool, and
167# must be a power of 2. The type of this attribute is size_t.
168HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT = 7
169
170# This memory_pool can be made directly accessible by all the agents in the
171# system (hsa_amd_agent_memory_pool_get_info returns
172# HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT for all agents). The type of
173# this attribute is bool.
174HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL = 15
175#------------------------------------------------------------------------------
176
177
178#------------------------------------------------------------------------------
179#
180# Type of accesses to a memory pool from a given agent.
181#
182# Enums of the type hsa_amd_memory_pool_access_t
183
184# The agent cannot directly access any buffer in the memory pool.
185HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED = 0
186
187# The agent can directly access a buffer located in the pool; the application
188# does not need to invoke hsa_amd_agents_allow_access.
189HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT = 1
190
191# The agent can directly access a buffer located in the pool, but only if the
192# application has previously requested access to that buffer using
193# hsa_amd_agents_allow_access.
194HSA_AMD_MEMORY_POOL_ACCESS_DISALLOWED_BY_DEFAULT = 2
195#------------------------------------------------------------------------------
196
197
198#------------------------------------------------------------------------------
199#
200# Properties of the relationship between an agent a memory pool.
201#
202# Enums of the type hsa_amd_link_info_type_t
203
204# Hyper-transport bus type.
205HSA_AMD_LINK_INFO_TYPE_HYPERTRANSPORT = 0
206
207# QPI bus type.
208HSA_AMD_LINK_INFO_TYPE_QPI = 1
209
210# PCIe bus type.
211HSA_AMD_LINK_INFO_TYPE_PCIE = 2
212
213# Infiniband bus type.
214HSA_AMD_LINK_INFO_TYPE_INFINBAND = 3
215#------------------------------------------------------------------------------
216
217
218#------------------------------------------------------------------------------
219#
220# Access to buffers located in the memory pool. The type of this attribute
221# is hsa_amd_memory_pool_access_t.
222#
223# Enums of type hsa_amd_agent_memory_pool_info_t.
224
225# An agent can always directly access buffers currently located in a memory
226# pool that is associated (the memory_pool is one of the values returned by
227# hsa_amd_agent_iterate_memory_pools on the agent) with that agent. If the
228# buffer is currently located in a memory pool that is not associated with
229# the agent, and the value returned by this function for the given
230# combination of agent and memory pool is not
231# HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED, the application still needs to
232# invoke hsa_amd_agents_allow_access in order to gain direct access to the
233# buffer.
234
235# If the given agent can directly access buffers the pool, the result is not
236# HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is associated
237# with the agent, or it is of fined-grained type, the result must not be
238# HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is not
239# associated with the agent, and does not reside in the global segment, the
240# result must be HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED.
241HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS = 0
242
243# Number of links to hop when accessing the memory pool from the specified
244# agent. The type of this attribute is uint32_t.
245HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS = 1
246
247# Details of each link hop when accessing the memory pool starting from the
248# specified agent. The type of this attribute is an array size of
249# HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS with each element containing
250# hsa_amd_memory_pool_link_info_t.
251HSA_AMD_AGENT_MEMORY_POOL_INFO_LINK_INFO = 2
252#------------------------------------------------------------------------------
253
254
255