Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / include / hsa_ext_amd.h
blob1f93e0d96cc471269c4b624e4d6e3f2365e0128f
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2014-2020 Advanced Micro Devices Inc. All rights reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person or organization
6 // obtaining a copy of the software and accompanying documentation covered by
7 // this license (the "Software") to use, reproduce, display, distribute,
8 // execute, and transmit the Software, and to prepare derivative works of the
9 // Software, and to permit third-parties to whom the Software is furnished to
10 // do so, all subject to the following:
12 // The copyright notices in the Software and this entire statement, including
13 // the above license grant, this restriction and the following disclaimer,
14 // must be included in all copies of the Software, in whole or in part, and
15 // all derivative works of the Software, unless such copies or derivative
16 // works are solely in the form of machine-executable object code generated by
17 // a source language processor.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
27 ////////////////////////////////////////////////////////////////////////////////
29 // HSA AMD extension.
31 #ifndef HSA_RUNTIME_EXT_AMD_H_
32 #define HSA_RUNTIME_EXT_AMD_H_
34 #include "hsa.h"
35 #include "hsa_ext_image.h"
37 #define HSA_AMD_INTERFACE_VERSION_MAJOR 1
38 #define HSA_AMD_INTERFACE_VERSION_MINOR 0
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /**
45 * @brief Enumeration constants added to ::hsa_status_t.
47 * @remark Additions to hsa_status_t
49 enum {
50 /**
51 * The memory pool is invalid.
53 HSA_STATUS_ERROR_INVALID_MEMORY_POOL = 40,
55 /**
56 * Agent accessed memory beyond the maximum legal address.
58 HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION = 41,
60 /**
61 * Agent executed an invalid shader instruction.
63 HSA_STATUS_ERROR_ILLEGAL_INSTRUCTION = 42,
66 /**
67 * @brief Agent attributes.
69 typedef enum hsa_amd_agent_info_s {
70 /**
71 * Chip identifier. The type of this attribute is uint32_t.
73 HSA_AMD_AGENT_INFO_CHIP_ID = 0xA000,
74 /**
75 * Size of a cacheline in bytes. The type of this attribute is uint32_t.
77 HSA_AMD_AGENT_INFO_CACHELINE_SIZE = 0xA001,
78 /**
79 * The number of compute unit available in the agent. The type of this
80 * attribute is uint32_t.
82 HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT = 0xA002,
83 /**
84 * The maximum clock frequency of the agent in MHz. The type of this
85 * attribute is uint32_t.
87 HSA_AMD_AGENT_INFO_MAX_CLOCK_FREQUENCY = 0xA003,
88 /**
89 * Internal driver node identifier. The type of this attribute is uint32_t.
91 HSA_AMD_AGENT_INFO_DRIVER_NODE_ID = 0xA004,
92 /**
93 * Max number of watch points on memory address ranges to generate exception
94 * events when the watched addresses are accessed. The type of this
95 * attribute is uint32_t.
97 HSA_AMD_AGENT_INFO_MAX_ADDRESS_WATCH_POINTS = 0xA005,
98 /**
99 * Agent BDF_ID, named LocationID in thunk. The type of this attribute is
100 * uint32_t.
102 HSA_AMD_AGENT_INFO_BDFID = 0xA006,
104 * Memory Interface width, the return value type is uint32_t.
105 * This attribute is deprecated.
107 HSA_AMD_AGENT_INFO_MEMORY_WIDTH = 0xA007,
109 * Max Memory Clock, the return value type is uint32_t.
111 HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY = 0xA008,
113 * Board name of Agent - populated from MarketingName of Kfd Node
114 * The value is an Ascii string of 64 chars.
116 HSA_AMD_AGENT_INFO_PRODUCT_NAME = 0xA009,
118 * Maximum number of waves possible in a Compute Unit.
119 * The type of this attribute is uint32_t.
121 HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU = 0xA00A,
123 * Number of SIMD's per compute unit CU
124 * The type of this attribute is uint32_t.
126 HSA_AMD_AGENT_INFO_NUM_SIMDS_PER_CU = 0xA00B,
128 * Number of Shader Engines (SE) in Gpu
129 * The type of this attribute is uint32_t.
131 HSA_AMD_AGENT_INFO_NUM_SHADER_ENGINES = 0xA00C,
133 * Number of Shader Arrays Per Shader Engines in Gpu
134 * The type of this attribute is uint32_t.
136 HSA_AMD_AGENT_INFO_NUM_SHADER_ARRAYS_PER_SE = 0xA00D,
138 * Address of the HDP flush registers. Use of these registers does not conform to the HSA memory
139 * model and should be treated with caution.
140 * The type of this attribute is hsa_amd_hdp_flush_t.
142 HSA_AMD_AGENT_INFO_HDP_FLUSH = 0xA00E,
144 * PCIe domain for the agent. Pairs with HSA_AMD_AGENT_INFO_BDFID
145 * to give the full physical location of the Agent.
146 * The type of this attribute is uint32_t.
148 HSA_AMD_AGENT_INFO_DOMAIN = 0xA00F,
150 * Queries for support of cooperative queues. See ::HSA_QUEUE_TYPE_COOPERATIVE.
151 * The type of this attribute is bool.
153 HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES = 0xA010,
155 * Queries UUID of an agent. The value is an Ascii string with a maximum
156 * of 21 chars including NUL. The string value consists of two parts: header
157 * and body. The header identifies device type (GPU, CPU, DSP) while body
158 * encodes UUID as a 16 digit hex string
160 * Agents that do not support UUID will return the string "GPU-XX" or
161 * "CPU-XX" or "DSP-XX" depending upon their device type ::hsa_device_type_t
163 HSA_AMD_AGENT_INFO_UUID = 0xA011,
165 * Queries for the ASIC revision of an agent. The value is an integer that
166 * increments for each revision. This can be used by user-level software to
167 * change how it operates, depending on the hardware version. This allows
168 * selective workarounds for hardware errata.
169 * The type of this attribute is uint32_t.
171 HSA_AMD_AGENT_INFO_ASIC_REVISION = 0xA012
172 } hsa_amd_agent_info_t;
174 typedef struct hsa_amd_hdp_flush_s {
175 uint32_t* HDP_MEM_FLUSH_CNTL;
176 uint32_t* HDP_REG_FLUSH_CNTL;
177 } hsa_amd_hdp_flush_t;
180 * @brief Region attributes.
182 typedef enum hsa_amd_region_info_s {
184 * Determine if host can access the region. The type of this attribute
185 * is bool.
187 HSA_AMD_REGION_INFO_HOST_ACCESSIBLE = 0xA000,
189 * Base address of the region in flat address space.
191 HSA_AMD_REGION_INFO_BASE = 0xA001,
193 * Memory Interface width, the return value type is uint32_t.
194 * This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_WIDTH.
196 HSA_AMD_REGION_INFO_BUS_WIDTH = 0xA002,
198 * Max Memory Clock, the return value type is uint32_t.
199 * This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY.
201 HSA_AMD_REGION_INFO_MAX_CLOCK_FREQUENCY = 0xA003
202 } hsa_amd_region_info_t;
205 * @brief Coherency attributes of fine grain region.
207 typedef enum hsa_amd_coherency_type_s {
209 * Coherent region.
211 HSA_AMD_COHERENCY_TYPE_COHERENT = 0,
213 * Non coherent region.
215 HSA_AMD_COHERENCY_TYPE_NONCOHERENT = 1
216 } hsa_amd_coherency_type_t;
219 * @brief Get the coherency type of the fine grain region of an agent.
221 * @param[in] agent A valid agent.
223 * @param[out] type Pointer to a memory location where the HSA runtime will
224 * store the coherency type of the fine grain region.
226 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
228 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
229 * initialized.
231 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
233 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p type is NULL.
235 hsa_status_t HSA_API hsa_amd_coherency_get_type(hsa_agent_t agent,
236 hsa_amd_coherency_type_t* type);
239 * @brief Set the coherency type of the fine grain region of an agent.
240 * Deprecated. This is supported on KV platforms. For backward compatibility
241 * other platforms will spuriously succeed.
243 * @param[in] agent A valid agent.
245 * @param[in] type The coherency type to be set.
247 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
249 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
250 * initialized.
252 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
254 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p type is invalid.
256 hsa_status_t HSA_API hsa_amd_coherency_set_type(hsa_agent_t agent,
257 hsa_amd_coherency_type_t type);
260 * @brief Structure containing profiling dispatch time information.
262 * Times are reported as ticks in the domain of the HSA system clock.
263 * The HSA system clock tick and frequency is obtained via hsa_system_get_info.
265 typedef struct hsa_amd_profiling_dispatch_time_s {
267 * Dispatch packet processing start time.
269 uint64_t start;
271 * Dispatch packet completion time.
273 uint64_t end;
274 } hsa_amd_profiling_dispatch_time_t;
277 * @brief Structure containing profiling async copy time information.
279 * Times are reported as ticks in the domain of the HSA system clock.
280 * The HSA system clock tick and frequency is obtained via hsa_system_get_info.
282 typedef struct hsa_amd_profiling_async_copy_time_s {
284 * Async copy processing start time.
286 uint64_t start;
288 * Async copy completion time.
290 uint64_t end;
291 } hsa_amd_profiling_async_copy_time_t;
294 * @brief Enable or disable profiling capability of a queue.
296 * @param[in] queue A valid queue.
298 * @param[in] enable 1 to enable profiling. 0 to disable profiling.
300 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
302 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
303 * initialized.
305 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
307 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
309 hsa_status_t HSA_API
310 hsa_amd_profiling_set_profiler_enabled(hsa_queue_t* queue, int enable);
313 * @brief Enable or disable asynchronous memory copy profiling.
315 * @details The runtime will provide the copy processing start timestamp and
316 * completion timestamp of each call to hsa_amd_memory_async_copy if the
317 * async copy profiling is enabled prior to the call to
318 * hsa_amd_memory_async_copy. The completion signal object is used to
319 * hold the last async copy start and end timestamp. The client can retrieve
320 * these timestamps via call to hsa_amd_profiling_get_async_copy_time.
322 * @param[in] enable True to enable profiling. False to disable profiling.
324 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
326 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
327 * initialized.
329 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Failed on allocating resources
330 * needed to profile the asynchronous copy.
332 hsa_status_t HSA_API
333 hsa_amd_profiling_async_copy_enable(bool enable);
336 * @brief Retrieve packet processing time stamps.
338 * @param[in] agent The agent with which the signal was last used. For
339 * instance, if the profiled dispatch packet is dispatched onto queue Q,
340 * which was created on agent A, then this parameter must be A.
342 * @param[in] signal A signal used as the completion signal of the dispatch
343 * packet to retrieve time stamps from. This dispatch packet must have been
344 * issued to a queue with profiling enabled and have already completed. Also
345 * the signal must not have yet been used in any other packet following the
346 * completion of the profiled dispatch packet.
348 * @param[out] time Packet processing timestamps in the HSA system clock
349 * domain.
351 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
353 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
354 * initialized.
356 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
358 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL The signal is invalid.
360 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p time is NULL.
362 hsa_status_t HSA_API hsa_amd_profiling_get_dispatch_time(
363 hsa_agent_t agent, hsa_signal_t signal,
364 hsa_amd_profiling_dispatch_time_t* time);
367 * @brief Retrieve asynchronous copy timestamps.
369 * @details Async copy profiling is enabled via call to
370 * hsa_amd_profiling_async_copy_enable.
372 * @param[in] signal A signal used as the completion signal of the call to
373 * hsa_amd_memory_async_copy.
375 * @param[out] time Async copy processing timestamps in the HSA system clock
376 * domain.
378 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
380 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
381 * initialized.
383 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL The signal is invalid.
385 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p time is NULL.
387 hsa_status_t HSA_API hsa_amd_profiling_get_async_copy_time(
388 hsa_signal_t signal, hsa_amd_profiling_async_copy_time_t* time);
391 * @brief Computes the frequency ratio and offset between the agent clock and
392 * HSA system clock and converts the agent's tick to HSA system domain tick.
394 * @param[in] agent The agent used to retrieve the agent_tick. It is user's
395 * responsibility to make sure the tick number is from this agent, otherwise,
396 * the behavior is undefined.
398 * @param[in] agent_tick The tick count retrieved from the specified @p agent.
400 * @param[out] system_tick The translated HSA system domain clock counter tick.
402 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
404 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
405 * initialized.
407 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
409 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p system_tick is NULL;
411 hsa_status_t HSA_API
412 hsa_amd_profiling_convert_tick_to_system_domain(hsa_agent_t agent,
413 uint64_t agent_tick,
414 uint64_t* system_tick);
417 * @brief Signal attribute flags.
419 typedef enum {
421 * Signal will only be consumed by AMD GPUs. Limits signal consumption to
422 * AMD GPU agents only. Ignored if @p num_consumers is not zero (all agents).
424 HSA_AMD_SIGNAL_AMD_GPU_ONLY = 1,
426 * Signal may be used for interprocess communication.
427 * IPC signals can be read, written, and waited on from any process.
428 * Profiling using an IPC enabled signal is only supported in a single process
429 * at a time. Producing profiling data in one process and consuming it in
430 * another process is undefined.
432 HSA_AMD_SIGNAL_IPC = 2,
433 } hsa_amd_signal_attribute_t;
436 * @brief Create a signal with specific attributes.
438 * @param[in] initial_value Initial value of the signal.
440 * @param[in] num_consumers Size of @p consumers. A value of 0 indicates that
441 * any agent might wait on the signal.
443 * @param[in] consumers List of agents that might consume (wait on) the
444 * signal. If @p num_consumers is 0, this argument is ignored; otherwise, the
445 * HSA runtime might use the list to optimize the handling of the signal
446 * object. If an agent not listed in @p consumers waits on the returned
447 * signal, the behavior is undefined. The memory associated with @p consumers
448 * can be reused or freed after the function returns.
450 * @param[in] attributes Requested signal attributes. Multiple signal attributes
451 * may be requested by combining them with bitwise OR. Requesting no attributes
452 * (@p attributes == 0) results in the same signal as would have been obtained
453 * via hsa_signal_create.
455 * @param[out] signal Pointer to a memory location where the HSA runtime will
456 * store the newly created signal handle. Must not be NULL.
458 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
460 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
461 * initialized.
463 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
464 * the required resources.
466 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is NULL, @p
467 * num_consumers is greater than 0 but @p consumers is NULL, or @p consumers
468 * contains duplicates.
470 hsa_status_t HSA_API hsa_amd_signal_create(hsa_signal_value_t initial_value, uint32_t num_consumers,
471 const hsa_agent_t* consumers, uint64_t attributes,
472 hsa_signal_t* signal);
475 * @brief Asyncronous signal handler function type.
477 * @details Type definition of callback function to be used with
478 * hsa_amd_signal_async_handler. This callback is invoked if the associated
479 * signal and condition are met. The callback receives the value of the signal
480 * which satisfied the associated wait condition and a user provided value. If
481 * the callback returns true then the callback will be called again if the
482 * associated signal and condition are satisfied again. If the callback returns
483 * false then it will not be called again.
485 * @param[in] value Contains the value of the signal observed by
486 * hsa_amd_signal_async_handler which caused the signal handler to be invoked.
488 * @param[in] arg Contains the user provided value given when the signal handler
489 * was registered with hsa_amd_signal_async_handler
491 * @retval true resumes monitoring the signal with this handler (as if calling
492 * hsa_amd_signal_async_handler again with identical parameters)
494 * @retval false stops monitoring the signal with this handler (handler will
495 * not be called again for this signal)
498 typedef bool (*hsa_amd_signal_handler)(hsa_signal_value_t value, void* arg);
501 * @brief Register asynchronous signal handler function.
503 * @details Allows registering a callback function and user provided value with
504 * a signal and wait condition. The callback will be invoked if the associated
505 * signal and wait condition are satisfied. Callbacks will be invoked serially
506 * but in an arbitrary order so callbacks should be independent of each other.
507 * After being invoked a callback may continue to wait for its associated signal
508 * and condition and, possibly, be invoked again. Or the callback may stop
509 * waiting. If the callback returns true then it will continue waiting and may
510 * be called again. If false then the callback will not wait again and will not
511 * be called again for the associated signal and condition. It is possible to
512 * register the same callback multiple times with the same or different signals
513 * and/or conditions. Each registration of the callback will be treated entirely
514 * independently.
516 * @param[in] signal hsa signal to be asynchronously monitored
518 * @param[in] cond condition value to monitor for
520 * @param[in] value signal value used in condition expression
522 * @param[in] handler asynchronous signal handler invoked when signal's
523 * condition is met
525 * @param[in] arg user provided value which is provided to handler when handler
526 * is invoked
528 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
530 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
531 * initialized.
533 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL signal is not a valid hsa_signal_t
535 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT handler is invalid (NULL)
537 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime is out of
538 * resources or blocking signals are not supported by the HSA driver component.
541 hsa_status_t HSA_API
542 hsa_amd_signal_async_handler(hsa_signal_t signal,
543 hsa_signal_condition_t cond,
544 hsa_signal_value_t value,
545 hsa_amd_signal_handler handler, void* arg);
548 * @brief Call a function asynchronously
550 * @details Provides access to the runtime's asynchronous event handling thread
551 * for general asynchronous functions. Functions queued this way are executed
552 * in the same manner as if they were a signal handler who's signal is
553 * satisfied.
555 * @param[in] callback asynchronous function to be invoked
557 * @param[in] arg user provided value which is provided to handler when handler
558 * is invoked
560 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
562 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
563 * initialized.
565 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT handler is invalid (NULL)
567 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime is out of
568 * resources or blocking signals are not supported by the HSA driver component.
571 hsa_status_t HSA_API
572 hsa_amd_async_function(void (*callback)(void* arg), void* arg);
575 * @brief Wait for any signal-condition pair to be satisfied.
577 * @details Allows waiting for any of several signal and conditions pairs to be
578 * satisfied. The function returns the index into the list of signals of the
579 * first satisfying signal-condition pair. The value of the satisfying signal's
580 * value is returned in satisfying_value unless satisfying_value is NULL. This
581 * function provides only relaxed memory semantics.
583 uint32_t HSA_API
584 hsa_amd_signal_wait_any(uint32_t signal_count, hsa_signal_t* signals,
585 hsa_signal_condition_t* conds,
586 hsa_signal_value_t* values, uint64_t timeout_hint,
587 hsa_wait_state_t wait_hint,
588 hsa_signal_value_t* satisfying_value);
591 * @brief Query image limits.
593 * @param[in] agent A valid agent.
595 * @param[in] attribute HSA image info attribute to query.
597 * @param[out] value Pointer to an application-allocated buffer where to store
598 * the value of the attribute. If the buffer passed by the application is not
599 * large enough to hold the value of @p attribute, the behavior is undefined.
601 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
603 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
604 * initialized.
606 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE @p value is NULL or @p attribute <
607 * HSA_EXT_AGENT_INFO_IMAGE_1D_MAX_ELEMENTS or @p attribute >
608 * HSA_EXT_AGENT_INFO_IMAGE_ARRAY_MAX_LAYERS.
611 hsa_status_t HSA_API hsa_amd_image_get_info_max_dim(hsa_agent_t agent,
612 hsa_agent_info_t attribute,
613 void* value);
616 * @brief Set a CU affinity to specific queues within the process, this function
617 * call is "atomic".
619 * @param[in] queue A pointer to HSA queue.
621 * @param[in] num_cu_mask_count Size of CUMask bit array passed in.
623 * @param[in] cu_mask Bit-vector representing the CU mask.
625 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
627 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
628 * initialized.
630 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE @p queue is NULL or invalid.
632 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_cu_mask_count is not
633 * multiple of 32 or @p cu_mask is NULL.
635 * @retval ::HSA_STATUS_ERROR failed to call thunk api
638 hsa_status_t HSA_API hsa_amd_queue_cu_set_mask(const hsa_queue_t* queue,
639 uint32_t num_cu_mask_count,
640 const uint32_t* cu_mask);
643 * @brief Memory segments associated with a memory pool.
645 typedef enum {
647 * Global segment. Used to hold data that is shared by all agents.
649 HSA_AMD_SEGMENT_GLOBAL = 0,
651 * Read-only segment. Used to hold data that remains constant during the
652 * execution of a kernel.
654 HSA_AMD_SEGMENT_READONLY = 1,
656 * Private segment. Used to hold data that is local to a single work-item.
658 HSA_AMD_SEGMENT_PRIVATE = 2,
660 * Group segment. Used to hold data that is shared by the work-items of a
661 * work-group.
663 HSA_AMD_SEGMENT_GROUP = 3,
664 } hsa_amd_segment_t;
667 * @brief A memory pool encapsulates physical storage on an agent
668 * along with a memory access model.
670 * @details A memory pool encapsulates a physical partition of an agent's
671 * memory system along with a memory access model. Division of a single
672 * memory system into separate pools allows querying each partition's access
673 * path properties (see ::hsa_amd_agent_memory_pool_get_info). Allocations
674 * from a pool are preferentially bound to that pool's physical partition.
675 * Binding to the pool's preferential physical partition may not be
676 * possible or persistent depending on the system's memory policy
677 * and/or state which is beyond the scope of HSA APIs.
679 * For example, a multi-node NUMA memory system may be represented by multiple
680 * pool's with each pool providing size and access path information for the
681 * partition it represents. Allocations from a pool are preferentially bound
682 * to the pool's partition (which in this example is a NUMA node) while
683 * following its memory access model. The actual placement may vary or migrate
684 * due to the system's NUMA policy and state, which is beyond the scope of
685 * HSA APIs.
687 typedef struct hsa_amd_memory_pool_s {
689 * Opaque handle.
691 uint64_t handle;
692 } hsa_amd_memory_pool_t;
694 typedef enum hsa_amd_memory_pool_global_flag_s {
696 * The application can use allocations in the memory pool to store kernel
697 * arguments, and provide the values for the kernarg segment of
698 * a kernel dispatch.
700 HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT = 1,
702 * Updates to memory in this pool conform to HSA memory consistency model.
703 * If this flag is set, then ::HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED
704 * must not be set.
706 HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED = 2,
708 * Writes to memory in this pool can be performed by a single agent at a time.
710 HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED = 4
711 } hsa_amd_memory_pool_global_flag_t;
714 * @brief Memory pool features.
716 typedef enum {
718 * Segment where the memory pool resides. The type of this attribute is
719 * ::hsa_amd_segment_t.
721 HSA_AMD_MEMORY_POOL_INFO_SEGMENT = 0,
723 * Flag mask. The value of this attribute is undefined if the value of
724 * ::HSA_AMD_MEMORY_POOL_INFO_SEGMENT is not ::HSA_AMD_SEGMENT_GLOBAL. The type
725 * of
726 * this attribute is uint32_t, a bit-field of
727 * ::hsa_amd_memory_pool_global_flag_t
728 * values.
730 HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS = 1,
732 * Size of this pool, in bytes. The type of this attribute is size_t.
734 HSA_AMD_MEMORY_POOL_INFO_SIZE = 2,
736 * Indicates whether memory in this pool can be allocated using
737 * ::hsa_amd_memory_pool_allocate. The type of this attribute is bool.
739 * The value of this flag is always false for memory pools in the group and
740 * private segments.
742 HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED = 5,
744 * Allocation granularity of buffers allocated by
745 * ::hsa_amd_memory_pool_allocate
746 * in this memory pool. The size of a buffer allocated in this pool is a
747 * multiple of the value of this attribute. The value of this attribute is
748 * only defined if ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for
749 * this pool. The type of this attribute is size_t.
751 HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE = 6,
753 * Alignment of buffers allocated by ::hsa_amd_memory_pool_allocate in this
754 * pool. The value of this attribute is only defined if
755 * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool, and
756 * must be a power of 2. The type of this attribute is size_t.
758 HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT = 7,
760 * This memory_pool can be made directly accessible by all the agents in the
761 * system (::hsa_amd_agent_memory_pool_get_info does not return
762 * ::HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED for any agent). The type of this
763 * attribute is bool.
765 HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL = 15,
767 * Maximum aggregate allocation size in bytes. The type of this attribute
768 * is size_t.
770 HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE = 16,
771 } hsa_amd_memory_pool_info_t;
774 * @brief Get the current value of an attribute of a memory pool.
776 * @param[in] memory_pool A valid memory pool.
778 * @param[in] attribute Attribute to query.
780 * @param[out] value Pointer to a application-allocated buffer where to store
781 * the value of the attribute. If the buffer passed by the application is not
782 * large enough to hold the value of @p attribute, the behavior is undefined.
784 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
787 hsa_status_t HSA_API
788 hsa_amd_memory_pool_get_info(hsa_amd_memory_pool_t memory_pool,
789 hsa_amd_memory_pool_info_t attribute,
790 void* value);
793 * @brief Iterate over the memory pools associated with a given agent, and
794 * invoke an application-defined callback on every iteration.
796 * @details An agent can directly access buffers located in some memory pool, or
797 * be enabled to access them by the application (see ::hsa_amd_agents_allow_access),
798 * yet that memory pool may not be returned by this function for that given
799 * agent.
801 * A memory pool of fine-grained type must be associated only with the host.
803 * @param[in] agent A valid agent.
805 * @param[in] callback Callback to be invoked on the same thread that called
806 * ::hsa_amd_agent_iterate_memory_pools, serially, once per memory pool that is
807 * associated with the agent. The HSA runtime passes two arguments to the
808 * callback: the memory pool, and the application data. If @p callback
809 * returns a status other than ::HSA_STATUS_SUCCESS for a particular iteration,
810 * the traversal stops and ::hsa_amd_agent_iterate_memory_pools returns that status
811 * value.
813 * @param[in] data Application data that is passed to @p callback on every
814 * iteration. May be NULL.
816 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
818 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
819 * initialized.
821 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
823 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
825 hsa_status_t HSA_API hsa_amd_agent_iterate_memory_pools(
826 hsa_agent_t agent,
827 hsa_status_t (*callback)(hsa_amd_memory_pool_t memory_pool, void* data),
828 void* data);
831 * @brief Allocate a block of memory (or buffer) in the specified pool.
833 * @param[in] memory_pool Memory pool where to allocate memory from. The memory
834 * pool must have the ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED flag set.
836 * @param[in] size Allocation size, in bytes. Must not be zero. This value is
837 * rounded up to the nearest multiple of
838 * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE in @p memory_pool.
840 * @param[in] flags A bit-field that is used to specify allocation
841 * directives. Reserved parameter, must be 0.
843 * @param[out] ptr Pointer to the location where to store the base virtual
844 * address of
845 * the allocated block. The returned base address is aligned to the value of
846 * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT in @p memory_pool. If the
847 * allocation fails, the returned value is undefined.
849 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
851 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
852 * initialized.
854 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES No memory is available.
856 * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL The memory pool is invalid.
858 * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The host is not allowed to
859 * allocate memory in @p memory_pool, or @p size is greater than
860 * the value of HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE in @p memory_pool.
862 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p size is 0,
863 * or flags is not 0.
866 hsa_status_t HSA_API
867 hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, size_t size,
868 uint32_t flags, void** ptr);
871 * @brief Deallocate a block of memory previously allocated using
872 * ::hsa_amd_memory_pool_allocate.
874 * @param[in] ptr Pointer to a memory block. If @p ptr does not match a value
875 * previously returned by ::hsa_amd_memory_pool_allocate, the behavior is undefined.
877 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
879 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
880 * initialized.
883 hsa_status_t HSA_API hsa_amd_memory_pool_free(void* ptr);
886 * @brief Asynchronously copy a block of memory from the location pointed to by
887 * @p src on the @p src_agent to the memory block pointed to by @p dst on the @p
888 * dst_agent.
889 * Because the DMA engines used may not be in the same coherency domain, the caller must ensure
890 * that buffers are system-level coherent. In general this requires the sending device to have
891 * released the buffer to system scope prior to executing the copy API and the receiving device
892 * must execute a system scope acquire fence prior to use of the destination buffer.
894 * @param[out] dst Buffer where the content is to be copied.
896 * @param[in] dst_agent Agent associated with the @p dst. The agent must be able to directly
897 * access both the source and destination buffers in their current locations.
899 * @param[in] src A valid pointer to the source of data to be copied. The source
900 * buffer must not overlap with the destination buffer, otherwise the copy will succeed
901 * but contents of @p dst is undefined.
903 * @param[in] src_agent Agent associated with the @p src. The agent must be able to directly
904 * access both the source and destination buffers in their current locations.
906 * @param[in] size Number of bytes to copy. If @p size is 0, no copy is
907 * performed and the function returns success. Copying a number of bytes larger
908 * than the size of the buffers pointed by @p dst or @p src results in undefined
909 * behavior.
911 * @param[in] num_dep_signals Number of dependent signals. Can be 0.
913 * @param[in] dep_signals List of signals that must be waited on before the copy
914 * operation starts. The copy will start after every signal has been observed with
915 * the value 0. The dependent signal should not include completion signal from hsa_amd_memory_async_copy
916 * operation to be issued in future as that can result in a deadlock. If @p num_dep_signals is 0, this
917 * argument is ignored.
919 * @param[in] completion_signal Signal used to indicate completion of the copy
920 * operation. When the copy operation is finished, the value of the signal is
921 * decremented. The runtime indicates that an error has occurred during the copy
922 * operation by setting the value of the completion signal to a negative
923 * number. The signal handle must not be 0.
925 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully. The
926 * application is responsible for checking for asynchronous error conditions
927 * (see the description of @p completion_signal).
929 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
930 * initialized.
932 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
934 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL @p completion_signal is invalid.
936 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
937 * pointers are NULL, or the completion signal is 0.
939 hsa_status_t HSA_API
940 hsa_amd_memory_async_copy(void* dst, hsa_agent_t dst_agent, const void* src,
941 hsa_agent_t src_agent, size_t size,
942 uint32_t num_dep_signals,
943 const hsa_signal_t* dep_signals,
944 hsa_signal_t completion_signal);
947 [Provisional API]
948 Pitched memory descriptor.
949 All elements must be 4 byte aligned. Pitch and slice are in bytes.
951 typedef struct hsa_pitched_ptr_s {
952 void* base;
953 size_t pitch;
954 size_t slice;
955 } hsa_pitched_ptr_t;
958 [Provisional API]
959 Copy direction flag.
961 typedef enum {
962 hsaHostToHost = 0,
963 hsaHostToDevice = 1,
964 hsaDeviceToHost = 2,
965 hsaDeviceToDevice = 3
966 } hsa_amd_copy_direction_t;
969 [Provisional API]
970 SDMA 3D memory copy API. The same requirements must be met by src and dst as in
971 hsa_amd_memory_async_copy.
972 Both src and dst must be directly accessible to the copy_agent during the copy, src and dst rects
973 must not overlap.
974 CPU agents are not supported. API requires SDMA and will return an error if SDMA is not available.
975 Offsets and range carry x in bytes, y and z in rows and layers.
977 hsa_status_t HSA_API hsa_amd_memory_async_copy_rect(
978 const hsa_pitched_ptr_t* dst, const hsa_dim3_t* dst_offset, const hsa_pitched_ptr_t* src,
979 const hsa_dim3_t* src_offset, const hsa_dim3_t* range, hsa_agent_t copy_agent,
980 hsa_amd_copy_direction_t dir, uint32_t num_dep_signals, const hsa_signal_t* dep_signals,
981 hsa_signal_t completion_signal);
984 * @brief Type of accesses to a memory pool from a given agent.
986 typedef enum {
988 * The agent cannot directly access any buffer in the memory pool.
990 HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED = 0,
992 * The agent can directly access a buffer located in the pool; the application
993 * does not need to invoke ::hsa_amd_agents_allow_access.
995 HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT = 1,
997 * The agent can directly access a buffer located in the pool, but only if the
998 * application has previously requested access to that buffer using
999 * ::hsa_amd_agents_allow_access.
1001 HSA_AMD_MEMORY_POOL_ACCESS_DISALLOWED_BY_DEFAULT = 2
1002 } hsa_amd_memory_pool_access_t;
1005 * @brief Properties of the relationship between an agent a memory pool.
1007 typedef enum {
1009 * Hyper-transport bus type.
1011 HSA_AMD_LINK_INFO_TYPE_HYPERTRANSPORT = 0,
1014 * QPI bus type.
1016 HSA_AMD_LINK_INFO_TYPE_QPI = 1,
1019 * PCIe bus type.
1021 HSA_AMD_LINK_INFO_TYPE_PCIE = 2,
1024 * Infiniband bus type.
1026 HSA_AMD_LINK_INFO_TYPE_INFINBAND = 3,
1029 * xGMI link type.
1031 HSA_AMD_LINK_INFO_TYPE_XGMI = 4
1033 } hsa_amd_link_info_type_t;
1036 * @brief Link properties when accessing the memory pool from the specified
1037 * agent.
1039 typedef struct hsa_amd_memory_pool_link_info_s {
1041 * Minimum transfer latency (rounded to ns).
1043 uint32_t min_latency;
1046 * Maximum transfer latency (rounded to ns).
1048 uint32_t max_latency;
1051 * Minimum link interface bandwidth in MB/s.
1053 uint32_t min_bandwidth;
1056 * Maximum link interface bandwidth in MB/s.
1058 uint32_t max_bandwidth;
1061 * Support for 32-bit atomic transactions.
1063 bool atomic_support_32bit;
1066 * Support for 64-bit atomic transactions.
1068 bool atomic_support_64bit;
1071 * Support for cache coherent transactions.
1073 bool coherent_support;
1076 * The type of bus/link.
1078 hsa_amd_link_info_type_t link_type;
1081 * NUMA distance of memory pool relative to querying agent
1083 uint32_t numa_distance;
1084 } hsa_amd_memory_pool_link_info_t;
1087 * @brief Properties of the relationship between an agent a memory pool.
1089 typedef enum {
1091 * Access to buffers located in the memory pool. The type of this attribute
1092 * is ::hsa_amd_memory_pool_access_t.
1094 * An agent can always directly access buffers currently located in a memory
1095 * pool that is associated (the memory_pool is one of the values returned by
1096 * ::hsa_amd_agent_iterate_memory_pools on the agent) with that agent. If the
1097 * buffer is currently located in a memory pool that is not associated with
1098 * the agent, and the value returned by this function for the given
1099 * combination of agent and memory pool is not
1100 * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED, the application still needs to invoke
1101 * ::hsa_amd_agents_allow_access in order to gain direct access to the buffer.
1103 * If the given agent can directly access buffers the pool, the result is not
1104 * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is associated with
1105 * the agent, or it is of fined-grained type, the result must not be
1106 * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is not associated
1107 * with the agent, and does not reside in the global segment, the result must
1108 * be HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED.
1110 HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS = 0,
1113 * Number of links to hop when accessing the memory pool from the specified
1114 * agent. The value of this attribute is zero if the memory pool is associated
1115 * with the agent, or if the access type is
1116 * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. The type of this attribute is
1117 * uint32_t.
1119 HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS = 1,
1122 * Details of each link hop when accessing the memory pool starting from the
1123 * specified agent. The type of this attribute is an array size of
1124 * HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS with each element containing
1125 * ::hsa_amd_memory_pool_link_info_t.
1127 HSA_AMD_AGENT_MEMORY_POOL_INFO_LINK_INFO = 2
1129 } hsa_amd_agent_memory_pool_info_t;
1132 * @brief Get the current value of an attribute of the relationship between an
1133 * agent and a memory pool.
1135 * @param[in] agent Agent.
1137 * @param[in] memory_pool Memory pool.
1139 * @param[in] attribute Attribute to query.
1141 * @param[out] value Pointer to a application-allocated buffer where to store
1142 * the value of the attribute. If the buffer passed by the application is not
1143 * large enough to hold the value of @p attribute, the behavior is undefined.
1145 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1148 hsa_status_t HSA_API hsa_amd_agent_memory_pool_get_info(
1149 hsa_agent_t agent, hsa_amd_memory_pool_t memory_pool,
1150 hsa_amd_agent_memory_pool_info_t attribute, void* value);
1153 * @brief Enable direct access to a buffer from a given set of agents.
1155 * @details
1157 * Upon return, only the listed agents and the agent associated with the
1158 * buffer's memory pool have direct access to the @p ptr.
1160 * Any agent that has access to the buffer before and after the call to
1161 * ::hsa_amd_agents_allow_access will also have access while
1162 * ::hsa_amd_agents_allow_access is in progress.
1164 * The caller is responsible for ensuring that each agent in the list
1165 * must be able to access the memory pool containing @p ptr
1166 * (using ::hsa_amd_agent_memory_pool_get_info with ::HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS attribute),
1167 * otherwise error code is returned.
1169 * @param[in] num_agents Size of @p agents.
1171 * @param[in] agents List of agents. If @p num_agents is 0, this argument is
1172 * ignored.
1174 * @param[in] flags A list of bit-field that is used to specify access
1175 * information in a per-agent basis. This is currently reserved and must be NULL.
1177 * @param[in] ptr A buffer previously allocated using ::hsa_amd_memory_pool_allocate.
1179 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1181 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1182 * initialized.
1184 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_agents is 0, or @p agents
1185 * is NULL, @p flags is not NULL, or attempting to enable access to agent(s)
1186 * because @p ptr is allocated from an inaccessible pool.
1189 hsa_status_t HSA_API
1190 hsa_amd_agents_allow_access(uint32_t num_agents, const hsa_agent_t* agents,
1191 const uint32_t* flags, const void* ptr);
1194 * @brief Query if buffers currently located in some memory pool can be
1195 * relocated to a destination memory pool.
1197 * @details If the returned value is non-zero, a migration of a buffer to @p
1198 * dst_memory_pool using ::hsa_amd_memory_migrate may nevertheless fail due to
1199 * resource limitations.
1201 * @param[in] src_memory_pool Source memory pool.
1203 * @param[in] dst_memory_pool Destination memory pool.
1205 * @param[out] result Pointer to a memory location where the result of the query
1206 * is stored. Must not be NULL. If buffers currently located in @p
1207 * src_memory_pool can be relocated to @p dst_memory_pool, the result is
1208 * true.
1210 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1212 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1213 * initialized.
1215 * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL One of the memory pools is
1216 * invalid.
1218 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
1220 hsa_status_t HSA_API
1221 hsa_amd_memory_pool_can_migrate(hsa_amd_memory_pool_t src_memory_pool,
1222 hsa_amd_memory_pool_t dst_memory_pool,
1223 bool* result);
1226 * @brief Relocate a buffer to a new memory pool.
1228 * @details When a buffer is migrated, its virtual address remains the same but
1229 * its physical contents are moved to the indicated memory pool.
1231 * After migration, only the agent associated with the destination pool will have access.
1233 * The caller is also responsible for ensuring that the allocation in the
1234 * source memory pool where the buffer is currently located can be migrated to the
1235 * specified destination memory pool (using ::hsa_amd_memory_pool_can_migrate returns a value of true
1236 * for the source and destination memory pools), otherwise behavior is undefined.
1238 * The caller must ensure that the buffer is not accessed while it is migrated.
1240 * @param[in] ptr Buffer to be relocated. The buffer must have been released to system
1241 * prior to call this API. The buffer will be released to system upon completion.
1243 * @param[in] memory_pool Memory pool where to place the buffer.
1245 * @param[in] flags A bit-field that is used to specify migration
1246 * information. Must be zero.
1248 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1250 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1251 * initialized.
1253 * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL The destination memory pool is
1254 * invalid.
1256 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1257 * allocating the necessary resources.
1259 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p flags is not 0.
1261 hsa_status_t HSA_API hsa_amd_memory_migrate(const void* ptr,
1262 hsa_amd_memory_pool_t memory_pool,
1263 uint32_t flags);
1267 * @brief Pin a host pointer allocated by C/C++ or OS allocator (i.e. ordinary system DRAM) and
1268 * return a new pointer accessible by the @p agents. If the @p host_ptr overlaps with previously
1269 * locked memory, then the overlap area is kept locked (i.e multiple mappings are permitted). In
1270 * this case, the same input @p host_ptr may give different locked @p agent_ptr and when it does,
1271 * they are not necessarily coherent (i.e. accessing either @p agent_ptr is not equivalent).
1272 * Accesses to @p agent_ptr are coarse grained.
1274 * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator.
1276 * @param[in] size The size to be locked.
1278 * @param[in] agents Array of agent handle to gain access to the @p host_ptr.
1279 * If this parameter is NULL and the @p num_agent is 0, all agents
1280 * in the platform will gain access to the @p host_ptr.
1282 * @param[out] agent_ptr Pointer to the location where to store the new address.
1284 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1286 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1287 * initialized.
1289 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1290 * allocating the necessary resources.
1292 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT One or more agent in @p agents is
1293 * invalid.
1295 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 or @p host_ptr or
1296 * @p agent_ptr is NULL or @p agents not NULL but @p num_agent is 0 or @p agents
1297 * is NULL but @p num_agent is not 0.
1299 hsa_status_t HSA_API hsa_amd_memory_lock(void* host_ptr, size_t size,
1300 hsa_agent_t* agents, int num_agent,
1301 void** agent_ptr);
1305 * @brief Pin a host pointer allocated by C/C++ or OS allocator (i.e. ordinary system DRAM) and
1306 * return a new pointer accessible by the @p agents. If the @p host_ptr overlaps with previously
1307 * locked memory, then the overlap area is kept locked (i.e. multiple mappings are permitted).
1308 * In this case, the same input @p host_ptr may give different locked @p agent_ptr and when it
1309 * does, they are not necessarily coherent (i.e. accessing either @p agent_ptr is not equivalent).
1310 * Acesses to the memory via @p agent_ptr have the same access properties as memory allocated from
1311 * @p pool as determined by ::hsa_amd_memory_pool_get_info and ::hsa_amd_agent_memory_pool_get_info
1312 * (ex. coarse/fine grain, platform atomic support, link info). Physical composition and placement
1313 * of the memory (ex. page size, NUMA binding) is not changed.
1315 * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator.
1317 * @param[in] size The size to be locked.
1319 * @param[in] agents Array of agent handle to gain access to the @p host_ptr.
1320 * If this parameter is NULL and the @p num_agent is 0, all agents
1321 * in the platform will gain access to the @p host_ptr.
1323 * @param[in] pool Global memory pool owned by a CPU agent.
1325 * @param[in] flags A bit-field that is used to specify allocation
1326 * directives. Reserved parameter, must be 0.
1328 * @param[out] agent_ptr Pointer to the location where to store the new address.
1330 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1332 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1333 * initialized.
1335 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1336 * allocating the necessary resources.
1338 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT One or more agent in @p agents is
1339 * invalid or can not access @p pool.
1341 * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL @p pool is invalid or not owned
1342 * by a CPU agent.
1344 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 or @p host_ptr or
1345 * @p agent_ptr is NULL or @p agents not NULL but @p num_agent is 0 or @p agents
1346 * is NULL but @p num_agent is not 0 or flags is not 0.
1348 hsa_status_t HSA_API hsa_amd_memory_lock_to_pool(void* host_ptr, size_t size, hsa_agent_t* agents,
1349 int num_agent, hsa_amd_memory_pool_t pool,
1350 uint32_t flags, void** agent_ptr);
1354 * @brief Unpin the host pointer previously pinned via ::hsa_amd_memory_lock or
1355 * ::hsa_amd_memory_lock_to_pool.
1357 * @details The behavior is undefined if the host pointer being unpinned does not
1358 * match previous pinned address or if the host pointer was already deallocated.
1360 * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator that was
1361 * pinned previously via ::hsa_amd_memory_lock or ::hsa_amd_memory_lock_to_pool.
1363 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1365 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1366 * initialized.
1368 hsa_status_t HSA_API hsa_amd_memory_unlock(void* host_ptr);
1371 * @brief Sets the first @p count of uint32_t of the block of memory pointed by
1372 * @p ptr to the specified @p value.
1374 * @param[in] ptr Pointer to the block of memory to fill.
1376 * @param[in] value Value to be set.
1378 * @param[in] count Number of uint32_t element to be set to the value.
1380 * @retval HSA_STATUS_SUCCESS The function has been executed successfully.
1382 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1383 * initialized.
1385 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL or
1386 * not 4 bytes aligned
1388 * @retval HSA_STATUS_ERROR_INVALID_ALLOCATION if the given memory
1389 * region was not allocated with HSA runtime APIs.
1392 hsa_status_t HSA_API
1393 hsa_amd_memory_fill(void* ptr, uint32_t value, size_t count);
1396 * @brief Maps an interop object into the HSA flat address space and establishes
1397 * memory residency. The metadata pointer is valid during the lifetime of the
1398 * map (until hsa_amd_interop_unmap_buffer is called).
1399 * Multiple calls to hsa_amd_interop_map_buffer with the same interop_handle
1400 * result in multiple mappings with potentially different addresses and
1401 * different metadata pointers. Concurrent operations on these addresses are
1402 * not coherent. Memory must be fenced to system scope to ensure consistency,
1403 * between mappings and with any views of this buffer in the originating
1404 * software stack.
1406 * @param[in] num_agents Number of agents which require access to the memory
1408 * @param[in] agents List of accessing agents.
1410 * @param[in] interop_handle Handle of interop buffer (dmabuf handle in Linux)
1412 * @param [in] flags Reserved, must be 0
1414 * @param[out] size Size in bytes of the mapped object
1416 * @param[out] ptr Base address of the mapped object
1418 * @param[out] metadata_size Size of metadata in bytes, may be NULL
1420 * @param[out] metadata Pointer to metadata, may be NULL
1422 * @retval HSA_STATUS_SUCCESS if successfully mapped
1424 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1426 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1427 * necessary resources
1429 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT all other errors
1431 hsa_status_t HSA_API hsa_amd_interop_map_buffer(uint32_t num_agents,
1432 hsa_agent_t* agents,
1433 int interop_handle,
1434 uint32_t flags,
1435 size_t* size,
1436 void** ptr,
1437 size_t* metadata_size,
1438 const void** metadata);
1441 * @brief Removes a previously mapped interop object from HSA's flat address space.
1442 * Ends lifetime for the mapping's associated metadata pointer.
1444 hsa_status_t HSA_API hsa_amd_interop_unmap_buffer(void* ptr);
1447 * @brief Encodes an opaque vendor specific image format. The length of data
1448 * depends on the underlying format. This structure must not be copied as its
1449 * true length can not be determined.
1451 typedef struct hsa_amd_image_descriptor_s {
1453 Version number of the descriptor
1455 uint32_t version;
1458 Vendor and device PCI IDs for the format as VENDOR_ID<<16|DEVICE_ID.
1460 uint32_t deviceID;
1463 Start of vendor specific data.
1465 uint32_t data[1];
1466 } hsa_amd_image_descriptor_t;
1469 * @brief Creates an image from an opaque vendor specific image format.
1470 * Does not modify data at image_data. Intended initially for
1471 * accessing interop images.
1473 * @param agent[in] Agent on which to create the image
1475 * @param[in] image_descriptor[in] Vendor specific image format
1477 * @param[in] image_data Pointer to image backing store
1479 * @param[in] access_permission Access permissions for the image object
1481 * @param[out] image Created image object.
1483 * @retval HSA_STATUS_SUCCESS Image created successfully
1485 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1487 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1488 * necessary resources
1490 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT Bad or mismatched descriptor,
1491 * null image_data, or mismatched access_permission.
1493 hsa_status_t HSA_API hsa_amd_image_create(
1494 hsa_agent_t agent,
1495 const hsa_ext_image_descriptor_t *image_descriptor,
1496 const hsa_amd_image_descriptor_t *image_layout,
1497 const void *image_data,
1498 hsa_access_permission_t access_permission,
1499 hsa_ext_image_t *image
1503 * @brief Denotes the type of memory in a pointer info query.
1505 typedef enum {
1507 Memory is not known to the HSA driver. Unallocated or unlocked system memory.
1509 HSA_EXT_POINTER_TYPE_UNKNOWN = 0,
1511 Memory was allocated with an HSA memory allocator.
1513 HSA_EXT_POINTER_TYPE_HSA = 1,
1515 System memory which has been locked for use with an HSA agent.
1517 Memory of this type is normal malloc'd memory and is always accessible to
1518 the CPU. Pointer info queries may not include CPU agents in the accessible
1519 agents list as the CPU has implicit access.
1521 HSA_EXT_POINTER_TYPE_LOCKED = 2,
1523 Memory originated in a graphics component and is shared with ROCr.
1525 HSA_EXT_POINTER_TYPE_GRAPHICS = 3,
1527 Memory has been shared with the local process via ROCr IPC APIs.
1529 HSA_EXT_POINTER_TYPE_IPC = 4
1530 } hsa_amd_pointer_type_t;
1533 * @brief Describes a memory allocation known to ROCr.
1534 * Within a ROCr major version this structure can only grow.
1536 typedef struct hsa_amd_pointer_info_s {
1538 Size in bytes of this structure. Used for version control within a major ROCr
1539 revision. Set to sizeof(hsa_amd_pointer_t) prior to calling
1540 hsa_amd_pointer_info. If the runtime supports an older version of pointer
1541 info then size will be smaller on return. Members starting after the return
1542 value of size will not be updated by hsa_amd_pointer_info.
1544 uint32_t size;
1546 The type of allocation referenced.
1548 hsa_amd_pointer_type_t type;
1550 Base address at which non-host agents may access the allocation.
1552 void* agentBaseAddress;
1554 Base address at which the host agent may access the allocation.
1556 void* hostBaseAddress;
1558 Size of the allocation
1560 size_t sizeInBytes;
1562 Application provided value.
1564 void* userData;
1566 Reports an agent which "owns" (ie has preferred access to) the pool in which the allocation was
1567 made. When multiple agents share equal access to a pool (ex: multiple CPU agents, or multi-die
1568 GPU boards) any such agent may be returned.
1570 hsa_agent_t agentOwner;
1571 } hsa_amd_pointer_info_t;
1574 * @brief Retrieves information about the allocation referenced by the given
1575 * pointer. Optionally returns the number and list of agents which can
1576 * directly access the allocation.
1578 * @param[in] ptr Pointer which references the allocation to retrieve info for.
1580 * @param[in, out] info Pointer to structure to be filled with allocation info.
1581 * Data member size must be set to the size of the structure prior to calling
1582 * hsa_amd_pointer_info. On return size will be set to the size of the
1583 * pointer info structure supported by the runtime, if smaller. Members
1584 * beyond the returned value of size will not be updated by the API.
1585 * Must not be NULL.
1587 * @param[in] alloc Function pointer to an allocator used to allocate the
1588 * @p accessible array. If NULL @p accessible will not be returned.
1590 * @param[out] num_agents_accessible Recieves the count of agents in
1591 * @p accessible. If NULL @p accessible will not be returned.
1593 * @param[out] accessible Recieves a pointer to the array, allocated by @p alloc,
1594 * holding the list of agents which may directly access the allocation.
1595 * May be NULL.
1597 * @retval HSA_STATUS_SUCCESS Info retrieved successfully
1599 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1601 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1602 * necessary resources
1604 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT NULL in @p ptr or @p info.
1606 hsa_status_t HSA_API hsa_amd_pointer_info(void* ptr,
1607 hsa_amd_pointer_info_t* info,
1608 void* (*alloc)(size_t),
1609 uint32_t* num_agents_accessible,
1610 hsa_agent_t** accessible);
1613 * @brief Associates an arbitrary pointer with an allocation known to ROCr.
1614 * The pointer can be fetched by hsa_amd_pointer_info in the userData field.
1616 * @param[in] ptr Pointer to the first byte of an allocation known to ROCr
1617 * with which to associate @p userdata.
1619 * @param[in] userdata Abitrary pointer to associate with the allocation.
1621 * @retval HSA_STATUS_SUCCESS @p userdata successfully stored.
1623 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1625 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1626 * necessary resources
1628 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is not known to ROCr.
1630 hsa_status_t HSA_API hsa_amd_pointer_info_set_userdata(void* ptr,
1631 void* userdata);
1634 * @brief 256-bit process independent identifier for a ROCr shared memory
1635 * allocation.
1637 typedef struct hsa_amd_ipc_memory_s {
1638 uint32_t handle[8];
1639 } hsa_amd_ipc_memory_t;
1642 * @brief Prepares an allocation for interprocess sharing and creates a
1643 * handle of type hsa_amd_ipc_memory_t uniquely identifying the allocation. A
1644 * handle is valid while the allocation it references remains accessible in
1645 * any process. In general applications should confirm that a shared memory
1646 * region has been attached (via hsa_amd_ipc_memory_attach) in the remote
1647 * process prior to releasing that memory in the local process.
1648 * Repeated calls for the same allocation may, but are not required to, return
1649 * unique handles.
1651 * @param[in] ptr Pointer to memory allocated via ROCr APIs to prepare for
1652 * sharing.
1654 * @param[in] len Length in bytes of the allocation to share.
1656 * @param[out] handle Process independent identifier referencing the shared
1657 * allocation.
1659 * @retval HSA_STATUS_SUCCESS allocation is prepared for interprocess sharing.
1661 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1663 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1664 * necessary resources
1666 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr does not point to the
1667 * first byte of an allocation made through ROCr, or len is not the full length
1668 * of the allocation or handle is NULL.
1670 hsa_status_t HSA_API hsa_amd_ipc_memory_create(void* ptr, size_t len,
1671 hsa_amd_ipc_memory_t* handle);
1674 * @brief Imports shared memory into the local process and makes it accessible
1675 * by the given agents. If a shared memory handle is attached multiple times
1676 * in a process each attach may return a different address. Each returned
1677 * address is refcounted and requires a matching number of calls to
1678 * hsa_amd_ipc_memory_detach to release the shared memory mapping.
1680 * @param[in] handle Pointer to the identifier for the shared memory.
1682 * @param[in] len Length of the shared memory to import.
1683 * Reserved. Must be the full length of the shared allocation in this version.
1685 * @param[in] num_agents Count of agents in @p mapping_agents.
1686 * May be zero if all agents are to be allowed access.
1688 * @param[in] mapping_agents List of agents to access the shared memory.
1689 * Ignored if @p num_agents is zero.
1691 * @param[out] mapped_ptr Recieves a process local pointer to the shared memory.
1693 * @retval HSA_STATUS_SUCCESS if memory is successfully imported.
1695 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1697 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1698 * necessary resources
1700 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p handle is not valid, @p len is
1701 * incorrect, @p mapped_ptr is NULL, or some agent for which access was
1702 * requested can not access the shared memory.
1704 hsa_status_t HSA_API hsa_amd_ipc_memory_attach(
1705 const hsa_amd_ipc_memory_t* handle, size_t len,
1706 uint32_t num_agents,
1707 const hsa_agent_t* mapping_agents,
1708 void** mapped_ptr);
1711 * @brief Decrements the reference count for the shared memory mapping and
1712 * releases access to shared memory imported with hsa_amd_ipc_memory_attach.
1714 * @param[in] mapped_ptr Pointer to the first byte of a shared allocation
1715 * imported with hsa_amd_ipc_memory_attach.
1717 * @retval HSA_STATUS_SUCCESS if @p mapped_ptr was imported with
1718 * hsa_amd_ipc_memory_attach.
1720 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1722 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p mapped_ptr was not imported
1723 * with hsa_amd_ipc_memory_attach.
1725 hsa_status_t HSA_API hsa_amd_ipc_memory_detach(void* mapped_ptr);
1728 * @brief 256-bit process independent identifier for a ROCr IPC signal.
1730 typedef hsa_amd_ipc_memory_t hsa_amd_ipc_signal_t;
1733 * @brief Obtains an interprocess sharing handle for a signal. The handle is
1734 * valid while the signal it references remains valid in any process. In
1735 * general applications should confirm that the signal has been attached (via
1736 * hsa_amd_ipc_signal_attach) in the remote process prior to destroying that
1737 * signal in the local process.
1738 * Repeated calls for the same signal may, but are not required to, return
1739 * unique handles.
1741 * @param[in] signal Signal created with attribute HSA_AMD_SIGNAL_IPC.
1743 * @param[out] handle Process independent identifier referencing the shared
1744 * signal.
1746 * @retval HSA_STATUS_SUCCESS @p handle is ready to use for interprocess sharing.
1748 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1750 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1751 * necessary resources
1753 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is not a valid signal
1754 * created with attribute HSA_AMD_SIGNAL_IPC or handle is NULL.
1756 hsa_status_t HSA_API hsa_amd_ipc_signal_create(hsa_signal_t signal, hsa_amd_ipc_signal_t* handle);
1759 * @brief Imports an IPC capable signal into the local process. If an IPC
1760 * signal handle is attached multiple times in a process each attach may return
1761 * a different signal handle. Each returned signal handle is refcounted and
1762 * requires a matching number of calls to hsa_signal_destroy to release the
1763 * shared signal.
1765 * @param[in] handle Pointer to the identifier for the shared signal.
1767 * @param[out] signal Recieves a process local signal handle to the shared signal.
1769 * @retval HSA_STATUS_SUCCESS if the signal is successfully imported.
1771 * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1773 * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1774 * necessary resources
1776 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p handle is not valid.
1778 hsa_status_t HSA_API hsa_amd_ipc_signal_attach(const hsa_amd_ipc_signal_t* handle,
1779 hsa_signal_t* signal);
1782 * @brief GPU system event type.
1784 typedef enum hsa_amd_event_type_s {
1786 AMD GPU memory fault.
1788 HSA_AMD_GPU_MEMORY_FAULT_EVENT = 0,
1789 } hsa_amd_event_type_t;
1792 * @brief Flags denoting the cause of a memory fault.
1794 typedef enum {
1795 // Page not present or supervisor privilege.
1796 HSA_AMD_MEMORY_FAULT_PAGE_NOT_PRESENT = 1 << 0,
1797 // Write access to a read-only page.
1798 HSA_AMD_MEMORY_FAULT_READ_ONLY = 1 << 1,
1799 // Execute access to a page marked NX.
1800 HSA_AMD_MEMORY_FAULT_NX = 1 << 2,
1801 // GPU attempted access to a host only page.
1802 HSA_AMD_MEMORY_FAULT_HOST_ONLY = 1 << 3,
1803 // DRAM ECC failure.
1804 HSA_AMD_MEMORY_FAULT_DRAM_ECC = 1 << 4,
1805 // Can't determine the exact fault address.
1806 HSA_AMD_MEMORY_FAULT_IMPRECISE = 1 << 5,
1807 // SRAM ECC failure (ie registers, no fault address).
1808 HSA_AMD_MEMORY_FAULT_SRAM_ECC = 1 << 6,
1809 // GPU reset following unspecified hang.
1810 HSA_AMD_MEMORY_FAULT_HANG = 1 << 31
1811 } hsa_amd_memory_fault_reason_t;
1814 * @brief AMD GPU memory fault event data.
1816 typedef struct hsa_amd_gpu_memory_fault_info_s {
1818 The agent where the memory fault occurred.
1820 hsa_agent_t agent;
1822 Virtual address accessed.
1824 uint64_t virtual_address;
1826 Bit field encoding the memory access failure reasons. There could be multiple bits set
1827 for one fault. Bits are defined in hsa_amd_memory_fault_reason_t.
1829 uint32_t fault_reason_mask;
1830 } hsa_amd_gpu_memory_fault_info_t;
1833 * @brief AMD GPU event data passed to event handler.
1835 typedef struct hsa_amd_event_s {
1837 The event type.
1839 hsa_amd_event_type_t event_type;
1840 union {
1842 The memory fault info, only valid when @p event_type is HSA_AMD_GPU_MEMORY_FAULT_EVENT.
1844 hsa_amd_gpu_memory_fault_info_t memory_fault;
1846 } hsa_amd_event_t;
1848 typedef hsa_status_t (*hsa_amd_system_event_callback_t)(const hsa_amd_event_t* event, void* data);
1851 * @brief Register AMD GPU event handler.
1853 * @param[in] callback Callback to be invoked when an event is triggered.
1854 * The HSA runtime passes two arguments to the callback: @p event
1855 * is defined per event by the HSA runtime, and @p data is the user data.
1857 * @param[in] data User data that is passed to @p callback. May be NULL.
1859 * @retval HSA_STATUS_SUCCESS The handler has been registered successfully.
1861 * @retval HSA_STATUS_ERROR An event handler has already been registered.
1863 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p event is invalid.
1865 hsa_status_t HSA_API hsa_amd_register_system_event_handler(hsa_amd_system_event_callback_t callback,
1866 void* data);
1869 * @brief Per-queue dispatch and wavefront scheduling priority.
1871 typedef enum hsa_amd_queue_priority_s {
1873 Below normal/high priority compute and all graphics
1875 HSA_AMD_QUEUE_PRIORITY_LOW = 0,
1877 Above low priority compute, below high priority compute and all graphics
1879 HSA_AMD_QUEUE_PRIORITY_NORMAL = 1,
1881 Above low/normal priority compute and all graphics
1883 HSA_AMD_QUEUE_PRIORITY_HIGH = 2,
1884 } hsa_amd_queue_priority_t;
1887 * @brief Modifies the dispatch and wavefront scheduling prioirty for a
1888 * given compute queue. The default is HSA_AMD_QUEUE_PRIORITY_NORMAL.
1890 * @param[in] queue Compute queue to apply new priority to.
1892 * @param[in] priority Priority to associate with queue.
1894 * @retval HSA_STATUS_SUCCESS if priority was changed successfully.
1896 * @retval HSA_STATUS_ERROR_INVALID_QUEUE if queue is not a valid
1897 * compute queue handle.
1899 * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT if priority is not a valid
1900 * value from hsa_amd_queue_priority_t.
1902 hsa_status_t HSA_API hsa_amd_queue_set_priority(hsa_queue_t* queue,
1903 hsa_amd_queue_priority_t priority);
1906 * @brief Deallocation notifier function type.
1908 typedef void (*hsa_amd_deallocation_callback_t)(void* ptr, void* user_data);
1911 * @brief Registers a deallocation notifier monitoring for release of agent
1912 * accessible address @p ptr. If successful, @p callback will be invoked when
1913 * @p ptr is removed from accessibility from all agents.
1915 * Notification callbacks are automatically deregistered when they are invoked.
1917 * Note: The current version supports notifications of address release
1918 * originating from ::hsa_amd_memory_pool_free. Support for other address
1919 * release APIs will follow.
1921 * @param[in] ptr Agent accessible address to monitor for deallocation. Passed
1922 * to @p callback.
1924 * @param[in] callback Notifier to be invoked when @p ptr is released from
1925 * agent accessibility.
1927 * @param[in] user_data User provided value passed to @p callback. May be NULL.
1929 * @retval ::HSA_STATUS_SUCCESS The notifier registered successfully
1931 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1932 * initialized.
1934 * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION @p ptr does not refer to a valid agent accessible
1935 * address.
1937 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL or @p ptr is NULL.
1939 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1940 * necessary resources
1942 hsa_status_t HSA_API hsa_amd_register_deallocation_callback(void* ptr,
1943 hsa_amd_deallocation_callback_t callback,
1944 void* user_data);
1947 * @brief Removes a deallocation notifier previously registered with
1948 * ::hsa_amd_register_deallocation_callback. Arguments must be identical to
1949 * those given in ::hsa_amd_register_deallocation_callback.
1951 * @param[in] ptr Agent accessible address which was monitored for deallocation.
1953 * @param[in] callback Notifier to be removed.
1955 * @retval ::HSA_STATUS_SUCCESS The notifier has been removed successfully.
1957 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1958 * initialized.
1960 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The given notifier was not registered.
1962 hsa_status_t HSA_API hsa_amd_deregister_deallocation_callback(void* ptr,
1963 hsa_amd_deallocation_callback_t callback);
1965 #ifdef __cplusplus
1966 } // end extern "C" block
1967 #endif
1969 #endif // header guard