1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // The University of Illinois/NCSA
4 // Open Source License (NCSA)
5 //
6 // Copyright (c) 2014-2015, 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 #define HSA_AMD_INTERFACE_VERSION_MAJOR 1
52 #define HSA_AMD_INTERFACE_VERSION_MINOR 0
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /**
59  * @brief Enumeration constants added to ::hsa_status_t.
60  *
61  * @remark Additions to hsa_status_t
62  */
63 enum {
64   /**
65    * The memory pool is invalid.
66    */
67   HSA_STATUS_ERROR_INVALID_MEMORY_POOL = 40
68 };
69 
70 /**
71  * @brief Agent attributes.
72  */
73 typedef enum hsa_amd_agent_info_s {
74   /**
75    * Chip identifier. The type of this attribute is uint32_t.
76    */
77   HSA_AMD_AGENT_INFO_CHIP_ID = 0xA000,
78   /**
79    * Size of a cacheline in bytes. The type of this attribute is uint32_t.
80    */
81   HSA_AMD_AGENT_INFO_CACHELINE_SIZE = 0xA001,
82   /**
83    * The number of compute unit available in the agent. The type of this
84    * attribute is uint32_t.
85    */
86   HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT = 0xA002,
87   /**
88    * The maximum clock frequency of the agent in MHz. The type of this
89    * attribute is uint32_t.
90    */
91   HSA_AMD_AGENT_INFO_MAX_CLOCK_FREQUENCY = 0xA003,
92   /**
93    * Internal driver node identifier. The type of this attribute is uint32_t.
94    */
95   HSA_AMD_AGENT_INFO_DRIVER_NODE_ID = 0xA004,
96   /**
97    * Max number of watch points on memory address ranges to generate exception
98    * events when the watched addresses are accessed.
99    */
100   HSA_AMD_AGENT_INFO_MAX_ADDRESS_WATCH_POINTS = 0xA005,
101   /**
102    * Agent BDF_ID, named LocationID in thunk. The type of this attribute is
103    * uint32_t.
104    */
105   HSA_AMD_AGENT_INFO_BDFID = 0xA006,
106   /**
107    * Memory Interface width, the return value type is uint32_t.
108    * This attribute is deprecated. Use
109    */
110   HSA_AMD_AGENT_INFO_MEMORY_WIDTH = 0xA007,
111   /**
112    * Max Memory Clock, the return value type is uint32_t.
113    */
114   HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY = 0xA008,
115   /**
116    * Board name of Agent - populated from MarketingName of Kfd Node
117    * The value is an Ascii string of 64 chars.
118    */
119   HSA_AMD_AGENT_INFO_PRODUCT_NAME = 0xA009,
120   /**
121    * Maximum number of waves possible in a Compute Unit.
122    * The type of this attribute is uint32_t.
123    */
124   HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU = 0xA00A,
125   /**
126    * Number of SIMD's per compute unit CU
127    * The type of this attribute is uint32_t.
128    */
129   HSA_AMD_AGENT_INFO_NUM_SIMDS_PER_CU = 0xA00B,
130   /**
131    * Number of Shader Engines (SE) in Gpu
132    * The type of this attribute is uint32_t.
133    */
134   HSA_AMD_AGENT_INFO_NUM_SHADER_ENGINES = 0xA00C,
135   /**
136    * Number of Shader Arrays Per Shader Engines in Gpu
137    * The type of this attribute is uint32_t.
138    */
139   HSA_AMD_AGENT_INFO_NUM_SHADER_ARRAYS_PER_SE = 0xA00D
140 } hsa_amd_agent_info_t;
141 
142 /**
143  * @brief Region attributes.
144  */
145 typedef enum hsa_amd_region_info_s {
146   /**
147    * Determine if host can access the region. The type of this attribute
148    * is bool.
149    */
150   HSA_AMD_REGION_INFO_HOST_ACCESSIBLE = 0xA000,
151   /**
152    * Base address of the region in flat address space.
153    */
154   HSA_AMD_REGION_INFO_BASE = 0xA001,
155   /**
156    * Memory Interface width, the return value type is uint32_t.
157    * This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_WIDTH.
158    */
159   HSA_AMD_REGION_INFO_BUS_WIDTH = 0xA002,
160   /**
161    * Max Memory Clock, the return value type is uint32_t.
162    * This attribute is deprecated. Use HSA_AMD_AGENT_INFO_MEMORY_MAX_FREQUENCY.
163    */
164   HSA_AMD_REGION_INFO_MAX_CLOCK_FREQUENCY = 0xA003
165 } hsa_amd_region_info_t;
166 
167 /**
168  * @brief Coherency attributes of fine grain region.
169  */
170 typedef enum hsa_amd_coherency_type_s {
171   /**
172    * Coherent region.
173    */
174   HSA_AMD_COHERENCY_TYPE_COHERENT = 0,
175   /**
176    * Non coherent region.
177    */
178   HSA_AMD_COHERENCY_TYPE_NONCOHERENT = 1
179 } hsa_amd_coherency_type_t;
180 
181 /**
182  * @brief Get the coherency type of the fine grain region of an agent.
183  *
184  * @param[in] agent A valid agent.
185  *
186  * @param[out] type Pointer to a memory location where the HSA runtime will
187  * store the coherency type of the fine grain region.
188  *
189  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
190  *
191  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
192  * initialized.
193  *
194  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
195  *
196  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p type is NULL.
197  */
198 hsa_status_t HSA_API hsa_amd_coherency_get_type(hsa_agent_t agent,
199                                                 hsa_amd_coherency_type_t* type);
200 
201 /**
202  * @brief Set the coherency type of the fine grain region of an agent.
203  * Deprecated.  This is supported on KV platforms.  For backward compatibility
204  * other platforms will spuriously succeed.
205  *
206  * @param[in] agent A valid agent.
207  *
208  * @param[in] type The coherency type to be set.
209  *
210  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
211  *
212  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
213  * initialized.
214  *
215  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
216  *
217  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p type is invalid.
218  */
219 hsa_status_t HSA_API hsa_amd_coherency_set_type(hsa_agent_t agent,
220                                                 hsa_amd_coherency_type_t type);
221 
222 /**
223  * @brief Structure containing profiling dispatch time information.
224  *
225  * Times are reported as ticks in the domain of the HSA system clock.
226  * The HSA system clock tick and frequency is obtained via hsa_system_get_info.
227  */
228 typedef struct hsa_amd_profiling_dispatch_time_s {
229   /**
230    * Dispatch packet processing start time.
231    */
232   uint64_t start;
233   /**
234    * Dispatch packet completion time.
235    */
236   uint64_t end;
237 } hsa_amd_profiling_dispatch_time_t;
238 
239 /**
240  * @brief Structure containing profiling async copy time information.
241  *
242  * Times are reported as ticks in the domain of the HSA system clock.
243  * The HSA system clock tick and frequency is obtained via hsa_system_get_info.
244  */
245 typedef struct hsa_amd_profiling_async_copy_time_s {
246   /**
247    * Async copy processing start time.
248    */
249   uint64_t start;
250   /**
251    * Async copy completion time.
252    */
253   uint64_t end;
254 } hsa_amd_profiling_async_copy_time_t;
255 
256 /**
257  * @brief Enable or disable profiling capability of a queue.
258  *
259  * @param[in] queue A valid queue.
260  *
261  * @param[in] enable 1 to enable profiling. 0 to disable profiling.
262  *
263  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
264  *
265  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
266  * initialized.
267  *
268  * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
269  *
270  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
271  */
272 hsa_status_t HSA_API
273     hsa_amd_profiling_set_profiler_enabled(hsa_queue_t* queue, int enable);
274 
275 /**
276  * @brief Enable or disable asynchronous memory copy profiling.
277  *
278  * @details The runtime will provide the copy processing start timestamp and
279  * completion timestamp of each call to hsa_amd_memory_async_copy if the
280  * async copy profiling is enabled prior to the call to
281  * hsa_amd_memory_async_copy. The completion signal object is used to
282  * hold the last async copy start and end timestamp. The client can retrieve
283  * these timestamps via call to hsa_amd_profiling_get_async_copy_time.
284  *
285  * @param[in] enable True to enable profiling. False to disable profiling.
286  *
287  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
288  *
289  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
290  * initialized.
291  *
292  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES Failed on allocating resources
293  * needed to profile the asynchronous copy.
294  */
295 hsa_status_t HSA_API
296     hsa_amd_profiling_async_copy_enable(bool enable);
297 
298 /**
299  * @brief Retrieve packet processing time stamps.
300  *
301  * @param[in] agent The agent with which the signal was last used.  For
302  * instance, if the profiled dispatch packet is dispatched onto queue Q,
303  * which was created on agent A, then this parameter must be A.
304  *
305  * @param[in] signal A signal used as the completion signal of the dispatch
306  * packet to retrieve time stamps from.  This dispatch packet must have been
307  * issued to a queue with profiling enabled and have already completed.  Also
308  * the signal must not have yet been used in any other packet following the
309  * completion of the profiled dispatch packet.
310  *
311  * @param[out] time Packet processing timestamps in the HSA system clock
312  * domain.
313  *
314  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
315  *
316  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
317  * initialized.
318  *
319  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
320  *
321  * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL The signal is invalid.
322  *
323  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p time is NULL.
324  */
325 hsa_status_t HSA_API hsa_amd_profiling_get_dispatch_time(
326     hsa_agent_t agent, hsa_signal_t signal,
327     hsa_amd_profiling_dispatch_time_t* time);
328 
329 /**
330  * @brief Retrieve asynchronous copy timestamps.
331  *
332  * @details Async copy profiling is enabled via call to
333  * hsa_amd_profiling_async_copy_enable.
334  *
335  * @param[in] signal A signal used as the completion signal of the call to
336  * hsa_amd_memory_async_copy.
337  *
338  * @param[out] time Async copy processing timestamps in the HSA system clock
339  * domain.
340  *
341  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
342  *
343  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
344  * initialized.
345  *
346  * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL The signal is invalid.
347  *
348  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p time is NULL.
349  */
350 hsa_status_t HSA_API hsa_amd_profiling_get_async_copy_time(
351     hsa_signal_t signal, hsa_amd_profiling_async_copy_time_t* time);
352 
353 /**
354  * @brief Computes the frequency ratio and offset between the agent clock and
355  * HSA system clock and converts the agent's tick to HSA system domain tick.
356  *
357  * @param[in] agent The agent used to retrieve the agent_tick. It is user's
358  * responsibility to make sure the tick number is from this agent, otherwise,
359  * the behavior is undefined.
360  *
361  * @param[in] agent_tick The tick count retrieved from the specified @p agent.
362  *
363  * @param[out] system_tick The translated HSA system domain clock counter tick.
364  *
365  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
366  *
367  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
368  * initialized.
369  *
370  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
371  *
372  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p system_tick is NULL;
373  */
374 hsa_status_t HSA_API
375     hsa_amd_profiling_convert_tick_to_system_domain(hsa_agent_t agent,
376                                                     uint64_t agent_tick,
377                                                     uint64_t* system_tick);
378 
379 /**
380  * @brief Signal attribute flags.
381  */
382 typedef enum {
383   /**
384    * Signal will only be consumed by AMD GPUs.  Limits signal consumption to
385    * AMD GPU agents only.  Ignored if @p num_consumers is not zero (all agents).
386    */
387   HSA_AMD_SIGNAL_AMD_GPU_ONLY = 1,
388   /**
389    * Signal may be used for interprocess communication.
390    * IPC signals can be read, written, and waited on from any process.
391    * Profiling using an IPC enabled signal is only supported in a single process
392    * at a time.  Producing profiling data in one process and consuming it in
393    * another process is undefined.
394    */
395   HSA_AMD_SIGNAL_IPC = 2,
396 } hsa_amd_signal_attribute_t;
397 
398 /**
399  * @brief Create a signal with specific attributes.
400  *
401  * @param[in] initial_value Initial value of the signal.
402  *
403  * @param[in] num_consumers Size of @p consumers. A value of 0 indicates that
404  * any agent might wait on the signal.
405  *
406  * @param[in] consumers List of agents that might consume (wait on) the
407  * signal. If @p num_consumers is 0, this argument is ignored; otherwise, the
408  * HSA runtime might use the list to optimize the handling of the signal
409  * object. If an agent not listed in @p consumers waits on the returned
410  * signal, the behavior is undefined. The memory associated with @p consumers
411  * can be reused or freed after the function returns.
412  *
413  * @param[in] attributes Requested signal attributes.  Multiple signal attributes
414  * may be requested by combining them with bitwise OR.  Requesting no attributes
415  * (@p attributes == 0) results in the same signal as would have been obtained
416  * via hsa_signal_create.
417  *
418  * @param[out] signal Pointer to a memory location where the HSA runtime will
419  * store the newly created signal handle. Must not be NULL.
420  *
421  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
422  *
423  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
424  * initialized.
425  *
426  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
427  * the required resources.
428  *
429  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is NULL, @p
430  * num_consumers is greater than 0 but @p consumers is NULL, or @p consumers
431  * contains duplicates.
432  */
433 hsa_status_t HSA_API hsa_amd_signal_create(hsa_signal_value_t initial_value, uint32_t num_consumers,
434                                            const hsa_agent_t* consumers, uint64_t attributes,
435                                            hsa_signal_t* signal);
436 
437 /**
438  * @brief Asyncronous signal handler function type.
439  *
440  * @details Type definition of callback function to be used with
441  * hsa_amd_signal_async_handler. This callback is invoked if the associated
442  * signal and condition are met. The callback receives the value of the signal
443  * which satisfied the associated wait condition and a user provided value. If
444  * the callback returns true then the callback will be called again if the
445  * associated signal and condition are satisfied again. If the callback returns
446  * false then it will not be called again.
447  *
448  * @param[in] value Contains the value of the signal observed by
449  * hsa_amd_signal_async_handler which caused the signal handler to be invoked.
450  *
451  * @param[in] arg Contains the user provided value given when the signal handler
452  * was registered with hsa_amd_signal_async_handler
453  *
454  * @retval true resumes monitoring the signal with this handler (as if calling
455  * hsa_amd_signal_async_handler again with identical parameters)
456  *
457  * @retval false stops monitoring the signal with this handler (handler will
458  * not be called again for this signal)
459  *
460  */
461 typedef bool (*hsa_amd_signal_handler)(hsa_signal_value_t value, void* arg);
462 
463 /**
464  * @brief Register asynchronous signal handler function.
465  *
466  * @details Allows registering a callback function and user provided value with
467  * a signal and wait condition. The callback will be invoked if the associated
468  * signal and wait condition are satisfied. Callbacks will be invoked serially
469  * but in an arbitrary order so callbacks should be independent of each other.
470  * After being invoked a callback may continue to wait for its associated signal
471  * and condition and, possibly, be invoked again. Or the callback may stop
472  * waiting. If the callback returns true then it will continue waiting and may
473  * be called again. If false then the callback will not wait again and will not
474  * be called again for the associated signal and condition. It is possible to
475  * register the same callback multiple times with the same or different signals
476  * and/or conditions. Each registration of the callback will be treated entirely
477  * independently.
478  *
479  * @param[in] signal hsa signal to be asynchronously monitored
480  *
481  * @param[in] cond condition value to monitor for
482  *
483  * @param[in] value signal value used in condition expression
484  *
485  * @param[in] handler asynchronous signal handler invoked when signal's
486  * condition is met
487  *
488  * @param[in] arg user provided value which is provided to handler when handler
489  * is invoked
490  *
491  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
492  *
493  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
494  * initialized.
495  *
496  * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL signal is not a valid hsa_signal_t
497  *
498  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT handler is invalid (NULL)
499  *
500  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime is out of
501  * resources or blocking signals are not supported by the HSA driver component.
502  *
503  */
504 hsa_status_t HSA_API
505     hsa_amd_signal_async_handler(hsa_signal_t signal,
506                                  hsa_signal_condition_t cond,
507                                  hsa_signal_value_t value,
508                                  hsa_amd_signal_handler handler, void* arg);
509 
510 /**
511  * @brief Call a function asynchronously
512  *
513  * @details Provides access to the runtime's asynchronous event handling thread
514  * for general asynchronous functions.  Functions queued this way are executed
515  * in the same manner as if they were a signal handler who's signal is
516  * satisfied.
517  *
518  * @param[in] callback asynchronous function to be invoked
519  *
520  * @param[in] arg user provided value which is provided to handler when handler
521  * is invoked
522  *
523  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
524  *
525  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
526  * initialized.
527  *
528  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT handler is invalid (NULL)
529  *
530  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime is out of
531  * resources or blocking signals are not supported by the HSA driver component.
532  *
533  */
534 hsa_status_t HSA_API
535     hsa_amd_async_function(void (*callback)(void* arg), void* arg);
536 
537 /**
538  * @brief Wait for any signal-condition pair to be satisfied.
539  *
540  * @details Allows waiting for any of several signal and conditions pairs to be
541  * satisfied. The function returns the index into the list of signals of the
542  * first satisfying signal-condition pair. The value of the satisfying signal's
543  * value is returned in satisfying_value unless satisfying_value is NULL. This
544  * function provides only relaxed memory semantics.
545  */
546 uint32_t HSA_API
547     hsa_amd_signal_wait_any(uint32_t signal_count, hsa_signal_t* signals,
548                             hsa_signal_condition_t* conds,
549                             hsa_signal_value_t* values, uint64_t timeout_hint,
550                             hsa_wait_state_t wait_hint,
551                             hsa_signal_value_t* satisfying_value);
552 
553 /**
554  * @brief Query image limits.
555  *
556  * @param[in] agent A valid agent.
557  *
558  * @param[in] attribute HSA image info attribute to query.
559  *
560  * @param[out] value Pointer to an application-allocated buffer where to store
561  * the value of the attribute. If the buffer passed by the application is not
562  * large enough to hold the value of @p attribute, the behavior is undefined.
563  *
564  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
565  *
566  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
567  * initialized.
568  *
569  * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE @p value is NULL or @p attribute <
570  * HSA_EXT_AGENT_INFO_IMAGE_1D_MAX_ELEMENTS or @p attribute >
571  * HSA_EXT_AGENT_INFO_IMAGE_ARRAY_MAX_LAYERS.
572  *
573  */
574 hsa_status_t HSA_API hsa_amd_image_get_info_max_dim(hsa_agent_t agent,
575                                                     hsa_agent_info_t attribute,
576                                                     void* value);
577 
578 /**
579  * @brief Set a CU affinity to specific queues within the process, this function
580  * call is "atomic".
581  *
582  * @param[in] queue A pointer to HSA queue.
583  *
584  * @param[in] num_cu_mask_count Size of CUMask bit array passed in.
585  *
586  * @param[in] cu_mask Bit-vector representing the CU mask.
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 @p queue is NULL or invalid.
594  *
595  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_cu_mask_count is not
596  * multiple of 32 or @p cu_mask is NULL.
597  *
598  * @retval ::HSA_STATUS_ERROR failed to call thunk api
599  *
600  */
601 hsa_status_t HSA_API hsa_amd_queue_cu_set_mask(const hsa_queue_t* queue,
602                                                uint32_t num_cu_mask_count,
603                                                const uint32_t* cu_mask);
604 
605 /**
606  * @brief Memory segments associated with a memory pool.
607  */
608 typedef enum {
609   /**
610    * Global segment. Used to hold data that is shared by all agents.
611    */
612   HSA_AMD_SEGMENT_GLOBAL = 0,
613   /**
614    * Read-only segment. Used to hold data that remains constant during the
615    * execution of a kernel.
616    */
617   HSA_AMD_SEGMENT_READONLY = 1,
618   /**
619    * Private segment. Used to hold data that is local to a single work-item.
620    */
621   HSA_AMD_SEGMENT_PRIVATE = 2,
622   /**
623    * Group segment. Used to hold data that is shared by the work-items of a
624    * work-group.
625    */
626   HSA_AMD_SEGMENT_GROUP = 3,
627 } hsa_amd_segment_t;
628 
629 /**
630  * @brief A memory pool represents physical storage on an agent.
631  */
632 typedef struct hsa_amd_memory_pool_s {
633   /**
634    * Opaque handle.
635    */
636   uint64_t handle;
637 } hsa_amd_memory_pool_t;
638 
639 typedef enum hsa_amd_memory_pool_global_flag_s {
640   /**
641    * The application can use allocations in the memory pool to store kernel
642    * arguments, and provide the values for the kernarg segment of
643    * a kernel dispatch.
644    */
645   HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT = 1,
646   /**
647    * Updates to memory in this pool conform to HSA memory consistency model.
648    * If this flag is set, then ::HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED
649    * must not be set.
650    */
651   HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED = 2,
652   /**
653    * Writes to memory in this pool can be performed by a single agent at a time.
654    */
655   HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED = 4
656 } hsa_amd_memory_pool_global_flag_t;
657 
658 /**
659  * @brief Memory pool features.
660  */
661 typedef enum {
662   /**
663   * Segment where the memory pool resides. The type of this attribute is
664   * ::hsa_amd_segment_t.
665   */
666   HSA_AMD_MEMORY_POOL_INFO_SEGMENT = 0,
667   /**
668   * Flag mask. The value of this attribute is undefined if the value of
669   * ::HSA_AMD_MEMORY_POOL_INFO_SEGMENT is not ::HSA_AMD_SEGMENT_GLOBAL. The type
670   * of
671   * this attribute is uint32_t, a bit-field of
672   * ::hsa_amd_memory_pool_global_flag_t
673   * values.
674   */
675   HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS = 1,
676   /**
677   * Size of this pool, in bytes. The type of this attribute is size_t.
678   */
679   HSA_AMD_MEMORY_POOL_INFO_SIZE = 2,
680   /**
681   * Indicates whether memory in this pool can be allocated using
682   * ::hsa_amd_memory_pool_allocate. The type of this attribute is bool.
683   *
684   * The value of this flag is always false for memory pools in the group and
685   * private segments.
686   */
687   HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED = 5,
688   /**
689   * Allocation granularity of buffers allocated by
690   * ::hsa_amd_memory_pool_allocate
691   * in this memory pool. The size of a buffer allocated in this pool is a
692   * multiple of the value of this attribute. The value of this attribute is
693   * only defined if ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for
694   * this pool. The type of this attribute is size_t.
695   */
696   HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE = 6,
697   /**
698   * Alignment of buffers allocated by ::hsa_amd_memory_pool_allocate in this
699   * pool. The value of this attribute is only defined if
700   * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool, and
701   * must be a power of 2. The type of this attribute is size_t.
702   */
703   HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT = 7,
704   /**
705   * This memory_pool can be made directly accessible by all the agents in the
706   * system (::hsa_amd_agent_memory_pool_get_info returns
707   * ::HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT for all agents). The type of
708   * this attribute is bool.
709   */
710   HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL = 15,
711 } hsa_amd_memory_pool_info_t;
712 
713 /**
714  * @brief Get the current value of an attribute of a memory pool.
715  *
716  * @param[in] memory_pool A valid memory pool.
717  *
718  * @param[in] attribute Attribute to query.
719  *
720  * @param[out] value Pointer to a application-allocated buffer where to store
721  * the value of the attribute. If the buffer passed by the application is not
722  * large enough to hold the value of @p attribute, the behavior is undefined.
723  *
724  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
725  *
726  */
727 hsa_status_t HSA_API
728     hsa_amd_memory_pool_get_info(hsa_amd_memory_pool_t memory_pool,
729                                  hsa_amd_memory_pool_info_t attribute,
730                                  void* value);
731 
732 /**
733  * @brief Iterate over the memory pools associated with a given agent, and
734  * invoke an application-defined callback on every iteration.
735  *
736  * @details An agent can directly access buffers located in some memory pool, or
737  * be enabled to access them by the application (see ::hsa_amd_agents_allow_access),
738  * yet that memory pool may not be returned by this function for that given
739  * agent.
740  *
741  * A memory pool of fine-grained type must be associated only with the host.
742  *
743  * @param[in] agent A valid agent.
744  *
745  * @param[in] callback Callback to be invoked on the same thread that called
746  * ::hsa_amd_agent_iterate_memory_pools, serially, once per memory pool that is
747  * associated with the agent.  The HSA runtime passes two arguments to the
748  * callback: the memory pool, and the application data.  If @p callback
749  * returns a status other than ::HSA_STATUS_SUCCESS for a particular iteration,
750  * the traversal stops and ::hsa_amd_agent_iterate_memory_pools returns that status
751  * value.
752  *
753  * @param[in] data Application data that is passed to @p callback on every
754  * iteration. May be NULL.
755  *
756  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
757  *
758  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
759  * initialized.
760  *
761  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
762  *
763  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
764  */
765 hsa_status_t HSA_API hsa_amd_agent_iterate_memory_pools(
766     hsa_agent_t agent,
767     hsa_status_t (*callback)(hsa_amd_memory_pool_t memory_pool, void* data),
768     void* data);
769 
770 /**
771  * @brief Allocate a block of memory (or buffer) in the specified pool.
772  *
773  * @param[in] memory_pool Memory pool where to allocate memory from. The memory
774  * pool must have the ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED flag set.
775  *
776  * @param[in] size Allocation size, in bytes. Must not be zero. This value is
777  * rounded up to the nearest multiple of
778  * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE in @p memory_pool.
779  *
780  * @param[in] flags A bit-field that is used to specify allocation
781  * directives. Must be 0.
782  *
783  * @param[out] ptr Pointer to the location where to store the base virtual
784  * address of
785  * the allocated block. The returned base address is aligned to the value of
786  * ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT in @p memory_pool. If the
787  * allocation fails, the returned value is undefined.
788  *
789  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
790  *
791  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
792  * initialized.
793  *
794  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES No memory is available.
795  *
796  * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL The memory pool is invalid.
797  *
798  * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The host is not allowed to
799  * allocate memory in @p memory_pool, or @p size is greater than the value of
800  * HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE in @p memory_pool.
801  *
802  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p size is 0.
803  *
804  */
805 hsa_status_t HSA_API
806     hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, size_t size,
807                                  uint32_t flags, void** ptr);
808 
809 /**
810  * @brief Deallocate a block of memory previously allocated using
811  * ::hsa_amd_memory_pool_allocate.
812  *
813  * @param[in] ptr Pointer to a memory block. If @p ptr does not match a value
814  * previously returned by ::hsa_amd_memory_pool_allocate, the behavior is undefined.
815  *
816  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
817  *
818  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
819  * initialized.
820  *
821  */
822 hsa_status_t HSA_API hsa_amd_memory_pool_free(void* ptr);
823 
824 /**
825  * @brief Asynchronously copy a block of memory from the location pointed to by
826  * @p src on the @p src_agent to the memory block pointed to by @p dst on the @p
827  * dst_agent.
828  * Because the DMA engines used may not be in the same coherency domain, the caller must ensure
829  * that buffers are system-level coherent. In general this requires the sending device to have
830  * released the buffer to system scope prior to executing the copy API and the receiving device
831  * must execute a system scope acquire fence prior to use of the destination buffer.
832  *
833  * @param[out] dst Buffer where the content is to be copied.
834  *
835  * @param[in] dst_agent Agent associated with the @p dst. The agent must be able to directly
836  * access both the source and destination buffers in their current locations.
837  *
838  * @param[in] src A valid pointer to the source of data to be copied. The source
839  * buffer must not overlap with the destination buffer, otherwise the copy will succeed
840  * but contents of @p dst is undefined.
841  *
842  * @param[in] src_agent Agent associated with the @p src. The agent must be able to directly
843  * access both the source and destination buffers in their current locations.
844  *
845  * @param[in] size Number of bytes to copy. If @p size is 0, no copy is
846  * performed and the function returns success. Copying a number of bytes larger
847  * than the size of the buffers pointed by @p dst or @p src results in undefined
848  * behavior.
849  *
850  * @param[in] num_dep_signals Number of dependent signals. Can be 0.
851  *
852  * @param[in] dep_signals List of signals that must be waited on before the copy
853  * operation starts. The copy will start after every signal has been observed with
854  * the value 0. The dependent signal should not include completion signal from hsa_amd_memory_async_copy
855  * operation to be issued in future as that can result in a deadlock. If @p num_dep_signals is 0, this
856  * argument is ignored.
857  *
858  * @param[in] completion_signal Signal used to indicate completion of the copy
859  * operation. When the copy operation is finished, the value of the signal is
860  * decremented. The runtime indicates that an error has occurred during the copy
861  * operation by setting the value of the completion signal to a negative
862  * number. The signal handle must not be 0.
863  *
864  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully. The
865  * application is responsible for checking for asynchronous error conditions
866  * (see the description of @p completion_signal).
867  *
868  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
869  * initialized.
870  *
871  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
872  *
873  * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL @p completion_signal is invalid.
874  *
875  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
876  * pointers are NULL, or the completion signal is 0.
877  */
878 hsa_status_t HSA_API
879     hsa_amd_memory_async_copy(void* dst, hsa_agent_t dst_agent, const void* src,
880                               hsa_agent_t src_agent, size_t size,
881                               uint32_t num_dep_signals,
882                               const hsa_signal_t* dep_signals,
883                               hsa_signal_t completion_signal);
884 
885 /**
886  * @brief Type of accesses to a memory pool from a given agent.
887  */
888 typedef enum {
889   /**
890   * The agent cannot directly access any buffer in the memory pool.
891   */
892   HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED = 0,
893   /**
894   * The agent can directly access a buffer located in the pool; the application
895   * does not need to invoke ::hsa_amd_agents_allow_access.
896   */
897   HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT = 1,
898   /**
899   * The agent can directly access a buffer located in the pool, but only if the
900   * application has previously requested access to that buffer using
901   * ::hsa_amd_agents_allow_access.
902   */
903   HSA_AMD_MEMORY_POOL_ACCESS_DISALLOWED_BY_DEFAULT = 2
904 } hsa_amd_memory_pool_access_t;
905 
906 /**
907  * @brief Properties of the relationship between an agent a memory pool.
908  */
909 typedef enum {
910   /**
911   * Hyper-transport bus type.
912   */
913   HSA_AMD_LINK_INFO_TYPE_HYPERTRANSPORT = 0,
914 
915   /**
916   * QPI bus type.
917   */
918   HSA_AMD_LINK_INFO_TYPE_QPI = 1,
919 
920   /**
921   * PCIe bus type.
922   */
923   HSA_AMD_LINK_INFO_TYPE_PCIE = 2,
924 
925   /**
926   * Infiniband bus type.
927   */
928   HSA_AMD_LINK_INFO_TYPE_INFINBAND = 3
929 
930 } hsa_amd_link_info_type_t;
931 
932 /**
933  * @brief Link properties when accessing the memory pool from the specified
934  * agent.
935  */
936 typedef struct hsa_amd_memory_pool_link_info_s {
937   /**
938   * Minimum transfer latency (rounded to ns).
939   */
940   uint32_t min_latency;
941 
942   /**
943   * Maximum transfer latency (rounded to ns).
944   */
945   uint32_t max_latency;
946 
947   /**
948   * Minimum link interface bandwidth in MB/s.
949   */
950   uint32_t min_bandwidth;
951 
952   /**
953   * Maximum link interface bandwidth in MB/s.
954   */
955   uint32_t max_bandwidth;
956 
957   /**
958   * Support for 32-bit atomic transactions.
959   */
960   bool atomic_support_32bit;
961 
962   /**
963   * Support for 64-bit atomic transactions.
964   */
965   bool atomic_support_64bit;
966 
967   /**
968   * Support for cache coherent transactions.
969   */
970   bool coherent_support;
971 
972   /**
973   * The type of bus/link.
974   */
975   hsa_amd_link_info_type_t link_type;
976 
977   /**
978    * NUMA distance of memory pool relative to querying agent
979    */
980   uint32_t numa_distance;
981 } hsa_amd_memory_pool_link_info_t;
982 
983 /**
984  * @brief Properties of the relationship between an agent a memory pool.
985  */
986 typedef enum {
987   /**
988   * Access to buffers located in the memory pool. The type of this attribute
989   * is ::hsa_amd_memory_pool_access_t.
990   *
991   * An agent can always directly access buffers currently located in a memory
992   * pool that is associated (the memory_pool is one of the values returned by
993   * ::hsa_amd_agent_iterate_memory_pools on the agent) with that agent. If the
994   * buffer is currently located in a memory pool that is not associated with
995   * the agent, and the value returned by this function for the given
996   * combination of agent and memory pool is not
997   * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED, the application still needs to invoke
998   * ::hsa_amd_agents_allow_access in order to gain direct access to the buffer.
999   *
1000   * If the given agent can directly access buffers the pool, the result is not
1001   * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is associated with
1002   * the agent, or it is of fined-grained type, the result must not be
1003   * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. If the memory pool is not associated
1004   * with the agent, and does not reside in the global segment, the result must
1005   * be HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED.
1006   */
1007   HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS = 0,
1008 
1009   /**
1010   * Number of links to hop when accessing the memory pool from the specified
1011   * agent. The value of this attribute is zero if the memory pool is associated
1012   * with the agent, or if the access type is
1013   * HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED. The type of this attribute is
1014   * uint32_t.
1015   */
1016   HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS = 1,
1017 
1018   /**
1019   * Details of each link hop when accessing the memory pool starting from the
1020   * specified agent. The type of this attribute is an array size of
1021   * HSA_AMD_AGENT_MEMORY_POOL_INFO_NUM_LINK_HOPS with each element containing
1022   * ::hsa_amd_memory_pool_link_info_t.
1023   */
1024   HSA_AMD_AGENT_MEMORY_POOL_INFO_LINK_INFO = 2
1025 
1026 } hsa_amd_agent_memory_pool_info_t;
1027 
1028 /**
1029  * @brief Get the current value of an attribute of the relationship between an
1030  * agent and a memory pool.
1031  *
1032  * @param[in] agent Agent.
1033  *
1034  * @param[in] memory_pool Memory pool.
1035  *
1036  * @param[in] attribute Attribute to query.
1037  *
1038  * @param[out] value Pointer to a application-allocated buffer where to store
1039  * the value of the attribute. If the buffer passed by the application is not
1040  * large enough to hold the value of @p attribute, the behavior is undefined.
1041  *
1042  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1043  *
1044  */
1045 hsa_status_t HSA_API hsa_amd_agent_memory_pool_get_info(
1046     hsa_agent_t agent, hsa_amd_memory_pool_t memory_pool,
1047     hsa_amd_agent_memory_pool_info_t attribute, void* value);
1048 
1049 /**
1050  * @brief Enable direct access to a buffer from a given set of agents.
1051  *
1052  * @details
1053  *
1054  * Upon return, only the listed agents and the agent associated with the
1055  * buffer's memory pool have direct access to the @p ptr.
1056  *
1057  * Any agent that has access to the buffer before and after the call to
1058  * ::hsa_amd_agents_allow_access will also have access while
1059  * ::hsa_amd_agents_allow_access is in progress.
1060  *
1061  * The caller is responsible for ensuring that each agent in the list
1062  * must be able to access the memory pool containing @p ptr
1063  * (using ::hsa_amd_agent_memory_pool_get_info with ::HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS attribute),
1064  * otherwise error code is returned.
1065  *
1066  * @param[in] num_agents Size of @p agents.
1067  *
1068  * @param[in] agents List of agents. If @p num_agents is 0, this argument is
1069  * ignored.
1070  *
1071  * @param[in] flags A list of bit-field that is used to specify access
1072  * information in a per-agent basis. The size of this list must match that of @p
1073  * agents. Must be NULL.
1074  *
1075  * @param[in] ptr A buffer previously allocated using ::hsa_amd_memory_pool_allocate.
1076  *
1077  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1078  *
1079  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1080  * initialized.
1081  *
1082  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_agents is 0, or @p agents
1083  * is NULL, @p flags is NULL, or attempting to enable access to agent(s) because
1084  * @p ptr is allocated from an inaccessible pool.
1085  *
1086  */
1087 hsa_status_t HSA_API
1088     hsa_amd_agents_allow_access(uint32_t num_agents, const hsa_agent_t* agents,
1089                                 const uint32_t* flags, const void* ptr);
1090 
1091 /**
1092  * @brief Query if buffers currently located in some memory pool can be
1093  * relocated to a destination memory pool.
1094  *
1095  * @details If the returned value is non-zero, a migration of a buffer to @p
1096  * dst_memory_pool using ::hsa_amd_memory_migrate may nevertheless fail due to
1097  * resource limitations.
1098  *
1099  * @param[in] src_memory_pool Source memory pool.
1100  *
1101  * @param[in] dst_memory_pool Destination memory pool.
1102  *
1103  * @param[out] result Pointer to a memory location where the result of the query
1104  * is stored. Must not be NULL. If buffers currently located in @p
1105  * src_memory_pool can be relocated to @p dst_memory_pool, the result is
1106  * true.
1107  *
1108  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1109  *
1110  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1111  * initialized.
1112  *
1113  * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL One of the memory pools is
1114  * invalid.
1115  *
1116  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
1117  */
1118 hsa_status_t HSA_API
1119     hsa_amd_memory_pool_can_migrate(hsa_amd_memory_pool_t src_memory_pool,
1120                                     hsa_amd_memory_pool_t dst_memory_pool,
1121                                     bool* result);
1122 
1123 /**
1124  * @brief Relocate a buffer to a new memory pool.
1125  *
1126  * @details When a buffer is migrated, its virtual address remains the same but
1127  * its physical contents are moved to the indicated memory pool.
1128  *
1129  * After migration, only the agent associated with the destination pool will have access.
1130  *
1131  * The caller is also responsible for ensuring that the allocation in the
1132  * source memory pool where the buffer is currently located can be migrated to the
1133  * specified destination memory pool (using ::hsa_amd_memory_pool_can_migrate returns a value of true
1134  * for the source and destination memory pools), otherwise behavior is undefined.
1135  *
1136  * The caller must ensure that the buffer is not accessed while it is migrated.
1137  *
1138  * @param[in] ptr Buffer to be relocated. The buffer must have been released to system
1139  * prior to call this API.  The buffer will be released to system upon completion.
1140  *
1141  * @param[in] memory_pool Memory pool where to place the buffer.
1142  *
1143  * @param[in] flags A bit-field that is used to specify migration
1144  * information. Must be zero.
1145  *
1146  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1147  *
1148  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1149  * initialized.
1150  *
1151  * @retval ::HSA_STATUS_ERROR_INVALID_MEMORY_POOL The destination memory pool is
1152  * invalid.
1153  *
1154  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1155  * allocating the necessary resources.
1156  *
1157  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p flags is not 0.
1158  */
1159 hsa_status_t HSA_API hsa_amd_memory_migrate(const void* ptr,
1160                                             hsa_amd_memory_pool_t memory_pool,
1161                                             uint32_t flags);
1162 
1163 /**
1164  *
1165  * @brief Pin a host pointer allocated by C/C++ or OS allocator (i.e. ordinary system DRAM) and return a new
1166  * pointer accessible by the @p agents. If the @p host_ptr overlaps with previously locked
1167  * memory, then the overlap area is kept locked (i.e multiple mappings are permitted). In this case,
1168  * the same input @p host_ptr may give different locked @p agent_ptr and when it does, they
1169  * are not necessarily coherent (i.e. accessing either @p agent_ptr is not equivalent).
1170  *
1171  * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator.
1172  *
1173  * @param[in] size The size to be locked.
1174  *
1175  * @param[in] agents Array of agent handle to gain access to the @p host_ptr.
1176  * If this parameter is NULL and the @p num_agent is 0, all agents
1177  * in the platform will gain access to the @p host_ptr.
1178  *
1179  * @param[out] agent_ptr Pointer to the location where to store the new address.
1180  *
1181  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1182  *
1183  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1184  * initialized.
1185  *
1186  * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES There is a failure in
1187  * allocating the necessary resources.
1188  *
1189  * @retval ::HSA_STATUS_ERROR_INVALID_AGENT One or more agent in @p agents is
1190  * invalid.
1191  *
1192  * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 or @p host_ptr or
1193  * @p agent_ptr is NULL or @p agents not NULL but @p num_agent is 0 or @p agents
1194  * is NULL but @p num_agent is not 0.
1195  */
1196 
1197 hsa_status_t HSA_API hsa_amd_memory_lock(void* host_ptr, size_t size,
1198                                          hsa_agent_t* agents, int num_agent,
1199                                          void** agent_ptr);
1200 
1201 /**
1202  *
1203  * @brief Unpin the host pointer previously pinned via ::hsa_amd_memory_lock.
1204  *
1205  * @details The behavior is undefined if the host pointer being unpinned does not
1206  * match previous pinned address or if the host pointer was already deallocated.
1207  *
1208  * @param[in] host_ptr A buffer allocated by C/C++ or OS allocator that was
1209  * pinned previously via ::hsa_amd_memory_lock.
1210  *
1211  * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1212  *
1213  * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1214  * initialized.
1215  */
1216 hsa_status_t HSA_API hsa_amd_memory_unlock(void* host_ptr);
1217 
1218 /**
1219  * @brief Sets the first @p count of uint32_t of the block of memory pointed by
1220  * @p ptr to the specified @p value.
1221  *
1222  * @param[in] ptr Pointer to the block of memory to fill.
1223  *
1224  * @param[in] value Value to be set.
1225  *
1226  * @param[in] count Number of uint32_t element to be set to the value.
1227  *
1228  * @retval HSA_STATUS_SUCCESS The function has been executed successfully.
1229  *
1230  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1231  * initialized.
1232  *
1233  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL or
1234  * not 4 bytes aligned
1235  *
1236  * @retval HSA_STATUS_ERROR_INVALID_ALLOCATION if the given memory
1237  * region was not allocated with HSA runtime APIs.
1238  *
1239  */
1240 hsa_status_t HSA_API
1241     hsa_amd_memory_fill(void* ptr, uint32_t value, size_t count);
1242 
1243 /**
1244  * @brief Maps an interop object into the HSA flat address space and establishes
1245  * memory residency.  The metadata pointer is valid during the lifetime of the
1246  * map (until hsa_amd_interop_unmap_buffer is called).
1247  * Multiple calls to hsa_amd_interop_map_buffer with the same interop_handle
1248  * result in multiple mappings with potentially different addresses and
1249  * different metadata pointers.  Concurrent operations on these addresses are
1250  * not coherent.  Memory must be fenced to system scope to ensure consistency,
1251  * between mappings and with any views of this buffer in the originating
1252  * software stack.
1253  *
1254  * @param[in] num_agents Number of agents which require access to the memory
1255  *
1256  * @param[in] agents List of accessing agents.
1257  *
1258  * @param[in] interop_handle Handle of interop buffer (dmabuf handle in Linux)
1259  *
1260  * @param [in] flags Reserved, must be 0
1261  *
1262  * @param[out] size Size in bytes of the mapped object
1263  *
1264  * @param[out] ptr Base address of the mapped object
1265  *
1266  * @param[out] metadata_size Size of metadata in bytes, may be NULL
1267  *
1268  * @param[out] metadata Pointer to metadata, may be NULL
1269  *
1270  * @retval HSA_STATUS_SUCCESS if successfully mapped
1271  *
1272  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1273  *
1274  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1275  * necessary resources
1276  *
1277  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT all other errors
1278  */
1279 hsa_status_t HSA_API hsa_amd_interop_map_buffer(uint32_t num_agents,
1280                                         hsa_agent_t* agents,
1281                                         int interop_handle,
1282                                         uint32_t flags,
1283                                         size_t* size,
1284                                         void** ptr,
1285                                         size_t* metadata_size,
1286                                         const void** metadata);
1287 
1288 /**
1289  * @brief Removes a previously mapped interop object from HSA's flat address space.
1290  * Ends lifetime for the mapping's associated metadata pointer.
1291  */
1292 hsa_status_t HSA_API hsa_amd_interop_unmap_buffer(void* ptr);
1293 
1294 /**
1295  * @brief Encodes an opaque vendor specific image format.  The length of data
1296  * depends on the underlying format.  This structure must not be copied as its
1297  * true length can not be determined.
1298  */
1299 typedef struct hsa_amd_image_descriptor_s {
1300   /*
1301   Version number of the descriptor
1302   */
1303   uint32_t version;
1304 
1305   /*
1306   Vendor and device PCI IDs for the format as VENDOR_ID<<16|DEVICE_ID.
1307   */
1308   uint32_t deviceID;
1309 
1310   /*
1311   Start of vendor specific data.
1312   */
1313   uint32_t data[1];
1314 } hsa_amd_image_descriptor_t;
1315 
1316 /**
1317  * @brief Creates an image from an opaque vendor specific image format.
1318  * Does not modify data at image_data.  Intended initially for
1319  * accessing interop images.
1320  *
1321  * @param agent[in] Agent on which to create the image
1322  *
1323  * @param[in] image_descriptor[in] Vendor specific image format
1324  *
1325  * @param[in] image_data Pointer to image backing store
1326  *
1327  * @param[in] access_permission Access permissions for the image object
1328  *
1329  * @param[out] image Created image object.
1330  *
1331  * @retval HSA_STATUS_SUCCESS Image created successfully
1332  *
1333  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1334  *
1335  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1336  * necessary resources
1337  *
1338  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT Bad or mismatched descriptor,
1339  * null image_data, or mismatched access_permission.
1340  */
1341 hsa_status_t HSA_API hsa_amd_image_create(
1342     hsa_agent_t agent,
1343     const hsa_ext_image_descriptor_t *image_descriptor,
1344     const hsa_amd_image_descriptor_t *image_layout,
1345     const void *image_data,
1346     hsa_access_permission_t access_permission,
1347     hsa_ext_image_t *image
1348 );
1349 
1350 /**
1351  * @brief Denotes the type of memory in a pointer info query.
1352  */
1353 typedef enum {
1354   /*
1355   Memory is not known to the HSA driver.  Unallocated or unlocked system memory.
1356   */
1357   HSA_EXT_POINTER_TYPE_UNKNOWN = 0,
1358   /*
1359   Memory was allocated with an HSA memory allocator.
1360   */
1361   HSA_EXT_POINTER_TYPE_HSA = 1,
1362   /*
1363   System memory which has been locked for use with an HSA agent.
1364 
1365   Memory of this type is normal malloc'd memory and is always accessible to
1366   the CPU.  Pointer info queries may not include CPU agents in the accessible
1367   agents list as the CPU has implicit access.
1368   */
1369   HSA_EXT_POINTER_TYPE_LOCKED = 2,
1370   /*
1371   Memory originated in a graphics component and is shared with ROCr.
1372   */
1373   HSA_EXT_POINTER_TYPE_GRAPHICS = 3,
1374   /*
1375   Memory has been shared with the local process via ROCr IPC APIs.
1376   */
1377   HSA_EXT_POINTER_TYPE_IPC = 4
1378 } hsa_amd_pointer_type_t;
1379 
1380 /**
1381  * @brief Describes a memory allocation known to ROCr.
1382  * Within a ROCr major version this structure can only grow.
1383  */
1384 typedef struct hsa_amd_pointer_info_s {
1385   /*
1386   Size in bytes of this structure.  Used for version control within a major ROCr
1387   revision.  Set to sizeof(hsa_amd_pointer_t) prior to calling
1388   hsa_amd_pointer_info.  If the runtime supports an older version of pointer
1389   info then size will be smaller on return.  Members starting after the return
1390   value of size will not be updated by hsa_amd_pointer_info.
1391   */
1392   uint32_t size;
1393   /*
1394   The type of allocation referenced.
1395   */
1396   hsa_amd_pointer_type_t type;
1397   /*
1398   Base address at which non-host agents may access the allocation.
1399   */
1400   void* agentBaseAddress;
1401   /*
1402   Base address at which the host agent may access the allocation.
1403   */
1404   void* hostBaseAddress;
1405   /*
1406   Size of the allocation
1407   */
1408   size_t sizeInBytes;
1409   /*
1410   Application provided value.
1411   */
1412   void* userData;
1413   /*
1414   Reports an agent which "owns" (ie has preferred access to) the pool in which the allocation was
1415   made.  When multiple agents share equal access to a pool (ex: multiple CPU agents, or multi-die
1416   GPU boards) any such agent may be returned.
1417   */
1418   hsa_agent_t agentOwner;
1419 } hsa_amd_pointer_info_t;
1420 
1421 /**
1422  * @brief Retrieves information about the allocation referenced by the given
1423  * pointer.  Optionally returns the number and list of agents which can
1424  * directly access the allocation.
1425  *
1426  * @param[in] ptr Pointer which references the allocation to retrieve info for.
1427  *
1428  * @param[in, out] info Pointer to structure to be filled with allocation info.
1429  * Data member size must be set to the size of the structure prior to calling
1430  * hsa_amd_pointer_info.  On return size will be set to the size of the
1431  * pointer info structure supported by the runtime, if smaller.  Members
1432  * beyond the returned value of size will not be updated by the API.
1433  * Must not be NULL.
1434  *
1435  * @param[in] alloc Function pointer to an allocator used to allocate the
1436  * @p accessible array.  If NULL @p accessible will not be returned.
1437  *
1438  * @param[out] num_agents_accessible Recieves the count of agents in
1439  * @p accessible.  If NULL @p accessible will not be returned.
1440  *
1441  * @param[out] accessible Recieves a pointer to the array, allocated by @p alloc,
1442  * holding the list of agents which may directly access the allocation.
1443  * May be NULL.
1444  *
1445  * @retval HSA_STATUS_SUCCESS Info retrieved successfully
1446  *
1447  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1448  *
1449  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1450  * necessary resources
1451  *
1452  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT NULL in @p ptr or @p info.
1453  */
1454 hsa_status_t HSA_API hsa_amd_pointer_info(void* ptr,
1455                                           hsa_amd_pointer_info_t* info,
1456                                           void* (*alloc)(size_t),
1457                                           uint32_t* num_agents_accessible,
1458                                           hsa_agent_t** accessible);
1459 
1460 /**
1461  * @brief Associates an arbitrary pointer with an allocation known to ROCr.
1462  * The pointer can be fetched by hsa_amd_pointer_info in the userData field.
1463  *
1464  * @param[in] ptr Pointer to the first byte of an allocation known to ROCr
1465  * with which to associate @p userdata.
1466  *
1467  * @param[in] userdata Abitrary pointer to associate with the allocation.
1468  *
1469  * @retval HSA_STATUS_SUCCESS @p userdata successfully stored.
1470  *
1471  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1472  *
1473  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1474  * necessary resources
1475  *
1476  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is not known to ROCr.
1477  */
1478 hsa_status_t HSA_API hsa_amd_pointer_info_set_userdata(void* ptr,
1479                                                        void* userdata);
1480 
1481 /**
1482  * @brief 256-bit process independent identifier for a ROCr shared memory
1483  * allocation.
1484  */
1485 typedef struct hsa_amd_ipc_memory_s {
1486   uint32_t handle[8];
1487 } hsa_amd_ipc_memory_t;
1488 
1489 /**
1490  * @brief Prepares an allocation for interprocess sharing and creates a
1491  * handle of type hsa_amd_ipc_memory_t uniquely identifying the allocation.  A
1492  * handle is valid while the allocation it references remains accessible in
1493  * any process.  In general applications should confirm that a shared memory
1494  * region has been attached (via hsa_amd_ipc_memory_attach) in the remote
1495  * process prior to releasing that memory in the local process.
1496  * Repeated calls for the same allocation may, but are not required to, return
1497  * unique handles.
1498  *
1499  * @param[in] ptr Pointer to memory allocated via ROCr APIs to prepare for
1500  * sharing.
1501  *
1502  * @param[in] len Length in bytes of the allocation to share.
1503  *
1504  * @param[out] handle Process independent identifier referencing the shared
1505  * allocation.
1506  *
1507  * @retval HSA_STATUS_SUCCESS allocation is prepared for interprocess sharing.
1508  *
1509  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1510  *
1511  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1512  * necessary resources
1513  *
1514  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr does not point to the
1515  * first byte of an allocation made through ROCr, or len is not the full length
1516  * of the allocation or handle is NULL.
1517  */
1518 hsa_status_t HSA_API hsa_amd_ipc_memory_create(void* ptr, size_t len,
1519                                                hsa_amd_ipc_memory_t* handle);
1520 
1521 /**
1522  * @brief Imports shared memory into the local process and makes it accessible
1523  * by the given agents.  If a shared memory handle is attached multiple times
1524  * in a process each attach may return a different address.  Each returned
1525  * address is refcounted and requires a matching number of calls to
1526  * hsa_amd_ipc_memory_detach to release the shared memory mapping.
1527  *
1528  * @param[in] handle Pointer to the identifier for the shared memory.
1529  *
1530  * @param[in] len Length of the shared memory to import.
1531  * Reserved.  Must be the full length of the shared allocation in this version.
1532  *
1533  * @param[in] num_agents Count of agents in @p mapping_agents.
1534  * May be zero if all agents are to be allowed access.
1535  *
1536  * @param[in] mapping_agents List of agents to access the shared memory.
1537  * Ignored if @p num_agents is zero.
1538  *
1539  * @param[out] mapped_ptr Recieves a process local pointer to the shared memory.
1540  *
1541  * @retval HSA_STATUS_SUCCESS if memory is successfully imported.
1542  *
1543  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1544  *
1545  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1546  * necessary resources
1547  *
1548  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p handle is not valid, @p len is
1549  * incorrect, @p mapped_ptr is NULL, or some agent for which access was
1550  * requested can not access the shared memory.
1551  */
1552 hsa_status_t HSA_API hsa_amd_ipc_memory_attach(
1553     const hsa_amd_ipc_memory_t* handle, size_t len,
1554     uint32_t num_agents,
1555     const hsa_agent_t* mapping_agents,
1556     void** mapped_ptr);
1557 
1558 /**
1559  * @brief Decrements the reference count for the shared memory mapping and
1560  * releases access to shared memory imported with hsa_amd_ipc_memory_attach.
1561  *
1562  * @param[in] mapped_ptr Pointer to the first byte of a shared allocation
1563  * imported with hsa_amd_ipc_memory_attach.
1564  *
1565  * @retval HSA_STATUS_SUCCESS if @p mapped_ptr was imported with
1566  * hsa_amd_ipc_memory_attach.
1567  *
1568  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1569  *
1570  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p mapped_ptr was not imported
1571  * with hsa_amd_ipc_memory_attach.
1572  */
1573 hsa_status_t HSA_API hsa_amd_ipc_memory_detach(void* mapped_ptr);
1574 
1575 /**
1576  * @brief 256-bit process independent identifier for a ROCr IPC signal.
1577  */
1578 typedef hsa_amd_ipc_memory_t hsa_amd_ipc_signal_t;
1579 
1580 /**
1581  * @brief Obtains an interprocess sharing handle for a signal.  The handle is
1582  * valid while the signal it references remains valid in any process.  In
1583  * general applications should confirm that the signal has been attached (via
1584  * hsa_amd_ipc_signal_attach) in the remote process prior to destroying that
1585  * signal in the local process.
1586  * Repeated calls for the same signal may, but are not required to, return
1587  * unique handles.
1588  *
1589  * @param[in] signal Signal created with attribute HSA_AMD_SIGNAL_IPC.
1590  *
1591  * @param[out] handle Process independent identifier referencing the shared
1592  * signal.
1593  *
1594  * @retval HSA_STATUS_SUCCESS @p handle is ready to use for interprocess sharing.
1595  *
1596  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1597  *
1598  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1599  * necessary resources
1600  *
1601  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is not a valid signal
1602  * created with attribute HSA_AMD_SIGNAL_IPC or handle is NULL.
1603  */
1604 hsa_status_t HSA_API hsa_amd_ipc_signal_create(hsa_signal_t signal, hsa_amd_ipc_signal_t* handle);
1605 
1606 /**
1607  * @brief Imports an IPC capable signal into the local process.  If an IPC
1608  * signal handle is attached multiple times in a process each attach may return
1609  * a different signal handle.  Each returned signal handle is refcounted and
1610  * requires a matching number of calls to hsa_signal_destroy to release the
1611  * shared signal.
1612  *
1613  * @param[in] handle Pointer to the identifier for the shared signal.
1614  *
1615  * @param[out] signal Recieves a process local signal handle to the shared signal.
1616  *
1617  * @retval HSA_STATUS_SUCCESS if the signal is successfully imported.
1618  *
1619  * @retval HSA_STATUS_ERROR_NOT_INITIALIZED if HSA is not initialized
1620  *
1621  * @retval HSA_STATUS_ERROR_OUT_OF_RESOURCES if there is a failure in allocating
1622  * necessary resources
1623  *
1624  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p handle is not valid.
1625  */
1626 hsa_status_t HSA_API hsa_amd_ipc_signal_attach(const hsa_amd_ipc_signal_t* handle,
1627                                                hsa_signal_t* signal);
1628 
1629 /**
1630  * @brief GPU system event type.
1631  */
1632 typedef enum hsa_amd_event_type_s {
1633   /*
1634    AMD GPU memory fault.
1635    */
1636   GPU_MEMORY_FAULT_EVENT = 0,
1637 } hsa_amd_event_type_t;
1638 
1639 /**
1640  * @brief AMD GPU memory fault event data.
1641  */
1642 typedef struct hsa_amd_gpu_memory_fault_info_s {
1643   /*
1644   The agent where the memory fault occurred.
1645   */
1646   hsa_agent_t agent;
1647   /*
1648   Virtual address accessed.
1649   */
1650   uint64_t virtual_address;
1651   /*
1652   Bit field encoding the memory access failure reasons. There could be multiple bits set
1653   for one fault.
1654   0x00000001 Page not present or supervisor privilege.
1655   0x00000010 Write access to a read-only page.
1656   0x00000100 Execute access to a page marked NX.
1657   0x00001000 Host access only.
1658   0x00010000 ECC failure (if supported by HW).
1659   0x00100000 Can't determine the exact fault address.
1660   */
1661   uint32_t fault_reason_mask;
1662 } hsa_amd_gpu_memory_fault_info_t;
1663 
1664 /**
1665  * @brief AMD GPU event data passed to event handler.
1666  */
1667 typedef struct hsa_amd_event_s {
1668   /*
1669   The event type.
1670   */
1671   hsa_amd_event_type_t event_type;
1672   union {
1673     /*
1674     The memory fault info, only valid when @p event_type is GPU_MEMORY_FAULT_EVENT.
1675     */
1676     hsa_amd_gpu_memory_fault_info_t memory_fault;
1677   };
1678 } hsa_amd_event_t;
1679 
1680 typedef hsa_status_t (*hsa_amd_system_event_callback_t)(const hsa_amd_event_t* event, void* data);
1681 
1682 /**
1683  * @brief Register AMD GPU event handler.
1684  *
1685  * @param[in] callback Callback to be invoked when an event is triggered.
1686  * The HSA runtime passes two arguments to the callback: @p event
1687  * is defined per event by the HSA runtime, and @p data is the user data.
1688  *
1689  * @param[in] data User data that is passed to @p callback. May be NULL.
1690  *
1691  * @retval HSA_STATUS_SUCCESS The handler has been registered successfully.
1692  *
1693  * @retval HSA_STATUS_ERROR An event handler has already been registered.
1694  *
1695  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT @p event is invalid.
1696  */
1697 hsa_status_t hsa_amd_register_system_event_handler(hsa_amd_system_event_callback_t callback,
1698                                                    void* data);
1699 
1700 /**
1701  * @brief Per-queue dispatch and wavefront scheduling priority.
1702  */
1703 typedef enum hsa_amd_queue_priority_s {
1704   /*
1705   Below normal/high priority compute and all graphics
1706   */
1707   HSA_AMD_QUEUE_PRIORITY_LOW = 0,
1708   /*
1709   Above low priority compute, below high priority compute and all graphics
1710   */
1711   HSA_AMD_QUEUE_PRIORITY_NORMAL = 1,
1712   /*
1713   Above low/normal priority compute and all graphics
1714   */
1715   HSA_AMD_QUEUE_PRIORITY_HIGH = 2,
1716 } hsa_amd_queue_priority_t;
1717 
1718 /**
1719  * @brief Modifies the dispatch and wavefront scheduling prioirty for a
1720  * given compute queue. The default is HSA_AMD_QUEUE_PRIORITY_NORMAL.
1721  *
1722  * @param[in] queue Compute queue to apply new priority to.
1723  *
1724  * @param[in] priority Priority to associate with queue.
1725  *
1726  * @retval HSA_STATUS_SUCCESS if priority was changed successfully.
1727  *
1728  * @retval HSA_STATUS_ERROR_INVALID_QUEUE if queue is not a valid
1729  * compute queue handle.
1730  *
1731  * @retval HSA_STATUS_ERROR_INVALID_ARGUMENT if priority is not a valid
1732  * value from hsa_amd_queue_priority_t.
1733  */
1734 hsa_status_t HSA_API hsa_amd_queue_set_priority(hsa_queue_t* queue,
1735                                                 hsa_amd_queue_priority_t priority);
1736 
1737 #ifdef __cplusplus
1738 }  // end extern "C" block
1739 #endif
1740 
1741 #endif  // header guard
1742