triton-windows 3.2.0.post19__cp310-cp310-win_amd64.whl → 3.2.0.post21__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of triton-windows might be problematic. Click here for more details.

Files changed (110) hide show
  1. triton/_C/libtriton.pyd +0 -0
  2. triton/backends/amd/driver.py +6 -1
  3. triton/backends/nvidia/compiler.py +1 -3
  4. triton/backends/nvidia/driver.py +7 -3
  5. triton/runtime/autotuner.py +2 -2
  6. triton/runtime/build.py +5 -5
  7. triton/runtime/tcc/lib/python310.def +1610 -0
  8. triton/runtime/tcc/lib/python311.def +1633 -0
  9. triton/runtime/tcc/lib/python312.def +1703 -0
  10. triton/runtime/tcc/lib/python313.def +1651 -0
  11. triton/runtime/tcc/lib/python313t.def +1656 -0
  12. triton/runtime/tcc/lib/python39.def +1644 -0
  13. triton/runtime/tcc/lib/python3t.def +905 -0
  14. triton/windows_utils.py +11 -4
  15. {triton_windows-3.2.0.post19.dist-info → triton_windows-3.2.0.post21.dist-info}/METADATA +1 -1
  16. {triton_windows-3.2.0.post19.dist-info → triton_windows-3.2.0.post21.dist-info}/RECORD +18 -103
  17. {triton_windows-3.2.0.post19.dist-info → triton_windows-3.2.0.post21.dist-info}/WHEEL +1 -1
  18. triton/backends/amd/include/hip/amd_detail/amd_channel_descriptor.h +0 -358
  19. triton/backends/amd/include/hip/amd_detail/amd_device_functions.h +0 -1031
  20. triton/backends/amd/include/hip/amd_detail/amd_hip_atomic.h +0 -1612
  21. triton/backends/amd/include/hip/amd_detail/amd_hip_bf16.h +0 -1337
  22. triton/backends/amd/include/hip/amd_detail/amd_hip_bfloat16.h +0 -293
  23. triton/backends/amd/include/hip/amd_detail/amd_hip_common.h +0 -32
  24. triton/backends/amd/include/hip/amd_detail/amd_hip_complex.h +0 -174
  25. triton/backends/amd/include/hip/amd_detail/amd_hip_cooperative_groups.h +0 -829
  26. triton/backends/amd/include/hip/amd_detail/amd_hip_fp16.h +0 -1809
  27. triton/backends/amd/include/hip/amd_detail/amd_hip_gl_interop.h +0 -108
  28. triton/backends/amd/include/hip/amd_detail/amd_hip_math_constants.h +0 -124
  29. triton/backends/amd/include/hip/amd_detail/amd_hip_runtime.h +0 -405
  30. triton/backends/amd/include/hip/amd_detail/amd_hip_runtime_pt_api.h +0 -196
  31. triton/backends/amd/include/hip/amd_detail/amd_hip_unsafe_atomics.h +0 -565
  32. triton/backends/amd/include/hip/amd_detail/amd_hip_vector_types.h +0 -2226
  33. triton/backends/amd/include/hip/amd_detail/amd_math_functions.h +0 -104
  34. triton/backends/amd/include/hip/amd_detail/amd_surface_functions.h +0 -244
  35. triton/backends/amd/include/hip/amd_detail/amd_warp_functions.h +0 -494
  36. triton/backends/amd/include/hip/amd_detail/concepts.hpp +0 -30
  37. triton/backends/amd/include/hip/amd_detail/device_library_decls.h +0 -133
  38. triton/backends/amd/include/hip/amd_detail/functional_grid_launch.hpp +0 -218
  39. triton/backends/amd/include/hip/amd_detail/grid_launch.h +0 -67
  40. triton/backends/amd/include/hip/amd_detail/grid_launch.hpp +0 -50
  41. triton/backends/amd/include/hip/amd_detail/grid_launch_GGL.hpp +0 -26
  42. triton/backends/amd/include/hip/amd_detail/helpers.hpp +0 -137
  43. triton/backends/amd/include/hip/amd_detail/hip_api_trace.hpp +0 -1350
  44. triton/backends/amd/include/hip/amd_detail/hip_assert.h +0 -101
  45. triton/backends/amd/include/hip/amd_detail/hip_cooperative_groups_helper.h +0 -242
  46. triton/backends/amd/include/hip/amd_detail/hip_fp16_gcc.h +0 -254
  47. triton/backends/amd/include/hip/amd_detail/hip_fp16_math_fwd.h +0 -96
  48. triton/backends/amd/include/hip/amd_detail/hip_ldg.h +0 -100
  49. triton/backends/amd/include/hip/amd_detail/hip_prof_str.h +0 -10169
  50. triton/backends/amd/include/hip/amd_detail/hip_runtime_prof.h +0 -77
  51. triton/backends/amd/include/hip/amd_detail/host_defines.h +0 -180
  52. triton/backends/amd/include/hip/amd_detail/hsa_helpers.hpp +0 -102
  53. triton/backends/amd/include/hip/amd_detail/macro_based_grid_launch.hpp +0 -798
  54. triton/backends/amd/include/hip/amd_detail/math_fwd.h +0 -698
  55. triton/backends/amd/include/hip/amd_detail/ockl_image.h +0 -177
  56. triton/backends/amd/include/hip/amd_detail/program_state.hpp +0 -107
  57. triton/backends/amd/include/hip/amd_detail/texture_fetch_functions.h +0 -491
  58. triton/backends/amd/include/hip/amd_detail/texture_indirect_functions.h +0 -478
  59. triton/backends/amd/include/hip/channel_descriptor.h +0 -39
  60. triton/backends/amd/include/hip/device_functions.h +0 -38
  61. triton/backends/amd/include/hip/driver_types.h +0 -468
  62. triton/backends/amd/include/hip/hip_bf16.h +0 -36
  63. triton/backends/amd/include/hip/hip_bfloat16.h +0 -44
  64. triton/backends/amd/include/hip/hip_common.h +0 -100
  65. triton/backends/amd/include/hip/hip_complex.h +0 -38
  66. triton/backends/amd/include/hip/hip_cooperative_groups.h +0 -46
  67. triton/backends/amd/include/hip/hip_deprecated.h +0 -95
  68. triton/backends/amd/include/hip/hip_ext.h +0 -159
  69. triton/backends/amd/include/hip/hip_fp16.h +0 -36
  70. triton/backends/amd/include/hip/hip_gl_interop.h +0 -32
  71. triton/backends/amd/include/hip/hip_hcc.h +0 -24
  72. triton/backends/amd/include/hip/hip_math_constants.h +0 -36
  73. triton/backends/amd/include/hip/hip_profile.h +0 -27
  74. triton/backends/amd/include/hip/hip_runtime.h +0 -75
  75. triton/backends/amd/include/hip/hip_runtime_api.h +0 -8919
  76. triton/backends/amd/include/hip/hip_texture_types.h +0 -29
  77. triton/backends/amd/include/hip/hip_vector_types.h +0 -41
  78. triton/backends/amd/include/hip/hip_version.h +0 -17
  79. triton/backends/amd/include/hip/hiprtc.h +0 -421
  80. triton/backends/amd/include/hip/library_types.h +0 -78
  81. triton/backends/amd/include/hip/math_functions.h +0 -42
  82. triton/backends/amd/include/hip/surface_types.h +0 -63
  83. triton/backends/amd/include/hip/texture_types.h +0 -194
  84. triton/backends/amd/include/hsa/Brig.h +0 -1131
  85. triton/backends/amd/include/hsa/amd_hsa_common.h +0 -91
  86. triton/backends/amd/include/hsa/amd_hsa_elf.h +0 -436
  87. triton/backends/amd/include/hsa/amd_hsa_kernel_code.h +0 -269
  88. triton/backends/amd/include/hsa/amd_hsa_queue.h +0 -109
  89. triton/backends/amd/include/hsa/amd_hsa_signal.h +0 -80
  90. triton/backends/amd/include/hsa/hsa.h +0 -5729
  91. triton/backends/amd/include/hsa/hsa_amd_tool.h +0 -91
  92. triton/backends/amd/include/hsa/hsa_api_trace.h +0 -566
  93. triton/backends/amd/include/hsa/hsa_ext_amd.h +0 -3090
  94. triton/backends/amd/include/hsa/hsa_ext_finalize.h +0 -531
  95. triton/backends/amd/include/hsa/hsa_ext_image.h +0 -1454
  96. triton/backends/amd/include/hsa/hsa_ven_amd_aqlprofile.h +0 -488
  97. triton/backends/amd/include/hsa/hsa_ven_amd_loader.h +0 -667
  98. triton/backends/amd/include/roctracer/ext/prof_protocol.h +0 -107
  99. triton/backends/amd/include/roctracer/hip_ostream_ops.h +0 -4435
  100. triton/backends/amd/include/roctracer/hsa_ostream_ops.h +0 -1467
  101. triton/backends/amd/include/roctracer/hsa_prof_str.h +0 -3027
  102. triton/backends/amd/include/roctracer/roctracer.h +0 -779
  103. triton/backends/amd/include/roctracer/roctracer_ext.h +0 -81
  104. triton/backends/amd/include/roctracer/roctracer_hcc.h +0 -24
  105. triton/backends/amd/include/roctracer/roctracer_hip.h +0 -37
  106. triton/backends/amd/include/roctracer/roctracer_hsa.h +0 -112
  107. triton/backends/amd/include/roctracer/roctracer_plugin.h +0 -137
  108. triton/backends/amd/include/roctracer/roctracer_roctx.h +0 -67
  109. triton/backends/amd/include/roctracer/roctx.h +0 -229
  110. {triton_windows-3.2.0.post19.dist-info → triton_windows-3.2.0.post21.dist-info}/top_level.txt +0 -0
