c++: ICE with VEC_INIT_EXPR and defarg [PR106925]
[official-gcc.git] / include / hsa.h
blobf9b5d9daf85d1f2a0ba3bf757f1c0a22227f1e1c
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 #ifndef HSA_RUNTIME_INC_HSA_H_
30 #define HSA_RUNTIME_INC_HSA_H_
32 #include <stddef.h> /* size_t */
33 #include <stdint.h> /* uintXX_t */
35 #ifndef __cplusplus
36 #include <stdbool.h> /* bool */
37 #endif /* __cplusplus */
39 // Placeholder for calling convention and import/export macros
40 #ifndef HSA_CALL
41 #define HSA_CALL
42 #endif
44 #ifndef HSA_EXPORT_DECORATOR
45 #ifdef __GNUC__
46 #define HSA_EXPORT_DECORATOR __attribute__ ((visibility ("default")))
47 #else
48 #define HSA_EXPORT_DECORATOR
49 #endif
50 #endif
51 #define HSA_API_EXPORT HSA_EXPORT_DECORATOR HSA_CALL
52 #define HSA_API_IMPORT HSA_CALL
54 #if !defined(HSA_API) && defined(HSA_EXPORT)
55 #define HSA_API HSA_API_EXPORT
56 #else
57 #define HSA_API HSA_API_IMPORT
58 #endif
60 // Detect and set large model builds.
61 #undef HSA_LARGE_MODEL
62 #if defined(__LP64__) || defined(_M_X64)
63 #define HSA_LARGE_MODEL
64 #endif
66 // Try to detect CPU endianness
67 #if !defined(LITTLEENDIAN_CPU) && !defined(BIGENDIAN_CPU)
68 #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \
69 defined(_M_X64)
70 #define LITTLEENDIAN_CPU
71 #endif
72 #endif
74 #undef HSA_LITTLE_ENDIAN
75 #if defined(LITTLEENDIAN_CPU)
76 #define HSA_LITTLE_ENDIAN
77 #elif defined(BIGENDIAN_CPU)
78 #else
79 #error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
80 #endif
82 #ifndef HSA_DEPRECATED
83 #define HSA_DEPRECATED
84 //#ifdef __GNUC__
85 //#define HSA_DEPRECATED __attribute__((deprecated))
86 //#else
87 //#define HSA_DEPRECATED __declspec(deprecated)
88 //#endif
89 #endif
91 #define HSA_VERSION_1_0 1
93 #ifdef __cplusplus
94 extern "C" {
95 #endif /* __cplusplus */
97 /** \defgroup status Runtime Notifications
98 * @{
102 * @brief Status codes.
104 typedef enum {
106 * The function has been executed successfully.
108 HSA_STATUS_SUCCESS = 0x0,
110 * A traversal over a list of elements has been interrupted by the
111 * application before completing.
113 HSA_STATUS_INFO_BREAK = 0x1,
115 * A generic error has occurred.
117 HSA_STATUS_ERROR = 0x1000,
119 * One of the actual arguments does not meet a precondition stated in the
120 * documentation of the corresponding formal argument.
122 HSA_STATUS_ERROR_INVALID_ARGUMENT = 0x1001,
124 * The requested queue creation is not valid.
126 HSA_STATUS_ERROR_INVALID_QUEUE_CREATION = 0x1002,
128 * The requested allocation is not valid.
130 HSA_STATUS_ERROR_INVALID_ALLOCATION = 0x1003,
132 * The agent is invalid.
134 HSA_STATUS_ERROR_INVALID_AGENT = 0x1004,
136 * The memory region is invalid.
138 HSA_STATUS_ERROR_INVALID_REGION = 0x1005,
140 * The signal is invalid.
142 HSA_STATUS_ERROR_INVALID_SIGNAL = 0x1006,
144 * The queue is invalid.
146 HSA_STATUS_ERROR_INVALID_QUEUE = 0x1007,
148 * The HSA runtime failed to allocate the necessary resources. This error
149 * may also occur when the HSA runtime needs to spawn threads or create
150 * internal OS-specific events.
152 HSA_STATUS_ERROR_OUT_OF_RESOURCES = 0x1008,
154 * The AQL packet is malformed.
156 HSA_STATUS_ERROR_INVALID_PACKET_FORMAT = 0x1009,
158 * An error has been detected while releasing a resource.
160 HSA_STATUS_ERROR_RESOURCE_FREE = 0x100A,
162 * An API other than ::hsa_init has been invoked while the reference count
163 * of the HSA runtime is 0.
165 HSA_STATUS_ERROR_NOT_INITIALIZED = 0x100B,
167 * The maximum reference count for the object has been reached.
169 HSA_STATUS_ERROR_REFCOUNT_OVERFLOW = 0x100C,
171 * The arguments passed to a functions are not compatible.
173 HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS = 0x100D,
175 * The index is invalid.
177 HSA_STATUS_ERROR_INVALID_INDEX = 0x100E,
179 * The instruction set architecture is invalid.
181 HSA_STATUS_ERROR_INVALID_ISA = 0x100F,
183 * The instruction set architecture name is invalid.
185 HSA_STATUS_ERROR_INVALID_ISA_NAME = 0x1017,
187 * The code object is invalid.
189 HSA_STATUS_ERROR_INVALID_CODE_OBJECT = 0x1010,
191 * The executable is invalid.
193 HSA_STATUS_ERROR_INVALID_EXECUTABLE = 0x1011,
195 * The executable is frozen.
197 HSA_STATUS_ERROR_FROZEN_EXECUTABLE = 0x1012,
199 * There is no symbol with the given name.
201 HSA_STATUS_ERROR_INVALID_SYMBOL_NAME = 0x1013,
203 * The variable is already defined.
205 HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED = 0x1014,
207 * The variable is undefined.
209 HSA_STATUS_ERROR_VARIABLE_UNDEFINED = 0x1015,
211 * An HSAIL operation resulted in a hardware exception.
213 HSA_STATUS_ERROR_EXCEPTION = 0x1016,
215 * The code object symbol is invalid.
217 HSA_STATUS_ERROR_INVALID_CODE_SYMBOL = 0x1018,
219 * The executable symbol is invalid.
221 HSA_STATUS_ERROR_INVALID_EXECUTABLE_SYMBOL = 0x1019,
223 * The file descriptor is invalid.
225 HSA_STATUS_ERROR_INVALID_FILE = 0x1020,
227 * The code object reader is invalid.
229 HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER = 0x1021,
231 * The cache is invalid.
233 HSA_STATUS_ERROR_INVALID_CACHE = 0x1022,
235 * The wavefront is invalid.
237 HSA_STATUS_ERROR_INVALID_WAVEFRONT = 0x1023,
239 * The signal group is invalid.
241 HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP = 0x1024,
243 * The HSA runtime is not in the configuration state.
245 HSA_STATUS_ERROR_INVALID_RUNTIME_STATE = 0x1025,
247 * The queue received an error that may require process termination.
249 HSA_STATUS_ERROR_FATAL = 0x1026
250 } hsa_status_t;
253 * @brief Query additional information about a status code.
255 * @param[in] status Status code.
257 * @param[out] status_string A NUL-terminated string that describes the error
258 * status.
260 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
262 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
263 * initialized.
265 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p status is an invalid
266 * status code, or @p status_string is NULL.
268 hsa_status_t HSA_API hsa_status_string(
269 hsa_status_t status,
270 const char ** status_string);
272 /** @} */
274 /** \defgroup common Common Definitions
275 * @{
279 * @brief Three-dimensional coordinate.
281 typedef struct hsa_dim3_s {
283 * X dimension.
285 uint32_t x;
288 * Y dimension.
290 uint32_t y;
293 * Z dimension.
295 uint32_t z;
296 } hsa_dim3_t;
299 * @brief Access permissions.
301 typedef enum {
303 * Read-only access.
305 HSA_ACCESS_PERMISSION_RO = 1,
307 * Write-only access.
309 HSA_ACCESS_PERMISSION_WO = 2,
311 * Read and write access.
313 HSA_ACCESS_PERMISSION_RW = 3
314 } hsa_access_permission_t;
317 * @brief POSIX file descriptor.
319 typedef int hsa_file_t;
321 /** @} **/
324 /** \defgroup initshutdown Initialization and Shut Down
325 * @{
329 * @brief Initialize the HSA runtime.
331 * @details Initializes the HSA runtime if it is not already initialized, and
332 * increases the reference counter associated with the HSA runtime for the
333 * current process. Invocation of any HSA function other than ::hsa_init results
334 * in undefined behavior if the current HSA runtime reference counter is less
335 * than one.
337 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
339 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
340 * the required resources.
342 * @retval ::HSA_STATUS_ERROR_REFCOUNT_OVERFLOW The HSA runtime reference
343 * count reaches INT32_MAX.
345 hsa_status_t HSA_API hsa_init();
348 * @brief Shut down the HSA runtime.
350 * @details Decreases the reference count of the HSA runtime instance. When the
351 * reference count reaches 0, the HSA runtime is no longer considered valid
352 * but the application might call ::hsa_init to initialize the HSA runtime
353 * again.
355 * Once the reference count of the HSA runtime reaches 0, all the resources
356 * associated with it (queues, signals, agent information, etc.) are
357 * considered invalid and any attempt to reference them in subsequent API calls
358 * results in undefined behavior. When the reference count reaches 0, the HSA
359 * runtime may release resources associated with it.
361 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
363 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
364 * initialized.
367 hsa_status_t HSA_API hsa_shut_down();
369 /** @} **/
371 /** \defgroup agentinfo System and Agent Information
372 * @{
376 * @brief Endianness. A convention used to interpret the bytes making up a data
377 * word.
379 typedef enum {
381 * The least significant byte is stored in the smallest address.
383 HSA_ENDIANNESS_LITTLE = 0,
385 * The most significant byte is stored in the smallest address.
387 HSA_ENDIANNESS_BIG = 1
388 } hsa_endianness_t;
391 * @brief Machine model. A machine model determines the size of certain data
392 * types in HSA runtime and an agent.
394 typedef enum {
396 * Small machine model. Addresses use 32 bits.
398 HSA_MACHINE_MODEL_SMALL = 0,
400 * Large machine model. Addresses use 64 bits.
402 HSA_MACHINE_MODEL_LARGE = 1
403 } hsa_machine_model_t;
406 * @brief Profile. A profile indicates a particular level of feature
407 * support. For example, in the base profile the application must use the HSA
408 * runtime allocator to reserve shared virtual memory, while in the full profile
409 * any host pointer can be shared across all the agents.
411 typedef enum {
413 * Base profile.
415 HSA_PROFILE_BASE = 0,
417 * Full profile.
419 HSA_PROFILE_FULL = 1
420 } hsa_profile_t;
423 * @brief System attributes.
425 typedef enum {
427 * Major version of the HSA runtime specification supported by the
428 * implementation. The type of this attribute is uint16_t.
430 HSA_SYSTEM_INFO_VERSION_MAJOR = 0,
432 * Minor version of the HSA runtime specification supported by the
433 * implementation. The type of this attribute is uint16_t.
435 HSA_SYSTEM_INFO_VERSION_MINOR = 1,
437 * Current timestamp. The value of this attribute monotonically increases at a
438 * constant rate. The type of this attribute is uint64_t.
440 HSA_SYSTEM_INFO_TIMESTAMP = 2,
442 * Timestamp value increase rate, in Hz. The timestamp (clock) frequency is
443 * in the range 1-400MHz. The type of this attribute is uint64_t.
445 HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY = 3,
447 * Maximum duration of a signal wait operation. Expressed as a count based on
448 * the timestamp frequency. The type of this attribute is uint64_t.
450 HSA_SYSTEM_INFO_SIGNAL_MAX_WAIT = 4,
452 * Endianness of the system. The type of this attribute is ::hsa_endianness_t.
454 HSA_SYSTEM_INFO_ENDIANNESS = 5,
456 * Machine model supported by the HSA runtime. The type of this attribute is
457 * ::hsa_machine_model_t.
459 HSA_SYSTEM_INFO_MACHINE_MODEL = 6,
461 * Bit-mask indicating which extensions are supported by the
462 * implementation. An extension with an ID of @p i is supported if the bit at
463 * position @p i is set. The type of this attribute is uint8_t[128].
465 HSA_SYSTEM_INFO_EXTENSIONS = 7,
467 * String containing the ROCr build identifier.
469 HSA_AMD_SYSTEM_INFO_BUILD_VERSION = 0x200
470 } hsa_system_info_t;
473 * @brief Get the current value of a system attribute.
475 * @param[in] attribute Attribute to query.
477 * @param[out] value Pointer to an application-allocated buffer where to store
478 * the value of the attribute. If the buffer passed by the application is not
479 * large enough to hold the value of @p attribute, the behavior is undefined.
481 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
483 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
484 * initialized.
486 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
487 * system attribute, or @p value is NULL.
489 hsa_status_t HSA_API hsa_system_get_info(
490 hsa_system_info_t attribute,
491 void* value);
494 * @brief HSA extensions.
496 typedef enum {
498 * Finalizer extension.
500 HSA_EXTENSION_FINALIZER = 0,
502 * Images extension.
504 HSA_EXTENSION_IMAGES = 1,
507 * Performance counter extension.
509 HSA_EXTENSION_PERFORMANCE_COUNTERS = 2,
512 * Profiling events extension.
514 HSA_EXTENSION_PROFILING_EVENTS = 3,
516 * Extension count.
518 HSA_EXTENSION_STD_LAST = 3,
520 * First AMD extension number.
522 HSA_AMD_FIRST_EXTENSION = 0x200,
524 * Profiler extension.
526 HSA_EXTENSION_AMD_PROFILER = 0x200,
528 * Loader extension.
530 HSA_EXTENSION_AMD_LOADER = 0x201,
532 * AqlProfile extension.
534 HSA_EXTENSION_AMD_AQLPROFILE = 0x202,
536 * Last AMD extension.
538 HSA_AMD_LAST_EXTENSION = 0x202
539 } hsa_extension_t;
542 * @brief Query the name of a given extension.
544 * @param[in] extension Extension identifier. If the extension is not supported
545 * by the implementation (see ::HSA_SYSTEM_INFO_EXTENSIONS), the behavior
546 * is undefined.
548 * @param[out] name Pointer to a memory location where the HSA runtime stores
549 * the extension name. The extension name is a NUL-terminated string.
551 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
553 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
554 * initialized.
556 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
557 * extension, or @p name is NULL.
559 hsa_status_t HSA_API hsa_extension_get_name(
560 uint16_t extension,
561 const char **name);
564 * @deprecated
566 * @brief Query if a given version of an extension is supported by the HSA
567 * implementation.
569 * @param[in] extension Extension identifier.
571 * @param[in] version_major Major version number.
573 * @param[in] version_minor Minor version number.
575 * @param[out] result Pointer to a memory location where the HSA runtime stores
576 * the result of the check. The result is true if the specified version of the
577 * extension is supported, and false otherwise.
579 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
581 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
582 * initialized.
584 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
585 * extension, or @p result is NULL.
587 hsa_status_t HSA_API HSA_DEPRECATED hsa_system_extension_supported(
588 uint16_t extension,
589 uint16_t version_major,
590 uint16_t version_minor,
591 bool* result);
594 * @brief Query if a given version of an extension is supported by the HSA
595 * implementation. All minor versions from 0 up to the returned @p version_minor
596 * must be supported by the implementation.
598 * @param[in] extension Extension identifier.
600 * @param[in] version_major Major version number.
602 * @param[out] version_minor Minor version number.
604 * @param[out] result Pointer to a memory location where the HSA runtime stores
605 * the result of the check. The result is true if the specified version of the
606 * extension is supported, and false otherwise.
608 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
610 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
611 * initialized.
613 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
614 * extension, or @p version_minor is NULL, or @p result is NULL.
616 hsa_status_t HSA_API hsa_system_major_extension_supported(
617 uint16_t extension,
618 uint16_t version_major,
619 uint16_t *version_minor,
620 bool* result);
624 * @deprecated
626 * @brief Retrieve the function pointers corresponding to a given version of an
627 * extension. Portable applications are expected to invoke the extension API
628 * using the returned function pointers
630 * @details The application is responsible for verifying that the given version
631 * of the extension is supported by the HSA implementation (see
632 * ::hsa_system_extension_supported). If the given combination of extension,
633 * major version, and minor version is not supported by the implementation, the
634 * behavior is undefined.
636 * @param[in] extension Extension identifier.
638 * @param[in] version_major Major version number for which to retrieve the
639 * function pointer table.
641 * @param[in] version_minor Minor version number for which to retrieve the
642 * function pointer table.
644 * @param[out] table Pointer to an application-allocated function pointer table
645 * that is populated by the HSA runtime. Must not be NULL. The memory associated
646 * with table can be reused or freed after the function returns.
648 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
650 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
651 * initialized.
653 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
654 * extension, or @p table is NULL.
656 hsa_status_t HSA_API HSA_DEPRECATED hsa_system_get_extension_table(
657 uint16_t extension,
658 uint16_t version_major,
659 uint16_t version_minor,
660 void *table);
663 * @brief Retrieve the function pointers corresponding to a given major version
664 * of an extension. Portable applications are expected to invoke the extension
665 * API using the returned function pointers.
667 * @details The application is responsible for verifying that the given major
668 * version of the extension is supported by the HSA implementation (see
669 * ::hsa_system_major_extension_supported). If the given combination of extension
670 * and major version is not supported by the implementation, the behavior is
671 * undefined. Additionally if the length doesn't allow space for a full minor
672 * version, it is implementation defined if only some of the function pointers for
673 * that minor version get written.
675 * @param[in] extension Extension identifier.
677 * @param[in] version_major Major version number for which to retrieve the
678 * function pointer table.
680 * @param[in] table_length Size in bytes of the function pointer table to be
681 * populated. The implementation will not write more than this many bytes to the
682 * table.
684 * @param[out] table Pointer to an application-allocated function pointer table
685 * that is populated by the HSA runtime. Must not be NULL. The memory associated
686 * with table can be reused or freed after the function returns.
688 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
690 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
691 * initialized.
693 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
694 * extension, or @p table is NULL.
696 hsa_status_t HSA_API hsa_system_get_major_extension_table(
697 uint16_t extension,
698 uint16_t version_major,
699 size_t table_length,
700 void *table);
703 * @brief Struct containing an opaque handle to an agent, a device that participates in
704 * the HSA memory model. An agent can submit AQL packets for execution, and
705 * may also accept AQL packets for execution (agent dispatch packets or kernel
706 * dispatch packets launching HSAIL-derived binaries).
708 typedef struct hsa_agent_s {
710 * Opaque handle. Two handles reference the same object of the enclosing type
711 * if and only if they are equal.
713 uint64_t handle;
714 } hsa_agent_t;
717 * @brief Agent features.
719 typedef enum {
721 * The agent supports AQL packets of kernel dispatch type. If this
722 * feature is enabled, the agent is also a kernel agent.
724 HSA_AGENT_FEATURE_KERNEL_DISPATCH = 1,
726 * The agent supports AQL packets of agent dispatch type.
728 HSA_AGENT_FEATURE_AGENT_DISPATCH = 2
729 } hsa_agent_feature_t;
732 * @brief Hardware device type.
734 typedef enum {
736 * CPU device.
738 HSA_DEVICE_TYPE_CPU = 0,
740 * GPU device.
742 HSA_DEVICE_TYPE_GPU = 1,
744 * DSP device.
746 HSA_DEVICE_TYPE_DSP = 2
747 } hsa_device_type_t;
750 * @brief Default floating-point rounding mode.
752 typedef enum {
754 * Use a default floating-point rounding mode specified elsewhere.
756 HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT = 0,
758 * Operations that specify the default floating-point mode are rounded to zero
759 * by default.
761 HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO = 1,
763 * Operations that specify the default floating-point mode are rounded to the
764 * nearest representable number and that ties should be broken by selecting
765 * the value with an even least significant bit.
767 HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR = 2
768 } hsa_default_float_rounding_mode_t;
771 * @brief Agent attributes.
773 typedef enum {
775 * Agent name. The type of this attribute is a NUL-terminated char[64]. The
776 * name must be at most 63 characters long (not including the NUL terminator)
777 * and all array elements not used for the name must be NUL.
779 HSA_AGENT_INFO_NAME = 0,
781 * Name of vendor. The type of this attribute is a NUL-terminated char[64].
782 * The name must be at most 63 characters long (not including the NUL
783 * terminator) and all array elements not used for the name must be NUL.
785 HSA_AGENT_INFO_VENDOR_NAME = 1,
787 * Agent capability. The type of this attribute is ::hsa_agent_feature_t.
789 HSA_AGENT_INFO_FEATURE = 2,
791 * @deprecated Query ::HSA_ISA_INFO_MACHINE_MODELS for a given intruction set
792 * architecture supported by the agent instead. If more than one ISA is
793 * supported by the agent, the returned value corresponds to the first ISA
794 * enumerated by ::hsa_agent_iterate_isas.
796 * Machine model supported by the agent. The type of this attribute is
797 * ::hsa_machine_model_t.
799 HSA_AGENT_INFO_MACHINE_MODEL = 3,
801 * @deprecated Query ::HSA_ISA_INFO_PROFILES for a given intruction set
802 * architecture supported by the agent instead. If more than one ISA is
803 * supported by the agent, the returned value corresponds to the first ISA
804 * enumerated by ::hsa_agent_iterate_isas.
806 * Profile supported by the agent. The type of this attribute is
807 * ::hsa_profile_t.
809 HSA_AGENT_INFO_PROFILE = 4,
811 * @deprecated Query ::HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES for a given
812 * intruction set architecture supported by the agent instead. If more than
813 * one ISA is supported by the agent, the returned value corresponds to the
814 * first ISA enumerated by ::hsa_agent_iterate_isas.
816 * Default floating-point rounding mode. The type of this attribute is
817 * ::hsa_default_float_rounding_mode_t, but the value
818 * ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT is not allowed.
820 HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 5,
822 * @deprecated Query ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES
823 * for a given intruction set architecture supported by the agent instead. If
824 * more than one ISA is supported by the agent, the returned value corresponds
825 * to the first ISA enumerated by ::hsa_agent_iterate_isas.
827 * A bit-mask of ::hsa_default_float_rounding_mode_t values, representing the
828 * default floating-point rounding modes supported by the agent in the Base
829 * profile. The type of this attribute is uint32_t. The default floating-point
830 * rounding mode (::HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE) bit must not
831 * be set.
833 HSA_AGENT_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES = 23,
835 * @deprecated Query ::HSA_ISA_INFO_FAST_F16_OPERATION for a given intruction
836 * set architecture supported by the agent instead. If more than one ISA is
837 * supported by the agent, the returned value corresponds to the first ISA
838 * enumerated by ::hsa_agent_iterate_isas.
840 * Flag indicating that the f16 HSAIL operation is at least as fast as the
841 * f32 operation in the current agent. The value of this attribute is
842 * undefined if the agent is not a kernel agent. The type of this
843 * attribute is bool.
845 HSA_AGENT_INFO_FAST_F16_OPERATION = 24,
847 * @deprecated Query ::HSA_WAVEFRONT_INFO_SIZE for a given wavefront and
848 * intruction set architecture supported by the agent instead. If more than
849 * one ISA is supported by the agent, the returned value corresponds to the
850 * first ISA enumerated by ::hsa_agent_iterate_isas and the first wavefront
851 * enumerated by ::hsa_isa_iterate_wavefronts for that ISA.
853 * Number of work-items in a wavefront. Must be a power of 2 in the range
854 * [1,256]. The value of this attribute is undefined if the agent is not
855 * a kernel agent. The type of this attribute is uint32_t.
857 HSA_AGENT_INFO_WAVEFRONT_SIZE = 6,
859 * @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_DIM for a given intruction
860 * set architecture supported by the agent instead. If more than one ISA is
861 * supported by the agent, the returned value corresponds to the first ISA
862 * enumerated by ::hsa_agent_iterate_isas.
864 * Maximum number of work-items of each dimension of a work-group. Each
865 * maximum must be greater than 0. No maximum can exceed the value of
866 * ::HSA_AGENT_INFO_WORKGROUP_MAX_SIZE. The value of this attribute is
867 * undefined if the agent is not a kernel agent. The type of this
868 * attribute is uint16_t[3].
870 HSA_AGENT_INFO_WORKGROUP_MAX_DIM = 7,
872 * @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE for a given intruction
873 * set architecture supported by the agent instead. If more than one ISA is
874 * supported by the agent, the returned value corresponds to the first ISA
875 * enumerated by ::hsa_agent_iterate_isas.
877 * Maximum total number of work-items in a work-group. The value of this
878 * attribute is undefined if the agent is not a kernel agent. The type
879 * of this attribute is uint32_t.
881 HSA_AGENT_INFO_WORKGROUP_MAX_SIZE = 8,
883 * @deprecated Query ::HSA_ISA_INFO_GRID_MAX_DIM for a given intruction set
884 * architecture supported by the agent instead.
886 * Maximum number of work-items of each dimension of a grid. Each maximum must
887 * be greater than 0, and must not be smaller than the corresponding value in
888 * ::HSA_AGENT_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
889 * ::HSA_AGENT_INFO_GRID_MAX_SIZE. The value of this attribute is undefined
890 * if the agent is not a kernel agent. The type of this attribute is
891 * ::hsa_dim3_t.
893 HSA_AGENT_INFO_GRID_MAX_DIM = 9,
895 * @deprecated Query ::HSA_ISA_INFO_GRID_MAX_SIZE for a given intruction set
896 * architecture supported by the agent instead. If more than one ISA is
897 * supported by the agent, the returned value corresponds to the first ISA
898 * enumerated by ::hsa_agent_iterate_isas.
900 * Maximum total number of work-items in a grid. The value of this attribute
901 * is undefined if the agent is not a kernel agent. The type of this
902 * attribute is uint32_t.
904 HSA_AGENT_INFO_GRID_MAX_SIZE = 10,
906 * @deprecated Query ::HSA_ISA_INFO_FBARRIER_MAX_SIZE for a given intruction
907 * set architecture supported by the agent instead. If more than one ISA is
908 * supported by the agent, the returned value corresponds to the first ISA
909 * enumerated by ::hsa_agent_iterate_isas.
911 * Maximum number of fbarriers per work-group. Must be at least 32. The value
912 * of this attribute is undefined if the agent is not a kernel agent. The
913 * type of this attribute is uint32_t.
915 HSA_AGENT_INFO_FBARRIER_MAX_SIZE = 11,
917 * @deprecated The maximum number of queues is not statically determined.
919 * Maximum number of queues that can be active (created but not destroyed) at
920 * one time in the agent. The type of this attribute is uint32_t.
922 HSA_AGENT_INFO_QUEUES_MAX = 12,
924 * Minimum number of packets that a queue created in the agent
925 * can hold. Must be a power of 2 greater than 0. Must not exceed
926 * the value of ::HSA_AGENT_INFO_QUEUE_MAX_SIZE. The type of this
927 * attribute is uint32_t.
929 HSA_AGENT_INFO_QUEUE_MIN_SIZE = 13,
931 * Maximum number of packets that a queue created in the agent can
932 * hold. Must be a power of 2 greater than 0. The type of this attribute
933 * is uint32_t.
935 HSA_AGENT_INFO_QUEUE_MAX_SIZE = 14,
937 * Type of a queue created in the agent. The type of this attribute is
938 * ::hsa_queue_type32_t.
940 HSA_AGENT_INFO_QUEUE_TYPE = 15,
942 * @deprecated NUMA information is not exposed anywhere else in the API.
944 * Identifier of the NUMA node associated with the agent. The type of this
945 * attribute is uint32_t.
947 HSA_AGENT_INFO_NODE = 16,
949 * Type of hardware device associated with the agent. The type of this
950 * attribute is ::hsa_device_type_t.
952 HSA_AGENT_INFO_DEVICE = 17,
954 * @deprecated Query ::hsa_agent_iterate_caches to retrieve information about
955 * the caches present in a given agent.
957 * Array of data cache sizes (L1..L4). Each size is expressed in bytes. A size
958 * of 0 for a particular level indicates that there is no cache information
959 * for that level. The type of this attribute is uint32_t[4].
961 HSA_AGENT_INFO_CACHE_SIZE = 18,
963 * @deprecated An agent may support multiple instruction set
964 * architectures. See ::hsa_agent_iterate_isas. If more than one ISA is
965 * supported by the agent, the returned value corresponds to the first ISA
966 * enumerated by ::hsa_agent_iterate_isas.
968 * Instruction set architecture of the agent. The type of this attribute
969 * is ::hsa_isa_t.
971 HSA_AGENT_INFO_ISA = 19,
973 * Bit-mask indicating which extensions are supported by the agent. An
974 * extension with an ID of @p i is supported if the bit at position @p i is
975 * set. The type of this attribute is uint8_t[128].
977 HSA_AGENT_INFO_EXTENSIONS = 20,
979 * Major version of the HSA runtime specification supported by the
980 * agent. The type of this attribute is uint16_t.
982 HSA_AGENT_INFO_VERSION_MAJOR = 21,
984 * Minor version of the HSA runtime specification supported by the
985 * agent. The type of this attribute is uint16_t.
987 HSA_AGENT_INFO_VERSION_MINOR = 22
989 } hsa_agent_info_t;
992 * @brief Get the current value of an attribute for a given agent.
994 * @param[in] agent A valid agent.
996 * @param[in] attribute Attribute to query.
998 * @param[out] value Pointer to an application-allocated buffer where to store
999 * the value of the attribute. If the buffer passed by the application is not
1000 * large enough to hold the value of @p attribute, the behavior is undefined.
1002 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1004 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1005 * initialized.
1007 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1009 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
1010 * agent attribute, or @p value is NULL.
1012 hsa_status_t HSA_API hsa_agent_get_info(
1013 hsa_agent_t agent,
1014 hsa_agent_info_t attribute,
1015 void* value);
1018 * @brief Iterate over the available agents, and invoke an
1019 * application-defined callback on every iteration.
1021 * @param[in] callback Callback to be invoked once per agent. The HSA
1022 * runtime passes two arguments to the callback: the agent and the
1023 * application data. If @p callback returns a status other than
1024 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
1025 * ::hsa_iterate_agents returns that status value.
1027 * @param[in] data Application data that is passed to @p callback on every
1028 * iteration. May be NULL.
1030 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1032 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1033 * initialized.
1035 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
1037 hsa_status_t HSA_API hsa_iterate_agents(
1038 hsa_status_t (*callback)(hsa_agent_t agent, void* data),
1039 void* data);
1043 // If we do not know the size of an attribute, we need to query it first
1044 // Note: this API will not be in the spec unless needed
1045 hsa_status_t HSA_API hsa_agent_get_info_size(
1046 hsa_agent_t agent,
1047 hsa_agent_info_t attribute,
1048 size_t* size);
1050 // Set the value of an agents attribute
1051 // Note: this API will not be in the spec unless needed
1052 hsa_status_t HSA_API hsa_agent_set_info(
1053 hsa_agent_t agent,
1054 hsa_agent_info_t attribute,
1055 void* value);
1060 * @brief Exception policies applied in the presence of hardware exceptions.
1062 typedef enum {
1064 * If a hardware exception is detected, a work-item signals an exception.
1066 HSA_EXCEPTION_POLICY_BREAK = 1,
1068 * If a hardware exception is detected, a hardware status bit is set.
1070 HSA_EXCEPTION_POLICY_DETECT = 2
1071 } hsa_exception_policy_t;
1074 * @deprecated Use ::hsa_isa_get_exception_policies for a given intruction set
1075 * architecture supported by the agent instead. If more than one ISA is
1076 * supported by the agent, this function uses the first value returned by
1077 * ::hsa_agent_iterate_isas.
1079 * @brief Retrieve the exception policy support for a given combination of
1080 * agent and profile
1082 * @param[in] agent Agent.
1084 * @param[in] profile Profile.
1086 * @param[out] mask Pointer to a memory location where the HSA runtime stores a
1087 * mask of ::hsa_exception_policy_t values. Must not be NULL.
1089 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1091 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1092 * initialized.
1094 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1096 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is not a valid
1097 * profile, or @p mask is NULL.
1100 hsa_status_t HSA_API HSA_DEPRECATED hsa_agent_get_exception_policies(
1101 hsa_agent_t agent,
1102 hsa_profile_t profile,
1103 uint16_t *mask);
1106 * @brief Cache handle.
1108 typedef struct hsa_cache_s {
1110 * Opaque handle. Two handles reference the same object of the enclosing type
1111 * if and only if they are equal.
1113 uint64_t handle;
1114 } hsa_cache_t;
1117 * @brief Cache attributes.
1119 typedef enum {
1121 * The length of the cache name in bytes, not including the NUL terminator.
1122 * The type of this attribute is uint32_t.
1124 HSA_CACHE_INFO_NAME_LENGTH = 0,
1126 * Human-readable description. The type of this attribute is a NUL-terminated
1127 * character array with the length equal to the value of
1128 * ::HSA_CACHE_INFO_NAME_LENGTH attribute.
1130 HSA_CACHE_INFO_NAME = 1,
1132 * Cache level. A L1 cache must return a value of 1, a L2 must return a value
1133 * of 2, and so on. The type of this attribute is uint8_t.
1135 HSA_CACHE_INFO_LEVEL = 2,
1137 * Cache size, in bytes. A value of 0 indicates that there is no size
1138 * information available. The type of this attribute is uint32_t.
1140 HSA_CACHE_INFO_SIZE = 3
1141 } hsa_cache_info_t;
1144 * @brief Get the current value of an attribute for a given cache object.
1146 * @param[in] cache Cache.
1148 * @param[in] attribute Attribute to query.
1150 * @param[out] value Pointer to an application-allocated buffer where to store
1151 * the value of the attribute. If the buffer passed by the application is not
1152 * large enough to hold the value of @p attribute, the behavior is undefined.
1154 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1156 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1157 * initialized.
1159 * @retval ::HSA_STATUS_ERROR_INVALID_CACHE The cache is invalid.
1161 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
1162 * instruction set architecture attribute, or @p value is
1163 * NULL.
1165 hsa_status_t HSA_API hsa_cache_get_info(
1166 hsa_cache_t cache,
1167 hsa_cache_info_t attribute,
1168 void* value);
1171 * @brief Iterate over the memory caches of a given agent, and
1172 * invoke an application-defined callback on every iteration.
1174 * @details Caches are visited in ascending order according to the value of the
1175 * ::HSA_CACHE_INFO_LEVEL attribute.
1177 * @param[in] agent A valid agent.
1179 * @param[in] callback Callback to be invoked once per cache that is present in
1180 * the agent. The HSA runtime passes two arguments to the callback: the cache
1181 * and the application data. If @p callback returns a status other than
1182 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
1183 * that value is returned.
1185 * @param[in] data Application data that is passed to @p callback on every
1186 * iteration. May be NULL.
1188 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1190 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1191 * initialized.
1193 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1195 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
1197 hsa_status_t HSA_API hsa_agent_iterate_caches(
1198 hsa_agent_t agent,
1199 hsa_status_t (*callback)(hsa_cache_t cache, void* data),
1200 void* data);
1203 * @deprecated
1205 * @brief Query if a given version of an extension is supported by an agent
1207 * @param[in] extension Extension identifier.
1209 * @param[in] agent Agent.
1211 * @param[in] version_major Major version number.
1213 * @param[in] version_minor Minor version number.
1215 * @param[out] result Pointer to a memory location where the HSA runtime stores
1216 * the result of the check. The result is true if the specified version of the
1217 * extension is supported, and false otherwise. The result must be false if
1218 * ::hsa_system_extension_supported returns false for the same extension
1219 * version.
1221 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1223 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1224 * initialized.
1226 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1228 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
1229 * extension, or @p result is NULL.
1231 hsa_status_t HSA_API HSA_DEPRECATED hsa_agent_extension_supported(
1232 uint16_t extension,
1233 hsa_agent_t agent,
1234 uint16_t version_major,
1235 uint16_t version_minor,
1236 bool* result);
1239 * @brief Query if a given version of an extension is supported by an agent. All
1240 * minor versions from 0 up to the returned @p version_minor must be supported.
1242 * @param[in] extension Extension identifier.
1244 * @param[in] agent Agent.
1246 * @param[in] version_major Major version number.
1248 * @param[out] version_minor Minor version number.
1250 * @param[out] result Pointer to a memory location where the HSA runtime stores
1251 * the result of the check. The result is true if the specified version of the
1252 * extension is supported, and false otherwise. The result must be false if
1253 * ::hsa_system_extension_supported returns false for the same extension
1254 * version.
1256 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1258 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1259 * initialized.
1261 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1263 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
1264 * extension, or @p version_minor is NULL, or @p result is NULL.
1266 hsa_status_t HSA_API hsa_agent_major_extension_supported(
1267 uint16_t extension,
1268 hsa_agent_t agent,
1269 uint16_t version_major,
1270 uint16_t *version_minor,
1271 bool* result);
1274 /** @} */
1277 /** \defgroup signals Signals
1278 * @{
1282 * @brief Signal handle.
1284 typedef struct hsa_signal_s {
1286 * Opaque handle. Two handles reference the same object of the enclosing type
1287 * if and only if they are equal. The value 0 is reserved.
1289 uint64_t handle;
1290 } hsa_signal_t;
1293 * @brief Signal value. The value occupies 32 bits in small machine mode, and 64
1294 * bits in large machine mode.
1296 #ifdef HSA_LARGE_MODEL
1297 typedef int64_t hsa_signal_value_t;
1298 #else
1299 typedef int32_t hsa_signal_value_t;
1300 #endif
1303 * @brief Create a signal.
1305 * @param[in] initial_value Initial value of the signal.
1307 * @param[in] num_consumers Size of @p consumers. A value of 0 indicates that
1308 * any agent might wait on the signal.
1310 * @param[in] consumers List of agents that might consume (wait on) the
1311 * signal. If @p num_consumers is 0, this argument is ignored; otherwise, the
1312 * HSA runtime might use the list to optimize the handling of the signal
1313 * object. If an agent not listed in @p consumers waits on the returned
1314 * signal, the behavior is undefined. The memory associated with @p consumers
1315 * can be reused or freed after the function returns.
1317 * @param[out] signal Pointer to a memory location where the HSA runtime will
1318 * store the newly created signal handle. Must not be NULL.
1320 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1322 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1323 * initialized.
1325 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
1326 * the required resources.
1328 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is NULL, @p
1329 * num_consumers is greater than 0 but @p consumers is NULL, or @p consumers
1330 * contains duplicates.
1332 hsa_status_t HSA_API hsa_signal_create(
1333 hsa_signal_value_t initial_value,
1334 uint32_t num_consumers,
1335 const hsa_agent_t *consumers,
1336 hsa_signal_t *signal);
1339 * @brief Destroy a signal previous created by ::hsa_signal_create.
1341 * @param[in] signal Signal.
1343 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1345 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1346 * initialized.
1348 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL @p signal is invalid.
1350 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The handle in @p signal is 0.
1352 hsa_status_t HSA_API hsa_signal_destroy(
1353 hsa_signal_t signal);
1356 * @brief Atomically read the current value of a signal.
1358 * @param[in] signal Signal.
1360 * @return Value of the signal.
1362 hsa_signal_value_t HSA_API hsa_signal_load_scacquire(
1363 hsa_signal_t signal);
1366 * @copydoc hsa_signal_load_scacquire
1368 hsa_signal_value_t HSA_API hsa_signal_load_relaxed(
1369 hsa_signal_t signal);
1372 * @deprecated Renamed as ::hsa_signal_load_scacquire.
1374 * @copydoc hsa_signal_load_scacquire
1376 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_load_acquire(
1377 hsa_signal_t signal);
1380 * @brief Atomically set the value of a signal.
1382 * @details If the value of the signal is changed, all the agents waiting
1383 * on @p signal for which @p value satisfies their wait condition are awakened.
1385 * @param[in] signal Signal.
1387 * @param[in] value New signal value.
1389 void HSA_API hsa_signal_store_relaxed(
1390 hsa_signal_t signal,
1391 hsa_signal_value_t value);
1394 * @copydoc hsa_signal_store_relaxed
1396 void HSA_API hsa_signal_store_screlease(
1397 hsa_signal_t signal,
1398 hsa_signal_value_t value);
1401 * @deprecated Renamed as ::hsa_signal_store_screlease.
1403 * @copydoc hsa_signal_store_screlease
1405 void HSA_API HSA_DEPRECATED hsa_signal_store_release(
1406 hsa_signal_t signal,
1407 hsa_signal_value_t value);
1410 * @brief Atomically set the value of a signal without necessarily notifying the
1411 * the agents waiting on it.
1413 * @details The agents waiting on @p signal may not wake up even when the new
1414 * value satisfies their wait condition. If the application wants to update the
1415 * signal and there is no need to notify any agent, invoking this function can
1416 * be more efficient than calling the non-silent counterpart.
1418 * @param[in] signal Signal.
1420 * @param[in] value New signal value.
1422 void HSA_API hsa_signal_silent_store_relaxed(
1423 hsa_signal_t signal,
1424 hsa_signal_value_t value);
1427 * @copydoc hsa_signal_silent_store_relaxed
1429 void HSA_API hsa_signal_silent_store_screlease(
1430 hsa_signal_t signal,
1431 hsa_signal_value_t value);
1434 * @brief Atomically set the value of a signal and return its previous value.
1436 * @details If the value of the signal is changed, all the agents waiting
1437 * on @p signal for which @p value satisfies their wait condition are awakened.
1439 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1440 * behavior is undefined.
1442 * @param[in] value New value.
1444 * @return Value of the signal prior to the exchange.
1447 hsa_signal_value_t HSA_API hsa_signal_exchange_scacq_screl(
1448 hsa_signal_t signal,
1449 hsa_signal_value_t value);
1452 * @deprecated Renamed as ::hsa_signal_exchange_scacq_screl.
1454 * @copydoc hsa_signal_exchange_scacq_screl
1456 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_exchange_acq_rel(
1457 hsa_signal_t signal,
1458 hsa_signal_value_t value);
1461 * @copydoc hsa_signal_exchange_scacq_screl
1463 hsa_signal_value_t HSA_API hsa_signal_exchange_scacquire(
1464 hsa_signal_t signal,
1465 hsa_signal_value_t value);
1468 * @deprecated Renamed as ::hsa_signal_exchange_scacquire.
1470 * @copydoc hsa_signal_exchange_scacquire
1472 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_exchange_acquire(
1473 hsa_signal_t signal,
1474 hsa_signal_value_t value);
1477 * @copydoc hsa_signal_exchange_scacq_screl
1479 hsa_signal_value_t HSA_API hsa_signal_exchange_relaxed(
1480 hsa_signal_t signal,
1481 hsa_signal_value_t value);
1483 * @copydoc hsa_signal_exchange_scacq_screl
1485 hsa_signal_value_t HSA_API hsa_signal_exchange_screlease(
1486 hsa_signal_t signal,
1487 hsa_signal_value_t value);
1490 * @deprecated Renamed as ::hsa_signal_exchange_screlease.
1492 * @copydoc hsa_signal_exchange_screlease
1494 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_exchange_release(
1495 hsa_signal_t signal,
1496 hsa_signal_value_t value);
1499 * @brief Atomically set the value of a signal if the observed value is equal to
1500 * the expected value. The observed value is returned regardless of whether the
1501 * replacement was done.
1503 * @details If the value of the signal is changed, all the agents waiting
1504 * on @p signal for which @p value satisfies their wait condition are awakened.
1506 * @param[in] signal Signal. If @p signal is a queue
1507 * doorbell signal, the behavior is undefined.
1509 * @param[in] expected Value to compare with.
1511 * @param[in] value New value.
1513 * @return Observed value of the signal.
1516 hsa_signal_value_t HSA_API hsa_signal_cas_scacq_screl(
1517 hsa_signal_t signal,
1518 hsa_signal_value_t expected,
1519 hsa_signal_value_t value);
1523 * @deprecated Renamed as ::hsa_signal_cas_scacq_screl.
1525 * @copydoc hsa_signal_cas_scacq_screl
1527 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_cas_acq_rel(
1528 hsa_signal_t signal,
1529 hsa_signal_value_t expected,
1530 hsa_signal_value_t value);
1533 * @copydoc hsa_signal_cas_scacq_screl
1535 hsa_signal_value_t HSA_API hsa_signal_cas_scacquire(
1536 hsa_signal_t signal,
1537 hsa_signal_value_t expected,
1538 hsa_signal_value_t value);
1541 * @deprecated Renamed as ::hsa_signal_cas_scacquire.
1543 * @copydoc hsa_signal_cas_scacquire
1545 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_cas_acquire(
1546 hsa_signal_t signal,
1547 hsa_signal_value_t expected,
1548 hsa_signal_value_t value);
1551 * @copydoc hsa_signal_cas_scacq_screl
1553 hsa_signal_value_t HSA_API hsa_signal_cas_relaxed(
1554 hsa_signal_t signal,
1555 hsa_signal_value_t expected,
1556 hsa_signal_value_t value);
1559 * @copydoc hsa_signal_cas_scacq_screl
1561 hsa_signal_value_t HSA_API hsa_signal_cas_screlease(
1562 hsa_signal_t signal,
1563 hsa_signal_value_t expected,
1564 hsa_signal_value_t value);
1567 * @deprecated Renamed as ::hsa_signal_cas_screlease.
1569 * @copydoc hsa_signal_cas_screlease
1571 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_cas_release(
1572 hsa_signal_t signal,
1573 hsa_signal_value_t expected,
1574 hsa_signal_value_t value);
1577 * @brief Atomically increment the value of a signal by a given amount.
1579 * @details If the value of the signal is changed, all the agents waiting on
1580 * @p signal for which @p value satisfies their wait condition are awakened.
1582 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1583 * behavior is undefined.
1585 * @param[in] value Value to add to the value of the signal.
1588 void HSA_API hsa_signal_add_scacq_screl(
1589 hsa_signal_t signal,
1590 hsa_signal_value_t value);
1593 * @deprecated Renamed as ::hsa_signal_add_scacq_screl.
1595 * @copydoc hsa_signal_add_scacq_screl
1597 void HSA_API HSA_DEPRECATED hsa_signal_add_acq_rel(
1598 hsa_signal_t signal,
1599 hsa_signal_value_t value);
1602 * @copydoc hsa_signal_add_scacq_screl
1604 void HSA_API hsa_signal_add_scacquire(
1605 hsa_signal_t signal,
1606 hsa_signal_value_t value);
1609 * @deprecated Renamed as ::hsa_signal_add_scacquire.
1611 * @copydoc hsa_signal_add_scacquire
1613 void HSA_API HSA_DEPRECATED hsa_signal_add_acquire(
1614 hsa_signal_t signal,
1615 hsa_signal_value_t value);
1618 * @copydoc hsa_signal_add_scacq_screl
1620 void HSA_API hsa_signal_add_relaxed(
1621 hsa_signal_t signal,
1622 hsa_signal_value_t value);
1625 * @copydoc hsa_signal_add_scacq_screl
1627 void HSA_API hsa_signal_add_screlease(
1628 hsa_signal_t signal,
1629 hsa_signal_value_t value);
1633 * @deprecated Renamed as ::hsa_signal_add_screlease.
1635 * @copydoc hsa_signal_add_screlease
1637 void HSA_API HSA_DEPRECATED hsa_signal_add_release(
1638 hsa_signal_t signal,
1639 hsa_signal_value_t value);
1642 * @brief Atomically decrement the value of a signal by a given amount.
1644 * @details If the value of the signal is changed, all the agents waiting on
1645 * @p signal for which @p value satisfies their wait condition are awakened.
1647 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1648 * behavior is undefined.
1650 * @param[in] value Value to subtract from the value of the signal.
1653 void HSA_API hsa_signal_subtract_scacq_screl(
1654 hsa_signal_t signal,
1655 hsa_signal_value_t value);
1659 * @deprecated Renamed as ::hsa_signal_subtract_scacq_screl.
1661 * @copydoc hsa_signal_subtract_scacq_screl
1663 void HSA_API HSA_DEPRECATED hsa_signal_subtract_acq_rel(
1664 hsa_signal_t signal,
1665 hsa_signal_value_t value);
1668 * @copydoc hsa_signal_subtract_scacq_screl
1670 void HSA_API hsa_signal_subtract_scacquire(
1671 hsa_signal_t signal,
1672 hsa_signal_value_t value);
1675 * @deprecated Renamed as ::hsa_signal_subtract_scacquire.
1677 * @copydoc hsa_signal_subtract_scacquire
1679 void HSA_API HSA_DEPRECATED hsa_signal_subtract_acquire(
1680 hsa_signal_t signal,
1681 hsa_signal_value_t value);
1684 * @copydoc hsa_signal_subtract_scacq_screl
1686 void HSA_API hsa_signal_subtract_relaxed(
1687 hsa_signal_t signal,
1688 hsa_signal_value_t value);
1691 * @copydoc hsa_signal_subtract_scacq_screl
1693 void HSA_API hsa_signal_subtract_screlease(
1694 hsa_signal_t signal,
1695 hsa_signal_value_t value);
1699 * @deprecated Renamed as ::hsa_signal_subtract_screlease.
1701 * @copydoc hsa_signal_subtract_screlease
1703 void HSA_API HSA_DEPRECATED hsa_signal_subtract_release(
1704 hsa_signal_t signal,
1705 hsa_signal_value_t value);
1708 * @brief Atomically perform a bitwise AND operation between the value of a
1709 * signal and a given value.
1711 * @details If the value of the signal is changed, all the agents waiting on
1712 * @p signal for which @p value satisfies their wait condition are awakened.
1714 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1715 * behavior is undefined.
1717 * @param[in] value Value to AND with the value of the signal.
1720 void HSA_API hsa_signal_and_scacq_screl(
1721 hsa_signal_t signal,
1722 hsa_signal_value_t value);
1725 * @deprecated Renamed as ::hsa_signal_and_scacq_screl.
1727 * @copydoc hsa_signal_and_scacq_screl
1729 void HSA_API HSA_DEPRECATED hsa_signal_and_acq_rel(
1730 hsa_signal_t signal,
1731 hsa_signal_value_t value);
1734 * @copydoc hsa_signal_and_scacq_screl
1736 void HSA_API hsa_signal_and_scacquire(
1737 hsa_signal_t signal,
1738 hsa_signal_value_t value);
1741 * @deprecated Renamed as ::hsa_signal_and_scacquire.
1743 * @copydoc hsa_signal_and_scacquire
1745 void HSA_API HSA_DEPRECATED hsa_signal_and_acquire(
1746 hsa_signal_t signal,
1747 hsa_signal_value_t value);
1750 * @copydoc hsa_signal_and_scacq_screl
1752 void HSA_API hsa_signal_and_relaxed(
1753 hsa_signal_t signal,
1754 hsa_signal_value_t value);
1757 * @copydoc hsa_signal_and_scacq_screl
1759 void HSA_API hsa_signal_and_screlease(
1760 hsa_signal_t signal,
1761 hsa_signal_value_t value);
1765 * @deprecated Renamed as ::hsa_signal_and_screlease.
1767 * @copydoc hsa_signal_and_screlease
1769 void HSA_API HSA_DEPRECATED hsa_signal_and_release(
1770 hsa_signal_t signal,
1771 hsa_signal_value_t value);
1774 * @brief Atomically perform a bitwise OR operation between the value of a
1775 * signal and a given value.
1777 * @details If the value of the signal is changed, all the agents waiting on
1778 * @p signal for which @p value satisfies their wait condition are awakened.
1780 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1781 * behavior is undefined.
1783 * @param[in] value Value to OR with the value of the signal.
1785 void HSA_API hsa_signal_or_scacq_screl(
1786 hsa_signal_t signal,
1787 hsa_signal_value_t value);
1791 * @deprecated Renamed as ::hsa_signal_or_scacq_screl.
1793 * @copydoc hsa_signal_or_scacq_screl
1795 void HSA_API HSA_DEPRECATED hsa_signal_or_acq_rel(
1796 hsa_signal_t signal,
1797 hsa_signal_value_t value);
1800 * @copydoc hsa_signal_or_scacq_screl
1802 void HSA_API hsa_signal_or_scacquire(
1803 hsa_signal_t signal,
1804 hsa_signal_value_t value);
1807 * @deprecated Renamed as ::hsa_signal_or_scacquire.
1809 * @copydoc hsa_signal_or_scacquire
1811 void HSA_API HSA_DEPRECATED hsa_signal_or_acquire(
1812 hsa_signal_t signal,
1813 hsa_signal_value_t value);
1816 * @copydoc hsa_signal_or_scacq_screl
1818 void HSA_API hsa_signal_or_relaxed(
1819 hsa_signal_t signal,
1820 hsa_signal_value_t value);
1823 * @copydoc hsa_signal_or_scacq_screl
1825 void HSA_API hsa_signal_or_screlease(
1826 hsa_signal_t signal,
1827 hsa_signal_value_t value);
1830 * @deprecated Renamed as ::hsa_signal_or_screlease.
1832 * @copydoc hsa_signal_or_screlease
1834 void HSA_API HSA_DEPRECATED hsa_signal_or_release(
1835 hsa_signal_t signal,
1836 hsa_signal_value_t value);
1839 * @brief Atomically perform a bitwise XOR operation between the value of a
1840 * signal and a given value.
1842 * @details If the value of the signal is changed, all the agents waiting on
1843 * @p signal for which @p value satisfies their wait condition are awakened.
1845 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1846 * behavior is undefined.
1848 * @param[in] value Value to XOR with the value of the signal.
1851 void HSA_API hsa_signal_xor_scacq_screl(
1852 hsa_signal_t signal,
1853 hsa_signal_value_t value);
1857 * @deprecated Renamed as ::hsa_signal_xor_scacq_screl.
1859 * @copydoc hsa_signal_xor_scacq_screl
1861 void HSA_API HSA_DEPRECATED hsa_signal_xor_acq_rel(
1862 hsa_signal_t signal,
1863 hsa_signal_value_t value);
1866 * @copydoc hsa_signal_xor_scacq_screl
1868 void HSA_API hsa_signal_xor_scacquire(
1869 hsa_signal_t signal,
1870 hsa_signal_value_t value);
1873 * @deprecated Renamed as ::hsa_signal_xor_scacquire.
1875 * @copydoc hsa_signal_xor_scacquire
1877 void HSA_API HSA_DEPRECATED hsa_signal_xor_acquire(
1878 hsa_signal_t signal,
1879 hsa_signal_value_t value);
1882 * @copydoc hsa_signal_xor_scacq_screl
1884 void HSA_API hsa_signal_xor_relaxed(
1885 hsa_signal_t signal,
1886 hsa_signal_value_t value);
1889 * @copydoc hsa_signal_xor_scacq_screl
1891 void HSA_API hsa_signal_xor_screlease(
1892 hsa_signal_t signal,
1893 hsa_signal_value_t value);
1896 * @deprecated Renamed as ::hsa_signal_xor_screlease.
1898 * @copydoc hsa_signal_xor_screlease
1900 void HSA_API HSA_DEPRECATED hsa_signal_xor_release(
1901 hsa_signal_t signal,
1902 hsa_signal_value_t value);
1905 * @brief Wait condition operator.
1907 typedef enum {
1909 * The two operands are equal.
1911 HSA_SIGNAL_CONDITION_EQ = 0,
1913 * The two operands are not equal.
1915 HSA_SIGNAL_CONDITION_NE = 1,
1917 * The first operand is less than the second operand.
1919 HSA_SIGNAL_CONDITION_LT = 2,
1921 * The first operand is greater than or equal to the second operand.
1923 HSA_SIGNAL_CONDITION_GTE = 3
1924 } hsa_signal_condition_t;
1927 * @brief State of the application thread during a signal wait.
1929 typedef enum {
1931 * The application thread may be rescheduled while waiting on the signal.
1933 HSA_WAIT_STATE_BLOCKED = 0,
1935 * The application thread stays active while waiting on a signal.
1937 HSA_WAIT_STATE_ACTIVE = 1
1938 } hsa_wait_state_t;
1942 * @brief Wait until a signal value satisfies a specified condition, or a
1943 * certain amount of time has elapsed.
1945 * @details A wait operation can spuriously resume at any time sooner than the
1946 * timeout (for example, due to system or other external factors) even when the
1947 * condition has not been met.
1949 * The function is guaranteed to return if the signal value satisfies the
1950 * condition at some point in time during the wait, but the value returned to
1951 * the application might not satisfy the condition. The application must ensure
1952 * that signals are used in such way that wait wakeup conditions are not
1953 * invalidated before dependent threads have woken up.
1955 * When the wait operation internally loads the value of the passed signal, it
1956 * uses the memory order indicated in the function name.
1958 * @param[in] signal Signal.
1960 * @param[in] condition Condition used to compare the signal value with @p
1961 * compare_value.
1963 * @param[in] compare_value Value to compare with.
1965 * @param[in] timeout_hint Maximum duration of the wait. Specified in the same
1966 * unit as the system timestamp. The operation might block for a shorter or
1967 * longer time even if the condition is not met. A value of UINT64_MAX indicates
1968 * no maximum.
1970 * @param[in] wait_state_hint Hint used by the application to indicate the
1971 * preferred waiting state. The actual waiting state is ultimately decided by
1972 * HSA runtime and may not match the provided hint. A value of
1973 * ::HSA_WAIT_STATE_ACTIVE may improve the latency of response to a signal
1974 * update by avoiding rescheduling overhead.
1976 * @return Observed value of the signal, which might not satisfy the specified
1977 * condition.
1980 hsa_signal_value_t HSA_API hsa_signal_wait_scacquire(
1981 hsa_signal_t signal,
1982 hsa_signal_condition_t condition,
1983 hsa_signal_value_t compare_value,
1984 uint64_t timeout_hint,
1985 hsa_wait_state_t wait_state_hint);
1988 * @copydoc hsa_signal_wait_scacquire
1990 hsa_signal_value_t HSA_API hsa_signal_wait_relaxed(
1991 hsa_signal_t signal,
1992 hsa_signal_condition_t condition,
1993 hsa_signal_value_t compare_value,
1994 uint64_t timeout_hint,
1995 hsa_wait_state_t wait_state_hint);
1998 * @deprecated Renamed as ::hsa_signal_wait_scacquire.
2000 * @copydoc hsa_signal_wait_scacquire
2002 hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_wait_acquire(
2003 hsa_signal_t signal,
2004 hsa_signal_condition_t condition,
2005 hsa_signal_value_t compare_value,
2006 uint64_t timeout_hint,
2007 hsa_wait_state_t wait_state_hint);
2010 * @brief Group of signals.
2012 typedef struct hsa_signal_group_s {
2014 * Opaque handle. Two handles reference the same object of the enclosing type
2015 * if and only if they are equal.
2017 uint64_t handle;
2018 } hsa_signal_group_t;
2021 * @brief Create a signal group.
2023 * @param[in] num_signals Number of elements in @p signals. Must not be 0.
2025 * @param[in] signals List of signals in the group. The list must not contain
2026 * any repeated elements. Must not be NULL.
2028 * @param[in] num_consumers Number of elements in @p consumers. Must not be 0.
2030 * @param[in] consumers List of agents that might consume (wait on) the signal
2031 * group. The list must not contain repeated elements, and must be a subset of
2032 * the set of agents that are allowed to wait on all the signals in the
2033 * group. If an agent not listed in @p consumers waits on the returned group,
2034 * the behavior is undefined. The memory associated with @p consumers can be
2035 * reused or freed after the function returns. Must not be NULL.
2037 * @param[out] signal_group Pointer to newly created signal group. Must not be
2038 * NULL.
2040 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2042 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2043 * initialized.
2045 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
2046 * the required resources.
2048 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_signals is 0, @p signals
2049 * is NULL, @p num_consumers is 0, @p consumers is NULL, or @p signal_group is
2050 * NULL.
2052 hsa_status_t HSA_API hsa_signal_group_create(
2053 uint32_t num_signals,
2054 const hsa_signal_t *signals,
2055 uint32_t num_consumers,
2056 const hsa_agent_t *consumers,
2057 hsa_signal_group_t *signal_group);
2060 * @brief Destroy a signal group previous created by ::hsa_signal_group_create.
2062 * @param[in] signal_group Signal group.
2064 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2066 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2067 * initialized.
2069 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP @p signal_group is invalid.
2071 hsa_status_t HSA_API hsa_signal_group_destroy(
2072 hsa_signal_group_t signal_group);
2075 * @brief Wait until the value of at least one of the signals in a signal group
2076 * satisfies its associated condition.
2078 * @details The function is guaranteed to return if the value of at least one of
2079 * the signals in the group satisfies its associated condition at some point in
2080 * time during the wait, but the signal value returned to the application may no
2081 * longer satisfy the condition. The application must ensure that signals in the
2082 * group are used in such way that wait wakeup conditions are not invalidated
2083 * before dependent threads have woken up.
2085 * When this operation internally loads the value of the passed signal, it uses
2086 * the memory order indicated in the function name.
2088 * @param[in] signal_group Signal group.
2090 * @param[in] conditions List of conditions. Each condition, and the value at
2091 * the same index in @p compare_values, is used to compare the value of the
2092 * signal at that index in @p signal_group (the signal passed by the application
2093 * to ::hsa_signal_group_create at that particular index). The size of @p
2094 * conditions must not be smaller than the number of signals in @p signal_group;
2095 * any extra elements are ignored. Must not be NULL.
2097 * @param[in] compare_values List of comparison values. The size of @p
2098 * compare_values must not be smaller than the number of signals in @p
2099 * signal_group; any extra elements are ignored. Must not be NULL.
2101 * @param[in] wait_state_hint Hint used by the application to indicate the
2102 * preferred waiting state. The actual waiting state is decided by the HSA runtime
2103 * and may not match the provided hint. A value of ::HSA_WAIT_STATE_ACTIVE may
2104 * improve the latency of response to a signal update by avoiding rescheduling
2105 * overhead.
2107 * @param[out] signal Signal in the group that satisfied the associated
2108 * condition. If several signals satisfied their condition, the function can
2109 * return any of those signals. Must not be NULL.
2111 * @param[out] value Observed value for @p signal, which might no longer satisfy
2112 * the specified condition. Must not be NULL.
2114 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2116 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP @p signal_group is invalid.
2118 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p conditions is NULL, @p
2119 * compare_values is NULL, @p signal is NULL, or @p value is NULL.
2121 hsa_status_t HSA_API hsa_signal_group_wait_any_scacquire(
2122 hsa_signal_group_t signal_group,
2123 const hsa_signal_condition_t *conditions,
2124 const hsa_signal_value_t *compare_values,
2125 hsa_wait_state_t wait_state_hint,
2126 hsa_signal_t *signal,
2127 hsa_signal_value_t *value);
2130 * @copydoc hsa_signal_group_wait_any_scacquire
2132 hsa_status_t HSA_API hsa_signal_group_wait_any_relaxed(
2133 hsa_signal_group_t signal_group,
2134 const hsa_signal_condition_t *conditions,
2135 const hsa_signal_value_t *compare_values,
2136 hsa_wait_state_t wait_state_hint,
2137 hsa_signal_t *signal,
2138 hsa_signal_value_t *value);
2140 /** @} */
2142 /** \defgroup memory Memory
2143 * @{
2147 * @brief A memory region represents a block of virtual memory with certain
2148 * properties. For example, the HSA runtime represents fine-grained memory in
2149 * the global segment using a region. A region might be associated with more
2150 * than one agent.
2152 typedef struct hsa_region_s {
2154 * Opaque handle. Two handles reference the same object of the enclosing type
2155 * if and only if they are equal.
2157 uint64_t handle;
2158 } hsa_region_t;
2160 /** @} */
2163 /** \defgroup queue Queues
2164 * @{
2168 * @brief Queue type. Intended to be used for dynamic queue protocol
2169 * determination.
2171 typedef enum {
2173 * Queue supports multiple producers. Use of multiproducer queue mechanics is
2174 * required.
2176 HSA_QUEUE_TYPE_MULTI = 0,
2178 * Queue only supports a single producer. In some scenarios, the application
2179 * may want to limit the submission of AQL packets to a single agent. Queues
2180 * that support a single producer may be more efficient than queues supporting
2181 * multiple producers. Use of multiproducer queue mechanics is not supported.
2183 HSA_QUEUE_TYPE_SINGLE = 1,
2185 * Queue supports multiple producers and cooperative dispatches. Cooperative
2186 * dispatches are able to use GWS synchronization. Queues of this type may be
2187 * limited in number. The runtime may return the same queue to serve multiple
2188 * ::hsa_queue_create calls when this type is given. Callers must inspect the
2189 * returned queue to discover queue size. Queues of this type are reference
2190 * counted and require a matching number of ::hsa_queue_destroy calls to
2191 * release. Use of multiproducer queue mechanics is required. See
2192 * ::HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES to query agent support for this
2193 * type.
2195 HSA_QUEUE_TYPE_COOPERATIVE = 2
2196 } hsa_queue_type_t;
2199 * @brief A fixed-size type used to represent ::hsa_queue_type_t constants.
2201 typedef uint32_t hsa_queue_type32_t;
2204 * @brief Queue features.
2206 typedef enum {
2208 * Queue supports kernel dispatch packets.
2210 HSA_QUEUE_FEATURE_KERNEL_DISPATCH = 1,
2213 * Queue supports agent dispatch packets.
2215 HSA_QUEUE_FEATURE_AGENT_DISPATCH = 2
2216 } hsa_queue_feature_t;
2219 * @brief User mode queue.
2221 * @details The queue structure is read-only and allocated by the HSA runtime,
2222 * but agents can directly modify the contents of the buffer pointed by @a
2223 * base_address, or use HSA runtime APIs to access the doorbell signal.
2226 typedef struct hsa_queue_s {
2228 * Queue type.
2230 hsa_queue_type32_t type;
2233 * Queue features mask. This is a bit-field of ::hsa_queue_feature_t
2234 * values. Applications should ignore any unknown set bits.
2236 uint32_t features;
2238 #ifdef HSA_LARGE_MODEL
2239 void* base_address;
2240 #elif defined HSA_LITTLE_ENDIAN
2242 * Starting address of the HSA runtime-allocated buffer used to store the AQL
2243 * packets. Must be aligned to the size of an AQL packet.
2245 void* base_address;
2247 * Reserved. Must be 0.
2249 uint32_t reserved0;
2250 #else
2251 uint32_t reserved0;
2252 void* base_address;
2253 #endif
2256 * Signal object used by the application to indicate the ID of a packet that
2257 * is ready to be processed. The HSA runtime manages the doorbell signal. If
2258 * the application tries to replace or destroy this signal, the behavior is
2259 * undefined.
2261 * If @a type is ::HSA_QUEUE_TYPE_SINGLE, the doorbell signal value must be
2262 * updated in a monotonically increasing fashion. If @a type is
2263 * ::HSA_QUEUE_TYPE_MULTI, the doorbell signal value can be updated with any
2264 * value.
2266 hsa_signal_t doorbell_signal;
2269 * Maximum number of packets the queue can hold. Must be a power of 2.
2271 uint32_t size;
2273 * Reserved. Must be 0.
2275 uint32_t reserved1;
2277 * Queue identifier, which is unique over the lifetime of the application.
2279 uint64_t id;
2281 } hsa_queue_t;
2284 * @brief Create a user mode queue.
2286 * @details The HSA runtime creates the queue structure, the underlying packet
2287 * buffer, the completion signal, and the write and read indexes. The initial
2288 * value of the write and read indexes is 0. The type of every packet in the
2289 * buffer is initialized to ::HSA_PACKET_TYPE_INVALID.
2291 * The application should only rely on the error code returned to determine if
2292 * the queue is valid.
2294 * @param[in] agent Agent where to create the queue.
2296 * @param[in] size Number of packets the queue is expected to
2297 * hold. Must be a power of 2 between 1 and the value of
2298 * ::HSA_AGENT_INFO_QUEUE_MAX_SIZE in @p agent. The size of the newly
2299 * created queue is the maximum of @p size and the value of
2300 * ::HSA_AGENT_INFO_QUEUE_MIN_SIZE in @p agent.
2302 * @param[in] type Type of the queue, a bitwise OR of hsa_queue_type_t values.
2303 * If the value of ::HSA_AGENT_INFO_QUEUE_TYPE in @p agent is ::HSA_QUEUE_TYPE_SINGLE,
2304 * then @p type must also be ::HSA_QUEUE_TYPE_SINGLE.
2306 * @param[in] callback Callback invoked by the HSA runtime for every
2307 * asynchronous event related to the newly created queue. May be NULL. The HSA
2308 * runtime passes three arguments to the callback: a code identifying the event
2309 * that triggered the invocation, a pointer to the queue where the event
2310 * originated, and the application data.
2312 * @param[in] data Application data that is passed to @p callback on every
2313 * iteration. May be NULL.
2315 * @param[in] private_segment_size Hint indicating the maximum
2316 * expected private segment usage per work-item, in bytes. There may
2317 * be performance degradation if the application places a kernel
2318 * dispatch packet in the queue and the corresponding private segment
2319 * usage exceeds @p private_segment_size. If the application does not
2320 * want to specify any particular value for this argument, @p
2321 * private_segment_size must be UINT32_MAX. If the queue does not
2322 * support kernel dispatch packets, this argument is ignored.
2324 * @param[in] group_segment_size Hint indicating the maximum expected
2325 * group segment usage per work-group, in bytes. There may be
2326 * performance degradation if the application places a kernel dispatch
2327 * packet in the queue and the corresponding group segment usage
2328 * exceeds @p group_segment_size. If the application does not want to
2329 * specify any particular value for this argument, @p
2330 * group_segment_size must be UINT32_MAX. If the queue does not
2331 * support kernel dispatch packets, this argument is ignored.
2333 * @param[out] queue Memory location where the HSA runtime stores a pointer to
2334 * the newly created queue.
2336 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2338 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2339 * initialized.
2341 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
2342 * the required resources.
2344 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
2346 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE_CREATION @p agent does not
2347 * support queues of the given type.
2349 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is not a power of two,
2350 * @p size is 0, @p type is an invalid queue type, or @p queue is NULL.
2353 hsa_status_t HSA_API hsa_queue_create(
2354 hsa_agent_t agent,
2355 uint32_t size,
2356 hsa_queue_type32_t type,
2357 void (*callback)(hsa_status_t status, hsa_queue_t *source, void *data),
2358 void *data,
2359 uint32_t private_segment_size,
2360 uint32_t group_segment_size,
2361 hsa_queue_t **queue);
2364 * @brief Create a queue for which the application or a kernel is responsible
2365 * for processing the AQL packets.
2367 * @details The application can use this function to create queues where AQL
2368 * packets are not parsed by the packet processor associated with an agent,
2369 * but rather by a unit of execution running on that agent (for example, a
2370 * thread in the host application).
2372 * The application is responsible for ensuring that all the producers and
2373 * consumers of the resulting queue can access the provided doorbell signal
2374 * and memory region. The application is also responsible for ensuring that the
2375 * unit of execution processing the queue packets supports the indicated
2376 * features (AQL packet types).
2378 * When the queue is created, the HSA runtime allocates the packet buffer using
2379 * @p region, and the write and read indexes. The initial value of the write and
2380 * read indexes is 0, and the type of every packet in the buffer is initialized
2381 * to ::HSA_PACKET_TYPE_INVALID. The value of the @e size, @e type, @e features,
2382 * and @e doorbell_signal fields in the returned queue match the values passed
2383 * by the application.
2385 * @param[in] region Memory region that the HSA runtime should use to allocate
2386 * the AQL packet buffer and any other queue metadata.
2388 * @param[in] size Number of packets the queue is expected to hold. Must be a
2389 * power of 2 greater than 0.
2391 * @param[in] type Queue type.
2393 * @param[in] features Supported queue features. This is a bit-field of
2394 * ::hsa_queue_feature_t values.
2396 * @param[in] doorbell_signal Doorbell signal that the HSA runtime must
2397 * associate with the returned queue. The signal handle must not be 0.
2399 * @param[out] queue Memory location where the HSA runtime stores a pointer to
2400 * the newly created queue. The application should not rely on the value
2401 * returned for this argument but only in the status code to determine if the
2402 * queue is valid. Must not be NULL.
2404 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2406 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2407 * initialized.
2409 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
2410 * the required resources.
2412 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is not a power of two, @p
2413 * size is 0, @p type is an invalid queue type, the doorbell signal handle is
2414 * 0, or @p queue is NULL.
2417 hsa_status_t HSA_API hsa_soft_queue_create(
2418 hsa_region_t region,
2419 uint32_t size,
2420 hsa_queue_type32_t type,
2421 uint32_t features,
2422 hsa_signal_t doorbell_signal,
2423 hsa_queue_t **queue);
2426 * @brief Destroy a user mode queue.
2428 * @details When a queue is destroyed, the state of the AQL packets that have
2429 * not been yet fully processed (their completion phase has not finished)
2430 * becomes undefined. It is the responsibility of the application to ensure that
2431 * all pending queue operations are finished if their results are required.
2433 * The resources allocated by the HSA runtime during queue creation (queue
2434 * structure, ring buffer, doorbell signal) are released. The queue should not
2435 * be accessed after being destroyed.
2437 * @param[in] queue Pointer to a queue created using ::hsa_queue_create.
2439 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2441 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2442 * initialized.
2444 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
2446 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
2448 hsa_status_t HSA_API hsa_queue_destroy(
2449 hsa_queue_t *queue);
2452 * @brief Inactivate a queue.
2454 * @details Inactivating the queue aborts any pending executions and prevent any
2455 * new packets from being processed. Any more packets written to the queue once
2456 * it is inactivated will be ignored by the packet processor.
2458 * @param[in] queue Pointer to a queue.
2460 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2462 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2463 * initialized.
2465 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
2467 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
2469 hsa_status_t HSA_API hsa_queue_inactivate(
2470 hsa_queue_t *queue);
2473 * @deprecated Renamed as ::hsa_queue_load_read_index_scacquire.
2475 * @copydoc hsa_queue_load_read_index_scacquire
2477 uint64_t HSA_API HSA_DEPRECATED hsa_queue_load_read_index_acquire(
2478 const hsa_queue_t *queue);
2481 * @brief Atomically load the read index of a queue.
2483 * @param[in] queue Pointer to a queue.
2485 * @return Read index of the queue pointed by @p queue.
2487 uint64_t HSA_API hsa_queue_load_read_index_scacquire(
2488 const hsa_queue_t *queue);
2491 * @copydoc hsa_queue_load_read_index_scacquire
2493 uint64_t HSA_API hsa_queue_load_read_index_relaxed(
2494 const hsa_queue_t *queue);
2497 * @deprecated Renamed as ::hsa_queue_load_write_index_scacquire.
2499 * @copydoc hsa_queue_load_write_index_scacquire
2501 uint64_t HSA_API HSA_DEPRECATED hsa_queue_load_write_index_acquire(
2502 const hsa_queue_t *queue);
2505 * @brief Atomically load the write index of a queue.
2507 * @param[in] queue Pointer to a queue.
2509 * @return Write index of the queue pointed by @p queue.
2511 uint64_t HSA_API hsa_queue_load_write_index_scacquire(
2512 const hsa_queue_t *queue);
2515 * @copydoc hsa_queue_load_write_index_scacquire
2517 uint64_t HSA_API hsa_queue_load_write_index_relaxed(
2518 const hsa_queue_t *queue);
2521 * @brief Atomically set the write index of a queue.
2523 * @details It is recommended that the application uses this function to update
2524 * the write index when there is a single agent submitting work to the queue
2525 * (the queue type is ::HSA_QUEUE_TYPE_SINGLE).
2527 * @param[in] queue Pointer to a queue.
2529 * @param[in] value Value to assign to the write index.
2532 void HSA_API hsa_queue_store_write_index_relaxed(
2533 const hsa_queue_t *queue,
2534 uint64_t value);
2537 * @deprecated Renamed as ::hsa_queue_store_write_index_screlease.
2539 * @copydoc hsa_queue_store_write_index_screlease
2541 void HSA_API HSA_DEPRECATED hsa_queue_store_write_index_release(
2542 const hsa_queue_t *queue,
2543 uint64_t value);
2546 * @copydoc hsa_queue_store_write_index_relaxed
2548 void HSA_API hsa_queue_store_write_index_screlease(
2549 const hsa_queue_t *queue,
2550 uint64_t value);
2553 * @deprecated Renamed as ::hsa_queue_cas_write_index_scacq_screl.
2555 * @copydoc hsa_queue_cas_write_index_scacq_screl
2557 uint64_t HSA_API HSA_DEPRECATED hsa_queue_cas_write_index_acq_rel(
2558 const hsa_queue_t *queue,
2559 uint64_t expected,
2560 uint64_t value);
2563 * @brief Atomically set the write index of a queue if the observed value is
2564 * equal to the expected value. The application can inspect the returned value
2565 * to determine if the replacement was done.
2567 * @param[in] queue Pointer to a queue.
2569 * @param[in] expected Expected value.
2571 * @param[in] value Value to assign to the write index if @p expected matches
2572 * the observed write index. Must be greater than @p expected.
2574 * @return Previous value of the write index.
2576 uint64_t HSA_API hsa_queue_cas_write_index_scacq_screl(
2577 const hsa_queue_t *queue,
2578 uint64_t expected,
2579 uint64_t value);
2582 * @deprecated Renamed as ::hsa_queue_cas_write_index_scacquire.
2584 * @copydoc hsa_queue_cas_write_index_scacquire
2586 uint64_t HSA_API HSA_DEPRECATED hsa_queue_cas_write_index_acquire(
2587 const hsa_queue_t *queue,
2588 uint64_t expected,
2589 uint64_t value);
2592 * @copydoc hsa_queue_cas_write_index_scacq_screl
2594 uint64_t HSA_API hsa_queue_cas_write_index_scacquire(
2595 const hsa_queue_t *queue,
2596 uint64_t expected,
2597 uint64_t value);
2600 * @copydoc hsa_queue_cas_write_index_scacq_screl
2602 uint64_t HSA_API hsa_queue_cas_write_index_relaxed(
2603 const hsa_queue_t *queue,
2604 uint64_t expected,
2605 uint64_t value);
2608 * @deprecated Renamed as ::hsa_queue_cas_write_index_screlease.
2610 * @copydoc hsa_queue_cas_write_index_screlease
2612 uint64_t HSA_API HSA_DEPRECATED hsa_queue_cas_write_index_release(
2613 const hsa_queue_t *queue,
2614 uint64_t expected,
2615 uint64_t value);
2618 * @copydoc hsa_queue_cas_write_index_scacq_screl
2620 uint64_t HSA_API hsa_queue_cas_write_index_screlease(
2621 const hsa_queue_t *queue,
2622 uint64_t expected,
2623 uint64_t value);
2626 * @deprecated Renamed as ::hsa_queue_add_write_index_scacq_screl.
2628 * @copydoc hsa_queue_add_write_index_scacq_screl
2630 uint64_t HSA_API HSA_DEPRECATED hsa_queue_add_write_index_acq_rel(
2631 const hsa_queue_t *queue,
2632 uint64_t value);
2635 * @brief Atomically increment the write index of a queue by an offset.
2637 * @param[in] queue Pointer to a queue.
2639 * @param[in] value Value to add to the write index.
2641 * @return Previous value of the write index.
2643 uint64_t HSA_API hsa_queue_add_write_index_scacq_screl(
2644 const hsa_queue_t *queue,
2645 uint64_t value);
2648 * @deprecated Renamed as ::hsa_queue_add_write_index_scacquire.
2650 * @copydoc hsa_queue_add_write_index_scacquire
2652 uint64_t HSA_API HSA_DEPRECATED hsa_queue_add_write_index_acquire(
2653 const hsa_queue_t *queue,
2654 uint64_t value);
2657 * @copydoc hsa_queue_add_write_index_scacq_screl
2659 uint64_t HSA_API hsa_queue_add_write_index_scacquire(
2660 const hsa_queue_t *queue,
2661 uint64_t value);
2664 * @copydoc hsa_queue_add_write_index_scacq_screl
2666 uint64_t HSA_API hsa_queue_add_write_index_relaxed(
2667 const hsa_queue_t *queue,
2668 uint64_t value);
2671 * @deprecated Renamed as ::hsa_queue_add_write_index_screlease.
2673 * @copydoc hsa_queue_add_write_index_screlease
2675 uint64_t HSA_API HSA_DEPRECATED hsa_queue_add_write_index_release(
2676 const hsa_queue_t *queue,
2677 uint64_t value);
2680 * @copydoc hsa_queue_add_write_index_scacq_screl
2682 uint64_t HSA_API hsa_queue_add_write_index_screlease(
2683 const hsa_queue_t *queue,
2684 uint64_t value);
2687 * @brief Atomically set the read index of a queue.
2689 * @details Modifications of the read index are not allowed and result in
2690 * undefined behavior if the queue is associated with an agent for which
2691 * only the corresponding packet processor is permitted to update the read
2692 * index.
2694 * @param[in] queue Pointer to a queue.
2696 * @param[in] value Value to assign to the read index.
2699 void HSA_API hsa_queue_store_read_index_relaxed(
2700 const hsa_queue_t *queue,
2701 uint64_t value);
2704 * @deprecated Renamed as ::hsa_queue_store_read_index_screlease.
2706 * @copydoc hsa_queue_store_read_index_screlease
2708 void HSA_API HSA_DEPRECATED hsa_queue_store_read_index_release(
2709 const hsa_queue_t *queue,
2710 uint64_t value);
2713 * @copydoc hsa_queue_store_read_index_relaxed
2715 void HSA_API hsa_queue_store_read_index_screlease(
2716 const hsa_queue_t *queue,
2717 uint64_t value);
2718 /** @} */
2721 /** \defgroup aql Architected Queuing Language
2722 * @{
2726 * @brief Packet type.
2728 typedef enum {
2730 * Vendor-specific packet.
2732 HSA_PACKET_TYPE_VENDOR_SPECIFIC = 0,
2734 * The packet has been processed in the past, but has not been reassigned to
2735 * the packet processor. A packet processor must not process a packet of this
2736 * type. All queues support this packet type.
2738 HSA_PACKET_TYPE_INVALID = 1,
2740 * Packet used by agents for dispatching jobs to kernel agents. Not all
2741 * queues support packets of this type (see ::hsa_queue_feature_t).
2743 HSA_PACKET_TYPE_KERNEL_DISPATCH = 2,
2745 * Packet used by agents to delay processing of subsequent packets, and to
2746 * express complex dependencies between multiple packets. All queues support
2747 * this packet type.
2749 HSA_PACKET_TYPE_BARRIER_AND = 3,
2751 * Packet used by agents for dispatching jobs to agents. Not all
2752 * queues support packets of this type (see ::hsa_queue_feature_t).
2754 HSA_PACKET_TYPE_AGENT_DISPATCH = 4,
2756 * Packet used by agents to delay processing of subsequent packets, and to
2757 * express complex dependencies between multiple packets. All queues support
2758 * this packet type.
2760 HSA_PACKET_TYPE_BARRIER_OR = 5
2761 } hsa_packet_type_t;
2764 * @brief Scope of the memory fence operation associated with a packet.
2766 typedef enum {
2768 * No scope (no fence is applied). The packet relies on external fences to
2769 * ensure visibility of memory updates.
2771 HSA_FENCE_SCOPE_NONE = 0,
2773 * The fence is applied with agent scope for the global segment.
2775 HSA_FENCE_SCOPE_AGENT = 1,
2777 * The fence is applied across both agent and system scope for the global
2778 * segment.
2780 HSA_FENCE_SCOPE_SYSTEM = 2
2781 } hsa_fence_scope_t;
2784 * @brief Sub-fields of the @a header field that is present in any AQL
2785 * packet. The offset (with respect to the address of @a header) of a sub-field
2786 * is identical to its enumeration constant. The width of each sub-field is
2787 * determined by the corresponding value in ::hsa_packet_header_width_t. The
2788 * offset and the width are expressed in bits.
2790 typedef enum {
2792 * Packet type. The value of this sub-field must be one of
2793 * ::hsa_packet_type_t. If the type is ::HSA_PACKET_TYPE_VENDOR_SPECIFIC, the
2794 * packet layout is vendor-specific.
2796 HSA_PACKET_HEADER_TYPE = 0,
2798 * Barrier bit. If the barrier bit is set, the processing of the current
2799 * packet only launches when all preceding packets (within the same queue) are
2800 * complete.
2802 HSA_PACKET_HEADER_BARRIER = 8,
2804 * Acquire fence scope. The value of this sub-field determines the scope and
2805 * type of the memory fence operation applied before the packet enters the
2806 * active phase. An acquire fence ensures that any subsequent global segment
2807 * or image loads by any unit of execution that belongs to a dispatch that has
2808 * not yet entered the active phase on any queue of the same kernel agent,
2809 * sees any data previously released at the scopes specified by the acquire
2810 * fence. The value of this sub-field must be one of ::hsa_fence_scope_t.
2812 HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE = 9,
2814 * @deprecated Renamed as ::HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE.
2816 HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE = 9,
2818 * Release fence scope, The value of this sub-field determines the scope and
2819 * type of the memory fence operation applied after kernel completion but
2820 * before the packet is completed. A release fence makes any global segment or
2821 * image data that was stored by any unit of execution that belonged to a
2822 * dispatch that has completed the active phase on any queue of the same
2823 * kernel agent visible in all the scopes specified by the release fence. The
2824 * value of this sub-field must be one of ::hsa_fence_scope_t.
2826 HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE = 11,
2828 * @deprecated Renamed as ::HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE.
2830 HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE = 11
2831 } hsa_packet_header_t;
2834 * @brief Width (in bits) of the sub-fields in ::hsa_packet_header_t.
2836 typedef enum {
2837 HSA_PACKET_HEADER_WIDTH_TYPE = 8,
2838 HSA_PACKET_HEADER_WIDTH_BARRIER = 1,
2839 HSA_PACKET_HEADER_WIDTH_SCACQUIRE_FENCE_SCOPE = 2,
2841 * @deprecated Use HSA_PACKET_HEADER_WIDTH_SCACQUIRE_FENCE_SCOPE.
2843 HSA_PACKET_HEADER_WIDTH_ACQUIRE_FENCE_SCOPE = 2,
2844 HSA_PACKET_HEADER_WIDTH_SCRELEASE_FENCE_SCOPE = 2,
2846 * @deprecated Use HSA_PACKET_HEADER_WIDTH_SCRELEASE_FENCE_SCOPE.
2848 HSA_PACKET_HEADER_WIDTH_RELEASE_FENCE_SCOPE = 2
2849 } hsa_packet_header_width_t;
2852 * @brief Sub-fields of the kernel dispatch packet @a setup field. The offset
2853 * (with respect to the address of @a setup) of a sub-field is identical to its
2854 * enumeration constant. The width of each sub-field is determined by the
2855 * corresponding value in ::hsa_kernel_dispatch_packet_setup_width_t. The
2856 * offset and the width are expressed in bits.
2858 typedef enum {
2860 * Number of dimensions of the grid. Valid values are 1, 2, or 3.
2863 HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS = 0
2864 } hsa_kernel_dispatch_packet_setup_t;
2867 * @brief Width (in bits) of the sub-fields in
2868 * ::hsa_kernel_dispatch_packet_setup_t.
2870 typedef enum {
2871 HSA_KERNEL_DISPATCH_PACKET_SETUP_WIDTH_DIMENSIONS = 2
2872 } hsa_kernel_dispatch_packet_setup_width_t;
2875 * @brief AQL kernel dispatch packet
2877 typedef struct hsa_kernel_dispatch_packet_s {
2879 * Packet header. Used to configure multiple packet parameters such as the
2880 * packet type. The parameters are described by ::hsa_packet_header_t.
2882 uint16_t header;
2885 * Dispatch setup parameters. Used to configure kernel dispatch parameters
2886 * such as the number of dimensions in the grid. The parameters are described
2887 * by ::hsa_kernel_dispatch_packet_setup_t.
2889 uint16_t setup;
2892 * X dimension of work-group, in work-items. Must be greater than 0.
2894 uint16_t workgroup_size_x;
2897 * Y dimension of work-group, in work-items. Must be greater than
2898 * 0. If the grid has 1 dimension, the only valid value is 1.
2900 uint16_t workgroup_size_y;
2903 * Z dimension of work-group, in work-items. Must be greater than
2904 * 0. If the grid has 1 or 2 dimensions, the only valid value is 1.
2906 uint16_t workgroup_size_z;
2909 * Reserved. Must be 0.
2911 uint16_t reserved0;
2914 * X dimension of grid, in work-items. Must be greater than 0. Must
2915 * not be smaller than @a workgroup_size_x.
2917 uint32_t grid_size_x;
2920 * Y dimension of grid, in work-items. Must be greater than 0. If the grid has
2921 * 1 dimension, the only valid value is 1. Must not be smaller than @a
2922 * workgroup_size_y.
2924 uint32_t grid_size_y;
2927 * Z dimension of grid, in work-items. Must be greater than 0. If the grid has
2928 * 1 or 2 dimensions, the only valid value is 1. Must not be smaller than @a
2929 * workgroup_size_z.
2931 uint32_t grid_size_z;
2934 * Size in bytes of private memory allocation request (per work-item).
2936 uint32_t private_segment_size;
2939 * Size in bytes of group memory allocation request (per work-group). Must not
2940 * be less than the sum of the group memory used by the kernel (and the
2941 * functions it calls directly or indirectly) and the dynamically allocated
2942 * group segment variables.
2944 uint32_t group_segment_size;
2947 * Opaque handle to a code object that includes an implementation-defined
2948 * executable code for the kernel.
2950 uint64_t kernel_object;
2952 #ifdef HSA_LARGE_MODEL
2953 void* kernarg_address;
2954 #elif defined HSA_LITTLE_ENDIAN
2956 * Pointer to a buffer containing the kernel arguments. May be NULL.
2958 * The buffer must be allocated using ::hsa_memory_allocate, and must not be
2959 * modified once the kernel dispatch packet is enqueued until the dispatch has
2960 * completed execution.
2962 void* kernarg_address;
2964 * Reserved. Must be 0.
2966 uint32_t reserved1;
2967 #else
2968 uint32_t reserved1;
2969 void* kernarg_address;
2970 #endif
2973 * Reserved. Must be 0.
2975 uint64_t reserved2;
2978 * Signal used to indicate completion of the job. The application can use the
2979 * special signal handle 0 to indicate that no signal is used.
2981 hsa_signal_t completion_signal;
2983 } hsa_kernel_dispatch_packet_t;
2986 * @brief Agent dispatch packet.
2988 typedef struct hsa_agent_dispatch_packet_s {
2990 * Packet header. Used to configure multiple packet parameters such as the
2991 * packet type. The parameters are described by ::hsa_packet_header_t.
2993 uint16_t header;
2996 * Application-defined function to be performed by the destination agent.
2998 uint16_t type;
3001 * Reserved. Must be 0.
3003 uint32_t reserved0;
3005 #ifdef HSA_LARGE_MODEL
3006 void* return_address;
3007 #elif defined HSA_LITTLE_ENDIAN
3009 * Address where to store the function return values, if any.
3011 void* return_address;
3013 * Reserved. Must be 0.
3015 uint32_t reserved1;
3016 #else
3017 uint32_t reserved1;
3018 void* return_address;
3019 #endif
3022 * Function arguments.
3024 uint64_t arg[4];
3027 * Reserved. Must be 0.
3029 uint64_t reserved2;
3032 * Signal used to indicate completion of the job. The application can use the
3033 * special signal handle 0 to indicate that no signal is used.
3035 hsa_signal_t completion_signal;
3037 } hsa_agent_dispatch_packet_t;
3040 * @brief Barrier-AND packet.
3042 typedef struct hsa_barrier_and_packet_s {
3044 * Packet header. Used to configure multiple packet parameters such as the
3045 * packet type. The parameters are described by ::hsa_packet_header_t.
3047 uint16_t header;
3050 * Reserved. Must be 0.
3052 uint16_t reserved0;
3055 * Reserved. Must be 0.
3057 uint32_t reserved1;
3060 * Array of dependent signal objects. Signals with a handle value of 0 are
3061 * allowed and are interpreted by the packet processor as satisfied
3062 * dependencies.
3064 hsa_signal_t dep_signal[5];
3067 * Reserved. Must be 0.
3069 uint64_t reserved2;
3072 * Signal used to indicate completion of the job. The application can use the
3073 * special signal handle 0 to indicate that no signal is used.
3075 hsa_signal_t completion_signal;
3077 } hsa_barrier_and_packet_t;
3080 * @brief Barrier-OR packet.
3082 typedef struct hsa_barrier_or_packet_s {
3084 * Packet header. Used to configure multiple packet parameters such as the
3085 * packet type. The parameters are described by ::hsa_packet_header_t.
3087 uint16_t header;
3090 * Reserved. Must be 0.
3092 uint16_t reserved0;
3095 * Reserved. Must be 0.
3097 uint32_t reserved1;
3100 * Array of dependent signal objects. Signals with a handle value of 0 are
3101 * allowed and are interpreted by the packet processor as dependencies not
3102 * satisfied.
3104 hsa_signal_t dep_signal[5];
3107 * Reserved. Must be 0.
3109 uint64_t reserved2;
3112 * Signal used to indicate completion of the job. The application can use the
3113 * special signal handle 0 to indicate that no signal is used.
3115 hsa_signal_t completion_signal;
3117 } hsa_barrier_or_packet_t;
3119 /** @} */
3121 /** \addtogroup memory Memory
3122 * @{
3126 * @brief Memory segments associated with a region.
3128 typedef enum {
3130 * Global segment. Used to hold data that is shared by all agents.
3132 HSA_REGION_SEGMENT_GLOBAL = 0,
3134 * Read-only segment. Used to hold data that remains constant during the
3135 * execution of a kernel.
3137 HSA_REGION_SEGMENT_READONLY = 1,
3139 * Private segment. Used to hold data that is local to a single work-item.
3141 HSA_REGION_SEGMENT_PRIVATE = 2,
3143 * Group segment. Used to hold data that is shared by the work-items of a
3144 * work-group.
3146 HSA_REGION_SEGMENT_GROUP = 3,
3148 * Kernarg segment. Used to store kernel arguments.
3150 HSA_REGION_SEGMENT_KERNARG = 4
3151 } hsa_region_segment_t;
3154 * @brief Global region flags.
3156 typedef enum {
3158 * The application can use memory in the region to store kernel arguments, and
3159 * provide the values for the kernarg segment of a kernel dispatch. If this
3160 * flag is set, then ::HSA_REGION_GLOBAL_FLAG_FINE_GRAINED must be set.
3162 HSA_REGION_GLOBAL_FLAG_KERNARG = 1,
3164 * Updates to memory in this region are immediately visible to all the
3165 * agents under the terms of the HSA memory model. If this
3166 * flag is set, then ::HSA_REGION_GLOBAL_FLAG_COARSE_GRAINED must not be set.
3168 HSA_REGION_GLOBAL_FLAG_FINE_GRAINED = 2,
3170 * Updates to memory in this region can be performed by a single agent at
3171 * a time. If a different agent in the system is allowed to access the
3172 * region, the application must explicitely invoke ::hsa_memory_assign_agent
3173 * in order to transfer ownership to that agent for a particular buffer.
3175 HSA_REGION_GLOBAL_FLAG_COARSE_GRAINED = 4
3176 } hsa_region_global_flag_t;
3179 * @brief Attributes of a memory region.
3181 typedef enum {
3183 * Segment where memory in the region can be used. The type of this
3184 * attribute is ::hsa_region_segment_t.
3186 HSA_REGION_INFO_SEGMENT = 0,
3188 * Flag mask. The value of this attribute is undefined if the value of
3189 * ::HSA_REGION_INFO_SEGMENT is not ::HSA_REGION_SEGMENT_GLOBAL. The type of
3190 * this attribute is uint32_t, a bit-field of ::hsa_region_global_flag_t
3191 * values.
3193 HSA_REGION_INFO_GLOBAL_FLAGS = 1,
3195 * Size of this region, in bytes. The type of this attribute is size_t.
3197 HSA_REGION_INFO_SIZE = 2,
3199 * Maximum allocation size in this region, in bytes. Must not exceed the value
3200 * of ::HSA_REGION_INFO_SIZE. The type of this attribute is size_t.
3202 * If the region is in the global or readonly segments, this is the maximum
3203 * size that the application can pass to ::hsa_memory_allocate.
3205 * If the region is in the group segment, this is the maximum size (per
3206 * work-group) that can be requested for a given kernel dispatch. If the
3207 * region is in the private segment, this is the maximum size (per work-item)
3208 * that can be requested for a specific kernel dispatch, and must be at least
3209 * 256 bytes.
3211 HSA_REGION_INFO_ALLOC_MAX_SIZE = 4,
3213 * Maximum size (per work-group) of private memory that can be requested for a
3214 * specific kernel dispatch. Must be at least 65536 bytes. The type of this
3215 * attribute is uint32_t. The value of this attribute is undefined if the
3216 * region is not in the private segment.
3218 HSA_REGION_INFO_ALLOC_MAX_PRIVATE_WORKGROUP_SIZE = 8,
3220 * Indicates whether memory in this region can be allocated using
3221 * ::hsa_memory_allocate. The type of this attribute is bool.
3223 * The value of this flag is always false for regions in the group and private
3224 * segments.
3226 HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED = 5,
3228 * Allocation granularity of buffers allocated by ::hsa_memory_allocate in
3229 * this region. The size of a buffer allocated in this region is a multiple of
3230 * the value of this attribute. The value of this attribute is only defined if
3231 * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED is true for this region. The type
3232 * of this attribute is size_t.
3234 HSA_REGION_INFO_RUNTIME_ALLOC_GRANULE = 6,
3236 * Alignment of buffers allocated by ::hsa_memory_allocate in this region. The
3237 * value of this attribute is only defined if
3238 * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED is true for this region, and must be
3239 * a power of 2. The type of this attribute is size_t.
3241 HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT = 7
3242 } hsa_region_info_t;
3245 * @brief Get the current value of an attribute of a region.
3247 * @param[in] region A valid region.
3249 * @param[in] attribute Attribute to query.
3251 * @param[out] value Pointer to a application-allocated buffer where to store
3252 * the value of the attribute. If the buffer passed by the application is not
3253 * large enough to hold the value of @p attribute, the behavior is undefined.
3255 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3257 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3258 * initialized.
3260 * @retval ::HSA_STATUS_ERROR_INVALID_REGION The region is invalid.
3262 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3263 * region attribute, or @p value is NULL.
3265 hsa_status_t HSA_API hsa_region_get_info(
3266 hsa_region_t region,
3267 hsa_region_info_t attribute,
3268 void* value);
3271 * @brief Iterate over the memory regions associated with a given agent, and
3272 * invoke an application-defined callback on every iteration.
3274 * @param[in] agent A valid agent.
3276 * @param[in] callback Callback to be invoked once per region that is
3277 * accessible from the agent. The HSA runtime passes two arguments to the
3278 * callback, the region and the application data. If @p callback returns a
3279 * status other than ::HSA_STATUS_SUCCESS for a particular iteration, the
3280 * traversal stops and ::hsa_agent_iterate_regions returns that status value.
3282 * @param[in] data Application data that is passed to @p callback on every
3283 * iteration. May be NULL.
3285 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3287 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3288 * initialized.
3290 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3292 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
3294 hsa_status_t HSA_API hsa_agent_iterate_regions(
3295 hsa_agent_t agent,
3296 hsa_status_t (*callback)(hsa_region_t region, void* data),
3297 void* data);
3300 * @brief Allocate a block of memory in a given region.
3302 * @param[in] region Region where to allocate memory from. The region must have
3303 * the ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED flag set.
3305 * @param[in] size Allocation size, in bytes. Must not be zero. This value is
3306 * rounded up to the nearest multiple of ::HSA_REGION_INFO_RUNTIME_ALLOC_GRANULE
3307 * in @p region.
3309 * @param[out] ptr Pointer to the location where to store the base address of
3310 * the allocated block. The returned base address is aligned to the value of
3311 * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT in @p region. If the allocation
3312 * fails, the returned value is undefined.
3314 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3316 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3317 * initialized.
3319 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
3320 * the required resources.
3322 * @retval ::HSA_STATUS_ERROR_INVALID_REGION The region is invalid.
3324 * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The host is not allowed to
3325 * allocate memory in @p region, or @p size is greater than the value of
3326 * HSA_REGION_INFO_ALLOC_MAX_SIZE in @p region.
3328 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p size is 0.
3330 hsa_status_t HSA_API hsa_memory_allocate(hsa_region_t region,
3331 size_t size,
3332 void** ptr);
3335 * @brief Deallocate a block of memory previously allocated using
3336 * ::hsa_memory_allocate.
3338 * @param[in] ptr Pointer to a memory block. If @p ptr does not match a value
3339 * previously returned by ::hsa_memory_allocate, the behavior is undefined.
3341 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3343 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3344 * initialized.
3346 hsa_status_t HSA_API hsa_memory_free(void* ptr);
3349 * @brief Copy a block of memory from the location pointed to by @p src to the
3350 * memory block pointed to by @p dst.
3352 * @param[out] dst Buffer where the content is to be copied. If @p dst is in
3353 * coarse-grained memory, the copied data is only visible to the agent currently
3354 * assigned (::hsa_memory_assign_agent) to @p dst.
3356 * @param[in] src A valid pointer to the source of data to be copied. The source
3357 * buffer must not overlap with the destination buffer. If the source buffer is
3358 * in coarse-grained memory then it must be assigned to an agent, from which the
3359 * data will be retrieved.
3361 * @param[in] size Number of bytes to copy. If @p size is 0, no copy is
3362 * performed and the function returns success. Copying a number of bytes larger
3363 * than the size of the buffers pointed by @p dst or @p src results in undefined
3364 * behavior.
3366 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3368 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3369 * initialized.
3371 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
3372 * pointers are NULL.
3374 hsa_status_t HSA_API hsa_memory_copy(
3375 void *dst,
3376 const void *src,
3377 size_t size);
3380 * @brief Change the ownership of a global, coarse-grained buffer.
3382 * @details The contents of a coarse-grained buffer are visible to an agent
3383 * only after ownership has been explicitely transferred to that agent. Once the
3384 * operation completes, the previous owner cannot longer access the data in the
3385 * buffer.
3387 * An implementation of the HSA runtime is allowed, but not required, to change
3388 * the physical location of the buffer when ownership is transferred to a
3389 * different agent. In general the application must not assume this
3390 * behavior. The virtual location (address) of the passed buffer is never
3391 * modified.
3393 * @param[in] ptr Base address of a global buffer. The pointer must match an
3394 * address previously returned by ::hsa_memory_allocate. The size of the buffer
3395 * affected by the ownership change is identical to the size of that previous
3396 * allocation. If @p ptr points to a fine-grained global buffer, no operation is
3397 * performed and the function returns success. If @p ptr does not point to
3398 * global memory, the behavior is undefined.
3400 * @param[in] agent Agent that becomes the owner of the buffer. The
3401 * application is responsible for ensuring that @p agent has access to the
3402 * region that contains the buffer. It is allowed to change ownership to an
3403 * agent that is already the owner of the buffer, with the same or different
3404 * access permissions.
3406 * @param[in] access Access permissions requested for the new owner.
3408 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3410 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3411 * initialized.
3413 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3415 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
3416 * the required resources.
3418 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p access is
3419 * not a valid access value.
3421 hsa_status_t HSA_API hsa_memory_assign_agent(
3422 void *ptr,
3423 hsa_agent_t agent,
3424 hsa_access_permission_t access);
3428 * @brief Register a global, fine-grained buffer.
3430 * @details Registering a buffer serves as an indication to the HSA runtime that
3431 * the memory might be accessed from a kernel agent other than the
3432 * host. Registration is a performance hint that allows the HSA runtime
3433 * implementation to know which buffers will be accessed by some of the kernel
3434 * agents ahead of time.
3436 * Registration is only recommended for buffers in the global segment that have
3437 * not been allocated using the HSA allocator (::hsa_memory_allocate), but an OS
3438 * allocator instead. Registering an OS-allocated buffer in the base profile is
3439 * equivalent to a no-op.
3441 * Registrations should not overlap.
3443 * @param[in] ptr A buffer in global, fine-grained memory. If a NULL pointer is
3444 * passed, no operation is performed. If the buffer has been allocated using
3445 * ::hsa_memory_allocate, or has already been registered, no operation is
3446 * performed.
3448 * @param[in] size Requested registration size in bytes. A size of 0 is
3449 * only allowed if @p ptr is NULL.
3451 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3453 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3454 * initialized.
3456 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
3457 * the required resources.
3459 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 but @p ptr
3460 * is not NULL.
3462 hsa_status_t HSA_API hsa_memory_register(
3463 void *ptr,
3464 size_t size);
3468 * @brief Deregister memory previously registered using ::hsa_memory_register.
3470 * @details If the memory interval being deregistered does not match a previous
3471 * registration (start and end addresses), the behavior is undefined.
3473 * @param[in] ptr A pointer to the base of the buffer to be deregistered. If
3474 * a NULL pointer is passed, no operation is performed.
3476 * @param[in] size Size of the buffer to be deregistered.
3478 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3480 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3481 * initialized.
3484 hsa_status_t HSA_API hsa_memory_deregister(
3485 void *ptr,
3486 size_t size);
3488 /** @} */
3491 /** \defgroup instruction-set-architecture Instruction Set Architecture.
3492 * @{
3496 * @brief Instruction set architecture.
3498 typedef struct hsa_isa_s {
3500 * Opaque handle. Two handles reference the same object of the enclosing type
3501 * if and only if they are equal.
3503 uint64_t handle;
3504 } hsa_isa_t;
3507 * @brief Retrieve a reference to an instruction set architecture handle out of
3508 * a symbolic name.
3510 * @param[in] name Vendor-specific name associated with a a particular
3511 * instruction set architecture. @p name must start with the vendor name and a
3512 * colon (for example, "AMD:"). The rest of the name is vendor-specific. Must be
3513 * a NUL-terminated string.
3515 * @param[out] isa Memory location where the HSA runtime stores the ISA handle
3516 * corresponding to the given name. Must not be NULL.
3518 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3520 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3521 * initialized.
3523 * @retval ::HSA_STATUS_ERROR_INVALID_ISA_NAME The given name does not
3524 * correspond to any instruction set architecture.
3526 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
3527 * allocate the required resources.
3529 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p name is NULL, or @p isa is
3530 * NULL.
3532 hsa_status_t HSA_API hsa_isa_from_name(
3533 const char *name,
3534 hsa_isa_t *isa);
3537 * @brief Iterate over the instruction sets supported by the given agent, and
3538 * invoke an application-defined callback on every iteration. The iterator is
3539 * deterministic: if an agent supports several instruction set architectures,
3540 * they are traversed in the same order in every invocation of this function.
3542 * @param[in] agent A valid agent.
3544 * @param[in] callback Callback to be invoked once per instruction set
3545 * architecture. The HSA runtime passes two arguments to the callback: the
3546 * ISA and the application data. If @p callback returns a status other than
3547 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
3548 * that status value is returned.
3550 * @param[in] data Application data that is passed to @p callback on every
3551 * iteration. May be NULL.
3553 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3555 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3556 * initialized.
3558 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3560 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
3562 hsa_status_t HSA_API hsa_agent_iterate_isas(
3563 hsa_agent_t agent,
3564 hsa_status_t (*callback)(hsa_isa_t isa, void *data),
3565 void *data);
3568 * @brief Instruction set architecture attributes.
3570 typedef enum {
3572 * The length of the ISA name in bytes, not including the NUL terminator. The
3573 * type of this attribute is uint32_t.
3575 HSA_ISA_INFO_NAME_LENGTH = 0,
3577 * Human-readable description. The type of this attribute is character array
3578 * with the length equal to the value of ::HSA_ISA_INFO_NAME_LENGTH attribute.
3580 HSA_ISA_INFO_NAME = 1,
3582 * @deprecated
3584 * Number of call conventions supported by the instruction set architecture.
3585 * Must be greater than zero. The type of this attribute is uint32_t.
3587 HSA_ISA_INFO_CALL_CONVENTION_COUNT = 2,
3589 * @deprecated
3591 * Number of work-items in a wavefront for a given call convention. Must be a
3592 * power of 2 in the range [1,256]. The type of this attribute is uint32_t.
3594 HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONT_SIZE = 3,
3596 * @deprecated
3598 * Number of wavefronts per compute unit for a given call convention. In
3599 * practice, other factors (for example, the amount of group memory used by a
3600 * work-group) may further limit the number of wavefronts per compute
3601 * unit. The type of this attribute is uint32_t.
3603 HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONTS_PER_COMPUTE_UNIT = 4,
3605 * Machine models supported by the instruction set architecture. The type of
3606 * this attribute is a bool[2]. If the ISA supports the small machine model,
3607 * the element at index ::HSA_MACHINE_MODEL_SMALL is true. If the ISA supports
3608 * the large model, the element at index ::HSA_MACHINE_MODEL_LARGE is true.
3610 HSA_ISA_INFO_MACHINE_MODELS = 5,
3612 * Profiles supported by the instruction set architecture. The type of this
3613 * attribute is a bool[2]. If the ISA supports the base profile, the element
3614 * at index ::HSA_PROFILE_BASE is true. If the ISA supports the full profile,
3615 * the element at index ::HSA_PROFILE_FULL is true.
3617 HSA_ISA_INFO_PROFILES = 6,
3619 * Default floating-point rounding modes supported by the instruction set
3620 * architecture. The type of this attribute is a bool[3]. The value at a given
3621 * index is true if the corresponding rounding mode in
3622 * ::hsa_default_float_rounding_mode_t is supported. At least one default mode
3623 * has to be supported.
3625 * If the default mode is supported, then
3626 * ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES must report that
3627 * both the zero and the near roundings modes are supported.
3629 HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES = 7,
3631 * Default floating-point rounding modes supported by the instruction set
3632 * architecture in the Base profile. The type of this attribute is a
3633 * bool[3]. The value at a given index is true if the corresponding rounding
3634 * mode in ::hsa_default_float_rounding_mode_t is supported. The value at
3635 * index HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT must be false. At least one
3636 * of the values at indexes ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO or
3637 * HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR must be true.
3639 HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES = 8,
3641 * Flag indicating that the f16 HSAIL operation is at least as fast as the
3642 * f32 operation in the instruction set architecture. The type of this
3643 * attribute is bool.
3645 HSA_ISA_INFO_FAST_F16_OPERATION = 9,
3647 * Maximum number of work-items of each dimension of a work-group. Each
3648 * maximum must be greater than 0. No maximum can exceed the value of
3649 * ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE. The type of this attribute is
3650 * uint16_t[3].
3652 HSA_ISA_INFO_WORKGROUP_MAX_DIM = 12,
3654 * Maximum total number of work-items in a work-group. The type
3655 * of this attribute is uint32_t.
3657 HSA_ISA_INFO_WORKGROUP_MAX_SIZE = 13,
3659 * Maximum number of work-items of each dimension of a grid. Each maximum must
3660 * be greater than 0, and must not be smaller than the corresponding value in
3661 * ::HSA_ISA_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
3662 * ::HSA_ISA_INFO_GRID_MAX_SIZE. The type of this attribute is
3663 * ::hsa_dim3_t.
3665 HSA_ISA_INFO_GRID_MAX_DIM = 14,
3667 * Maximum total number of work-items in a grid. The type of this
3668 * attribute is uint64_t.
3670 HSA_ISA_INFO_GRID_MAX_SIZE = 16,
3672 * Maximum number of fbarriers per work-group. Must be at least 32. The
3673 * type of this attribute is uint32_t.
3675 HSA_ISA_INFO_FBARRIER_MAX_SIZE = 17
3676 } hsa_isa_info_t;
3679 * @deprecated The concept of call convention has been deprecated. If the
3680 * application wants to query the value of an attribute for a given instruction
3681 * set architecture, use ::hsa_isa_get_info_alt instead. If the application
3682 * wants to query an attribute that is specific to a given combination of ISA
3683 * and wavefront, use ::hsa_wavefront_get_info.
3685 * @brief Get the current value of an attribute for a given instruction set
3686 * architecture (ISA).
3688 * @param[in] isa A valid instruction set architecture.
3690 * @param[in] attribute Attribute to query.
3692 * @param[in] index Call convention index. Used only for call convention
3693 * attributes, otherwise ignored. Must have a value between 0 (inclusive) and
3694 * the value of the attribute ::HSA_ISA_INFO_CALL_CONVENTION_COUNT (not
3695 * inclusive) in @p isa.
3697 * @param[out] value Pointer to an application-allocated buffer where to store
3698 * the value of the attribute. If the buffer passed by the application is not
3699 * large enough to hold the value of @p attribute, the behavior is undefined.
3701 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3703 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3704 * initialized.
3706 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3707 * invalid.
3709 * @retval ::HSA_STATUS_ERROR_INVALID_INDEX The index is out of range.
3711 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3712 * instruction set architecture attribute, or @p value is
3713 * NULL.
3715 hsa_status_t HSA_API HSA_DEPRECATED hsa_isa_get_info(
3716 hsa_isa_t isa,
3717 hsa_isa_info_t attribute,
3718 uint32_t index,
3719 void *value);
3722 * @brief Get the current value of an attribute for a given instruction set
3723 * architecture (ISA).
3725 * @param[in] isa A valid instruction set architecture.
3727 * @param[in] attribute Attribute to query.
3729 * @param[out] value Pointer to an application-allocated buffer where to store
3730 * the value of the attribute. If the buffer passed by the application is not
3731 * large enough to hold the value of @p attribute, the behavior is undefined.
3733 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3735 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3736 * initialized.
3738 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3739 * invalid.
3741 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3742 * instruction set architecture attribute, or @p value is
3743 * NULL.
3745 hsa_status_t HSA_API hsa_isa_get_info_alt(
3746 hsa_isa_t isa,
3747 hsa_isa_info_t attribute,
3748 void *value);
3751 * @brief Retrieve the exception policy support for a given combination of
3752 * instruction set architecture and profile.
3754 * @param[in] isa A valid instruction set architecture.
3756 * @param[in] profile Profile.
3758 * @param[out] mask Pointer to a memory location where the HSA runtime stores a
3759 * mask of ::hsa_exception_policy_t values. Must not be NULL.
3761 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3763 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3764 * initialized.
3766 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3767 * invalid.
3769 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is not a valid
3770 * profile, or @p mask is NULL.
3772 hsa_status_t HSA_API hsa_isa_get_exception_policies(
3773 hsa_isa_t isa,
3774 hsa_profile_t profile,
3775 uint16_t *mask);
3778 * @brief Floating-point types.
3780 typedef enum {
3782 * 16-bit floating-point type.
3784 HSA_FP_TYPE_16 = 1,
3786 * 32-bit floating-point type.
3788 HSA_FP_TYPE_32 = 2,
3790 * 64-bit floating-point type.
3792 HSA_FP_TYPE_64 = 4
3793 } hsa_fp_type_t;
3796 * @brief Flush to zero modes.
3798 typedef enum {
3800 * Flush to zero.
3802 HSA_FLUSH_MODE_FTZ = 1,
3804 * Do not flush to zero.
3806 HSA_FLUSH_MODE_NON_FTZ = 2
3807 } hsa_flush_mode_t;
3810 * @brief Round methods.
3812 typedef enum {
3814 * Single round method.
3816 HSA_ROUND_METHOD_SINGLE = 1,
3818 * Double round method.
3820 HSA_ROUND_METHOD_DOUBLE = 2
3821 } hsa_round_method_t;
3824 * @brief Retrieve the round method (single or double) used to implement the
3825 * floating-point multiply add instruction (mad) for a given combination of
3826 * instruction set architecture, floating-point type, and flush to zero
3827 * modifier.
3829 * @param[in] isa Instruction set architecture.
3831 * @param[in] fp_type Floating-point type.
3833 * @param[in] flush_mode Flush to zero modifier.
3835 * @param[out] round_method Pointer to a memory location where the HSA
3836 * runtime stores the round method used by the implementation. Must not be NULL.
3838 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3840 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3841 * initialized.
3843 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3844 * invalid.
3846 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p fp_type is not a valid
3847 * floating-point type, or @p flush_mode is not a valid flush to zero modifier,
3848 * or @p round_method is NULL.
3850 hsa_status_t HSA_API hsa_isa_get_round_method(
3851 hsa_isa_t isa,
3852 hsa_fp_type_t fp_type,
3853 hsa_flush_mode_t flush_mode,
3854 hsa_round_method_t *round_method);
3857 * @brief Wavefront handle
3859 typedef struct hsa_wavefront_s {
3861 * Opaque handle. Two handles reference the same object of the enclosing type
3862 * if and only if they are equal.
3864 uint64_t handle;
3865 } hsa_wavefront_t;
3868 * @brief Wavefront attributes.
3870 typedef enum {
3872 * Number of work-items in the wavefront. Must be a power of 2 in the range
3873 * [1,256]. The type of this attribute is uint32_t.
3875 HSA_WAVEFRONT_INFO_SIZE = 0
3876 } hsa_wavefront_info_t;
3879 * @brief Get the current value of a wavefront attribute.
3881 * @param[in] wavefront A wavefront.
3883 * @param[in] attribute Attribute to query.
3885 * @param[out] value Pointer to an application-allocated buffer where to store
3886 * the value of the attribute. If the buffer passed by the application is not
3887 * large enough to hold the value of @p attribute, the behavior is undefined.
3889 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3891 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3892 * initialized.
3894 * @retval ::HSA_STATUS_ERROR_INVALID_WAVEFRONT The wavefront is invalid.
3896 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3897 * wavefront attribute, or @p value is NULL.
3899 hsa_status_t HSA_API hsa_wavefront_get_info(
3900 hsa_wavefront_t wavefront,
3901 hsa_wavefront_info_t attribute,
3902 void *value);
3905 * @brief Iterate over the different wavefronts supported by an instruction set
3906 * architecture, and invoke an application-defined callback on every iteration.
3908 * @param[in] isa Instruction set architecture.
3910 * @param[in] callback Callback to be invoked once per wavefront that is
3911 * supported by the agent. The HSA runtime passes two arguments to the callback:
3912 * the wavefront handle and the application data. If @p callback returns a
3913 * status other than ::HSA_STATUS_SUCCESS for a particular iteration, the
3914 * traversal stops and that value is returned.
3916 * @param[in] data Application data that is passed to @p callback on every
3917 * iteration. May be NULL.
3919 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3921 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3922 * initialized.
3924 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3925 * invalid.
3927 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
3929 hsa_status_t HSA_API hsa_isa_iterate_wavefronts(
3930 hsa_isa_t isa,
3931 hsa_status_t (*callback)(hsa_wavefront_t wavefront, void *data),
3932 void *data);
3935 * @deprecated Use ::hsa_agent_iterate_isas to query which instructions set
3936 * architectures are supported by a given agent.
3938 * @brief Check if the instruction set architecture of a code object can be
3939 * executed on an agent associated with another architecture.
3941 * @param[in] code_object_isa Instruction set architecture associated with a
3942 * code object.
3944 * @param[in] agent_isa Instruction set architecture associated with an agent.
3946 * @param[out] result Pointer to a memory location where the HSA runtime stores
3947 * the result of the check. If the two architectures are compatible, the result
3948 * is true; if they are incompatible, the result is false.
3950 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3952 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3953 * initialized.
3955 * @retval ::HSA_STATUS_ERROR_INVALID_ISA @p code_object_isa or @p agent_isa are
3956 * invalid.
3958 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
3960 hsa_status_t HSA_API HSA_DEPRECATED hsa_isa_compatible(
3961 hsa_isa_t code_object_isa,
3962 hsa_isa_t agent_isa,
3963 bool *result);
3965 /** @} */
3968 /** \defgroup executable Executable
3969 * @{
3973 * @brief Code object reader handle. A code object reader is used to
3974 * load a code object from file (when created using
3975 * ::hsa_code_object_reader_create_from_file), or from memory (if created using
3976 * ::hsa_code_object_reader_create_from_memory).
3978 typedef struct hsa_code_object_reader_s {
3980 * Opaque handle. Two handles reference the same object of the enclosing type
3981 * if and only if they are equal.
3983 uint64_t handle;
3984 } hsa_code_object_reader_t;
3987 * @brief Create a code object reader to operate on a file.
3989 * @param[in] file File descriptor. The file must have been opened by
3990 * application with at least read permissions prior calling this function. The
3991 * file must contain a vendor-specific code object.
3993 * The file is owned and managed by the application; the lifetime of the file
3994 * descriptor must exceed that of any associated code object reader.
3996 * @param[out] code_object_reader Memory location to store the newly created
3997 * code object reader handle. Must not be NULL.
3999 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4001 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4002 * initialized.
4004 * @retval ::HSA_STATUS_ERROR_INVALID_FILE @p file is invalid.
4006 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4007 * allocate the required resources.
4009 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p code_object_reader is NULL.
4011 hsa_status_t HSA_API hsa_code_object_reader_create_from_file(
4012 hsa_file_t file,
4013 hsa_code_object_reader_t *code_object_reader);
4016 * @brief Create a code object reader to operate on memory.
4018 * @param[in] code_object Memory buffer that contains a vendor-specific code
4019 * object. The buffer is owned and managed by the application; the lifetime of
4020 * the buffer must exceed that of any associated code object reader.
4022 * @param[in] size Size of the buffer pointed to by @p code_object. Must not be
4023 * 0.
4025 * @param[out] code_object_reader Memory location to store newly created code
4026 * object reader handle. Must not be NULL.
4028 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4030 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4031 * initialized.
4033 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4034 * allocate the required resources.
4036 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p code_object is NULL, @p size
4037 * is zero, or @p code_object_reader is NULL.
4039 hsa_status_t HSA_API hsa_code_object_reader_create_from_memory(
4040 const void *code_object,
4041 size_t size,
4042 hsa_code_object_reader_t *code_object_reader);
4045 * @brief Destroy a code object reader.
4047 * @details The code object reader handle becomes invalid after completion of
4048 * this function. Any file or memory used to create the code object read is not
4049 * closed, removed, or deallocated by this function.
4051 * @param[in] code_object_reader Code object reader to destroy.
4053 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4055 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4056 * initialized.
4058 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
4059 * is invalid.
4061 hsa_status_t HSA_API hsa_code_object_reader_destroy(
4062 hsa_code_object_reader_t code_object_reader);
4065 * @brief Struct containing an opaque handle to an executable, which contains
4066 * ISA for finalized kernels and indirect functions together with the allocated
4067 * global or readonly segment variables they reference.
4069 typedef struct hsa_executable_s {
4071 * Opaque handle. Two handles reference the same object of the enclosing type
4072 * if and only if they are equal.
4074 uint64_t handle;
4075 } hsa_executable_t;
4078 * @brief Executable state.
4080 typedef enum {
4082 * Executable state, which allows the user to load code objects and define
4083 * external variables. Variable addresses, kernel code handles, and
4084 * indirect function code handles are not available in query operations until
4085 * the executable is frozen (zero always returned).
4087 HSA_EXECUTABLE_STATE_UNFROZEN = 0,
4089 * Executable state, which allows the user to query variable addresses,
4090 * kernel code handles, and indirect function code handles using query
4091 * operations. Loading new code objects, as well as defining external
4092 * variables, is not allowed in this state.
4094 HSA_EXECUTABLE_STATE_FROZEN = 1
4095 } hsa_executable_state_t;
4098 * @deprecated Use ::hsa_executable_create_alt instead, which allows the
4099 * application to specify the default floating-point rounding mode of the
4100 * executable and assumes an unfrozen initial state.
4102 * @brief Create an empty executable.
4104 * @param[in] profile Profile used in the executable.
4106 * @param[in] executable_state Executable state. If the state is
4107 * ::HSA_EXECUTABLE_STATE_FROZEN, the resulting executable is useless because no
4108 * code objects can be loaded, and no variables can be defined.
4110 * @param[in] options Standard and vendor-specific options. Unknown options are
4111 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4112 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4113 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4114 * NUL-terminated string. May be NULL.
4116 * @param[out] executable Memory location where the HSA runtime stores the newly
4117 * created executable handle.
4119 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4121 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4122 * initialized.
4124 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4125 * allocate the required resources.
4127 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is invalid, or
4128 * @p executable is NULL.
4130 hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_create(
4131 hsa_profile_t profile,
4132 hsa_executable_state_t executable_state,
4133 const char *options,
4134 hsa_executable_t *executable);
4137 * @brief Create an empty executable.
4139 * @param[in] profile Profile used in the executable.
4141 * @param[in] default_float_rounding_mode Default floating-point rounding mode
4142 * used in the executable. Allowed rounding modes are near and zero (default is
4143 * not allowed).
4145 * @param[in] options Standard and vendor-specific options. Unknown options are
4146 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4147 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4148 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4149 * NUL-terminated string. May be NULL.
4151 * @param[out] executable Memory location where the HSA runtime stores newly
4152 * created executable handle. The initial state of the executable is
4153 * ::HSA_EXECUTABLE_STATE_UNFROZEN.
4155 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4157 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4158 * initialized.
4160 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4161 * allocate the required resources.
4163 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is invalid, or
4164 * @p executable is NULL.
4166 hsa_status_t HSA_API hsa_executable_create_alt(
4167 hsa_profile_t profile,
4168 hsa_default_float_rounding_mode_t default_float_rounding_mode,
4169 const char *options,
4170 hsa_executable_t *executable);
4173 * @brief Destroy an executable.
4175 * @details An executable handle becomes invalid after the executable has been
4176 * destroyed. Code object handles that were loaded into this executable are
4177 * still valid after the executable has been destroyed, and can be used as
4178 * intended. Resources allocated outside and associated with this executable
4179 * (such as external global or readonly variables) can be released after the
4180 * executable has been destroyed.
4182 * Executable should not be destroyed while kernels are in flight.
4184 * @param[in] executable Executable.
4186 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4188 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4189 * initialized.
4191 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4193 hsa_status_t HSA_API hsa_executable_destroy(
4194 hsa_executable_t executable);
4197 * @brief Loaded code object handle.
4199 typedef struct hsa_loaded_code_object_s {
4201 * Opaque handle. Two handles reference the same object of the enclosing type
4202 * if and only if they are equal.
4204 uint64_t handle;
4205 } hsa_loaded_code_object_t;
4208 * @brief Load a program code object into an executable.
4210 * @details A program code object contains information about resources that are
4211 * accessible by all kernel agents that run the executable, and can be loaded
4212 * at most once into an executable.
4214 * If the program code object uses extensions, the implementation must support
4215 * them for this operation to return successfully.
4217 * @param[in] executable Executable.
4219 * @param[in] code_object_reader A code object reader that holds the program
4220 * code object to load. If a code object reader is destroyed before all the
4221 * associated executables are destroyed, the behavior is undefined.
4223 * @param[in] options Standard and vendor-specific options. Unknown options are
4224 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4225 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4226 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4227 * NUL-terminated string. May be NULL.
4229 * @param[out] loaded_code_object Pointer to a memory location where the HSA
4230 * runtime stores the loaded code object handle. May be NULL.
4232 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4234 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4235 * initialized.
4237 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4238 * allocate the required resources.
4240 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4242 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE The executable is frozen.
4244 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
4245 * is invalid.
4247 * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS The program code object is
4248 * not compatible with the executable or the implementation (for example, the
4249 * code object uses an extension that is not supported by the implementation).
4251 hsa_status_t HSA_API hsa_executable_load_program_code_object(
4252 hsa_executable_t executable,
4253 hsa_code_object_reader_t code_object_reader,
4254 const char *options,
4255 hsa_loaded_code_object_t *loaded_code_object);
4258 * @brief Load an agent code object into an executable.
4260 * @details The agent code object contains all defined agent
4261 * allocation variables, functions, indirect functions, and kernels in a given
4262 * program for a given instruction set architecture.
4264 * Any module linkage declaration must have been defined either by a define
4265 * variable or by loading a code object that has a symbol with module linkage
4266 * definition.
4268 * The default floating-point rounding mode of the code object associated with
4269 * @p code_object_reader must match that of the executable
4270 * (::HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE), or be default (in which
4271 * case the value of ::HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE is used).
4272 * If the agent code object uses extensions, the implementation and the agent
4273 * must support them for this operation to return successfully.
4275 * @param[in] executable Executable.
4277 * @param[in] agent Agent to load code object for. A code object can be loaded
4278 * into an executable at most once for a given agent. The instruction set
4279 * architecture of the code object must be supported by the agent.
4281 * @param[in] code_object_reader A code object reader that holds the code object
4282 * to load. If a code object reader is destroyed before all the associated
4283 * executables are destroyed, the behavior is undefined.
4285 * @param[in] options Standard and vendor-specific options. Unknown options are
4286 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4287 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4288 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4289 * NUL-terminated string. May be NULL.
4291 * @param[out] loaded_code_object Pointer to a memory location where the HSA
4292 * runtime stores the loaded code object handle. May be NULL.
4294 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4296 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4297 * initialized.
4299 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4300 * allocate the required resources.
4302 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4304 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE The executable is frozen.
4306 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
4308 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
4309 * is invalid.
4311 * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS The code object read by @p
4312 * code_object_reader is not compatible with the agent (for example, the agent
4313 * does not support the instruction set architecture of the code object), the
4314 * executable (for example, there is a default floating-point mode mismatch
4315 * between the two), or the implementation.
4317 hsa_status_t HSA_API hsa_executable_load_agent_code_object(
4318 hsa_executable_t executable,
4319 hsa_agent_t agent,
4320 hsa_code_object_reader_t code_object_reader,
4321 const char *options,
4322 hsa_loaded_code_object_t *loaded_code_object);
4325 * @brief Freeze the executable.
4327 * @details No modifications to executable can be made after freezing: no code
4328 * objects can be loaded to the executable, and no external variables can be
4329 * defined. Freezing the executable does not prevent querying the executable's
4330 * attributes. The application must define all the external variables in an
4331 * executable before freezing it.
4333 * @param[in] executable Executable.
4335 * @param[in] options Standard and vendor-specific options. Unknown options are
4336 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4337 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4338 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4339 * NUL-terminated string. May be NULL.
4341 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4343 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4344 * initialized.
4346 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4348 * @retval ::HSA_STATUS_ERROR_VARIABLE_UNDEFINED One or more variables are
4349 * undefined in the executable.
4351 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is already frozen.
4353 hsa_status_t HSA_API hsa_executable_freeze(
4354 hsa_executable_t executable,
4355 const char *options);
4358 * @brief Executable attributes.
4360 typedef enum {
4362 * Profile this executable is created for. The type of this attribute is
4363 * ::hsa_profile_t.
4365 HSA_EXECUTABLE_INFO_PROFILE = 1,
4367 * Executable state. The type of this attribute is ::hsa_executable_state_t.
4369 HSA_EXECUTABLE_INFO_STATE = 2,
4371 * Default floating-point rounding mode specified when executable was created.
4372 * The type of this attribute is ::hsa_default_float_rounding_mode_t.
4374 HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 3
4375 } hsa_executable_info_t;
4378 * @brief Get the current value of an attribute for a given executable.
4380 * @param[in] executable Executable.
4382 * @param[in] attribute Attribute to query.
4384 * @param[out] value Pointer to an application-allocated buffer where to store
4385 * the value of the attribute. If the buffer passed by the application is not
4386 * large enough to hold the value of @p attribute, the behavior is undefined.
4388 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4390 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4391 * initialized.
4393 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4395 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
4396 * executable attribute, or @p value is NULL.
4398 hsa_status_t HSA_API hsa_executable_get_info(
4399 hsa_executable_t executable,
4400 hsa_executable_info_t attribute,
4401 void *value);
4404 * @brief Define an external global variable with program allocation.
4406 * @details This function allows the application to provide the definition
4407 * of a variable in the global segment memory with program allocation. The
4408 * variable must be defined before loading a code object into an executable.
4409 * In addition, code objects loaded must not define the variable.
4411 * @param[in] executable Executable. Must not be in frozen state.
4413 * @param[in] variable_name Name of the variable. The Programmer's Reference
4414 * Manual describes the standard name mangling scheme.
4416 * @param[in] address Address where the variable is defined. This address must
4417 * be in global memory and can be read and written by any agent in the
4418 * system. The application cannot deallocate the buffer pointed by @p address
4419 * before @p executable is destroyed.
4421 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4423 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4424 * initialized.
4426 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4427 * allocate the required resources.
4429 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4431 * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
4432 * already defined.
4434 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
4435 * @p variable_name.
4437 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
4439 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
4441 hsa_status_t HSA_API hsa_executable_global_variable_define(
4442 hsa_executable_t executable,
4443 const char *variable_name,
4444 void *address);
4447 * @brief Define an external global variable with agent allocation.
4449 * @details This function allows the application to provide the definition
4450 * of a variable in the global segment memory with agent allocation. The
4451 * variable must be defined before loading a code object into an executable.
4452 * In addition, code objects loaded must not define the variable.
4454 * @param[in] executable Executable. Must not be in frozen state.
4456 * @param[in] agent Agent for which the variable is being defined.
4458 * @param[in] variable_name Name of the variable. The Programmer's Reference
4459 * Manual describes the standard name mangling scheme.
4461 * @param[in] address Address where the variable is defined. This address must
4462 * have been previously allocated using ::hsa_memory_allocate in a global region
4463 * that is only visible to @p agent. The application cannot deallocate the
4464 * buffer pointed by @p address before @p executable is destroyed.
4466 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4468 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4469 * initialized.
4471 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4472 * allocate the required resources.
4474 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4476 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT @p agent is invalid.
4478 * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
4479 * already defined.
4481 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
4482 * @p variable_name.
4484 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
4486 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
4488 hsa_status_t HSA_API hsa_executable_agent_global_variable_define(
4489 hsa_executable_t executable,
4490 hsa_agent_t agent,
4491 const char *variable_name,
4492 void *address);
4495 * @brief Define an external readonly variable.
4497 * @details This function allows the application to provide the definition
4498 * of a variable in the readonly segment memory. The variable must be defined
4499 * before loading a code object into an executable. In addition, code objects
4500 * loaded must not define the variable.
4502 * @param[in] executable Executable. Must not be in frozen state.
4504 * @param[in] agent Agent for which the variable is being defined.
4506 * @param[in] variable_name Name of the variable. The Programmer's Reference
4507 * Manual describes the standard name mangling scheme.
4509 * @param[in] address Address where the variable is defined. This address must
4510 * have been previously allocated using ::hsa_memory_allocate in a readonly
4511 * region associated with @p agent. The application cannot deallocate the buffer
4512 * pointed by @p address before @p executable is destroyed.
4514 * @param[in] address Address where the variable is defined. The buffer pointed
4515 * by @p address is owned by the application, and cannot be deallocated before
4516 * @p executable is destroyed.
4518 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4520 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4521 * initialized.
4523 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4524 * allocate the required resources.
4526 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE Executable is invalid.
4528 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT @p agent is invalid.
4530 * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
4531 * already defined.
4533 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
4534 * @p variable_name.
4536 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
4538 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
4540 hsa_status_t HSA_API hsa_executable_readonly_variable_define(
4541 hsa_executable_t executable,
4542 hsa_agent_t agent,
4543 const char *variable_name,
4544 void *address);
4547 * @brief Validate an executable. Checks that all code objects have matching
4548 * machine model, profile, and default floating-point rounding mode. Checks that
4549 * all declarations have definitions. Checks declaration-definition
4550 * compatibility (see the HSA Programming Reference Manual for compatibility
4551 * rules). Invoking this function is equivalent to invoking
4552 * ::hsa_executable_validate_alt with no options.
4554 * @param[in] executable Executable. Must be in frozen state.
4556 * @param[out] result Memory location where the HSA runtime stores the
4557 * validation result. If the executable passes validation, the result is 0.
4559 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4561 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4562 * initialized.
4564 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE @p executable is invalid.
4566 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
4568 hsa_status_t HSA_API hsa_executable_validate(
4569 hsa_executable_t executable,
4570 uint32_t *result);
4573 * @brief Validate an executable. Checks that all code objects have matching
4574 * machine model, profile, and default floating-point rounding mode. Checks that
4575 * all declarations have definitions. Checks declaration-definition
4576 * compatibility (see the HSA Programming Reference Manual for compatibility
4577 * rules).
4579 * @param[in] executable Executable. Must be in frozen state.
4581 * @param[in] options Standard and vendor-specific options. Unknown options are
4582 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4583 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4584 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4585 * NUL-terminated string. May be NULL.
4587 * @param[out] result Memory location where the HSA runtime stores the
4588 * validation result. If the executable passes validation, the result is 0.
4590 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4592 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4593 * initialized.
4595 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE @p executable is invalid.
4597 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
4599 hsa_status_t HSA_API hsa_executable_validate_alt(
4600 hsa_executable_t executable,
4601 const char *options,
4602 uint32_t *result);
4605 * @brief Executable symbol handle.
4607 * The lifetime of an executable object symbol matches that of the executable
4608 * associated with it. An operation on a symbol whose associated executable has
4609 * been destroyed results in undefined behavior.
4611 typedef struct hsa_executable_symbol_s {
4613 * Opaque handle. Two handles reference the same object of the enclosing type
4614 * if and only if they are equal.
4616 uint64_t handle;
4617 } hsa_executable_symbol_t;
4620 * @deprecated Use ::hsa_executable_get_symbol_by_name instead.
4622 * @brief Get the symbol handle for a given a symbol name.
4624 * @param[in] executable Executable.
4626 * @param[in] module_name Module name. Must be NULL if the symbol has
4627 * program linkage.
4629 * @param[in] symbol_name Symbol name.
4631 * @param[in] agent Agent associated with the symbol. If the symbol is
4632 * independent of any agent (for example, a variable with program
4633 * allocation), this argument is ignored.
4635 * @param[in] call_convention Call convention associated with the symbol. If the
4636 * symbol does not correspond to an indirect function, this argument is ignored.
4638 * @param[out] symbol Memory location where the HSA runtime stores the symbol
4639 * handle.
4641 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4643 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4644 * initialized.
4646 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4648 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
4649 * that matches @p symbol_name.
4651 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
4652 * @p symbol is NULL.
4654 hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_get_symbol(
4655 hsa_executable_t executable,
4656 const char *module_name,
4657 const char *symbol_name,
4658 hsa_agent_t agent,
4659 int32_t call_convention,
4660 hsa_executable_symbol_t *symbol);
4663 * @brief Retrieve the symbol handle corresponding to a given a symbol name.
4665 * @param[in] executable Executable.
4667 * @param[in] symbol_name Symbol name. Must be a NUL-terminated character
4668 * array. The Programmer's Reference Manual describes the standard name mangling
4669 * scheme.
4671 * @param[in] agent Pointer to the agent for which the symbol with the given
4672 * name is defined. If the symbol corresponding to the given name has program
4673 * allocation, @p agent must be NULL.
4675 * @param[out] symbol Memory location where the HSA runtime stores the symbol
4676 * handle. Must not be NULL.
4678 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4680 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4681 * initialized.
4683 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4685 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
4686 * that matches @p symbol_name.
4688 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or @p
4689 * symbol is NULL.
4691 hsa_status_t HSA_API hsa_executable_get_symbol_by_name(
4692 hsa_executable_t executable,
4693 const char *symbol_name,
4694 const hsa_agent_t *agent,
4695 hsa_executable_symbol_t *symbol);
4698 * @brief Symbol type.
4700 typedef enum {
4702 * Variable.
4704 HSA_SYMBOL_KIND_VARIABLE = 0,
4706 * Kernel.
4708 HSA_SYMBOL_KIND_KERNEL = 1,
4710 * Indirect function.
4712 HSA_SYMBOL_KIND_INDIRECT_FUNCTION = 2
4713 } hsa_symbol_kind_t;
4716 * @brief Linkage type of a symbol.
4718 typedef enum {
4720 * Module linkage.
4722 HSA_SYMBOL_LINKAGE_MODULE = 0,
4724 * Program linkage.
4726 HSA_SYMBOL_LINKAGE_PROGRAM = 1
4727 } hsa_symbol_linkage_t;
4730 * @brief Allocation type of a variable.
4732 typedef enum {
4734 * Agent allocation.
4736 HSA_VARIABLE_ALLOCATION_AGENT = 0,
4738 * Program allocation.
4740 HSA_VARIABLE_ALLOCATION_PROGRAM = 1
4741 } hsa_variable_allocation_t;
4744 * @brief Memory segment associated with a variable.
4746 typedef enum {
4748 * Global memory segment.
4750 HSA_VARIABLE_SEGMENT_GLOBAL = 0,
4752 * Readonly memory segment.
4754 HSA_VARIABLE_SEGMENT_READONLY = 1
4755 } hsa_variable_segment_t;
4758 * @brief Executable symbol attributes.
4760 typedef enum {
4762 * The kind of the symbol. The type of this attribute is ::hsa_symbol_kind_t.
4764 HSA_EXECUTABLE_SYMBOL_INFO_TYPE = 0,
4766 * The length of the symbol name in bytes, not including the NUL terminator.
4767 * The type of this attribute is uint32_t.
4769 HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH = 1,
4771 * The name of the symbol. The type of this attribute is character array with
4772 * the length equal to the value of ::HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH
4773 * attribute.
4775 HSA_EXECUTABLE_SYMBOL_INFO_NAME = 2,
4777 * @deprecated
4779 * The length of the module name in bytes (not including the NUL terminator)
4780 * to which this symbol belongs if this symbol has module linkage, otherwise 0
4781 * is returned. The type of this attribute is uint32_t.
4783 HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME_LENGTH = 3,
4785 * @deprecated
4787 * The module name to which this symbol belongs if this symbol has module
4788 * linkage, otherwise an empty string is returned. The type of this attribute
4789 * is character array with the length equal to the value of
4790 * ::HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME_LENGTH attribute.
4792 HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME = 4,
4794 * @deprecated
4796 * Agent associated with this symbol. If the symbol is a variable, the
4797 * value of this attribute is only defined if
4798 * ::HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALLOCATION is
4799 * ::HSA_VARIABLE_ALLOCATION_AGENT. The type of this attribute is hsa_agent_t.
4801 HSA_EXECUTABLE_SYMBOL_INFO_AGENT = 20,
4803 * The address of the variable. The value of this attribute is undefined if
4804 * the symbol is not a variable. The type of this attribute is uint64_t.
4806 * If executable's state is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0 is
4807 * returned.
4809 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS = 21,
4811 * The linkage kind of the symbol. The type of this attribute is
4812 * ::hsa_symbol_linkage_t.
4814 HSA_EXECUTABLE_SYMBOL_INFO_LINKAGE = 5,
4816 * Indicates whether the symbol corresponds to a definition. The type of this
4817 * attribute is bool.
4819 HSA_EXECUTABLE_SYMBOL_INFO_IS_DEFINITION = 17,
4821 * @deprecated
4823 * The allocation kind of the variable. The value of this attribute is
4824 * undefined if the symbol is not a variable. The type of this attribute is
4825 * ::hsa_variable_allocation_t.
4827 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALLOCATION = 6,
4829 * @deprecated
4831 * The segment kind of the variable. The value of this attribute is undefined
4832 * if the symbol is not a variable. The type of this attribute is
4833 * ::hsa_variable_segment_t.
4835 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SEGMENT = 7,
4837 * @deprecated
4839 * Alignment of the symbol in memory. The value of this attribute is undefined
4840 * if the symbol is not a variable. The type of this attribute is uint32_t.
4842 * The current alignment of the variable in memory may be greater than the
4843 * value specified in the source program variable declaration.
4845 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALIGNMENT = 8,
4847 * @deprecated
4849 * Size of the variable. The value of this attribute is undefined if
4850 * the symbol is not a variable. The type of this attribute is uint32_t.
4852 * A value of 0 is returned if the variable is an external variable and has an
4853 * unknown dimension.
4855 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SIZE = 9,
4857 * @deprecated
4859 * Indicates whether the variable is constant. The value of this attribute is
4860 * undefined if the symbol is not a variable. The type of this attribute is
4861 * bool.
4863 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_IS_CONST = 10,
4865 * Kernel object handle, used in the kernel dispatch packet. The value of this
4866 * attribute is undefined if the symbol is not a kernel. The type of this
4867 * attribute is uint64_t.
4869 * If the state of the executable is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0
4870 * is returned.
4872 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT = 22,
4874 * Size of kernarg segment memory that is required to hold the values of the
4875 * kernel arguments, in bytes. Must be a multiple of 16. The value of this
4876 * attribute is undefined if the symbol is not a kernel. The type of this
4877 * attribute is uint32_t.
4879 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE = 11,
4881 * Alignment (in bytes) of the buffer used to pass arguments to the kernel,
4882 * which is the maximum of 16 and the maximum alignment of any of the kernel
4883 * arguments. The value of this attribute is undefined if the symbol is not a
4884 * kernel. The type of this attribute is uint32_t.
4886 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT = 12,
4888 * Size of static group segment memory required by the kernel (per
4889 * work-group), in bytes. The value of this attribute is undefined
4890 * if the symbol is not a kernel. The type of this attribute is uint32_t.
4892 * The reported amount does not include any dynamically allocated group
4893 * segment memory that may be requested by the application when a kernel is
4894 * dispatched.
4896 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE = 13,
4898 * Size of static private, spill, and arg segment memory required by
4899 * this kernel (per work-item), in bytes. The value of this attribute is
4900 * undefined if the symbol is not a kernel. The type of this attribute is
4901 * uint32_t.
4903 * If the value of ::HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK is
4904 * true, the kernel may use more private memory than the reported value, and
4905 * the application must add the dynamic call stack usage to @a
4906 * private_segment_size when populating a kernel dispatch packet.
4908 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE = 14,
4910 * Dynamic callstack flag. The value of this attribute is undefined if the
4911 * symbol is not a kernel. The type of this attribute is bool.
4913 * If this flag is set (the value is true), the kernel uses a dynamically
4914 * sized call stack. This can happen if recursive calls, calls to indirect
4915 * functions, or the HSAIL alloca instruction are present in the kernel.
4917 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK = 15,
4919 * @deprecated
4921 * Call convention of the kernel. The value of this attribute is undefined if
4922 * the symbol is not a kernel. The type of this attribute is uint32_t.
4924 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_CALL_CONVENTION = 18,
4926 * Indirect function object handle. The value of this attribute is undefined
4927 * if the symbol is not an indirect function, or the associated agent does
4928 * not support the Full Profile. The type of this attribute depends on the
4929 * machine model: the type is uint32_t for small machine model, and uint64_t
4930 * for large model.
4932 * If the state of the executable is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0
4933 * is returned.
4935 HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_OBJECT = 23,
4937 * @deprecated
4939 * Call convention of the indirect function. The value of this attribute is
4940 * undefined if the symbol is not an indirect function, or the associated
4941 * agent does not support the Full Profile. The type of this attribute is
4942 * uint32_t.
4944 HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION = 16
4945 } hsa_executable_symbol_info_t;
4948 * @brief Get the current value of an attribute for a given executable symbol.
4950 * @param[in] executable_symbol Executable symbol.
4952 * @param[in] attribute Attribute to query.
4954 * @param[out] value Pointer to an application-allocated buffer where to store
4955 * the value of the attribute. If the buffer passed by the application is not
4956 * large enough to hold the value of @p attribute, the behavior is undefined.
4958 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4960 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4961 * initialized.
4963 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE_SYMBOL The executable symbol is
4964 * invalid.
4966 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
4967 * executable symbol attribute, or @p value is NULL.
4969 hsa_status_t HSA_API hsa_executable_symbol_get_info(
4970 hsa_executable_symbol_t executable_symbol,
4971 hsa_executable_symbol_info_t attribute,
4972 void *value);
4975 * @deprecated
4977 * @brief Iterate over the symbols in a executable, and invoke an
4978 * application-defined callback on every iteration.
4980 * @param[in] executable Executable.
4982 * @param[in] callback Callback to be invoked once per executable symbol. The
4983 * HSA runtime passes three arguments to the callback: the executable, a symbol,
4984 * and the application data. If @p callback returns a status other than
4985 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
4986 * ::hsa_executable_iterate_symbols returns that status value.
4988 * @param[in] data Application data that is passed to @p callback on every
4989 * iteration. May be NULL.
4991 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4993 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4994 * initialized.
4996 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4998 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5000 hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_iterate_symbols(
5001 hsa_executable_t executable,
5002 hsa_status_t (*callback)(hsa_executable_t exec,
5003 hsa_executable_symbol_t symbol,
5004 void *data),
5005 void *data);
5008 * @brief Iterate over the kernels, indirect functions, and agent allocation
5009 * variables in an executable for a given agent, and invoke an application-
5010 * defined callback on every iteration.
5012 * @param[in] executable Executable.
5014 * @param[in] agent Agent.
5016 * @param[in] callback Callback to be invoked once per executable symbol. The
5017 * HSA runtime passes three arguments to the callback: the executable, a symbol,
5018 * and the application data. If @p callback returns a status other than
5019 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
5020 * ::hsa_executable_iterate_symbols returns that status value.
5022 * @param[in] data Application data that is passed to @p callback on every
5023 * iteration. May be NULL.
5025 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5027 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5028 * initialized.
5030 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5032 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5034 hsa_status_t HSA_API hsa_executable_iterate_agent_symbols(
5035 hsa_executable_t executable,
5036 hsa_agent_t agent,
5037 hsa_status_t (*callback)(hsa_executable_t exec,
5038 hsa_agent_t agent,
5039 hsa_executable_symbol_t symbol,
5040 void *data),
5041 void *data);
5044 * @brief Iterate over the program allocation variables in an executable, and
5045 * invoke an application-defined callback on every iteration.
5047 * @param[in] executable Executable.
5049 * @param[in] callback Callback to be invoked once per executable symbol. The
5050 * HSA runtime passes three arguments to the callback: the executable, a symbol,
5051 * and the application data. If @p callback returns a status other than
5052 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
5053 * ::hsa_executable_iterate_symbols returns that status value.
5055 * @param[in] data Application data that is passed to @p callback on every
5056 * iteration. May be NULL.
5058 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5060 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5061 * initialized.
5063 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5065 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5067 hsa_status_t HSA_API hsa_executable_iterate_program_symbols(
5068 hsa_executable_t executable,
5069 hsa_status_t (*callback)(hsa_executable_t exec,
5070 hsa_executable_symbol_t symbol,
5071 void *data),
5072 void *data);
5074 /** @} */
5077 /** \defgroup code-object Code Objects (deprecated).
5078 * @{
5082 * @deprecated
5084 * @brief Struct containing an opaque handle to a code object, which contains
5085 * ISA for finalized kernels and indirect functions together with information
5086 * about the global or readonly segment variables they reference.
5088 typedef struct hsa_code_object_s {
5090 * Opaque handle. Two handles reference the same object of the enclosing type
5091 * if and only if they are equal.
5093 uint64_t handle;
5094 } hsa_code_object_t;
5097 * @deprecated
5099 * @brief Application data handle that is passed to the serialization
5100 * and deserialization functions.
5102 typedef struct hsa_callback_data_s {
5104 * Opaque handle.
5106 uint64_t handle;
5107 } hsa_callback_data_t;
5110 * @deprecated
5112 * @brief Serialize a code object. Can be used for offline finalization,
5113 * install-time finalization, disk code caching, etc.
5115 * @param[in] code_object Code object.
5117 * @param[in] alloc_callback Callback function for memory allocation. Must not
5118 * be NULL. The HSA runtime passes three arguments to the callback: the
5119 * allocation size, the application data, and a pointer to a memory location
5120 * where the application stores the allocation result. The HSA runtime invokes
5121 * @p alloc_callback once to allocate a buffer that contains the serialized
5122 * version of @p code_object. If the callback returns a status code other than
5123 * ::HSA_STATUS_SUCCESS, this function returns the same code.
5125 * @param[in] callback_data Application data that is passed to @p
5126 * alloc_callback. May be NULL.
5128 * @param[in] options Standard and vendor-specific options. Unknown options are
5129 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
5130 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
5131 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
5132 * NUL-terminated string. May be NULL.
5134 * @param[out] serialized_code_object Memory location where the HSA runtime
5135 * stores a pointer to the serialized code object. Must not be NULL.
5137 * @param[out] serialized_code_object_size Memory location where the HSA runtime
5138 * stores the size (in bytes) of @p serialized_code_object. The returned value
5139 * matches the allocation size passed by the HSA runtime to @p
5140 * alloc_callback. Must not be NULL.
5142 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5144 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5145 * initialized.
5147 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
5148 * allocate the required resources.
5150 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5152 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p alloc_callback, @p
5153 * serialized_code_object, or @p serialized_code_object_size are NULL.
5155 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_serialize(
5156 hsa_code_object_t code_object,
5157 hsa_status_t (*alloc_callback)(size_t size,
5158 hsa_callback_data_t data,
5159 void **address),
5160 hsa_callback_data_t callback_data,
5161 const char *options,
5162 void **serialized_code_object,
5163 size_t *serialized_code_object_size);
5166 * @deprecated
5168 * @brief Deserialize a code object.
5170 * @param[in] serialized_code_object A serialized code object. Must not be NULL.
5172 * @param[in] serialized_code_object_size The size (in bytes) of @p
5173 * serialized_code_object. Must not be 0.
5175 * @param[in] options Standard and vendor-specific options. Unknown options are
5176 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
5177 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
5178 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
5179 * NUL-terminated string. May be NULL.
5181 * @param[out] code_object Memory location where the HSA runtime stores the
5182 * deserialized code object.
5184 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5186 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5187 * initialized.
5189 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
5190 * allocate the required resources.
5192 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p serialized_code_object, or @p
5193 * code_object are NULL, or @p serialized_code_object_size is 0.
5195 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_deserialize(
5196 void *serialized_code_object,
5197 size_t serialized_code_object_size,
5198 const char *options,
5199 hsa_code_object_t *code_object);
5202 * @deprecated
5204 * @brief Destroy a code object.
5206 * @details The lifetime of a code object must exceed that of any executable
5207 * where it has been loaded. If an executable that loaded @p code_object has not
5208 * been destroyed, the behavior is undefined.
5210 * @param[in] code_object Code object. The handle becomes invalid after it has
5211 * been destroyed.
5213 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5215 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5216 * initialized.
5218 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5220 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_destroy(
5221 hsa_code_object_t code_object);
5224 * @deprecated
5226 * @brief Code object type.
5228 typedef enum {
5230 * Produces code object that contains ISA for all kernels and indirect
5231 * functions in HSA source.
5233 HSA_CODE_OBJECT_TYPE_PROGRAM = 0
5234 } hsa_code_object_type_t;
5237 * @deprecated
5239 * @brief Code object attributes.
5241 typedef enum {
5243 * The version of the code object. The type of this attribute is a
5244 * NUL-terminated char[64]. The name must be at most 63 characters long (not
5245 * including the NUL terminator) and all array elements not used for the name
5246 * must be NUL.
5248 HSA_CODE_OBJECT_INFO_VERSION = 0,
5250 * Type of code object. The type of this attribute is
5251 * ::hsa_code_object_type_t.
5253 HSA_CODE_OBJECT_INFO_TYPE = 1,
5255 * Instruction set architecture this code object is produced for. The type of
5256 * this attribute is ::hsa_isa_t.
5258 HSA_CODE_OBJECT_INFO_ISA = 2,
5260 * Machine model this code object is produced for. The type of this attribute
5261 * is ::hsa_machine_model_t.
5263 HSA_CODE_OBJECT_INFO_MACHINE_MODEL = 3,
5265 * Profile this code object is produced for. The type of this attribute is
5266 * ::hsa_profile_t.
5268 HSA_CODE_OBJECT_INFO_PROFILE = 4,
5270 * Default floating-point rounding mode used when the code object is
5271 * produced. The type of this attribute is
5272 * ::hsa_default_float_rounding_mode_t.
5274 HSA_CODE_OBJECT_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 5
5275 } hsa_code_object_info_t;
5278 * @deprecated
5280 * @brief Get the current value of an attribute for a given code object.
5282 * @param[in] code_object Code object.
5284 * @param[in] attribute Attribute to query.
5286 * @param[out] value Pointer to an application-allocated buffer where to store
5287 * the value of the attribute. If the buffer passed by the application is not
5288 * large enough to hold the value of @p attribute, the behavior is undefined.
5290 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5292 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5293 * initialized.
5295 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5297 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
5298 * code object attribute, or @p value is NULL.
5300 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_get_info(
5301 hsa_code_object_t code_object,
5302 hsa_code_object_info_t attribute,
5303 void *value);
5306 * @deprecated
5308 * @brief Load code object into the executable.
5310 * @details Every global or readonly variable that is external must be defined
5311 * before loading the code object. An internal global or readonly variable is
5312 * allocated once the code object, that is being loaded, references this
5313 * variable and this variable is not allocated.
5315 * Any module linkage declaration must have been defined either by a define
5316 * variable or by loading a code object that has a symbol with module linkage
5317 * definition.
5319 * @param[in] executable Executable.
5321 * @param[in] agent Agent to load code object for. The agent must support the
5322 * default floating-point rounding mode used by @p code_object.
5324 * @param[in] code_object Code object to load. The lifetime of the code object
5325 * must exceed that of the executable: if @p code_object is destroyed before @p
5326 * executable, the behavior is undefined.
5328 * @param[in] options Standard and vendor-specific options. Unknown options are
5329 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
5330 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
5331 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
5332 * NUL-terminated string. May be NULL.
5334 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5336 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5337 * initialized.
5339 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
5340 * allocate the required resources.
5342 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5344 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
5346 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5348 * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS @p agent is not compatible
5349 * with @p code_object (for example, @p agent does not support the default
5350 * floating-point rounding mode specified by @p code_object), or @p code_object
5351 * is not compatible with @p executable (for example, @p code_object and @p
5352 * executable have different machine models or profiles).
5354 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
5356 hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_load_code_object(
5357 hsa_executable_t executable,
5358 hsa_agent_t agent,
5359 hsa_code_object_t code_object,
5360 const char *options);
5363 * @deprecated
5365 * @brief Code object symbol handle.
5367 * The lifetime of a code object symbol matches that of the code object
5368 * associated with it. An operation on a symbol whose associated code object has
5369 * been destroyed results in undefined behavior.
5371 typedef struct hsa_code_symbol_s {
5373 * Opaque handle. Two handles reference the same object of the enclosing type
5374 * if and only if they are equal.
5376 uint64_t handle;
5377 } hsa_code_symbol_t;
5380 * @deprecated
5382 * @brief Get the symbol handle within a code object for a given a symbol name.
5384 * @param[in] code_object Code object.
5386 * @param[in] symbol_name Symbol name.
5388 * @param[out] symbol Memory location where the HSA runtime stores the symbol
5389 * handle.
5391 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5393 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5394 * initialized.
5396 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5398 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
5399 * that matches @p symbol_name.
5401 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
5402 * @p symbol is NULL.
5404 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_get_symbol(
5405 hsa_code_object_t code_object,
5406 const char *symbol_name,
5407 hsa_code_symbol_t *symbol);
5410 * @deprecated
5412 * @brief Get the symbol handle within a code object for a given a symbol name.
5414 * @param[in] code_object Code object.
5416 * @param[in] module_name Module name. Must be NULL if the symbol has
5417 * program linkage.
5419 * @param[in] symbol_name Symbol name.
5421 * @param[out] symbol Memory location where the HSA runtime stores the symbol
5422 * handle.
5424 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5426 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5427 * initialized.
5429 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5431 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
5432 * that matches @p symbol_name.
5434 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
5435 * @p symbol is NULL.
5437 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_get_symbol_from_name(
5438 hsa_code_object_t code_object,
5439 const char *module_name,
5440 const char *symbol_name,
5441 hsa_code_symbol_t *symbol);
5444 * @deprecated
5446 * @brief Code object symbol attributes.
5448 typedef enum {
5450 * The type of the symbol. The type of this attribute is ::hsa_symbol_kind_t.
5452 HSA_CODE_SYMBOL_INFO_TYPE = 0,
5454 * The length of the symbol name in bytes, not including the NUL terminator.
5455 * The type of this attribute is uint32_t.
5457 HSA_CODE_SYMBOL_INFO_NAME_LENGTH = 1,
5459 * The name of the symbol. The type of this attribute is character array with
5460 * the length equal to the value of ::HSA_CODE_SYMBOL_INFO_NAME_LENGTH
5461 * attribute.
5463 HSA_CODE_SYMBOL_INFO_NAME = 2,
5465 * The length of the module name in bytes (not including the NUL terminator)
5466 * to which this symbol belongs if this symbol has module linkage, otherwise 0
5467 * is returned. The type of this attribute is uint32_t.
5469 HSA_CODE_SYMBOL_INFO_MODULE_NAME_LENGTH = 3,
5471 * The module name to which this symbol belongs if this symbol has module
5472 * linkage, otherwise an empty string is returned. The type of this attribute
5473 * is character array with the length equal to the value of
5474 * ::HSA_CODE_SYMBOL_INFO_MODULE_NAME_LENGTH attribute.
5476 HSA_CODE_SYMBOL_INFO_MODULE_NAME = 4,
5478 * The linkage kind of the symbol. The type of this attribute is
5479 * ::hsa_symbol_linkage_t.
5481 HSA_CODE_SYMBOL_INFO_LINKAGE = 5,
5483 * Indicates whether the symbol corresponds to a definition. The type of this
5484 * attribute is bool.
5486 HSA_CODE_SYMBOL_INFO_IS_DEFINITION = 17,
5488 * The allocation kind of the variable. The value of this attribute is
5489 * undefined if the symbol is not a variable. The type of this attribute is
5490 * ::hsa_variable_allocation_t.
5492 HSA_CODE_SYMBOL_INFO_VARIABLE_ALLOCATION = 6,
5494 * The segment kind of the variable. The value of this attribute is
5495 * undefined if the symbol is not a variable. The type of this attribute is
5496 * ::hsa_variable_segment_t.
5498 HSA_CODE_SYMBOL_INFO_VARIABLE_SEGMENT = 7,
5500 * Alignment of the symbol in memory. The value of this attribute is undefined
5501 * if the symbol is not a variable. The type of this attribute is uint32_t.
5503 * The current alignment of the variable in memory may be greater than the
5504 * value specified in the source program variable declaration.
5506 HSA_CODE_SYMBOL_INFO_VARIABLE_ALIGNMENT = 8,
5508 * Size of the variable. The value of this attribute is undefined if the
5509 * symbol is not a variable. The type of this attribute is uint32_t.
5511 * A size of 0 is returned if the variable is an external variable and has an
5512 * unknown dimension.
5514 HSA_CODE_SYMBOL_INFO_VARIABLE_SIZE = 9,
5516 * Indicates whether the variable is constant. The value of this attribute is
5517 * undefined if the symbol is not a variable. The type of this attribute is
5518 * bool.
5520 HSA_CODE_SYMBOL_INFO_VARIABLE_IS_CONST = 10,
5522 * Size of kernarg segment memory that is required to hold the values of the
5523 * kernel arguments, in bytes. Must be a multiple of 16. The value of this
5524 * attribute is undefined if the symbol is not a kernel. The type of this
5525 * attribute is uint32_t.
5527 HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE = 11,
5529 * Alignment (in bytes) of the buffer used to pass arguments to the kernel,
5530 * which is the maximum of 16 and the maximum alignment of any of the kernel
5531 * arguments. The value of this attribute is undefined if the symbol is not a
5532 * kernel. The type of this attribute is uint32_t.
5534 HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT = 12,
5536 * Size of static group segment memory required by the kernel (per
5537 * work-group), in bytes. The value of this attribute is undefined
5538 * if the symbol is not a kernel. The type of this attribute is uint32_t.
5540 * The reported amount does not include any dynamically allocated group
5541 * segment memory that may be requested by the application when a kernel is
5542 * dispatched.
5544 HSA_CODE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE = 13,
5546 * Size of static private, spill, and arg segment memory required by
5547 * this kernel (per work-item), in bytes. The value of this attribute is
5548 * undefined if the symbol is not a kernel. The type of this attribute is
5549 * uint32_t.
5551 * If the value of ::HSA_CODE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK is true,
5552 * the kernel may use more private memory than the reported value, and the
5553 * application must add the dynamic call stack usage to @a
5554 * private_segment_size when populating a kernel dispatch packet.
5556 HSA_CODE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE = 14,
5558 * Dynamic callstack flag. The value of this attribute is undefined if the
5559 * symbol is not a kernel. The type of this attribute is bool.
5561 * If this flag is set (the value is true), the kernel uses a dynamically
5562 * sized call stack. This can happen if recursive calls, calls to indirect
5563 * functions, or the HSAIL alloca instruction are present in the kernel.
5565 HSA_CODE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK = 15,
5567 * Call convention of the kernel. The value of this attribute is undefined if
5568 * the symbol is not a kernel. The type of this attribute is uint32_t.
5570 HSA_CODE_SYMBOL_INFO_KERNEL_CALL_CONVENTION = 18,
5572 * Call convention of the indirect function. The value of this attribute is
5573 * undefined if the symbol is not an indirect function. The type of this
5574 * attribute is uint32_t.
5576 HSA_CODE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION = 16
5577 } hsa_code_symbol_info_t;
5580 * @deprecated
5582 * @brief Get the current value of an attribute for a given code symbol.
5584 * @param[in] code_symbol Code symbol.
5586 * @param[in] attribute Attribute to query.
5588 * @param[out] value Pointer to an application-allocated buffer where to store
5589 * the value of the attribute. If the buffer passed by the application is not
5590 * large enough to hold the value of @p attribute, the behavior is undefined.
5592 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5594 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5595 * initialized.
5597 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_SYMBOL The code symbol is invalid.
5599 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
5600 * code symbol attribute, or @p value is NULL.
5602 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_symbol_get_info(
5603 hsa_code_symbol_t code_symbol,
5604 hsa_code_symbol_info_t attribute,
5605 void *value);
5608 * @deprecated
5610 * @brief Iterate over the symbols in a code object, and invoke an
5611 * application-defined callback on every iteration.
5613 * @param[in] code_object Code object.
5615 * @param[in] callback Callback to be invoked once per code object symbol. The
5616 * HSA runtime passes three arguments to the callback: the code object, a
5617 * symbol, and the application data. If @p callback returns a status other than
5618 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
5619 * ::hsa_code_object_iterate_symbols returns that status value.
5621 * @param[in] data Application data that is passed to @p callback on every
5622 * iteration. May be NULL.
5624 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5626 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5627 * initialized.
5629 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5631 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5633 hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_iterate_symbols(
5634 hsa_code_object_t code_object,
5635 hsa_status_t (*callback)(hsa_code_object_t code_object,
5636 hsa_code_symbol_t symbol,
5637 void *data),
5638 void *data);
5640 /** @} */
5642 #ifdef __cplusplus
5643 } // end extern "C" block
5644 #endif
5646 #endif // header guard