@@ -1,3090 +0,0 @@
1
- ////////////////////////////////////////////////////////////////////////////////
2
- //
3
- // The University of Illinois/NCSA
4
- // Open Source License (NCSA)
5
- //
6
- // Copyright (c) 2014-2020, Advanced Micro Devices, Inc. All rights reserved.
7
- //
8
- // Developed by:
9
- //
10
- // AMD Research and AMD HSA Software Development
11
- //
12
- // Advanced Micro Devices, Inc.
13
- //
14
- // www.amd.com
15
- //
16
- // Permission is hereby granted, free of charge, to any person obtaining a copy
17
- // of this software and associated documentation files (the "Software"), to
18
- // deal with the Software without restriction, including without limitation
19
- // the rights to use, copy, modify, merge, publish, distribute, sublicense,
20
- // and/or sell copies of the Software, and to permit persons to whom the
21
- // Software is furnished to do so, subject to the following conditions:
22
- //
23
- // - Redistributions of source code must retain the above copyright notice,
24
- // this list of conditions and the following disclaimers.
25
- // - Redistributions in binary form must reproduce the above copyright
26
- // notice, this list of conditions and the following disclaimers in
27
- // the documentation and/or other materials provided with the distribution.
28
- // - Neither the names of Advanced Micro Devices, Inc,
29
- // nor the names of its contributors may be used to endorse or promote
30
- // products derived from this Software without specific prior written
31
- // permission.
32
- //
33
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
36
- // THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
37
- // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
38
- // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
39
- // DEALINGS WITH THE SOFTWARE.
40
- //
41
- ////////////////////////////////////////////////////////////////////////////////
42
-
43
- // HSA AMD extension.
44
-
45
- #ifndef HSA_RUNTIME_EXT_AMD_H_
46
- #define HSA_RUNTIME_EXT_AMD_H_
47
-
48
- #include "hsa.h"
49
- #include "hsa_ext_image.h"
50
-
51
- /*
52
- * - 1.0 - initial version
53
- * - 1.1 - dmabuf export
54
- * - 1.2 - hsa_amd_memory_async_copy_on_engine
55
- * - 1.3 - HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_EXTENDED_SCOPE_FINE_GRAINED pool
56
- * - 1.4 - Virtual Memory API
57
- */
58
- #define HSA_AMD_INTERFACE_VERSION_MAJOR 1
59
- #define HSA_AMD_INTERFACE_VERSION_MINOR 4
60
-
61
- #ifdef __cplusplus
62
- extern "C" {
63
- #endif
64
-
65
- /** \addtogroup aql Architected Queuing Language
66
- * @{
67
- */
68
-
69
- /**
70
- * @brief Macro to use to determine that a flag is set when querying flags within uint8_t[8]
71
- * types
72
- */
73
- static inline bool hsa_flag_isset64(uint8_t* value, uint32_t bit) {
74
- unsigned int index = bit / 8;
75
- unsigned int subBit = bit % 8;
76
- return ((uint8_t*)value)[index] & (1 << subBit);
77
- }
78
-
79
- /**
80
- * @brief A fixed-size type used to represent ::hsa_signal_condition_t constants.
81
- */
82
- typedef uint32_t hsa_signal_condition32_t;
83
-
84
- /**
85
- * @brief AMD vendor specific packet type.
86
- */
87
- typedef enum {
88
- /**
89
- * Packet used by agents to delay processing of subsequent packets until a
90
- * configurable condition is satisfied by an HSA signal. Only kernel dispatch
91
- * queues created from AMD GPU Agents support this packet.
92
- */
93
- HSA_AMD_PACKET_TYPE_BARRIER_VALUE = 2,
94
- } hsa_amd_packet_type_t;
95
-
96
- /**
97
- * @brief A fixed-size type used to represent ::hsa_amd_packet_type_t constants.
98
- */
99
- typedef uint8_t hsa_amd_packet_type8_t;
100
-
101
- /**
102
- * @brief AMD vendor specific AQL packet header
103
- */
104
- typedef struct hsa_amd_packet_header_s {
105
- /**
106
- * Packet header. Used to configure multiple packet parameters such as the
107
- * packet type. The parameters are described by ::hsa_packet_header_t.
108
- */
109
- uint16_t header;
110
-
111
- /**
112
- *Format of the vendor specific packet.
113
- */
114
- hsa_amd_packet_type8_t AmdFormat;
115
-
116
- /**
117
- * Reserved. Must be 0.
118
- */
119
- uint8_t reserved;
120
- } hsa_amd_vendor_packet_header_t;
121
-
122
- /**
123
- * @brief AMD barrier value packet. Halts packet processing and waits for
124
- * (signal_value & ::mask) ::cond ::value to be satisfied, where signal_value
125
- * is the value of the signal ::signal.
126
- */
127
- typedef struct hsa_amd_barrier_value_packet_s {
128
- /**
129
- * AMD vendor specific packet header.
130
- */
131
- hsa_amd_vendor_packet_header_t header;
132
-
133
- /**
134
- * Reserved. Must be 0.
135
- */
136
- uint32_t reserved0;
137
-
138
- /**
139
- * Dependent signal object. A signal with a handle value of 0 is
140
- * allowed and is interpreted by the packet processor a satisfied
141
- * dependency.
142
- */
143
- hsa_signal_t signal;
144
-
145
- /**
146
- * Value to compare against.
147
- */
148
- hsa_signal_value_t value;
149
-
150
- /**
151
- * Bit mask to be combined by bitwise AND with ::signal's value.
152
- */
153
- hsa_signal_value_t mask;
154
-
155
- /**
156
- * Comparison operation. See ::hsa_signal_condition_t.
157
- */
158
- hsa_signal_condition32_t cond;
159
-
160
- /**
161
- * Reserved. Must be 0.
162
- */
163
- uint32_t reserved1;
164
-
165
- /**
166
- * Reserved. Must be 0.
167
- */
168
- uint64_t reserved2;
169
-
170
- /**
171
- * Reserved. Must be 0.
172
- */
173
- uint64_t reserved3;
174
-
175
- /**
176
- * Signal used to indicate completion of the job. The application can use the
177
- * special signal handle 0 to indicate that no signal is used.
178
- */
179
- hsa_signal_t completion_signal;
180
- } hsa_amd_barrier_value_packet_t;
181
-
182
- /** @} */
183
-
184
- /**
185
- * @brief Enumeration constants added to ::hsa_status_t.
186
- *
187
- * @remark Additions to hsa_status_t
188
- */
189
- enum {
190
- /**
191
- * The memory pool is invalid.
192
- */
193
- HSA_STATUS_ERROR_INVALID_MEMORY_POOL = 40,
194
-
195
- /**
196
- * Agent accessed memory beyond the maximum legal address.
197
- */
198
- HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION = 41,
199
-
200
- /**
201
- * Agent executed an invalid shader instruction.
202
- */
203
- HSA_STATUS_ERROR_ILLEGAL_INSTRUCTION = 42,
204
-
205
- /**
206
- * Agent attempted to access an inaccessible address.
207
- * See hsa_amd_register_system_event_handler and
208
- * HSA_AMD_GPU_MEMORY_FAULT_EVENT for more information on illegal accesses.
209
- */
210
- HSA_STATUS_ERROR_MEMORY_FAULT = 43,
211
-
212
- /**
213
- * The CU mask was successfully set but the mask attempted to enable a CU
214
- * which was disabled for the process. CUs disabled for the process remain
215
- * disabled.
216
- */
217
- HSA_STATUS_CU_MASK_REDUCED = 44,
218
-
219
- /**
220
- * Exceeded number of VGPRs available on this agent
221
- */
222
- HSA_STATUS_ERROR_OUT_OF_REGISTERS = 45,
223
- };
224
-
225
- /**
226
- * @brief IOMMU version supported
227
- */
228
- typedef enum {
229
- /**
230
- * IOMMU not supported
231
- */
232
- HSA_IOMMU_SUPPORT_NONE = 0,
233
- /* IOMMU V1 support is not relevant to user applications, so not reporting it */
234
- /**
235
- * IOMMU V2 supported
236
- */
237
- HSA_IOMMU_SUPPORT_V2 = 1,
238
- } hsa_amd_iommu_version_t;
239
-
240
- /**
241
- * @brief Agent attributes.
242
- */
243
- typedef enum hsa_amd_agent_info_s {
244
- /**
245
- * Chip identifier. The type of this attribute is uint32_t.
246
- */
247
- HSA_AMD_AGENT_INFO_CHIP_ID = 0xA000,
248
- /**
249
- * Size of a cacheline in bytes. The type of this attribute is uint32_t.
250
- */
251
- HSA_AMD_AGENT_INFO_CACHELINE_SIZE = 0xA001,
252
- /**
253
- * The number of compute unit available in the agent. The type of this
254
- * attribute is uint32_t.
255
- */
256
- HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT = 0xA002,
257
- /**
258
- * The maximum clock frequency of the agent in MHz. The type of this
259
- * attribute is uint32_t.
260
- */
261
- HSA_AMD_AGENT_INFO_MAX_CLOCK_FREQUENCY = 0xA003,
262
- /**
263
- * Internal driver node identifier. The type of this attribute is uint32_t.
264
- */
265
- HSA_AMD_AGENT_INFO_DRIVER_NODE_ID = 0xA004,
266
- /**
267
- * Max number of watch points on memory address ranges to generate exception
268
- * events when the watched addresses are accessed. The type of this
269
- * attribute is uint32_t.
270
- */
271
- HSA_AMD_AGENT_INFO_MAX_ADDRESS_WATCH_POINTS = 0xA005,
272
- /**
273
- * Agent BDF_ID, named LocationID in thunk. The type of this attribute is
274
- * uint32_t.
275
- */
276
- HSA_AMD_AGENT_INFO_BDFID = 0xA006,
277
- /**
278
- * Memory Interface width, the return value type is uint32_t.
279
- * This attribute is deprecated.
280
- */
281
- HSA_AMD_AGENT_INFO_MEMORY_WIDTH = 0xA007,
282
- /**
283
- * Max Memory Clock, the return value type is uint32_t.
284
- */
285
- HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY = 0xA008,
286
- /**
287
- * Board name of Agent - populated from MarketingName of Kfd Node
288
- * The value is an Ascii string of 64 chars.
289
- */
290
- HSA_AMD_AGENT_INFO_PRODUCT_NAME = 0xA009,
291
- /**
292
- * Maximum number of waves possible in a Compute Unit.
293
- * The type of this attribute is uint32_t.
294
- */
295
- HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU = 0xA00A,
296
- /**
297
- * Number of SIMD's per compute unit CU
298
- * The type of this attribute is uint32_t.
299
- */
300
- HSA_AMD_AGENT_INFO_NUM_SIMDS_PER_CU = 0xA00B,
301
- /**
302
- * Number of Shader Engines (SE) in Gpu
303
- * The type of this attribute is uint32_t.
304
- */
305
- HSA_AMD_AGENT_INFO_NUM_SHADER_ENGINES = 0xA00C,
306
- /**
307
- * Number of Shader Arrays Per Shader Engines in Gpu
308
- * The type of this attribute is uint32_t.
309
- */
310
- HSA_AMD_AGENT_INFO_NUM_SHADER_ARRAYS_PER_SE = 0xA00D,
311
- /**
312
- * Address of the HDP flush registers. Use of these registers does not conform to the HSA memory
313
- * model and should be treated with caution.
314
- * The type of this attribute is hsa_amd_hdp_flush_t.
315
- */
316
- HSA_AMD_AGENT_INFO_HDP_FLUSH = 0xA00E,
317
- /**
318
- * PCIe domain for the agent. Pairs with HSA_AMD_AGENT_INFO_BDFID
319
- * to give the full physical location of the Agent.
320
- * The type of this attribute is uint32_t.
321
- */
322
- HSA_AMD_AGENT_INFO_DOMAIN = 0xA00F,
323
- /**
324
- * Queries for support of cooperative queues. See ::HSA_QUEUE_TYPE_COOPERATIVE.
325
- * The type of this attribute is bool.
326
- */
327
- HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES = 0xA010,
328
- /**
329
- * Queries UUID of an agent. The value is an Ascii string with a maximum
330
- * of 21 chars including NUL. The string value consists of two parts: header
331
- * and body. The header identifies device type (GPU, CPU, DSP) while body
332
- * encodes UUID as a 16 digit hex string
333
- *
334
- * Agents that do not support UUID will return the string "GPU-XX" or
335
- * "CPU-XX" or "DSP-XX" depending upon their device type ::hsa_device_type_t
336
- */
337
- HSA_AMD_AGENT_INFO_UUID = 0xA011,
338
- /**
339
- * Queries for the ASIC revision of an agent. The value is an integer that
340
- * increments for each revision. This can be used by user-level software to
341
- * change how it operates, depending on the hardware version. This allows
342
- * selective workarounds for hardware errata.
343
- * The type of this attribute is uint32_t.
344
- */
345
- HSA_AMD_AGENT_INFO_ASIC_REVISION = 0xA012,
346
- /**
347
- * Queries whether or not the host can directly access SVM memory that is
348
- * physically resident in the agent's local memory.
349
- * The type of this attribute is bool.
350
- */
351
- HSA_AMD_AGENT_INFO_SVM_DIRECT_HOST_ACCESS = 0xA013,
352
- /**
353
- * Some processors support more CUs than can reliably be used in a cooperative
354
- * dispatch. This queries the count of CUs which are fully enabled for
355
- * cooperative dispatch.
356
- * The type of this attribute is uint32_t.
357
- */
358
- HSA_AMD_AGENT_INFO_COOPERATIVE_COMPUTE_UNIT_COUNT = 0xA014,
359
- /**
360
- * Queries the amount of memory available in bytes accross all global pools
361
- * owned by the agent.
362
- * The type of this attribute is uint64_t.
363
- */
364
- HSA_AMD_AGENT_INFO_MEMORY_AVAIL = 0xA015,
365
- /**
366
- * Timestamp value increase rate, in Hz. The timestamp (clock) frequency is
367
- * in the range 1-400MHz.
368
- * The type of this attribute is uint64_t.
369
- */
370
- HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY = 0xA016,
371
- /**
372
- * Queries for the ASIC family ID of an agent.
373
- * The type of this attribute is uint32_t.
374
- */
375
- HSA_AMD_AGENT_INFO_ASIC_FAMILY_ID = 0xA107,
376
- /**
377
- * Queries for the Packet Processor(CP Firmware) ucode version of an agent.
378
- * The type of this attribute is uint32_t.
379
- */
380
- HSA_AMD_AGENT_INFO_UCODE_VERSION = 0xA108,
381
- /**
382
- * Queries for the SDMA engine ucode of an agent.
383
- * The type of this attribute is uint32_t.
384
- */
385
- HSA_AMD_AGENT_INFO_SDMA_UCODE_VERSION = 0xA109,
386
- /**
387
- * Queries the number of SDMA engines.
388
- * If HSA_AMD_AGENT_INFO_NUM_SDMA_XGMI_ENG query returns non-zero,
389
- * this query returns the the number of SDMA engines optimized for
390
- * host to device bidirectional traffic.
391
- * The type of this attribute is uint32_t.
392
- */
393
- HSA_AMD_AGENT_INFO_NUM_SDMA_ENG = 0xA10A,
394
- /**
395
- * Queries the number of additional SDMA engines optimized for D2D xGMI copies.
396
- * The type of this attribute is uint32_t.
397
- */
398
- HSA_AMD_AGENT_INFO_NUM_SDMA_XGMI_ENG = 0xA10B,
399
- /**
400
- * Queries for version of IOMMU supported by agent.
401
- * The type of this attribute is hsa_amd_iommu_version_t.
402
- */
403
- HSA_AMD_AGENT_INFO_IOMMU_SUPPORT = 0xA110,
404
- /**
405
- * Queries for number of XCCs within the agent.
406
- * The type of this attribute is uint32_t.
407
- */
408
- HSA_AMD_AGENT_INFO_NUM_XCC = 0xA111,
409
- /**
410
- * Queries for driver unique identifier.
411
- * The type of this attribute is uint32_t.
412
- */
413
- HSA_AMD_AGENT_INFO_DRIVER_UID = 0xA112,
414
- /**
415
- * Returns the hsa_agent_t of the nearest CPU agent
416
- * The type of this attribute is hsa_agent_t.
417
- */
418
- HSA_AMD_AGENT_INFO_NEAREST_CPU = 0xA113,
419
- /**
420
- * Bit-mask indicating memory properties of this agent. A memory property is set if the flag bit
421
- * is set at that position. User may use the hsa_flag_isset64 macro to verify whether a flag
422
- * is set. The type of this attribute is uint8_t[8].
423
- */
424
- HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES = 0xA114,
425
- /**
426
- * Bit-mask indicating AQL Extensions supported by this agent. An AQL extension is set if the flag
427
- * bit is set at that position. User may use the hsa_flag_isset64 macro to verify whether a flag
428
- * is set. The type of this attribute is uint8_t[8].
429
- */
430
- HSA_AMD_AGENT_INFO_AQL_EXTENSIONS = 0xA115 /* Not implemented yet */
431
- } hsa_amd_agent_info_t;
432
-
433
- /**
434
- * @brief Agent memory properties attributes
435
- */
436
- typedef enum hsa_amd_agent_memory_properties_s {
437
- HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU = (1 << 0),
438
- } hsa_amd_agent_memory_properties_t;
439
-
440
- /**
441
- * @brief SDMA engine IDs unique by single set bit position.
442
- */
443
- typedef enum hsa_amd_sdma_engine_id {
444
- HSA_AMD_SDMA_ENGINE_0 = 0x1,
445
- HSA_AMD_SDMA_ENGINE_1 = 0x2,
446
- HSA_AMD_SDMA_ENGINE_2 = 0x4,
447
- HSA_AMD_SDMA_ENGINE_3 = 0x8,
448
- HSA_AMD_SDMA_ENGINE_4 = 0x10,
449
- HSA_AMD_SDMA_ENGINE_5 = 0x20,
450
- HSA_AMD_SDMA_ENGINE_6 = 0x40,
451
- HSA_AMD_SDMA_ENGINE_7 = 0x80,
452
- HSA_AMD_SDMA_ENGINE_8 = 0x100,
453
- HSA_AMD_SDMA_ENGINE_9 = 0x200,
454
- HSA_AMD_SDMA_ENGINE_10 = 0x400,
455
- HSA_AMD_SDMA_ENGINE_11 = 0x800,
456
- HSA_AMD_SDMA_ENGINE_12 = 0x1000,
457
- HSA_AMD_SDMA_ENGINE_13 = 0x2000,
458
- HSA_AMD_SDMA_ENGINE_14 = 0x4000,
459
- HSA_AMD_SDMA_ENGINE_15 = 0x8000
460
- } hsa_amd_sdma_engine_id_t;
461
-
462
- typedef struct hsa_amd_hdp_flush_s {
463
- uint32_t* HDP_MEM_FLUSH_CNTL;
464
- uint32_t* HDP_REG_FLUSH_CNTL;
465
- } hsa_amd_hdp_flush_t;
466
-
467
- /**
468
- * @brief Region attributes.
469
- */
470
- typedef enum hsa_amd_region_info_s {
471
- /**
472
- * Determine if host can access the region. The type of this attribute
473
- * is bool.
474
- */
475
- HSA_AMD_REGION_INFO_HOST_ACCESSIBLE = 0xA000,
476
- /**
477
- * Base address of the region in flat address space.
478
- */
479
- HSA_AMD_REGION_INFO_BASE = 0xA001,
480
- /**
481
- * Memory Interface width, the return value type is uint32_t.
482
- * This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_WIDTH.
483
- */
484
- HSA_AMD_REGION_INFO_BUS_WIDTH = 0xA002,
485
- /**
486
- * Max Memory Clock, the return value type is uint32_t.
487
- * This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY.
488
- */
489
- HSA_AMD_REGION_INFO_MAX_CLOCK_FREQUENCY = 0xA003,
490
- } hsa_amd_region_info_t;
491
-
492
- /**
493
- * @brief Coherency attributes of fine grain region.
494
- */
495
- typedef enum hsa_amd_coherency_type_s {
496
- /**
497
- * Coherent region.
498
- */
499
- HSA_AMD_COHERENCY_TYPE_COHERENT = 0,
500
- /**
501
- * Non coherent region.
502
- */
503
- HSA_AMD_COHERENCY_TYPE_NONCOHERENT = 1
504
- } hsa_amd_coherency_type_t;
505
-
506
- /**
507
- * @brief Get the coherency type of the fine grain region of an agent.
508
- *
509
- * @param[in] agent A valid agent.
510
- *
511
- * @param[out] type Pointer to a memory location where the HSA runtime will
512
- * store the coherency type of the fine grain region.
513
- *
514
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
515
- *
516
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
517
- * initialized.
518
- *
519
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
520
- *
521
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p type is NULL.
522
- */
523
- hsa_status_t HSA_API hsa_amd_coherency_get_type(hsa_agent_t agent,
524
- hsa_amd_coherency_type_t* type);
525
-
526
- /**
527
- * @brief Set the coherency type of the fine grain region of an agent.
528
- * Deprecated. This is supported on KV platforms. For backward compatibility
529
- * other platforms will spuriously succeed.
530
- *
531
- * @param[in] agent A valid agent.
532
- *
533
- * @param[in] type The coherency type to be set.
534
- *
535
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
536
- *
537
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
538
- * initialized.
539
- *
540
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
541
- *
542
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p type is invalid.
543
- */
544
- hsa_status_t HSA_API hsa_amd_coherency_set_type(hsa_agent_t agent,
545
- hsa_amd_coherency_type_t type);
546
-
547
- /**
548
- * @brief Structure containing profiling dispatch time information.
549
- *
550
- * Times are reported as ticks in the domain of the HSA system clock.
551
- * The HSA system clock tick and frequency is obtained via hsa_system_get_info.
552
- */
553
- typedef struct hsa_amd_profiling_dispatch_time_s {
554
- /**
555
- * Dispatch packet processing start time.
556
- */
557
- uint64_t start;
558
- /**
559
- * Dispatch packet completion time.
560
- */
561
- uint64_t end;
562
- } hsa_amd_profiling_dispatch_time_t;
563
-
564
- /**
565
- * @brief Structure containing profiling async copy time information.
566
- *
567
- * Times are reported as ticks in the domain of the HSA system clock.
568
- * The HSA system clock tick and frequency is obtained via hsa_system_get_info.
569
- */
570
- typedef struct hsa_amd_profiling_async_copy_time_s {
571
- /**
572
- * Async copy processing start time.
573
- */
574
- uint64_t start;
575
- /**
576
- * Async copy completion time.
577
- */
578
- uint64_t end;
579
- } hsa_amd_profiling_async_copy_time_t;
580
-
581
- /**
582
- * @brief Enable or disable profiling capability of a queue.
583
- *
584
- * @param[in] queue A valid queue.
585
- *
586
- * @param[in] enable 1 to enable profiling. 0 to disable profiling.
587
- *
588
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
589
- *
590
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
591
- * initialized.
592
- *
593
- * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
594
- *
595
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
596
- */
597
- hsa_status_t HSA_API
598
- hsa_amd_profiling_set_profiler_enabled(hsa_queue_t* queue, int enable);
599
-
600
- /**
601
- * @brief Enable or disable asynchronous memory copy profiling.
602
- *
603
- * @details The runtime will provide the copy processing start timestamp and
604
- * completion timestamp of each call to hsa_amd_memory_async_copy if the
605
- * async copy profiling is enabled prior to the call to
606
- * hsa_amd_memory_async_copy. The completion signal object is used to
607
- * hold the last async copy start and end timestamp. The client can retrieve
608
- * these timestamps via call to hsa_amd_profiling_get_async_copy_time.
609
- *
610
- * @param[in] enable True to enable profiling. False to disable profiling.
611
- *
612
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
613
- *
614
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
615
- * initialized.
616
- *
617
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Failed on allocating resources
618
- * needed to profile the asynchronous copy.
619
- */
620
- hsa_status_t HSA_API
621
- hsa_amd_profiling_async_copy_enable(bool enable);
622
-
623
- /**
624
- * @brief Retrieve packet processing time stamps.
625
- *
626
- * @param[in] agent The agent with which the signal was last used. For
627
- * instance, if the profiled dispatch packet is dispatched onto queue Q,
628
- * which was created on agent A, then this parameter must be A.
629
- *
630
- * @param[in] signal A signal used as the completion signal of the dispatch
631
- * packet to retrieve time stamps from. This dispatch packet must have been
632
- * issued to a queue with profiling enabled and have already completed. Also
633
- * the signal must not have yet been used in any other packet following the
634
- * completion of the profiled dispatch packet.
635
- *
636
- * @param[out] time Packet processing timestamps in the HSA system clock
637
- * domain.
638
- *
639
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
640
- *
641
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
642
- * initialized.
643
- *
644
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
645
- *
646
- * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL The signal is invalid.
647
- *
648
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p time is NULL.
649
- */
650
- hsa_status_t HSA_API hsa_amd_profiling_get_dispatch_time(
651
- hsa_agent_t agent, hsa_signal_t signal,
652
- hsa_amd_profiling_dispatch_time_t* time);
653
-
654
- /**
655
- * @brief Retrieve asynchronous copy timestamps.
656
- *
657
- * @details Async copy profiling is enabled via call to
658
- * hsa_amd_profiling_async_copy_enable.
659
- *
660
- * @param[in] signal A signal used as the completion signal of the call to
661
- * hsa_amd_memory_async_copy.
662
- *
663
- * @param[out] time Async copy processing timestamps in the HSA system clock
664
- * domain.
665
- *
666
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
667
- *
668
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
669
- * initialized.
670
- *
671
- * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL The signal is invalid.
672
- *
673
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p time is NULL.
674
- */
675
- hsa_status_t HSA_API hsa_amd_profiling_get_async_copy_time(
676
- hsa_signal_t signal, hsa_amd_profiling_async_copy_time_t* time);
677
-
678
- /**
679
- * @brief Computes the frequency ratio and offset between the agent clock and
680
- * HSA system clock and converts the agent's tick to HSA system domain tick.
681
- *
682
- * @param[in] agent The agent used to retrieve the agent_tick. It is user's
683
- * responsibility to make sure the tick number is from this agent, otherwise,
684
- * the behavior is undefined.
685
- *
686
- * @param[in] agent_tick The tick count retrieved from the specified @p agent.
687
- *
688
- * @param[out] system_tick The translated HSA system domain clock counter tick.
689
- *
690
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
691
- *
692
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
693
- * initialized.
694
- *
695
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
696
- *
697
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p system_tick is NULL;
698
- */
699
- hsa_status_t HSA_API
700
- hsa_amd_profiling_convert_tick_to_system_domain(hsa_agent_t agent,
701
- uint64_t agent_tick,
702
- uint64_t* system_tick);
703
-
704
- /**
705
- * @brief Signal attribute flags.
706
- */
707
- typedef enum {
708
- /**
709
- * Signal will only be consumed by AMD GPUs. Limits signal consumption to
710
- * AMD GPU agents only. Ignored if @p num_consumers is not zero (all agents).
711
- */
712
- HSA_AMD_SIGNAL_AMD_GPU_ONLY = 1,
713
- /**
714
- * Signal may be used for interprocess communication.
715
- * IPC signals can be read, written, and waited on from any process.
716
- * Profiling using an IPC enabled signal is only supported in a single process
717
- * at a time. Producing profiling data in one process and consuming it in
718
- * another process is undefined.
719
- */
720
- HSA_AMD_SIGNAL_IPC = 2,
721
- } hsa_amd_signal_attribute_t;
722
-
723
- /**
724
- * @brief Create a signal with specific attributes.
725
- *
726
- * @param[in] initial_value Initial value of the signal.
727
- *
728
- * @param[in] num_consumers Size of @p consumers. A value of 0 indicates that
729
- * any agent might wait on the signal.
730
- *
731
- * @param[in] consumers List of agents that might consume (wait on) the
732
- * signal. If @p num_consumers is 0, this argument is ignored; otherwise, the
733
- * HSA runtime might use the list to optimize the handling of the signal
734
- * object. If an agent not listed in @p consumers waits on the returned
735
- * signal, the behavior is undefined. The memory associated with @p consumers
736
- * can be reused or freed after the function returns.
737
- *
738
- * @param[in] attributes Requested signal attributes. Multiple signal attributes
739
- * may be requested by combining them with bitwise OR. Requesting no attributes
740
- * (@p attributes == 0) results in the same signal as would have been obtained
741
- * via hsa_signal_create.
742
- *
743
- * @param[out] signal Pointer to a memory location where the HSA runtime will
744
- * store the newly created signal handle. Must not be NULL.
745
- *
746
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
747
- *
748
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
749
- * initialized.
750
- *
751
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
752
- * the required resources.
753
- *
754
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is NULL, @p
755
- * num_consumers is greater than 0 but @p consumers is NULL, or @p consumers
756
- * contains duplicates.
757
- */
758
- hsa_status_t HSA_API hsa_amd_signal_create(hsa_signal_value_t initial_value, uint32_t num_consumers,
759
- const hsa_agent_t* consumers, uint64_t attributes,
760
- hsa_signal_t* signal);
761
-
762
- /**
763
- * @brief Returns a pointer to the value of a signal.
764
- *
765
- * Use of this API does not modify the lifetime of ::signal and any
766
- * hsa_signal_value_t retrieved by this API has lifetime equal to that of
767
- * ::signal.
768
- *
769
- * This API is intended for partial interoperability with non-HSA compatible
770
- * devices and should not be used where HSA interfaces are available.
771
- *
772
- * Use of the signal value must comply with use restritions of ::signal.
773
- * Use may result in data races if the operations performed are not platform
774
- * atomic. Use with HSA_AMD_SIGNAL_AMD_GPU_ONLY or HSA_AMD_SIGNAL_IPC
775
- * attributed signals is required.
776
- *
777
- * @param[in] Signal handle to extract the signal value pointer from.
778
- *
779
- * @param[out] Location where the extracted signal value pointer will be placed.
780
- *
781
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
782
- *
783
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
784
- * initialized.
785
- *
786
- * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL signal is not a valid hsa_signal_t
787
- *
788
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT value_ptr is NULL.
789
- */
790
- hsa_status_t hsa_amd_signal_value_pointer(hsa_signal_t signal,
791
- volatile hsa_signal_value_t** value_ptr);
792
-
793
- /**
794
- * @brief Asyncronous signal handler function type.
795
- *
796
- * @details Type definition of callback function to be used with
797
- * hsa_amd_signal_async_handler. This callback is invoked if the associated
798
- * signal and condition are met. The callback receives the value of the signal
799
- * which satisfied the associated wait condition and a user provided value. If
800
- * the callback returns true then the callback will be called again if the
801
- * associated signal and condition are satisfied again. If the callback returns
802
- * false then it will not be called again.
803
- *
804
- * @param[in] value Contains the value of the signal observed by
805
- * hsa_amd_signal_async_handler which caused the signal handler to be invoked.
806
- *
807
- * @param[in] arg Contains the user provided value given when the signal handler
808
- * was registered with hsa_amd_signal_async_handler
809
- *
810
- * @retval true resumes monitoring the signal with this handler (as if calling
811
- * hsa_amd_signal_async_handler again with identical parameters)
812
- *
813
- * @retval false stops monitoring the signal with this handler (handler will
814
- * not be called again for this signal)
815
- *
816
- */
817
- typedef bool (*hsa_amd_signal_handler)(hsa_signal_value_t value, void* arg);
818
-
819
- /**
820
- * @brief Register asynchronous signal handler function.
821
- *
822
- * @details Allows registering a callback function and user provided value with
823
- * a signal and wait condition. The callback will be invoked if the associated
824
- * signal and wait condition are satisfied. Callbacks will be invoked serially
825
- * but in an arbitrary order so callbacks should be independent of each other.
826
- * After being invoked a callback may continue to wait for its associated signal
827
- * and condition and, possibly, be invoked again. Or the callback may stop
828
- * waiting. If the callback returns true then it will continue waiting and may
829
- * be called again. If false then the callback will not wait again and will not
830
- * be called again for the associated signal and condition. It is possible to
831
- * register the same callback multiple times with the same or different signals
832
- * and/or conditions. Each registration of the callback will be treated entirely
833
- * independently.
834
- *
835
- * @param[in] signal hsa signal to be asynchronously monitored
836
- *
837
- * @param[in] cond condition value to monitor for
838
- *
839
- * @param[in] value signal value used in condition expression
840
- *
841
- * @param[in] handler asynchronous signal handler invoked when signal's
842
- * condition is met
843
- *
844
- * @param[in] arg user provided value which is provided to handler when handler
845
- * is invoked
846
- *
847
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
848
- *
849
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
850
- * initialized.
851
- *
852
- * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL signal is not a valid hsa_signal_t
853
- *
854
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT handler is invalid (NULL)
855
- *
856
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime is out of
857
- * resources or blocking signals are not supported by the HSA driver component.
858
- *
859
- */
860
- hsa_status_t HSA_API
861
- hsa_amd_signal_async_handler(hsa_signal_t signal,
862
- hsa_signal_condition_t cond,
863
- hsa_signal_value_t value,
864
- hsa_amd_signal_handler handler, void* arg);
865
-
866
- /**
867
- * @brief Call a function asynchronously
868
- *
869
- * @details Provides access to the runtime's asynchronous event handling thread
870
- * for general asynchronous functions. Functions queued this way are executed
871
- * in the same manner as if they were a signal handler who's signal is
872
- * satisfied.
873
- *
874
- * @param[in] callback asynchronous function to be invoked
875
- *
876
- * @param[in] arg user provided value which is provided to handler when handler
877
- * is invoked
878
- *
879
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
880
- *
881
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
882
- * initialized.
883
- *
884
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT handler is invalid (NULL)
885
- *
886
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime is out of
887
- * resources or blocking signals are not supported by the HSA driver component.
888
- *
889
- */
890
- hsa_status_t HSA_API
891
- hsa_amd_async_function(void (*callback)(void* arg), void* arg);
892
-
893
- /**
894
- * @brief Wait for any signal-condition pair to be satisfied.
895
- *
896
- * @details Allows waiting for any of several signal and conditions pairs to be
897
- * satisfied. The function returns the index into the list of signals of the
898
- * first satisfying signal-condition pair. The value of the satisfying signal's
899
- * value is returned in satisfying_value unless satisfying_value is NULL. This
900
- * function provides only relaxed memory semantics.
901
- */
902
- uint32_t HSA_API
903
- hsa_amd_signal_wait_any(uint32_t signal_count, hsa_signal_t* signals,
904
- hsa_signal_condition_t* conds,
905
- hsa_signal_value_t* values, uint64_t timeout_hint,
906
- hsa_wait_state_t wait_hint,
907
- hsa_signal_value_t* satisfying_value);
908
-
909
- /**
910
- * @brief Query image limits.
911
- *
912
- * @param[in] agent A valid agent.
913
- *
914
- * @param[in] attribute HSA image info attribute to query.
915
- *
916
- * @param[out] value Pointer to an application-allocated buffer where to store
917
- * the value of the attribute. If the buffer passed by the application is not
918
- * large enough to hold the value of @p attribute, the behavior is undefined.
919
- *
920
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
921
- *
922
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
923
- * initialized.
924
- *
925
- * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE @p value is NULL or @p attribute <
926
- * HSA_EXT_AGENT_INFO_IMAGE_1D_MAX_ELEMENTS or @p attribute >
927
- * HSA_EXT_AGENT_INFO_IMAGE_ARRAY_MAX_LAYERS.
928
- *
929
- */
930
- hsa_status_t HSA_API hsa_amd_image_get_info_max_dim(hsa_agent_t agent,
931
- hsa_agent_info_t attribute,
932
- void* value);
933
-
934
- /**
935
- * @brief Set a queue's CU affinity mask.
936
- *
937
- * @details Enables the queue to run on only selected CUs. The given mask is
938
- * combined by bitwise AND with any device wide mask in HSA_CU_MASK before
939
- * being applied.
940
- * If num_cu_mask_count is 0 then the request is interpreted as a request to
941
- * enable all CUs and no cu_mask array need be given.
942
- *
943
- * @param[in] queue A pointer to HSA queue.
944
- *
945
- * @param[in] num_cu_mask_count Size of CUMask bit array passed in, in bits.
946
- *
947
- * @param[in] cu_mask Bit-vector representing the CU mask.
948
- *
949
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
950
- *
951
- * @retval ::HSA_STATUS_CU_MASK_REDUCED The function was successfully executed
952
- * but the given mask attempted to enable a CU which was disabled by
953
- * HSA_CU_MASK. CUs disabled by HSA_CU_MASK remain disabled.
954
- *
955
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
956
- * initialized.
957
- *
958
- * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE @p queue is NULL or invalid.
959
- *
960
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_cu_mask_count is not
961
- * a multiple of 32 or @p num_cu_mask_count is not 0 and cu_mask is NULL.
962
- * Devices with work group processors must even-index contiguous pairwise
963
- * CU enable e.g. 0x33(b'110011) is valid while 0x5(0x101) and 0x6(b'0110)
964
- * are invalid.
965
- *
966
- */
967
- hsa_status_t HSA_API hsa_amd_queue_cu_set_mask(const hsa_queue_t* queue,
968
- uint32_t num_cu_mask_count,
969
- const uint32_t* cu_mask);
970
-
971
- /**
972
- * @brief Retrieve a queue's CU affinity mask.
973
- *
974
- * @details Returns the first num_cu_mask_count bits of a queue's CU mask.
975
- * Ensure that num_cu_mask_count is at least as large as
976
- * HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT to retrieve the entire mask.
977
- *
978
- * @param[in] queue A pointer to HSA queue.
979
- *
980
- * @param[in] num_cu_mask_count Size of CUMask bit array passed in, in bits.
981
- *
982
- * @param[out] cu_mask Bit-vector representing the CU mask.
983
- *
984
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
985
- *
986
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
987
- * initialized.
988
- *
989
- * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE @p queue is NULL or invalid.
990
- *
991
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_cu_mask_count is 0, not
992
- * a multiple of 32 or @p cu_mask is NULL.
993
- *
994
- */
995
- hsa_status_t HSA_API hsa_amd_queue_cu_get_mask(const hsa_queue_t* queue, uint32_t num_cu_mask_count,
996
- uint32_t* cu_mask);
997
-
998
- /**
999
- * @brief Memory segments associated with a memory pool.
1000
- */
1001
- typedef enum {
1002
- /**
1003
- * Global segment. Used to hold data that is shared by all agents.
1004
- */
1005
- HSA_AMD_SEGMENT_GLOBAL = 0,
1006
- /**
1007
- * Read-only segment. Used to hold data that remains constant during the
1008
- * execution of a kernel.
1009
- */
1010
- HSA_AMD_SEGMENT_READONLY = 1,
1011
- /**
1012
- * Private segment. Used to hold data that is local to a single work-item.
1013
- */
1014
- HSA_AMD_SEGMENT_PRIVATE = 2,
1015
- /**
1016
- * Group segment. Used to hold data that is shared by the work-items of a
1017
- * work-group.
1018
- */
1019
- HSA_AMD_SEGMENT_GROUP = 3,
1020
- } hsa_amd_segment_t;
1021
-
1022
- /**
1023
- * @brief A memory pool encapsulates physical storage on an agent
1024
- * along with a memory access model.
1025
- *
1026
- * @details A memory pool encapsulates a physical partition of an agent's
1027
- * memory system along with a memory access model. Division of a single
1028
- * memory system into separate pools allows querying each partition's access
1029
- * path properties (see ::hsa_amd_agent_memory_pool_get_info). Allocations
1030
- * from a pool are preferentially bound to that pool's physical partition.
1031
- * Binding to the pool's preferential physical partition may not be
1032
- * possible or persistent depending on the system's memory policy
1033
- * and/or state which is beyond the scope of HSA APIs.
1034
- *
1035
- * For example, a multi-node NUMA memory system may be represented by multiple
1036
- * pool's with each pool providing size and access path information for the
1037
- * partition it represents. Allocations from a pool are preferentially bound
1038
- * to the pool's partition (which in this example is a NUMA node) while
1039
- * following its memory access model. The actual placement may vary or migrate
1040
- * due to the system's NUMA policy and state, which is beyond the scope of
1041
- * HSA APIs.
1042
- */
1043
- typedef struct hsa_amd_memory_pool_s {
1044
- /**
1045
- * Opaque handle.
1046
- */
1047
- uint64_t handle;
1048
- } hsa_amd_memory_pool_t;
1049
-
1050
- typedef enum hsa_amd_memory_pool_global_flag_s {
1051
- /**
1052
- * The application can use allocations in the memory pool to store kernel
1053
- * arguments, and provide the values for the kernarg segment of
1054
- * a kernel dispatch.
1055
- */
1056
- HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT = 1,
1057
- /**
1058
- * Updates to memory in this pool conform to HSA memory consistency model.
1059
- * If this flag is set, then ::HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED
1060
- * must not be set.
1061
- */
1062
- HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED = 2,
1063
- /**
1064
- * Writes to memory in this pool can be performed by a single agent at a time.
1065
- */
1066
- HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED = 4,
1067
-
1068
- /** Updates to memory in this memory pool have extended scope, acting as
1069
- * system-scope atomics for variables in memory regions of this type.
1070
- * Note: On non-compliant systems, device-specific actions may be required
1071
- * for system-scope coherence. */
1072
- HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_EXTENDED_SCOPE_FINE_GRAINED = 8,
1073
-
1074
- } hsa_amd_memory_pool_global_flag_t;
1075
-
1076
- typedef enum hsa_amd_memory_pool_location_s {
1077
- /**
1078
- * This memory pool resides on the host (CPU)
1079
- */
1080
- HSA_AMD_MEMORY_POOL_LOCATION_CPU = 0,
1081
- /**
1082
- * This memory pool resides on a GPU
1083
- */
1084
- HSA_AMD_MEMORY_POOL_LOCATION_GPU = 1
1085
- } hsa_amd_memory_pool_location_t;
1086
-
1087
- /**
1088
- * @brief Memory pool features.
1089
- */
1090
- typedef enum {
1091
- /**
1092
- * Segment where the memory pool resides. The type of this attribute is
1093
- * ::hsa_amd_segment_t.
1094
- */
1095
- HSA_AMD_MEMORY_POOL_INFO_SEGMENT = 0,
1096
- /**
1097
- * Flag mask. The value of this attribute is undefined if the value of
1098
- * ::HSA_AMD_MEMORY_POOL_INFO_SEGMENT is not ::HSA_AMD_SEGMENT_GLOBAL. The type
1099
- * of
1100
- * this attribute is uint32_t, a bit-field of
1101
- * ::hsa_amd_memory_pool_global_flag_t
1102
- * values.
1103
- */
1104
- HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS = 1,
1105
- /**
1106
- * Size of this pool, in bytes. The type of this attribute is size_t.
1107
- */
1108
- HSA_AMD_MEMORY_POOL_INFO_SIZE = 2,
1109
- /**
1110
- * Indicates whether memory in this pool can be allocated using
1111
- * ::hsa_amd_memory_pool_allocate. The type of this attribute is bool.
1112
- *
1113
- * The value of this flag is always false for memory pools in the group and
1114
- * private segments.
1115
- */
1116
- HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED = 5,
1117
- /**
1118
- * Allocation granularity of buffers allocated by
1119
- * ::hsa_amd_memory_pool_allocate
1120
- * in this memory pool. The size of a buffer allocated in this pool is a
1121
- * multiple of the value of this attribute. While this is the minimum size of
1122
- * allocation allowed, it is recommened to use
1123
- * HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE to obtain the recommended
1124
- * allocation granularity size for this pool.
1125
- * The value of this attribute is only defined if
1126
- * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for
1127
- * this pool. The type of this attribute is size_t.
1128
- */
1129
- HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE = 6,
1130
- /**
1131
- * Alignment of buffers allocated by ::hsa_amd_memory_pool_allocate in this
1132
- * pool. The value of this attribute is only defined if
1133
- * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool, and
1134
- * must be a power of 2. The type of this attribute is size_t.
1135
- */
1136
- HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT = 7,
1137
- /**
1138
- * This memory_pool can be made directly accessible by all the agents in the
1139
- * system (::hsa_amd_agent_memory_pool_get_info does not return
1140
- * ::HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED for any agent). The type of this
1141
- * attribute is bool.
1142
- */
1143
- HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL = 15,
1144
- /**
1145
- * Maximum aggregate allocation size in bytes. The type of this attribute
1146
- * is size_t.
1147
- */
1148
- HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE = 16,
1149
- /**
1150
- * Location of this memory pool. The type of this attribute
1151
- * is hsa_amd_memory_pool_location_t.
1152
- */
1153
- HSA_AMD_MEMORY_POOL_INFO_LOCATION = 17,
1154
- /**
1155
- * Internal block size for allocations. This would also be the recommended
1156
- * granularity size for allocations as this prevents internal fragmentation.
1157
- * The value of this attribute is only defined if
1158
- * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool.
1159
- * The size of this attribute is size_t.
1160
- */
1161
- HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE = 18,
1162
- } hsa_amd_memory_pool_info_t;
1163
-
1164
- /**
1165
- * @brief Memory pool flag used to specify allocation directives
1166
- *
1167
- */
1168
- typedef enum hsa_amd_memory_pool_flag_s {
1169
- /**
1170
- * Allocates memory that conforms to standard HSA memory consistency model
1171
- */
1172
- HSA_AMD_MEMORY_POOL_STANDARD_FLAG = 0,
1173
- /**
1174
- * Allocates fine grain memory type where memory ordering is per point to point
1175
- * connection. Atomic memory operations on these memory buffers are not
1176
- * guaranteed to be visible at system scope.
1177
- */
1178
- HSA_AMD_MEMORY_POOL_PCIE_FLAG = 1,
1179
-
1180
- } hsa_amd_memory_pool_flag_t;
1181
-
1182
- /**
1183
- * @brief Get the current value of an attribute of a memory pool.
1184
- *
1185
- * @param[in] memory_pool A valid memory pool.
1186
- *
1187
- * @param[in] attribute Attribute to query.
1188
- *
1189
- * @param[out] value Pointer to a application-allocated buffer where to store
1190
- * the value of the attribute. If the buffer passed by the application is not
1191
- * large enough to hold the value of @p attribute, the behavior is undefined.
1192
- *
1193
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1194
- *
1195
- */
1196
- hsa_status_t HSA_API
1197
- hsa_amd_memory_pool_get_info(hsa_amd_memory_pool_t memory_pool,
1198
- hsa_amd_memory_pool_info_t attribute,
1199
- void* value);
1200
-
1201
- /**
1202
- * @brief Iterate over the memory pools associated with a given agent, and
1203
- * invoke an application-defined callback on every iteration.
1204
- *
1205
- * @details An agent can directly access buffers located in some memory pool, or
1206
- * be enabled to access them by the application (see ::hsa_amd_agents_allow_access),
1207
- * yet that memory pool may not be returned by this function for that given
1208
- * agent.
1209
- *
1210
- * A memory pool of fine-grained type must be associated only with the host.
1211
- *
1212
- * @param[in] agent A valid agent.
1213
- *
1214
- * @param[in] callback Callback to be invoked on the same thread that called
1215
- * ::hsa_amd_agent_iterate_memory_pools, serially, once per memory pool that is
1216
- * associated with the agent. The HSA runtime passes two arguments to the
1217
- * callback: the memory pool, and the application data. If @p callback
1218
- * returns a status other than ::HSA_STATUS_SUCCESS for a particular iteration,
1219
- * the traversal stops and ::hsa_amd_agent_iterate_memory_pools returns that status
1220
- * value.
1221
- *
1222
- * @param[in] data Application data that is passed to @p callback on every
1223
- * iteration. May be NULL.
1224
- *
1225
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1226
- *
1227
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1228
- * initialized.
1229
- *
1230
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1231
- *
1232
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
1233
- */
1234
- hsa_status_t HSA_API hsa_amd_agent_iterate_memory_pools(
1235
- hsa_agent_t agent,
1236
- hsa_status_t (*callback)(hsa_amd_memory_pool_t memory_pool, void* data),
1237
- void* data);
1238
-
1239
- /**
1240
- * @brief Allocate a block of memory (or buffer) in the specified pool.
1241
- *
1242
- * @param[in] memory_pool Memory pool where to allocate memory from. The memory
1243
- * pool must have the ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED flag set.
1244
- *
1245
- * @param[in] size Allocation size, in bytes. Must not be zero. This value is
1246
- * rounded up to the nearest multiple of
1247
- * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE in @p memory_pool.
1248
- *
1249
- * @param[in] flags A bit-field that is used to specify allocation
1250
- * directives.
1251
- *
1252
- * @param[out] ptr Pointer to the location where to store the base virtual
1253
- * address of
1254
- * the allocated block. The returned base address is aligned to the value of
1255
- * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT in @p memory_pool. If the
1256
- * allocation fails, the returned value is undefined.
1257
- *
1258
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1259
- *
1260
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1261
- * initialized.
1262
- *
1263
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES No memory is available.
1264
- *
1265
- * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL The memory pool is invalid.
1266
- *
1267
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The host is not allowed to
1268
- * allocate memory in @p memory_pool, or @p size is greater than
1269
- * the value of HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE in @p memory_pool.
1270
- *
1271
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p size is 0,
1272
- * or flags is not 0.
1273
- *
1274
- */
1275
- hsa_status_t HSA_API
1276
- hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, size_t size,
1277
- uint32_t flags, void** ptr);
1278
-
1279
- /**
1280
- * @brief Deallocate a block of memory previously allocated using
1281
- * ::hsa_amd_memory_pool_allocate.
1282
- *
1283
- * @param[in] ptr Pointer to a memory block. If @p ptr does not match a value
1284
- * previously returned by ::hsa_amd_memory_pool_allocate, the behavior is undefined.
1285
- *
1286
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1287
- *
1288
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1289
- * initialized.
1290
- *
1291
- */
1292
- hsa_status_t HSA_API hsa_amd_memory_pool_free(void* ptr);
1293
-
1294
- /**
1295
- * @brief Asynchronously copy a block of memory from the location pointed to by
1296
- * @p src on the @p src_agent to the memory block pointed to by @p dst on the @p
1297
- * dst_agent.
1298
- * Because the DMA engines used may not be in the same coherency domain, the caller must ensure
1299
- * that buffers are system-level coherent. In general this requires the sending device to have
1300
- * released the buffer to system scope prior to executing the copy API and the receiving device
1301
- * must execute a system scope acquire fence prior to use of the destination buffer.
1302
- *
1303
- * @param[out] dst Buffer where the content is to be copied.
1304
- *
1305
- * @param[in] dst_agent Agent associated with the @p dst. The agent must be able to directly
1306
- * access both the source and destination buffers in their current locations.
1307
- * May be zero in which case the runtime will attempt to discover the destination agent.
1308
- * Discovery may have variable and/or high latency.
1309
- *
1310
- * @param[in] src A valid pointer to the source of data to be copied. The source
1311
- * buffer must not overlap with the destination buffer, otherwise the copy will succeed
1312
- * but contents of @p dst is undefined.
1313
- *
1314
- * @param[in] src_agent Agent associated with the @p src. The agent must be able to directly
1315
- * access both the source and destination buffers in their current locations.
1316
- * May be zero in which case the runtime will attempt to discover the destination agent.
1317
- * Discovery may have variable and/or high latency.
1318
- *
1319
- * @param[in] size Number of bytes to copy. If @p size is 0, no copy is
1320
- * performed and the function returns success. Copying a number of bytes larger
1321
- * than the size of the buffers pointed by @p dst or @p src results in undefined
1322
- * behavior.
1323
- *
1324
- * @param[in] num_dep_signals Number of dependent signals. Can be 0.
1325
- *
1326
- * @param[in] dep_signals List of signals that must be waited on before the copy
1327
- * operation starts. The copy will start after every signal has been observed with
1328
- * the value 0. The dependent signal should not include completion signal from
1329
- * hsa_amd_memory_async_copy operation to be issued in future as that can result
1330
- * in a deadlock. If @p num_dep_signals is 0, this argument is ignored.
1331
- *
1332
- * @param[in] completion_signal Signal used to indicate completion of the copy
1333
- * operation. When the copy operation is finished, the value of the signal is
1334
- * decremented. The runtime indicates that an error has occurred during the copy
1335
- * operation by setting the value of the completion signal to a negative
1336
- * number. The signal handle must not be 0.
1337
- *
1338
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully. The
1339
- * application is responsible for checking for asynchronous error conditions
1340
- * (see the description of @p completion_signal).
1341
- *
1342
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1343
- * initialized.
1344
- *
1345
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT An agent is invalid or no discovered agent has access.
1346
- *
1347
- * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL @p completion_signal is invalid.
1348
- *
1349
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
1350
- * pointers are NULL, or the completion signal is 0.
1351
- */
1352
- hsa_status_t HSA_API
1353
- hsa_amd_memory_async_copy(void* dst, hsa_agent_t dst_agent, const void* src,
1354
- hsa_agent_t src_agent, size_t size,
1355
- uint32_t num_dep_signals,
1356
- const hsa_signal_t* dep_signals,
1357
- hsa_signal_t completion_signal);
1358
-
1359
- /**
1360
- * @brief Asynchronously copy a block of memory from the location pointed to by
1361
- * @p src on the @p src_agent to the memory block pointed to by @p dst on the @p
1362
- * dst_agent on engine_id.
1363
- *
1364
- * WARNING: Concurrent use of this call with hsa_amd_memory_async_copy can result
1365
- * in resource conflicts as HSA runtime will auto assign engines with the latter
1366
- * call. Approach using both calls concurrently with caution.
1367
- *
1368
- * All param definitions are identical to hsa_amd_memory_async_copy with the
1369
- * exception of engine_id and force_copy_on_sdma.
1370
- *
1371
- * @param[in] - engine_id Target engine defined by hsa_amd_sdma_engine_id_t.
1372
- * Client should use hsa_amd_memory_copy_engine_status first to get the ID
1373
- * availability.
1374
- *
1375
- * @param[in] - force_copy_on_sdma By default, blit kernel copies are used when
1376
- * dst_agent == src_agent. Setting this to true will force the copy over SDMA1.
1377
- *
1378
- * All return definitions are identical to hsa_amd_memory_async_copy with the
1379
- * following ammendments:
1380
- *
1381
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
1382
- * pointers are NULL, or the completion signal is 0 or engine_id is improperly
1383
- * bounded.
1384
- */
1385
- hsa_status_t HSA_API
1386
- hsa_amd_memory_async_copy_on_engine(void* dst, hsa_agent_t dst_agent, const void* src,
1387
- hsa_agent_t src_agent, size_t size,
1388
- uint32_t num_dep_signals,
1389
- const hsa_signal_t* dep_signals,
1390
- hsa_signal_t completion_signal,
1391
- hsa_amd_sdma_engine_id_t engine_id,
1392
- bool force_copy_on_sdma);
1393
- /**
1394
- * @brief Reports the availability of SDMA copy engines.
1395
- *
1396
- * @param[in] dst_agent Destination agent of copy status direction.
1397
- *
1398
- * @param[in] src_agent Source agent of copy status direction.
1399
- *
1400
- * @param[out] engine_ids_mask returns available SDMA engine IDs that can be masked
1401
- * with hsa_amd_sdma_engine_id_t.
1402
- *
1403
- * @retval ::HSA_STATUS_SUCCESS Agent has available SDMA engines.
1404
- *
1405
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Agent does not have available SDMA engines.
1406
- *
1407
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT dst_agent and src_agent are the same as
1408
- * dst_agent == src_agent is generally used for shader copies.
1409
- */
1410
- hsa_status_t HSA_API
1411
- hsa_amd_memory_copy_engine_status(hsa_agent_t dst_agent, hsa_agent_t src_agent,
1412
- uint32_t *engine_ids_mask);
1413
-
1414
- /*
1415
- [Provisional API]
1416
- Pitched memory descriptor.
1417
- All elements must be 4 byte aligned. Pitch and slice are in bytes.
1418
- */
1419
- typedef struct hsa_pitched_ptr_s {
1420
- void* base;
1421
- size_t pitch;
1422
- size_t slice;
1423
- } hsa_pitched_ptr_t;
1424
-
1425
- /*
1426
- [Provisional API]
1427
- Copy direction flag.
1428
- */
1429
- typedef enum {
1430
- hsaHostToHost = 0,
1431
- hsaHostToDevice = 1,
1432
- hsaDeviceToHost = 2,
1433
- hsaDeviceToDevice = 3
1434
- } hsa_amd_copy_direction_t;
1435
-
1436
- /*
1437
- [Provisional API]
1438
- SDMA 3D memory copy API. The same requirements must be met by src and dst as in
1439
- hsa_amd_memory_async_copy.
1440
- Both src and dst must be directly accessible to the copy_agent during the copy, src and dst rects
1441
- must not overlap.
1442
- CPU agents are not supported. API requires SDMA and will return an error if SDMA is not available.
1443
- Offsets and range carry x in bytes, y and z in rows and layers.
1444
- */
1445
- hsa_status_t HSA_API hsa_amd_memory_async_copy_rect(
1446
- const hsa_pitched_ptr_t* dst, const hsa_dim3_t* dst_offset, const hsa_pitched_ptr_t* src,
1447
- const hsa_dim3_t* src_offset, const hsa_dim3_t* range, hsa_agent_t copy_agent,
1448
- hsa_amd_copy_direction_t dir, uint32_t num_dep_signals, const hsa_signal_t* dep_signals,
1449
- hsa_signal_t completion_signal);
1450
-
1451
- /**
1452
- * @brief Type of accesses to a memory pool from a given agent.
1453
- */
1454
- typedef enum {
1455
- /**
1456
- * The agent cannot directly access any buffer in the memory pool.
1457
- */
1458
- HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED = 0,
1459
- /**
1460
- * The agent can directly access a buffer located in the pool; the application
1461
- * does not need to invoke ::hsa_amd_agents_allow_access.
1462
- */
1463
- HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT = 1,
1464
- /**
1465
- * The agent can directly access a buffer located in the pool, but only if the
1466
- * application has previously requested access to that buffer using
1467
- * ::hsa_amd_agents_allow_access.
1468
- */
1469
- HSA_AMD_MEMORY_POOL_ACCESS_DISALLOWED_BY_DEFAULT = 2
1470
- } hsa_amd_memory_pool_access_t;
1471
-
1472
- /**
1473
- * @brief Properties of the relationship between an agent a memory pool.
1474
- */
1475
- typedef enum {
1476
- /**
1477
- * Hyper-transport bus type.
1478
- */
1479
- HSA_AMD_LINK_INFO_TYPE_HYPERTRANSPORT = 0,
1480
-
1481
- /**
1482
- * QPI bus type.
1483
- */
1484
- HSA_AMD_LINK_INFO_TYPE_QPI = 1,
1485
-
1486
- /**
1487
- * PCIe bus type.
1488
- */
1489
- HSA_AMD_LINK_INFO_TYPE_PCIE = 2,
1490
-
1491
- /**
1492
- * Infiniband bus type.
1493
- */
1494
- HSA_AMD_LINK_INFO_TYPE_INFINBAND = 3,
1495
-
1496
- /**
1497
- * xGMI link type.
1498
- */
1499
- HSA_AMD_LINK_INFO_TYPE_XGMI = 4
1500
-
1501
- } hsa_amd_link_info_type_t;
1502
-
1503
- /**
1504
- * @brief Link properties when accessing the memory pool from the specified
1505
- * agent.
1506
- */
1507
- typedef struct hsa_amd_memory_pool_link_info_s {
1508
- /**
1509
- * Minimum transfer latency (rounded to ns).
1510
- */
1511
- uint32_t min_latency;
1512
-
1513
- /**
1514
- * Maximum transfer latency (rounded to ns).
1515
- */
1516
- uint32_t max_latency;
1517
-
1518
- /**
1519
- * Minimum link interface bandwidth in MB/s.
1520
- */
1521
- uint32_t min_bandwidth;
1522
-
1523
- /**
1524
- * Maximum link interface bandwidth in MB/s.
1525
- */
1526
- uint32_t max_bandwidth;
1527
-
1528
- /**
1529
- * Support for 32-bit atomic transactions.
1530
- */
1531
- bool atomic_support_32bit;
1532
-
1533
- /**
1534
- * Support for 64-bit atomic transactions.
1535
- */
1536
- bool atomic_support_64bit;
1537
-
1538
- /**
1539
- * Support for cache coherent transactions.
1540
- */
1541
- bool coherent_support;
1542
-
1543
- /**
1544
- * The type of bus/link.
1545
- */
1546
- hsa_amd_link_info_type_t link_type;
1547
-
1548
- /**
1549
- * NUMA distance of memory pool relative to querying agent
1550
- */
1551
- uint32_t numa_distance;
1552
- } hsa_amd_memory_pool_link_info_t;
1553
-
1554
- /**
1555
- * @brief Properties of the relationship between an agent a memory pool.
1556
- */
1557
- typedef enum {
1558
- /**
1559
- * Access to buffers located in the memory pool. The type of this attribute
1560
- * is ::hsa_amd_memory_pool_access_t.
1561
- *
1562
- * An agent can always directly access buffers currently located in a memory
1563
- * pool that is associated (the memory_pool is one of the values returned by
1564
- * ::hsa_amd_agent_iterate_memory_pools on the agent) with that agent. If the
1565
- * buffer is currently located in a memory pool that is not associated with
1566
- * the agent, and the value returned by this function for the given
1567
- * combination of agent and memory pool is not
1568
- * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED, the application still needs to invoke
1569
- * ::hsa_amd_agents_allow_access in order to gain direct access to the buffer.
1570
- *
1571
- * If the given agent can directly access buffers the pool, the result is not
1572
- * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is associated with
1573
- * the agent, or it is of fined-grained type, the result must not be
1574
- * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is not associated
1575
- * with the agent, and does not reside in the global segment, the result must
1576
- * be HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED.
1577
- */
1578
- HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS = 0,
1579
-
1580
- /**
1581
- * Number of links to hop when accessing the memory pool from the specified
1582
- * agent. The value of this attribute is zero if the memory pool is associated
1583
- * with the agent, or if the access type is
1584
- * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. The type of this attribute is
1585
- * uint32_t.
1586
- */
1587
- HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS = 1,
1588
-
1589
- /**
1590
- * Details of each link hop when accessing the memory pool starting from the
1591
- * specified agent. The type of this attribute is an array size of
1592
- * HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS with each element containing
1593
- * ::hsa_amd_memory_pool_link_info_t.
1594
- */
1595
- HSA_AMD_AGENT_MEMORY_POOL_INFO_LINK_INFO = 2
1596
-
1597
- } hsa_amd_agent_memory_pool_info_t;
1598
-
1599
- /**
1600
- * @brief Get the current value of an attribute of the relationship between an
1601
- * agent and a memory pool.
1602
- *
1603
- * @param[in] agent Agent.
1604
- *
1605
- * @param[in] memory_pool Memory pool.
1606
- *
1607
- * @param[in] attribute Attribute to query.
1608
- *
1609
- * @param[out] value Pointer to a application-allocated buffer where to store
1610
- * the value of the attribute. If the buffer passed by the application is not
1611
- * large enough to hold the value of @p attribute, the behavior is undefined.
1612
- *
1613
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1614
- *
1615
- */
1616
- hsa_status_t HSA_API hsa_amd_agent_memory_pool_get_info(
1617
- hsa_agent_t agent, hsa_amd_memory_pool_t memory_pool,
1618
- hsa_amd_agent_memory_pool_info_t attribute, void* value);
1619
-
1620
- /**
1621
- * @brief Enable direct access to a buffer from a given set of agents.
1622
- *
1623
- * @details
1624
- *
1625
- * Upon return, only the listed agents and the agent associated with the
1626
- * buffer's memory pool have direct access to the @p ptr.
1627
- *
1628
- * Any agent that has access to the buffer before and after the call to
1629
- * ::hsa_amd_agents_allow_access will also have access while
1630
- * ::hsa_amd_agents_allow_access is in progress.
1631
- *
1632
- * The caller is responsible for ensuring that each agent in the list
1633
- * must be able to access the memory pool containing @p ptr
1634
- * (using ::hsa_amd_agent_memory_pool_get_info with ::HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS attribute),
1635
- * otherwise error code is returned.
1636
- *
1637
- * @param[in] num_agents Size of @p agents.
1638
- *
1639
- * @param[in] agents List of agents. If @p num_agents is 0, this argument is
1640
- * ignored.
1641
- *
1642
- * @param[in] flags A list of bit-field that is used to specify access
1643
- * information in a per-agent basis. This is currently reserved and must be NULL.
1644
- *
1645
- * @param[in] ptr A buffer previously allocated using ::hsa_amd_memory_pool_allocate.
1646
- *
1647
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1648
- *
1649
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1650
- * initialized.
1651
- *
1652
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_agents is 0, or @p agents
1653
- * is NULL, @p flags is not NULL, or attempting to enable access to agent(s)
1654
- * because @p ptr is allocated from an inaccessible pool.
1655
- *
1656
- */
1657
- hsa_status_t HSA_API
1658
- hsa_amd_agents_allow_access(uint32_t num_agents, const hsa_agent_t* agents,
1659
- const uint32_t* flags, const void* ptr);
1660
-
1661
- /**
1662
- * @brief Query if buffers currently located in some memory pool can be
1663
- * relocated to a destination memory pool.
1664
- *
1665
- * @details If the returned value is non-zero, a migration of a buffer to @p
1666
- * dst_memory_pool using ::hsa_amd_memory_migrate may nevertheless fail due to
1667
- * resource limitations.
1668
- *
1669
- * @param[in] src_memory_pool Source memory pool.
1670
- *
1671
- * @param[in] dst_memory_pool Destination memory pool.
1672
- *
1673
- * @param[out] result Pointer to a memory location where the result of the query
1674
- * is stored. Must not be NULL. If buffers currently located in @p
1675
- * src_memory_pool can be relocated to @p dst_memory_pool, the result is
1676
- * true.
1677
- *
1678
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1679
- *
1680
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1681
- * initialized.
1682
- *
1683
- * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL One of the memory pools is
1684
- * invalid.
1685
- *
1686
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
1687
- */
1688
- hsa_status_t HSA_API
1689
- hsa_amd_memory_pool_can_migrate(hsa_amd_memory_pool_t src_memory_pool,
1690
- hsa_amd_memory_pool_t dst_memory_pool,
1691
- bool* result);
1692
-
1693
- /**
1694
- * @brief Relocate a buffer to a new memory pool.
1695
- *
1696
- * @details When a buffer is migrated, its virtual address remains the same but
1697
- * its physical contents are moved to the indicated memory pool.
1698
- *
1699
- * After migration, only the agent associated with the destination pool will have access.
1700
- *
1701
- * The caller is also responsible for ensuring that the allocation in the
1702
- * source memory pool where the buffer is currently located can be migrated to the
1703
- * specified destination memory pool (using ::hsa_amd_memory_pool_can_migrate returns a value of true
1704
- * for the source and destination memory pools), otherwise behavior is undefined.
1705
- *
1706
- * The caller must ensure that the buffer is not accessed while it is migrated.
1707
- *
1708
- * @param[in] ptr Buffer to be relocated. The buffer must have been released to system
1709
- * prior to call this API. The buffer will be released to system upon completion.
1710
- *
1711
- * @param[in] memory_pool Memory pool where to place the buffer.
1712
- *
1713
- * @param[in] flags A bit-field that is used to specify migration
1714
- * information. Must be zero.
1715
- *
1716
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1717
- *
1718
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1719
- * initialized.
1720
- *
1721
- * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL The destination memory pool is
1722
- * invalid.
1723
- *
1724
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1725
- * allocating the necessary resources.
1726
- *
1727
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p flags is not 0.
1728
- */
1729
- hsa_status_t HSA_API hsa_amd_memory_migrate(const void* ptr,
1730
- hsa_amd_memory_pool_t memory_pool,
1731
- uint32_t flags);
1732
-
1733
- /**
1734
- *
1735
- * @brief Pin a host pointer allocated by C/C++ or OS allocator (i.e. ordinary system DRAM) and
1736
- * return a new pointer accessible by the @p agents. If the @p host_ptr overlaps with previously
1737
- * locked memory, then the overlap area is kept locked (i.e multiple mappings are permitted). In
1738
- * this case, the same input @p host_ptr may give different locked @p agent_ptr and when it does,
1739
- * they are not necessarily coherent (i.e. accessing either @p agent_ptr is not equivalent).
1740
- * Accesses to @p agent_ptr are coarse grained.
1741
- *
1742
- * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator.
1743
- *
1744
- * @param[in] size The size to be locked.
1745
- *
1746
- * @param[in] agents Array of agent handle to gain access to the @p host_ptr.
1747
- * If this parameter is NULL and the @p num_agent is 0, all agents
1748
- * in the platform will gain access to the @p host_ptr.
1749
- *
1750
- * @param[out] agent_ptr Pointer to the location where to store the new address.
1751
- *
1752
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1753
- *
1754
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1755
- * initialized.
1756
- *
1757
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1758
- * allocating the necessary resources.
1759
- *
1760
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT One or more agent in @p agents is
1761
- * invalid.
1762
- *
1763
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 or @p host_ptr or
1764
- * @p agent_ptr is NULL or @p agents not NULL but @p num_agent is 0 or @p agents
1765
- * is NULL but @p num_agent is not 0.
1766
- */
1767
- hsa_status_t HSA_API hsa_amd_memory_lock(void* host_ptr, size_t size,
1768
- hsa_agent_t* agents, int num_agent,
1769
- void** agent_ptr);
1770
-
1771
- /**
1772
- *
1773
- * @brief Pin a host pointer allocated by C/C++ or OS allocator (i.e. ordinary system DRAM) and
1774
- * return a new pointer accessible by the @p agents. If the @p host_ptr overlaps with previously
1775
- * locked memory, then the overlap area is kept locked (i.e. multiple mappings are permitted).
1776
- * In this case, the same input @p host_ptr may give different locked @p agent_ptr and when it
1777
- * does, they are not necessarily coherent (i.e. accessing either @p agent_ptr is not equivalent).
1778
- * Acesses to the memory via @p agent_ptr have the same access properties as memory allocated from
1779
- * @p pool as determined by ::hsa_amd_memory_pool_get_info and ::hsa_amd_agent_memory_pool_get_info
1780
- * (ex. coarse/fine grain, platform atomic support, link info). Physical composition and placement
1781
- * of the memory (ex. page size, NUMA binding) is not changed.
1782
- *
1783
- * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator.
1784
- *
1785
- * @param[in] size The size to be locked.
1786
- *
1787
- * @param[in] agents Array of agent handle to gain access to the @p host_ptr.
1788
- * If this parameter is NULL and the @p num_agent is 0, all agents
1789
- * in the platform will gain access to the @p host_ptr.
1790
- *
1791
- * @param[in] pool Global memory pool owned by a CPU agent.
1792
- *
1793
- * @param[in] flags A bit-field that is used to specify allocation
1794
- * directives. Reserved parameter, must be 0.
1795
- *
1796
- * @param[out] agent_ptr Pointer to the location where to store the new address.
1797
- *
1798
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1799
- *
1800
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1801
- * initialized.
1802
- *
1803
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1804
- * allocating the necessary resources.
1805
- *
1806
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT One or more agent in @p agents is
1807
- * invalid or can not access @p pool.
1808
- *
1809
- * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL @p pool is invalid or not owned
1810
- * by a CPU agent.
1811
- *
1812
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 or @p host_ptr or
1813
- * @p agent_ptr is NULL or @p agents not NULL but @p num_agent is 0 or @p agents
1814
- * is NULL but @p num_agent is not 0 or flags is not 0.
1815
- */
1816
- hsa_status_t HSA_API hsa_amd_memory_lock_to_pool(void* host_ptr, size_t size, hsa_agent_t* agents,
1817
- int num_agent, hsa_amd_memory_pool_t pool,
1818
- uint32_t flags, void** agent_ptr);
1819
-
1820
- /**
1821
- *
1822
- * @brief Unpin the host pointer previously pinned via ::hsa_amd_memory_lock or
1823
- * ::hsa_amd_memory_lock_to_pool.
1824
- *
1825
- * @details The behavior is undefined if the host pointer being unpinned does not
1826
- * match previous pinned address or if the host pointer was already deallocated.
1827
- *
1828
- * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator that was
1829
- * pinned previously via ::hsa_amd_memory_lock or ::hsa_amd_memory_lock_to_pool.
1830
- *
1831
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1832
- *
1833
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1834
- * initialized.
1835
- */
1836
- hsa_status_t HSA_API hsa_amd_memory_unlock(void* host_ptr);
1837
-
1838
- /**
1839
- * @brief Sets the first @p count of uint32_t of the block of memory pointed by
1840
- * @p ptr to the specified @p value.
1841
- *
1842
- * @param[in] ptr Pointer to the block of memory to fill.
1843
- *
1844
- * @param[in] value Value to be set.
1845
- *
1846
- * @param[in] count Number of uint32_t element to be set to the value.
1847
- *
1848
- * @retval HSA_STATUS_SUCCESS The function has been executed successfully.
1849
- *
1850
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1851
- * initialized.
1852
- *
1853
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL or
1854
- * not 4 bytes aligned
1855
- *
1856
- * @retval HSA_STATUS_ERROR_INVALID_ALLOCATION if the given memory
1857
- * region was not allocated with HSA runtime APIs.
1858
- *
1859
- */
1860
- hsa_status_t HSA_API
1861
- hsa_amd_memory_fill(void* ptr, uint32_t value, size_t count);
1862
-
1863
- /**
1864
- * @brief Maps an interop object into the HSA flat address space and establishes
1865
- * memory residency. The metadata pointer is valid during the lifetime of the
1866
- * map (until hsa_amd_interop_unmap_buffer is called).
1867
- * Multiple calls to hsa_amd_interop_map_buffer with the same interop_handle
1868
- * result in multiple mappings with potentially different addresses and
1869
- * different metadata pointers. Concurrent operations on these addresses are
1870
- * not coherent. Memory must be fenced to system scope to ensure consistency,
1871
- * between mappings and with any views of this buffer in the originating
1872
- * software stack.
1873
- *
1874
- * @param[in] num_agents Number of agents which require access to the memory
1875
- *
1876
- * @param[in] agents List of accessing agents.
1877
- *
1878
- * @param[in] interop_handle Handle of interop buffer (dmabuf handle in Linux)
1879
- *
1880
- * @param [in] flags Reserved, must be 0
1881
- *
1882
- * @param[out] size Size in bytes of the mapped object
1883
- *
1884
- * @param[out] ptr Base address of the mapped object
1885
- *
1886
- * @param[out] metadata_size Size of metadata in bytes, may be NULL
1887
- *
1888
- * @param[out] metadata Pointer to metadata, may be NULL
1889
- *
1890
- * @retval HSA_STATUS_SUCCESS if successfully mapped
1891
- *
1892
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1893
- *
1894
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1895
- * necessary resources
1896
- *
1897
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT all other errors
1898
- */
1899
- hsa_status_t HSA_API hsa_amd_interop_map_buffer(uint32_t num_agents,
1900
- hsa_agent_t* agents,
1901
- int interop_handle,
1902
- uint32_t flags,
1903
- size_t* size,
1904
- void** ptr,
1905
- size_t* metadata_size,
1906
- const void** metadata);
1907
-
1908
- /**
1909
- * @brief Removes a previously mapped interop object from HSA's flat address space.
1910
- * Ends lifetime for the mapping's associated metadata pointer.
1911
- */
1912
- hsa_status_t HSA_API hsa_amd_interop_unmap_buffer(void* ptr);
1913
-
1914
- /**
1915
- * @brief Encodes an opaque vendor specific image format. The length of data
1916
- * depends on the underlying format. This structure must not be copied as its
1917
- * true length can not be determined.
1918
- */
1919
- typedef struct hsa_amd_image_descriptor_s {
1920
- /*
1921
- Version number of the descriptor
1922
- */
1923
- uint32_t version;
1924
-
1925
- /*
1926
- Vendor and device PCI IDs for the format as VENDOR_ID<<16|DEVICE_ID.
1927
- */
1928
- uint32_t deviceID;
1929
-
1930
- /*
1931
- Start of vendor specific data.
1932
- */
1933
- uint32_t data[1];
1934
- } hsa_amd_image_descriptor_t;
1935
-
1936
- /**
1937
- * @brief Creates an image from an opaque vendor specific image format.
1938
- * Does not modify data at image_data. Intended initially for
1939
- * accessing interop images.
1940
- *
1941
- * @param agent[in] Agent on which to create the image
1942
- *
1943
- * @param[in] image_descriptor[in] Vendor specific image format
1944
- *
1945
- * @param[in] image_data Pointer to image backing store
1946
- *
1947
- * @param[in] access_permission Access permissions for the image object
1948
- *
1949
- * @param[out] image Created image object.
1950
- *
1951
- * @retval HSA_STATUS_SUCCESS Image created successfully
1952
- *
1953
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1954
- *
1955
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1956
- * necessary resources
1957
- *
1958
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT Bad or mismatched descriptor,
1959
- * null image_data, or mismatched access_permission.
1960
- */
1961
- hsa_status_t HSA_API hsa_amd_image_create(
1962
- hsa_agent_t agent,
1963
- const hsa_ext_image_descriptor_t *image_descriptor,
1964
- const hsa_amd_image_descriptor_t *image_layout,
1965
- const void *image_data,
1966
- hsa_access_permission_t access_permission,
1967
- hsa_ext_image_t *image
1968
- );
1969
-
1970
- /**
1971
- * @brief Denotes the type of memory in a pointer info query.
1972
- */
1973
- typedef enum {
1974
- /*
1975
- Memory is not known to the HSA driver. Unallocated or unlocked system memory.
1976
- */
1977
- HSA_EXT_POINTER_TYPE_UNKNOWN = 0,
1978
- /*
1979
- Memory was allocated with an HSA memory allocator.
1980
- */
1981
- HSA_EXT_POINTER_TYPE_HSA = 1,
1982
- /*
1983
- System memory which has been locked for use with an HSA agent.
1984
-
1985
- Memory of this type is normal malloc'd memory and is always accessible to
1986
- the CPU. Pointer info queries may not include CPU agents in the accessible
1987
- agents list as the CPU has implicit access.
1988
- */
1989
- HSA_EXT_POINTER_TYPE_LOCKED = 2,
1990
- /*
1991
- Memory originated in a graphics component and is shared with ROCr.
1992
- */
1993
- HSA_EXT_POINTER_TYPE_GRAPHICS = 3,
1994
- /*
1995
- Memory has been shared with the local process via ROCr IPC APIs.
1996
- */
1997
- HSA_EXT_POINTER_TYPE_IPC = 4
1998
- } hsa_amd_pointer_type_t;
1999
-
2000
- /**
2001
- * @brief Describes a memory allocation known to ROCr.
2002
- * Within a ROCr major version this structure can only grow.
2003
- */
2004
- typedef struct hsa_amd_pointer_info_s {
2005
- /*
2006
- Size in bytes of this structure. Used for version control within a major ROCr
2007
- revision. Set to sizeof(hsa_amd_pointer_t) prior to calling
2008
- hsa_amd_pointer_info. If the runtime supports an older version of pointer
2009
- info then size will be smaller on return. Members starting after the return
2010
- value of size will not be updated by hsa_amd_pointer_info.
2011
- */
2012
- uint32_t size;
2013
- /*
2014
- The type of allocation referenced.
2015
- */
2016
- hsa_amd_pointer_type_t type;
2017
- /*
2018
- Base address at which non-host agents may access the allocation. This field is
2019
- not meaningful if the type of the allocation is HSA_EXT_POINTER_TYPE_UNKNOWN.
2020
- */
2021
- void* agentBaseAddress;
2022
- /*
2023
- Base address at which the host agent may access the allocation. This field is
2024
- not meaningful if the type of the allocation is HSA_EXT_POINTER_TYPE_UNKNOWN.
2025
- */
2026
- void* hostBaseAddress;
2027
- /*
2028
- Size of the allocation. This field is not meaningful if the type of the allocation
2029
- is HSA_EXT_POINTER_TYPE_UNKNOWN.
2030
- */
2031
- size_t sizeInBytes;
2032
- /*
2033
- Application provided value. This field is not meaningful if the type of the
2034
- allocation is HSA_EXT_POINTER_TYPE_UNKNOWN.
2035
- */
2036
- void* userData;
2037
- /*
2038
- Reports an agent which "owns" (ie has preferred access to) the pool in which the
2039
- allocation was
2040
- made. When multiple agents share equal access to a pool (ex: multiple CPU agents, or multi-die
2041
- GPU boards) any such agent may be returned. This field is not meaningful if
2042
- the type of the allocation is HSA_EXT_POINTER_TYPE_UNKNOWN or if this agent is not available in
2043
- this process, for e.g if this agent is masked using ROCR_VISIBLE_DEVICES.
2044
- */
2045
- hsa_agent_t agentOwner;
2046
- /*
2047
- Contains a bitfield of hsa_amd_memory_pool_global_flag_t values.
2048
- Reports the effective global flags bitmask for the allocation. This field is not
2049
- meaningful if the type of the allocation is HSA_EXT_POINTER_TYPE_UNKNOWN.
2050
- */
2051
- uint32_t global_flags;
2052
- } hsa_amd_pointer_info_t;
2053
-
2054
- /**
2055
- * @brief Retrieves information about the allocation referenced by the given
2056
- * pointer. Optionally returns the number and list of agents which can
2057
- * directly access the allocation. In case this virtual address is unknown, the
2058
- * pointer type returned will be HSA_EXT_POINTER_TYPE_UNKNOWN and the only fields
2059
- * that are valid after hsa_amd_pointer_info returns are size and type.
2060
- *
2061
- * @param[in] ptr Pointer which references the allocation to retrieve info for.
2062
- *
2063
- * @param[in, out] info Pointer to structure to be filled with allocation info.
2064
- * Data member size must be set to the size of the structure prior to calling
2065
- * hsa_amd_pointer_info. On return size will be set to the size of the
2066
- * pointer info structure supported by the runtime, if smaller. Members
2067
- * beyond the returned value of size will not be updated by the API.
2068
- * Must not be NULL.
2069
- *
2070
- * @param[in] alloc Function pointer to an allocator used to allocate the
2071
- * @p accessible array. If NULL @p accessible will not be returned.
2072
- *
2073
- * @param[out] num_agents_accessible Recieves the count of agents in
2074
- * @p accessible. If NULL @p accessible will not be returned.
2075
- *
2076
- * @param[out] accessible Recieves a pointer to the array, allocated by @p alloc,
2077
- * holding the list of agents which may directly access the allocation.
2078
- * May be NULL.
2079
- *
2080
- * @retval HSA_STATUS_SUCCESS Info retrieved successfully
2081
- *
2082
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2083
- *
2084
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2085
- * necessary resources
2086
- *
2087
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT NULL in @p ptr or @p info.
2088
- */
2089
- hsa_status_t HSA_API hsa_amd_pointer_info(const void* ptr,
2090
- hsa_amd_pointer_info_t* info,
2091
- void* (*alloc)(size_t),
2092
- uint32_t* num_agents_accessible,
2093
- hsa_agent_t** accessible);
2094
-
2095
- /**
2096
- * @brief Associates an arbitrary pointer with an allocation known to ROCr.
2097
- * The pointer can be fetched by hsa_amd_pointer_info in the userData field.
2098
- *
2099
- * @param[in] ptr Pointer to the first byte of an allocation known to ROCr
2100
- * with which to associate @p userdata.
2101
- *
2102
- * @param[in] userdata Abitrary pointer to associate with the allocation.
2103
- *
2104
- * @retval HSA_STATUS_SUCCESS @p userdata successfully stored.
2105
- *
2106
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2107
- *
2108
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2109
- * necessary resources
2110
- *
2111
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is not known to ROCr.
2112
- */
2113
- hsa_status_t HSA_API hsa_amd_pointer_info_set_userdata(const void* ptr,
2114
- void* userdata);
2115
-
2116
- /**
2117
- * @brief 256-bit process independent identifier for a ROCr shared memory
2118
- * allocation.
2119
- */
2120
- typedef struct hsa_amd_ipc_memory_s {
2121
- uint32_t handle[8];
2122
- } hsa_amd_ipc_memory_t;
2123
-
2124
- /**
2125
- * @brief Prepares an allocation for interprocess sharing and creates a
2126
- * handle of type hsa_amd_ipc_memory_t uniquely identifying the allocation. A
2127
- * handle is valid while the allocation it references remains accessible in
2128
- * any process. In general applications should confirm that a shared memory
2129
- * region has been attached (via hsa_amd_ipc_memory_attach) in the remote
2130
- * process prior to releasing that memory in the local process.
2131
- * Repeated calls for the same allocation may, but are not required to, return
2132
- * unique handles. The allocation needs to be on memory on an agent of type
2133
- * HSA_DEVICE_TYPE_GPU.
2134
- *
2135
- * @param[in] ptr Pointer to device memory allocated via ROCr APIs to prepare for
2136
- * sharing.
2137
- *
2138
- * @param[in] len Length in bytes of the allocation to share.
2139
- *
2140
- * @param[out] handle Process independent identifier referencing the shared
2141
- * allocation.
2142
- *
2143
- * @retval HSA_STATUS_SUCCESS allocation is prepared for interprocess sharing.
2144
- *
2145
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2146
- *
2147
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2148
- * necessary resources
2149
- *
2150
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr does not point to the
2151
- * first byte of an allocation made through ROCr, or len is not the full length
2152
- * of the allocation or handle is NULL.
2153
- */
2154
- hsa_status_t HSA_API hsa_amd_ipc_memory_create(void* ptr, size_t len,
2155
- hsa_amd_ipc_memory_t* handle);
2156
-
2157
- /**
2158
- * @brief Imports shared memory into the local process and makes it accessible
2159
- * by the given agents. If a shared memory handle is attached multiple times
2160
- * in a process each attach may return a different address. Each returned
2161
- * address is refcounted and requires a matching number of calls to
2162
- * hsa_amd_ipc_memory_detach to release the shared memory mapping.
2163
- *
2164
- * @param[in] handle Pointer to the identifier for the shared memory.
2165
- *
2166
- * @param[in] len Length of the shared memory to import.
2167
- * Reserved. Must be the full length of the shared allocation in this version.
2168
- *
2169
- * @param[in] num_agents Count of agents in @p mapping_agents.
2170
- * May be zero if all agents are to be allowed access.
2171
- *
2172
- * @param[in] mapping_agents List of agents to access the shared memory.
2173
- * Ignored if @p num_agents is zero.
2174
- *
2175
- * @param[out] mapped_ptr Recieves a process local pointer to the shared memory.
2176
- *
2177
- * @retval HSA_STATUS_SUCCESS if memory is successfully imported.
2178
- *
2179
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2180
- *
2181
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2182
- * necessary resources
2183
- *
2184
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p handle is not valid, @p len is
2185
- * incorrect, @p mapped_ptr is NULL, or some agent for which access was
2186
- * requested can not access the shared memory.
2187
- */
2188
- hsa_status_t HSA_API hsa_amd_ipc_memory_attach(
2189
- const hsa_amd_ipc_memory_t* handle, size_t len,
2190
- uint32_t num_agents,
2191
- const hsa_agent_t* mapping_agents,
2192
- void** mapped_ptr);
2193
-
2194
- /**
2195
- * @brief Decrements the reference count for the shared memory mapping and
2196
- * releases access to shared memory imported with hsa_amd_ipc_memory_attach.
2197
- *
2198
- * @param[in] mapped_ptr Pointer to the first byte of a shared allocation
2199
- * imported with hsa_amd_ipc_memory_attach.
2200
- *
2201
- * @retval HSA_STATUS_SUCCESS if @p mapped_ptr was imported with
2202
- * hsa_amd_ipc_memory_attach.
2203
- *
2204
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2205
- *
2206
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p mapped_ptr was not imported
2207
- * with hsa_amd_ipc_memory_attach.
2208
- */
2209
- hsa_status_t HSA_API hsa_amd_ipc_memory_detach(void* mapped_ptr);
2210
-
2211
- /**
2212
- * @brief 256-bit process independent identifier for a ROCr IPC signal.
2213
- */
2214
- typedef hsa_amd_ipc_memory_t hsa_amd_ipc_signal_t;
2215
-
2216
- /**
2217
- * @brief Obtains an interprocess sharing handle for a signal. The handle is
2218
- * valid while the signal it references remains valid in any process. In
2219
- * general applications should confirm that the signal has been attached (via
2220
- * hsa_amd_ipc_signal_attach) in the remote process prior to destroying that
2221
- * signal in the local process.
2222
- * Repeated calls for the same signal may, but are not required to, return
2223
- * unique handles.
2224
- *
2225
- * @param[in] signal Signal created with attribute HSA_AMD_SIGNAL_IPC.
2226
- *
2227
- * @param[out] handle Process independent identifier referencing the shared
2228
- * signal.
2229
- *
2230
- * @retval HSA_STATUS_SUCCESS @p handle is ready to use for interprocess sharing.
2231
- *
2232
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2233
- *
2234
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2235
- * necessary resources
2236
- *
2237
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is not a valid signal
2238
- * created with attribute HSA_AMD_SIGNAL_IPC or handle is NULL.
2239
- */
2240
- hsa_status_t HSA_API hsa_amd_ipc_signal_create(hsa_signal_t signal, hsa_amd_ipc_signal_t* handle);
2241
-
2242
- /**
2243
- * @brief Imports an IPC capable signal into the local process. If an IPC
2244
- * signal handle is attached multiple times in a process each attach may return
2245
- * a different signal handle. Each returned signal handle is refcounted and
2246
- * requires a matching number of calls to hsa_signal_destroy to release the
2247
- * shared signal.
2248
- *
2249
- * @param[in] handle Pointer to the identifier for the shared signal.
2250
- *
2251
- * @param[out] signal Recieves a process local signal handle to the shared signal.
2252
- *
2253
- * @retval HSA_STATUS_SUCCESS if the signal is successfully imported.
2254
- *
2255
- * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
2256
- *
2257
- * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2258
- * necessary resources
2259
- *
2260
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p handle is not valid.
2261
- */
2262
- hsa_status_t HSA_API hsa_amd_ipc_signal_attach(const hsa_amd_ipc_signal_t* handle,
2263
- hsa_signal_t* signal);
2264
-
2265
- /**
2266
- * @brief GPU system event type.
2267
- */
2268
- typedef enum hsa_amd_event_type_s {
2269
- /*
2270
- AMD GPU memory fault.
2271
- */
2272
- HSA_AMD_GPU_MEMORY_FAULT_EVENT = 0,
2273
- /*
2274
- AMD GPU HW Exception.
2275
- */
2276
- HSA_AMD_GPU_HW_EXCEPTION_EVENT,
2277
- } hsa_amd_event_type_t;
2278
-
2279
- /**
2280
- * @brief Flags denoting the cause of a memory fault.
2281
- */
2282
- typedef enum {
2283
- // Page not present or supervisor privilege.
2284
- HSA_AMD_MEMORY_FAULT_PAGE_NOT_PRESENT = 1 << 0,
2285
- // Write access to a read-only page.
2286
- HSA_AMD_MEMORY_FAULT_READ_ONLY = 1 << 1,
2287
- // Execute access to a page marked NX.
2288
- HSA_AMD_MEMORY_FAULT_NX = 1 << 2,
2289
- // GPU attempted access to a host only page.
2290
- HSA_AMD_MEMORY_FAULT_HOST_ONLY = 1 << 3,
2291
- // DRAM ECC failure.
2292
- HSA_AMD_MEMORY_FAULT_DRAMECC = 1 << 4,
2293
- // Can't determine the exact fault address.
2294
- HSA_AMD_MEMORY_FAULT_IMPRECISE = 1 << 5,
2295
- // SRAM ECC failure (ie registers, no fault address).
2296
- HSA_AMD_MEMORY_FAULT_SRAMECC = 1 << 6,
2297
- // GPU reset following unspecified hang.
2298
- HSA_AMD_MEMORY_FAULT_HANG = 1U << 31
2299
- } hsa_amd_memory_fault_reason_t;
2300
-
2301
- /**
2302
- * @brief AMD GPU memory fault event data.
2303
- */
2304
- typedef struct hsa_amd_gpu_memory_fault_info_s {
2305
- /*
2306
- The agent where the memory fault occurred.
2307
- */
2308
- hsa_agent_t agent;
2309
- /*
2310
- Virtual address accessed.
2311
- */
2312
- uint64_t virtual_address;
2313
- /*
2314
- Bit field encoding the memory access failure reasons. There could be multiple bits set
2315
- for one fault. Bits are defined in hsa_amd_memory_fault_reason_t.
2316
- */
2317
- uint32_t fault_reason_mask;
2318
- } hsa_amd_gpu_memory_fault_info_t;
2319
-
2320
- /**
2321
- * @brief Flags denoting the type of a HW exception
2322
- */
2323
- typedef enum {
2324
- // Unused for now
2325
- HSA_AMD_HW_EXCEPTION_RESET_TYPE_OTHER = 1 << 0,
2326
- } hsa_amd_hw_exception_reset_type_t;
2327
-
2328
- /**
2329
- * @brief Flags denoting the cause of a HW exception
2330
- */
2331
- typedef enum {
2332
- // GPU Hang
2333
- HSA_AMD_HW_EXCEPTION_CAUSE_GPU_HANG = 1 << 0,
2334
- // SRAM ECC
2335
- HSA_AMD_HW_EXCEPTION_CAUSE_ECC = 1 << 1,
2336
- } hsa_amd_hw_exception_reset_cause_t;
2337
-
2338
- /**
2339
- * @brief AMD GPU HW Exception event data.
2340
- */
2341
- typedef struct hsa_amd_gpu_hw_exception_info_s {
2342
- /*
2343
- The agent where the HW exception occurred.
2344
- */
2345
- hsa_agent_t agent;
2346
- hsa_amd_hw_exception_reset_type_t reset_type;
2347
- hsa_amd_hw_exception_reset_cause_t reset_cause;
2348
- } hsa_amd_gpu_hw_exception_info_t;
2349
-
2350
- /**
2351
- * @brief AMD GPU event data passed to event handler.
2352
- */
2353
- typedef struct hsa_amd_event_s {
2354
- /*
2355
- The event type.
2356
- */
2357
- hsa_amd_event_type_t event_type;
2358
- union {
2359
- /*
2360
- The memory fault info, only valid when @p event_type is HSA_AMD_GPU_MEMORY_FAULT_EVENT.
2361
- */
2362
- hsa_amd_gpu_memory_fault_info_t memory_fault;
2363
- /*
2364
- The memory fault info, only valid when @p event_type is HSA_AMD_GPU_HW_EXCEPTION_EVENT.
2365
- */
2366
- hsa_amd_gpu_hw_exception_info_t hw_exception;
2367
- };
2368
- } hsa_amd_event_t;
2369
-
2370
- typedef hsa_status_t (*hsa_amd_system_event_callback_t)(const hsa_amd_event_t* event, void* data);
2371
-
2372
- /**
2373
- * @brief Register AMD GPU event handler.
2374
- *
2375
- * @param[in] callback Callback to be invoked when an event is triggered.
2376
- * The HSA runtime passes two arguments to the callback: @p event
2377
- * is defined per event by the HSA runtime, and @p data is the user data.
2378
- *
2379
- * @param[in] data User data that is passed to @p callback. May be NULL.
2380
- *
2381
- * @retval HSA_STATUS_SUCCESS The handler has been registered successfully.
2382
- *
2383
- * @retval HSA_STATUS_ERROR An event handler has already been registered.
2384
- *
2385
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p event is invalid.
2386
- */
2387
- hsa_status_t HSA_API hsa_amd_register_system_event_handler(hsa_amd_system_event_callback_t callback,
2388
- void* data);
2389
-
2390
- /**
2391
- * @brief Per-queue dispatch and wavefront scheduling priority.
2392
- */
2393
- typedef enum hsa_amd_queue_priority_s {
2394
- /*
2395
- Below normal/high priority compute and all graphics
2396
- */
2397
- HSA_AMD_QUEUE_PRIORITY_LOW = 0,
2398
- /*
2399
- Above low priority compute, below high priority compute and all graphics
2400
- */
2401
- HSA_AMD_QUEUE_PRIORITY_NORMAL = 1,
2402
- /*
2403
- Above low/normal priority compute and all graphics
2404
- */
2405
- HSA_AMD_QUEUE_PRIORITY_HIGH = 2,
2406
- } hsa_amd_queue_priority_t;
2407
-
2408
- /**
2409
- * @brief Modifies the dispatch and wavefront scheduling prioirty for a
2410
- * given compute queue. The default is HSA_AMD_QUEUE_PRIORITY_NORMAL.
2411
- *
2412
- * @param[in] queue Compute queue to apply new priority to.
2413
- *
2414
- * @param[in] priority Priority to associate with queue.
2415
- *
2416
- * @retval HSA_STATUS_SUCCESS if priority was changed successfully.
2417
- *
2418
- * @retval HSA_STATUS_ERROR_INVALID_QUEUE if queue is not a valid
2419
- * compute queue handle.
2420
- *
2421
- * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT if priority is not a valid
2422
- * value from hsa_amd_queue_priority_t.
2423
- */
2424
- hsa_status_t HSA_API hsa_amd_queue_set_priority(hsa_queue_t* queue,
2425
- hsa_amd_queue_priority_t priority);
2426
-
2427
- /**
2428
- * @brief Deallocation notifier function type.
2429
- */
2430
- typedef void (*hsa_amd_deallocation_callback_t)(void* ptr, void* user_data);
2431
-
2432
- /**
2433
- * @brief Registers a deallocation notifier monitoring for release of agent
2434
- * accessible address @p ptr. If successful, @p callback will be invoked when
2435
- * @p ptr is removed from accessibility from all agents.
2436
- *
2437
- * Notification callbacks are automatically deregistered when they are invoked.
2438
- *
2439
- * Note: The current version supports notifications of address release
2440
- * originating from ::hsa_amd_memory_pool_free. Support for other address
2441
- * release APIs will follow.
2442
- *
2443
- * @param[in] ptr Agent accessible address to monitor for deallocation. Passed
2444
- * to @p callback.
2445
- *
2446
- * @param[in] callback Notifier to be invoked when @p ptr is released from
2447
- * agent accessibility.
2448
- *
2449
- * @param[in] user_data User provided value passed to @p callback. May be NULL.
2450
- *
2451
- * @retval ::HSA_STATUS_SUCCESS The notifier registered successfully
2452
- *
2453
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2454
- * initialized.
2455
- *
2456
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION @p ptr does not refer to a valid agent accessible
2457
- * address.
2458
- *
2459
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL or @p ptr is NULL.
2460
- *
2461
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
2462
- * necessary resources
2463
- */
2464
- hsa_status_t HSA_API hsa_amd_register_deallocation_callback(void* ptr,
2465
- hsa_amd_deallocation_callback_t callback,
2466
- void* user_data);
2467
-
2468
- /**
2469
- * @brief Removes a deallocation notifier previously registered with
2470
- * ::hsa_amd_register_deallocation_callback. Arguments must be identical to
2471
- * those given in ::hsa_amd_register_deallocation_callback.
2472
- *
2473
- * @param[in] ptr Agent accessible address which was monitored for deallocation.
2474
- *
2475
- * @param[in] callback Notifier to be removed.
2476
- *
2477
- * @retval ::HSA_STATUS_SUCCESS The notifier has been removed successfully.
2478
- *
2479
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2480
- * initialized.
2481
- *
2482
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The given notifier was not registered.
2483
- */
2484
- hsa_status_t HSA_API hsa_amd_deregister_deallocation_callback(void* ptr,
2485
- hsa_amd_deallocation_callback_t callback);
2486
-
2487
- typedef enum hsa_amd_svm_model_s {
2488
- /**
2489
- * Updates to memory with this attribute conform to HSA memory consistency
2490
- * model.
2491
- */
2492
- HSA_AMD_SVM_GLOBAL_FLAG_FINE_GRAINED = 0,
2493
- /**
2494
- * Writes to memory with this attribute can be performed by a single agent
2495
- * at a time.
2496
- */
2497
- HSA_AMD_SVM_GLOBAL_FLAG_COARSE_GRAINED = 1,
2498
- /**
2499
- * Memory region queried contains subregions with both
2500
- * HSA_AMD_SVM_GLOBAL_FLAG_COARSE_GRAINED and
2501
- * HSA_AMD_SVM_GLOBAL_FLAG_FINE_GRAINED attributes.
2502
- *
2503
- * This attribute can not be used in hsa_amd_svm_attributes_set. It is a
2504
- * possible return from hsa_amd_svm_attributes_get indicating that the query
2505
- * region contains both coarse and fine grained memory.
2506
- */
2507
- HSA_AMD_SVM_GLOBAL_FLAG_INDETERMINATE = 2
2508
- } hsa_amd_svm_model_t;
2509
-
2510
- typedef enum hsa_amd_svm_attribute_s {
2511
- // Memory model attribute.
2512
- // Type of this attribute is hsa_amd_svm_model_t.
2513
- HSA_AMD_SVM_ATTRIB_GLOBAL_FLAG = 0,
2514
- // Marks the range read only. This allows multiple physical copies to be
2515
- // placed local to each accessing device.
2516
- // Type of this attribute is bool.
2517
- HSA_AMD_SVM_ATTRIB_READ_ONLY = 1,
2518
- // Automatic migrations should attempt to keep the memory within the xgmi hive
2519
- // containing accessible agents.
2520
- // Type of this attribute is bool.
2521
- HSA_AMD_SVM_ATTRIB_HIVE_LOCAL = 2,
2522
- // Page granularity to migrate at once. Page granularity is specified as
2523
- // log2(page_count).
2524
- // Type of this attribute is uint64_t.
2525
- HSA_AMD_SVM_ATTRIB_MIGRATION_GRANULARITY = 3,
2526
- // Physical location to prefer when automatic migration occurs.
2527
- // Set to the null agent handle (handle == 0) to indicate there
2528
- // is no preferred location.
2529
- // Type of this attribute is hsa_agent_t.
2530
- HSA_AMD_SVM_ATTRIB_PREFERRED_LOCATION = 4,
2531
- // This attribute can not be used in ::hsa_amd_svm_attributes_set (see
2532
- // ::hsa_amd_svm_prefetch_async).
2533
- // Queries the physical location of most recent prefetch command.
2534
- // If the prefetch location has not been set or is not uniform across the
2535
- // address range then returned hsa_agent_t::handle will be 0.
2536
- // Querying this attribute will return the destination agent of the most
2537
- // recent ::hsa_amd_svm_prefetch_async targeting the address range. If
2538
- // multiple async prefetches have been issued targeting the region and the
2539
- // most recently issued prefetch has completed then the query will return
2540
- // the location of the most recently completed prefetch.
2541
- // Type of this attribute is hsa_agent_t.
2542
- HSA_AMD_SVM_ATTRIB_PREFETCH_LOCATION = 5,
2543
- // Optimizes with the anticipation that the majority of operations to the
2544
- // range will be read operations.
2545
- // Type of this attribute is bool.
2546
- HSA_AMD_SVM_ATTRIB_READ_MOSTLY = 6,
2547
- // Allows the execution on GPU.
2548
- // Type of this attribute is bool.
2549
- HSA_AMD_SVM_ATTRIB_GPU_EXEC = 7,
2550
- // This attribute can not be used in ::hsa_amd_svm_attributes_get.
2551
- // Enables an agent for access to the range. Access may incur a page fault
2552
- // and associated memory migration. Either this or
2553
- // HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE is required prior to SVM
2554
- // access if HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT is false.
2555
- // Type of this attribute is hsa_agent_t.
2556
- HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE = 0x200,
2557
- // This attribute can not be used in ::hsa_amd_svm_attributes_get.
2558
- // Enables an agent for access to the range without page faults. Access
2559
- // will not incur a page fault and will not cause access based migration.
2560
- // and associated memory migration. Either this or
2561
- // HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE is required prior to SVM access if
2562
- // HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT is false.
2563
- // Type of this attribute is hsa_agent_t.
2564
- HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE = 0x201,
2565
- // This attribute can not be used in ::hsa_amd_svm_attributes_get.
2566
- // Denies an agent access to the memory range. Access will cause a terminal
2567
- // segfault.
2568
- // Type of this attribute is hsa_agent_t.
2569
- HSA_AMD_SVM_ATTRIB_AGENT_NO_ACCESS = 0x202,
2570
- // This attribute can not be used in ::hsa_amd_svm_attributes_set.
2571
- // Returns the access attribute associated with the agent.
2572
- // The agent to query must be set in the attribute value field.
2573
- // The attribute enum will be replaced with the agent's current access
2574
- // attribute for the address range.
2575
- // TODO: Clarify KFD return value for non-uniform access attribute.
2576
- // Type of this attribute is hsa_agent_t.
2577
- HSA_AMD_SVM_ATTRIB_ACCESS_QUERY = 0x203,
2578
- } hsa_amd_svm_attribute_t;
2579
-
2580
- // List type for hsa_amd_svm_attributes_set/get.
2581
- typedef struct hsa_amd_svm_attribute_pair_s {
2582
- // hsa_amd_svm_attribute_t value.
2583
- uint64_t attribute;
2584
- // Attribute value. Bit values should be interpreted according to the type
2585
- // given in the associated attribute description.
2586
- uint64_t value;
2587
- } hsa_amd_svm_attribute_pair_t;
2588
-
2589
- /**
2590
- * @brief Sets SVM memory attributes.
2591
- *
2592
- * If HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT returns false then enabling
2593
- * access to an Agent via this API (setting HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE
2594
- * or HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE) is required prior to SVM
2595
- * memory access by that Agent.
2596
- *
2597
- * Attributes HSA_AMD_SVM_ATTRIB_ACCESS_QUERY and HSA_AMD_SVM_ATTRIB_PREFETCH_LOCATION
2598
- * may not be used with this API.
2599
- *
2600
- * @param[in] ptr Will be aligned down to nearest page boundary.
2601
- *
2602
- * @param[in] size Will be aligned up to nearest page boundary.
2603
- *
2604
- * @param[in] attribute_list List of attributes to set for the address range.
2605
- *
2606
- * @param[in] attribute_count Length of @p attribute_list.
2607
- */
2608
- hsa_status_t hsa_amd_svm_attributes_set(void* ptr, size_t size,
2609
- hsa_amd_svm_attribute_pair_t* attribute_list,
2610
- size_t attribute_count);
2611
-
2612
- /**
2613
- * @brief Gets SVM memory attributes.
2614
- *
2615
- * Attributes HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE,
2616
- * HSA_AMD_SVM_ATTRIB_AGENT_ACCESSIBLE_IN_PLACE and
2617
- * HSA_AMD_SVM_ATTRIB_PREFETCH_LOCATION may not be used with this API.
2618
- *
2619
- * Note that attribute HSA_AMD_SVM_ATTRIB_ACCESS_QUERY takes as input an
2620
- * hsa_agent_t and returns the current access type through its attribute field.
2621
- *
2622
- * @param[in] ptr Will be aligned down to nearest page boundary.
2623
- *
2624
- * @param[in] size Will be aligned up to nearest page boundary.
2625
- *
2626
- * @param[in] attribute_list List of attributes to set for the address range.
2627
- *
2628
- * @param[in] attribute_count Length of @p attribute_list.
2629
- */
2630
- hsa_status_t hsa_amd_svm_attributes_get(void* ptr, size_t size,
2631
- hsa_amd_svm_attribute_pair_t* attribute_list,
2632
- size_t attribute_count);
2633
-
2634
- /**
2635
- * @brief Asynchronously migrates memory to an agent.
2636
- *
2637
- * Schedules memory migration to @p agent when @p dep_signals have been observed equal to zero.
2638
- * @p completion_signal will decrement when the migration is complete.
2639
- *
2640
- * @param[in] ptr Will be aligned down to nearest page boundary.
2641
- *
2642
- * @param[in] size Will be aligned up to nearest page boundary.
2643
- *
2644
- * @param[in] agent Agent to migrate to.
2645
- *
2646
- * @param[in] num_dep_signals Number of dependent signals. Can be 0.
2647
- *
2648
- * @param[in] dep_signals List of signals that must be waited on before the migration
2649
- * operation starts. The migration will start after every signal has been observed with
2650
- * the value 0. If @p num_dep_signals is 0, this argument is ignored.
2651
- *
2652
- * @param[in] completion_signal Signal used to indicate completion of the migration
2653
- * operation. When the migration operation is finished, the value of the signal is
2654
- * decremented. The runtime indicates that an error has occurred during the copy
2655
- * operation by setting the value of the completion signal to a negative
2656
- * number. If no completion signal is required this handle may be null.
2657
- */
2658
- hsa_status_t hsa_amd_svm_prefetch_async(void* ptr, size_t size, hsa_agent_t agent,
2659
- uint32_t num_dep_signals, const hsa_signal_t* dep_signals,
2660
- hsa_signal_t completion_signal);
2661
-
2662
- /**
2663
- * @brief Acquire Stream Performance Monitor on an agent
2664
- *
2665
- * Acquire exclusive use of SPM on @p preferred_agent.
2666
- * See hsa_amd_spm_set_dest_buffer to provide a destination buffer to KFD to start recording and
2667
- * retrieve this data.
2668
- * @param[in] preferred_agent Agent on which to acquire SPM
2669
- */
2670
- hsa_status_t hsa_amd_spm_acquire(hsa_agent_t preferred_agent);
2671
-
2672
- /**
2673
- * @brief Release Stream Performance Monitor on an agent
2674
- *
2675
- * Release exclusive use of SPM on @p preferred_agent. This will stop KFD writing SPM data.
2676
- * If a destination buffer is set, then data in the destination buffer is available to user
2677
- * when this function returns.
2678
- *
2679
- * @param[in] preferred_agent Agent on which to release SPM
2680
- */
2681
- hsa_status_t hsa_amd_spm_release(hsa_agent_t preferred_agent);
2682
-
2683
- /**
2684
- * @brief Set up the current destination user mode buffer for stream performance
2685
- * counter data. KFD will start writing SPM data into the destination buffer. KFD will continue
2686
- * to copy data into the current destination buffer until any of the following functions are called
2687
- * - hsa_amd_spm_release
2688
- * - hsa_amd_spm_set_dest_buffer with dest set to NULL
2689
- * - hsa_amd_spm_set_dest_buffer with dest set to a new buffer
2690
- *
2691
- * if @p timeout is non-0, the call will wait for up to @p timeout ms for the previous
2692
- * buffer to be filled. If previous buffer to be filled before timeout, the @p timeout
2693
- * will be updated value with the time remaining. If the timeout is exceeded, the function
2694
- * copies any partial data available into the previous user buffer and returns success.
2695
- * User should not access destination data while KFD is copying data.
2696
- * If the previous destination buffer was full, then @p is_data_loss flag is set.
2697
- * @p dest is CPU accessible memory. It could be malloc'ed memory or host allocated memory
2698
- *
2699
- * @param[in] preferred_agent Agent on which to set the dest buffer
2700
- *
2701
- * @param[in] size_in_bytes size of the buffer
2702
- *
2703
- * @param[in/out] timeout timeout in milliseconds
2704
- *
2705
- * @param[out] size_copied number of bytes copied
2706
- *
2707
- * @param[in] dest destination address. Set to NULL to stop copy on previous buffer
2708
- *
2709
- * @param[out] is_data_loss true is data was lost
2710
- */
2711
- hsa_status_t hsa_amd_spm_set_dest_buffer(hsa_agent_t preferred_agent, size_t size_in_bytes,
2712
- uint32_t* timeout, uint32_t* size_copied, void* dest,
2713
- bool* is_data_loss);
2714
- /**
2715
- * @brief Obtains an OS specific, vendor neutral, handle to a memory allocation.
2716
- *
2717
- * Obtains an OS specific handle to GPU agent memory. The memory must be part
2718
- * of a single allocation from an hsa_amd_memory_pool_t exposed by a GPU Agent.
2719
- * The handle may be used with other APIs (e.g. Vulkan) to obtain shared access
2720
- * to the allocation.
2721
- *
2722
- * Shared access to the memory is not guaranteed to be fine grain coherent even
2723
- * if the allocation exported is from a fine grain pool. The shared memory
2724
- * consistency model will be no stronger than the model exported from, consult
2725
- * the importing API to determine the final consistency model.
2726
- *
2727
- * The allocation's memory remains valid as long as the handle and any mapping
2728
- * of the handle remains valid. When the handle and all mappings are closed
2729
- * the backing memory will be released for reuse.
2730
- *
2731
- * @param[in] ptr Pointer to the allocation being exported.
2732
- *
2733
- * @param[in] size Size in bytes to export following @p ptr. The entire range
2734
- * being exported must be contained within a single allocation.
2735
- *
2736
- * @param[out] dmabuf Pointer to a dma-buf file descriptor holding a reference to the
2737
- * allocation. Contents will not be altered in the event of failure.
2738
- *
2739
- * @param[out] offset Offset in bytes into the memory referenced by the dma-buf
2740
- * object at which @p ptr resides. Contents will not be altered in the event
2741
- * of failure.
2742
- *
2743
- * @retval ::HSA_STATUS_SUCCESS Export completed successfully.
2744
- *
2745
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2746
- * initialized.
2747
- *
2748
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT One or more arguments is NULL.
2749
- *
2750
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The address range described by
2751
- * @p ptr and @p size are not contained within a single allocation.
2752
- *
2753
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The allocation described by @p ptr
2754
- * and @p size was allocated on a device which can not export memory.
2755
- *
2756
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The return file descriptor,
2757
- * @p dmabuf, could not be created.
2758
- */
2759
- hsa_status_t hsa_amd_portable_export_dmabuf(const void* ptr, size_t size, int* dmabuf,
2760
- uint64_t* offset);
2761
-
2762
- /**
2763
- * @brief Closes an OS specific, vendor neutral, handle to a memory allocation.
2764
- *
2765
- * Closes an OS specific handle to GPU agent memory.
2766
- *
2767
- * Applications should close a handle after imports are complete. The handle
2768
- * is not required to remain open for the lifetime of imported mappings. The
2769
- * referenced allocation will remain valid until all handles and mappings
2770
- * are closed.
2771
- *
2772
- * @param[in] dmabuf Handle to be closed.
2773
- *
2774
- * @retval ::HSA_STATUS_SUCCESS Handle closed successfully.
2775
- *
2776
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2777
- * initialized.
2778
- *
2779
- * @retval ::HSA_STATUS_ERROR_RESOURCE_FREE A generic error was encountered
2780
- * when closing the handle. The handle may have been closed already or an
2781
- * async IO error may have occured.
2782
- */
2783
- hsa_status_t hsa_amd_portable_close_dmabuf(int dmabuf);
2784
-
2785
- /*
2786
- * @brief Allocate a reserved address range
2787
- *
2788
- * Reserve a virtual address range. The size must be a multiple of the system page size.
2789
- * If it is not possible to allocate the address specified by @p address, then @p va will be
2790
- * a different address range.
2791
- * Address range should be released by calling hsa_amd_vmem_address_free.
2792
- *
2793
- * @param[out] va virtual address allocated
2794
- * @param[in] size of address range requested
2795
- * @param[in] address requested
2796
- * @param[in] flags currently unsupported
2797
- *
2798
- * @retval ::HSA_STATUS_SUCCESS Address range allocated successfully
2799
- *
2800
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2801
- * initialized.
2802
- *
2803
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Insufficient resources to allocate an address
2804
- * range of this size.
2805
- */
2806
- hsa_status_t hsa_amd_vmem_address_reserve(void** va, size_t size, uint64_t address,
2807
- uint64_t flags);
2808
-
2809
- /*
2810
- * @brief Free a reserved address range
2811
- *
2812
- * Free a previously allocated address range. The size must match the size of a previously
2813
- * allocated address range.
2814
- *
2815
- * @param[out] va virtual address to be freed
2816
- * @param[in] size of address range
2817
- *
2818
- * @retval ::HSA_STATUS_SUCCESS Address range released successfully
2819
- *
2820
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION Invalid va specified
2821
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT Invalid size specified
2822
- * @retval ::HSA_STATUS_ERROR_RESOURCE_FREE Address range is still in use
2823
- * @retval ::HSA_STATUS_ERROR Internal unexpected error
2824
- */
2825
- hsa_status_t hsa_amd_vmem_address_free(void* va, size_t size);
2826
-
2827
- /**
2828
- * @brief Struct containing an opaque handle to a memory allocation handle
2829
- */
2830
- typedef struct hsa_amd_vmem_alloc_handle_s {
2831
- /**
2832
- * Opaque handle. Two handles reference the same object of the enclosing type
2833
- * if and only if they are equal.
2834
- */
2835
- uint64_t handle;
2836
- } hsa_amd_vmem_alloc_handle_t;
2837
-
2838
- typedef enum {
2839
- MEMORY_TYPE_NONE,
2840
- MEMORY_TYPE_PINNED,
2841
- } hsa_amd_memory_type_t;
2842
-
2843
- /*
2844
- * @brief Create a virtual memory handle
2845
- *
2846
- * Create a virtual memory handle within this pool
2847
- * @p size must be a aligned to allocation granule size for this memory pool, see
2848
- * HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE
2849
- * To minimize internal memory fragmentation, align the size to the recommended allocation granule
2850
- * size, see HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE
2851
- *
2852
- * @param[in] pool memory to use
2853
- * @param[in] size of the memory allocation
2854
- * @param[in] type of memory
2855
- * @param[in] flags - currently unsupported
2856
- * @param[out] memory_handle - handle for the allocation
2857
- *
2858
- * @retval ::HSA_STATUS_SUCCESS memory allocated successfully
2859
- *
2860
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been initialized.
2861
- *
2862
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT Invalid arguments
2863
- *
2864
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION This memory pool does not support allocations
2865
- *
2866
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Insufficient resources to allocate this memory
2867
- */
2868
- hsa_status_t hsa_amd_vmem_handle_create(hsa_amd_memory_pool_t pool, size_t size,
2869
- hsa_amd_memory_type_t type, uint64_t flags,
2870
- hsa_amd_vmem_alloc_handle_t* memory_handle);
2871
-
2872
- /*
2873
- * @brief Release a virtual memory handle
2874
- *
2875
- * @param[in] memory handle that was previously allocated
2876
- *
2877
- * @retval ::HSA_STATUS_SUCCESS Address range allocated successfully
2878
- *
2879
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION Invalid memory handle
2880
- */
2881
- hsa_status_t hsa_amd_vmem_handle_release(hsa_amd_vmem_alloc_handle_t memory_handle);
2882
-
2883
- /*
2884
- * @brief Map a virtual memory handle
2885
- *
2886
- * Map a virtual memory handle to a reserved address range. The virtual address requested must be
2887
- * within a previously reserved address range. @p va and (@p va + size) must be must be within
2888
- * (va + size) of the previous allocated address range.
2889
- * @p size must be equal to size of the @p memory_handle
2890
- * hsa_amd_vmem_set_access needs to be called to make the memory accessible to specific agents
2891
- *
2892
- * @param[in] va virtual address range where memory will be mapped
2893
- * @param[in] size of memory mapping
2894
- * @param[in] in_offset offset into memory. Currently unsupported
2895
- * @param[in] memory_handle virtual memory handle to be mapped
2896
- * @param[in] flags. Currently unsupported
2897
- *
2898
- * @retval ::HSA_STATUS_SUCCESS Memory mapped successfully
2899
- *
2900
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT va, size or memory_handle are invalid
2901
- *
2902
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Insufficient resources
2903
- *
2904
- * @retval ::HSA_STATUS_ERROR Unexpected internal error
2905
- */
2906
- hsa_status_t hsa_amd_vmem_map(void* va, size_t size, size_t in_offset,
2907
- hsa_amd_vmem_alloc_handle_t memory_handle, uint64_t flags);
2908
-
2909
- /*
2910
- * @brief Unmap a virtual memory handle
2911
- *
2912
- * Unmap previously mapped virtual address range
2913
- *
2914
- * @param[in] va virtual address range where memory will be mapped
2915
- * @param[in] size of memory mapping
2916
- *
2917
- * @retval ::HSA_STATUS_SUCCESS Memory backing unmapped successfully
2918
- *
2919
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION memory_handle is invalid
2920
- *
2921
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT size is invalid
2922
- *
2923
- * @retval ::HSA_STATUS_ERROR Unexpected internal error
2924
- */
2925
- hsa_status_t hsa_amd_vmem_unmap(void* va, size_t size);
2926
-
2927
- typedef struct hsa_amd_memory_access_desc_s {
2928
- hsa_access_permission_t permissions;
2929
- hsa_agent_t agent_handle;
2930
- } hsa_amd_memory_access_desc_t;
2931
-
2932
- /*
2933
- * @brief Make a memory mapping accessible
2934
- *
2935
- * Make previously mapped virtual address accessible to specific agents. @p size must be equal to
2936
- * size of previously mapped virtual memory handle.
2937
- * Calling hsa_amd_vmem_set_access multiple times on the same @p va will overwrite previous
2938
- * permissions for all agents
2939
- *
2940
- * @param[in] va previously mapped virtual address
2941
- * @param[in] size of memory mapping
2942
- * @param[in] desc list of access permissions for each agent
2943
- * @param[in] desc_cnt number of elements in desc
2944
- *
2945
- * @retval ::HSA_STATUS_SUCCESS
2946
- *
2947
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT va, size or memory_handle are invalid
2948
- *
2949
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION memory_handle is invalid
2950
- *
2951
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Insufficient resources
2952
- *
2953
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT Invalid agent in desc
2954
- *
2955
- * @retval ::HSA_STATUS_ERROR Unexpected internal error
2956
- */
2957
- hsa_status_t hsa_amd_vmem_set_access(void* va, size_t size,
2958
- const hsa_amd_memory_access_desc_t* desc,
2959
- size_t desc_cnt);
2960
-
2961
- /*
2962
- * @brief Get current access permissions for memory mapping
2963
- *
2964
- * Get access permissions for memory mapping for specific agent.
2965
- *
2966
- * @param[in] va previously mapped virtual address
2967
- * @param[in] perms current permissions
2968
- * @param[in] agent_handle agent
2969
- *
2970
- * @retval ::HSA_STATUS_SUCCESS
2971
- *
2972
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT Invalid agent
2973
- *
2974
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION va is not mapped or permissions never set for this
2975
- * agent
2976
- *
2977
- * @retval ::HSA_STATUS_ERROR Unexpected internal error
2978
- */
2979
- hsa_status_t hsa_amd_vmem_get_access(void* va, hsa_access_permission_t* perms,
2980
- hsa_agent_t agent_handle);
2981
-
2982
- /*
2983
- * @brief Get an exportable shareable handle
2984
- *
2985
- * Get an exportable shareable handle for a memory_handle. This shareabl handle can then be used to
2986
- * re-create a virtual memory handle using hsa_amd_vmem_import_shareable_handle. The shareable
2987
- * handle can be transferred using mechanisms that support posix file descriptors Once all shareable
2988
- * handles are closed, the memory_handle is released.
2989
- *
2990
- * @param[out] dmabuf_fd shareable handle
2991
- * @param[in] handle previously allocated virtual memory handle
2992
- * @param[in] flags Currently unsupported
2993
- *
2994
- * @retval ::HSA_STATUS_SUCCESS
2995
- *
2996
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION Invalid memory handle
2997
- *
2998
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Out of resources
2999
- *
3000
- * @retval ::HSA_STATUS_ERROR Unexpected internal error
3001
- */
3002
- hsa_status_t hsa_amd_vmem_export_shareable_handle(int* dmabuf_fd,
3003
- hsa_amd_vmem_alloc_handle_t handle,
3004
- uint64_t flags);
3005
- /*
3006
- * @brief Import a shareable handle
3007
- *
3008
- * Import a shareable handle for a memory handle. Importing a shareable handle that has been closed
3009
- * and released results in undefined behavior.
3010
- *
3011
- * @param[in] dmabuf_fd shareable handle exported with hsa_amd_vmem_export_shareable_handle
3012
- * @param[out] handle virtual memory handle
3013
- *
3014
- * @retval ::HSA_STATUS_SUCCESS
3015
- *
3016
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION Invalid memory handle
3017
- *
3018
- * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Out of resources
3019
- *
3020
- * @retval ::HSA_STATUS_ERROR Unexpected internal error
3021
- */
3022
- hsa_status_t hsa_amd_vmem_import_shareable_handle(int dmabuf_fd,
3023
- hsa_amd_vmem_alloc_handle_t* handle);
3024
-
3025
- /*
3026
- * @brief Returns memory handle for mapped memory
3027
- *
3028
- * Return a memory handle for previously mapped memory. The handle will be the same value of handle
3029
- * used to map the memory. The returned handle must be released with corresponding number of calls
3030
- * to hsa_amd_vmem_handle_release.
3031
- *
3032
- * @param[out] memory_handle memory handle for this mapped address
3033
- * @param[in] mapped address
3034
- *
3035
- * @retval ::HSA_STATUS_SUCCESS
3036
- *
3037
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION Invalid address
3038
- */
3039
- hsa_status_t hsa_amd_vmem_retain_alloc_handle(hsa_amd_vmem_alloc_handle_t* memory_handle,
3040
- void* addr);
3041
-
3042
- /*
3043
- * @brief Returns the current allocation properties of a handle
3044
- *
3045
- * Returns the allocation properties of an existing handle
3046
- *
3047
- * @param[in] memory_handle memory handle to be queried
3048
- * @param[out] pool memory pool that owns this handle
3049
- * @param[out] memory type
3050
-
3051
- * @retval ::HSA_STATUS_SUCCESS
3052
- *
3053
- * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION Invalid memory_handle
3054
- */
3055
- hsa_status_t hsa_amd_vmem_get_alloc_properties_from_handle(
3056
- hsa_amd_vmem_alloc_handle_t memory_handle, hsa_amd_memory_pool_t* pool,
3057
- hsa_amd_memory_type_t* type);
3058
-
3059
- /**
3060
- * @brief Set the asynchronous scratch limit threshold on all the queues for this agent.
3061
- * Dispatches that are enqueued on HW queues on this agent that are smaller than threshold will not
3062
- * result in a scratch use-once method.
3063
- *
3064
- * Increasing this threshold will only increase the internal limit and not cause immediate allocation
3065
- * of additional scratch memory. Decreasing this threshold will result in a release in scratch memory
3066
- * on queues where the current amount of allocated scratch exceeds the new limit.
3067
- *
3068
- * This API is only supported on devices that support asynchronous scratch reclaim.
3069
- *
3070
- * @param[in] agent A valid agent.
3071
- *
3072
- * @param[in] threshold Threshold size in bytes
3073
- *
3074
- * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3075
- *
3076
- * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3077
- * initialized.
3078
- *
3079
- * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3080
- *
3081
- * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT This agent does not support asynchronous scratch
3082
- * reclaim
3083
- */
3084
- hsa_status_t HSA_API hsa_amd_agent_set_async_scratch_limit(hsa_agent_t agent, size_t threshold);
3085
-
3086
- #ifdef __cplusplus
3087
- } // end extern "C" block
3088
- #endif
3089
-
3090
- #endif // header guard