1 ////////////////////////////////////////////////////////////////////////////////
3 // Copyright (C) 2014-2020 Advanced Micro Devices Inc. All rights reserved.
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 */
36 #include <stdbool.h> /* bool */
37 #endif /* __cplusplus */
39 // Placeholder for calling convention and import/export macros
44 #ifndef HSA_EXPORT_DECORATOR
46 #define HSA_EXPORT_DECORATOR __attribute__ ((visibility ("default")))
48 #define HSA_EXPORT_DECORATOR
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
57 #define HSA_API HSA_API_IMPORT
60 // Detect and set large model builds.
61 #undef HSA_LARGE_MODEL
62 #if defined(__LP64__) || defined(_M_X64)
63 #define HSA_LARGE_MODEL
66 // Try to detect CPU endianness
67 #if !defined(LITTLEENDIAN_CPU) && !defined(BIGENDIAN_CPU)
68 #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \
70 #define LITTLEENDIAN_CPU
74 #undef HSA_LITTLE_ENDIAN
75 #if defined(LITTLEENDIAN_CPU)
76 #define HSA_LITTLE_ENDIAN
77 #elif defined(BIGENDIAN_CPU)
79 #error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
82 #ifndef HSA_DEPRECATED
83 #define HSA_DEPRECATED
85 //#define HSA_DEPRECATED __attribute__((deprecated))
87 //#define HSA_DEPRECATED __declspec(deprecated)
91 #define HSA_VERSION_1_0 1
95 #endif /* __cplusplus */
97 /** \defgroup status Runtime Notifications
102 * @brief Status codes.
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
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
260 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
262 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
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(
270 const char ** status_string
);
274 /** \defgroup common Common Definitions
279 * @brief Three-dimensional coordinate.
281 typedef struct hsa_dim3_s
{
299 * @brief Access permissions.
305 HSA_ACCESS_PERMISSION_RO
= 1,
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
;
324 /** \defgroup initshutdown Initialization and Shut Down
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
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
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
367 hsa_status_t HSA_API
hsa_shut_down();
371 /** \defgroup agentinfo System and Agent Information
376 * @brief Endianness. A convention used to interpret the bytes making up a data
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
391 * @brief Machine model. A machine model determines the size of certain data
392 * types in HSA runtime and an agent.
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.
415 HSA_PROFILE_BASE
= 0,
423 * @brief System attributes.
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,
471 HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT
= 0x202
475 * @brief Get the current value of a system attribute.
477 * @param[in] attribute Attribute to query.
479 * @param[out] value Pointer to an application-allocated buffer where to store
480 * the value of the attribute. If the buffer passed by the application is not
481 * large enough to hold the value of @p attribute, the behavior is undefined.
483 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
485 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
488 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
489 * system attribute, or @p value is NULL.
491 hsa_status_t HSA_API
hsa_system_get_info(
492 hsa_system_info_t attribute
,
496 * @brief HSA extensions.
500 * Finalizer extension.
502 HSA_EXTENSION_FINALIZER
= 0,
506 HSA_EXTENSION_IMAGES
= 1,
509 * Performance counter extension.
511 HSA_EXTENSION_PERFORMANCE_COUNTERS
= 2,
514 * Profiling events extension.
516 HSA_EXTENSION_PROFILING_EVENTS
= 3,
520 HSA_EXTENSION_STD_LAST
= 3,
522 * First AMD extension number.
524 HSA_AMD_FIRST_EXTENSION
= 0x200,
526 * Profiler extension.
528 HSA_EXTENSION_AMD_PROFILER
= 0x200,
532 HSA_EXTENSION_AMD_LOADER
= 0x201,
534 * AqlProfile extension.
536 HSA_EXTENSION_AMD_AQLPROFILE
= 0x202,
538 * Last AMD extension.
540 HSA_AMD_LAST_EXTENSION
= 0x202
544 * @brief Query the name of a given extension.
546 * @param[in] extension Extension identifier. If the extension is not supported
547 * by the implementation (see ::HSA_SYSTEM_INFO_EXTENSIONS), the behavior
550 * @param[out] name Pointer to a memory location where the HSA runtime stores
551 * the extension name. The extension name is a NUL-terminated string.
553 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
555 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
558 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
559 * extension, or @p name is NULL.
561 hsa_status_t HSA_API
hsa_extension_get_name(
568 * @brief Query if a given version of an extension is supported by the HSA
571 * @param[in] extension Extension identifier.
573 * @param[in] version_major Major version number.
575 * @param[in] version_minor Minor version number.
577 * @param[out] result Pointer to a memory location where the HSA runtime stores
578 * the result of the check. The result is true if the specified version of the
579 * extension is supported, and false otherwise.
581 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
583 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
586 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
587 * extension, or @p result is NULL.
589 hsa_status_t HSA_API HSA_DEPRECATED
hsa_system_extension_supported(
591 uint16_t version_major
,
592 uint16_t version_minor
,
596 * @brief Query if a given version of an extension is supported by the HSA
597 * implementation. All minor versions from 0 up to the returned @p version_minor
598 * must be supported by the implementation.
600 * @param[in] extension Extension identifier.
602 * @param[in] version_major Major version number.
604 * @param[out] version_minor Minor version number.
606 * @param[out] result Pointer to a memory location where the HSA runtime stores
607 * the result of the check. The result is true if the specified version of the
608 * extension is supported, and false otherwise.
610 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
612 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
615 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
616 * extension, or @p version_minor is NULL, or @p result is NULL.
618 hsa_status_t HSA_API
hsa_system_major_extension_supported(
620 uint16_t version_major
,
621 uint16_t *version_minor
,
628 * @brief Retrieve the function pointers corresponding to a given version of an
629 * extension. Portable applications are expected to invoke the extension API
630 * using the returned function pointers
632 * @details The application is responsible for verifying that the given version
633 * of the extension is supported by the HSA implementation (see
634 * ::hsa_system_extension_supported). If the given combination of extension,
635 * major version, and minor version is not supported by the implementation, the
636 * behavior is undefined.
638 * @param[in] extension Extension identifier.
640 * @param[in] version_major Major version number for which to retrieve the
641 * function pointer table.
643 * @param[in] version_minor Minor version number for which to retrieve the
644 * function pointer table.
646 * @param[out] table Pointer to an application-allocated function pointer table
647 * that is populated by the HSA runtime. Must not be NULL. The memory associated
648 * with table can be reused or freed after the function returns.
650 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
652 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
655 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
656 * extension, or @p table is NULL.
658 hsa_status_t HSA_API HSA_DEPRECATED
hsa_system_get_extension_table(
660 uint16_t version_major
,
661 uint16_t version_minor
,
665 * @brief Retrieve the function pointers corresponding to a given major version
666 * of an extension. Portable applications are expected to invoke the extension
667 * API using the returned function pointers.
669 * @details The application is responsible for verifying that the given major
670 * version of the extension is supported by the HSA implementation (see
671 * ::hsa_system_major_extension_supported). If the given combination of extension
672 * and major version is not supported by the implementation, the behavior is
673 * undefined. Additionally if the length doesn't allow space for a full minor
674 * version, it is implementation defined if only some of the function pointers for
675 * that minor version get written.
677 * @param[in] extension Extension identifier.
679 * @param[in] version_major Major version number for which to retrieve the
680 * function pointer table.
682 * @param[in] table_length Size in bytes of the function pointer table to be
683 * populated. The implementation will not write more than this many bytes to the
686 * @param[out] table Pointer to an application-allocated function pointer table
687 * that is populated by the HSA runtime. Must not be NULL. The memory associated
688 * with table can be reused or freed after the function returns.
690 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
692 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
695 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
696 * extension, or @p table is NULL.
698 hsa_status_t HSA_API
hsa_system_get_major_extension_table(
700 uint16_t version_major
,
705 * @brief Struct containing an opaque handle to an agent, a device that participates in
706 * the HSA memory model. An agent can submit AQL packets for execution, and
707 * may also accept AQL packets for execution (agent dispatch packets or kernel
708 * dispatch packets launching HSAIL-derived binaries).
710 typedef struct hsa_agent_s
{
712 * Opaque handle. Two handles reference the same object of the enclosing type
713 * if and only if they are equal.
719 * @brief Agent features.
723 * The agent supports AQL packets of kernel dispatch type. If this
724 * feature is enabled, the agent is also a kernel agent.
726 HSA_AGENT_FEATURE_KERNEL_DISPATCH
= 1,
728 * The agent supports AQL packets of agent dispatch type.
730 HSA_AGENT_FEATURE_AGENT_DISPATCH
= 2
731 } hsa_agent_feature_t
;
734 * @brief Hardware device type.
740 HSA_DEVICE_TYPE_CPU
= 0,
744 HSA_DEVICE_TYPE_GPU
= 1,
748 HSA_DEVICE_TYPE_DSP
= 2
752 * @brief Default floating-point rounding mode.
756 * Use a default floating-point rounding mode specified elsewhere.
758 HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT
= 0,
760 * Operations that specify the default floating-point mode are rounded to zero
763 HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO
= 1,
765 * Operations that specify the default floating-point mode are rounded to the
766 * nearest representable number and that ties should be broken by selecting
767 * the value with an even least significant bit.
769 HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR
= 2
770 } hsa_default_float_rounding_mode_t
;
773 * @brief Agent attributes.
777 * Agent name. The type of this attribute is a NUL-terminated char[64]. The
778 * name must be at most 63 characters long (not including the NUL terminator)
779 * and all array elements not used for the name must be NUL.
781 HSA_AGENT_INFO_NAME
= 0,
783 * Name of vendor. The type of this attribute is a NUL-terminated char[64].
784 * The name must be at most 63 characters long (not including the NUL
785 * terminator) and all array elements not used for the name must be NUL.
787 HSA_AGENT_INFO_VENDOR_NAME
= 1,
789 * Agent capability. The type of this attribute is ::hsa_agent_feature_t.
791 HSA_AGENT_INFO_FEATURE
= 2,
793 * @deprecated Query ::HSA_ISA_INFO_MACHINE_MODELS for a given intruction set
794 * architecture supported by the agent instead. If more than one ISA is
795 * supported by the agent, the returned value corresponds to the first ISA
796 * enumerated by ::hsa_agent_iterate_isas.
798 * Machine model supported by the agent. The type of this attribute is
799 * ::hsa_machine_model_t.
801 HSA_AGENT_INFO_MACHINE_MODEL
= 3,
803 * @deprecated Query ::HSA_ISA_INFO_PROFILES for a given intruction set
804 * architecture supported by the agent instead. If more than one ISA is
805 * supported by the agent, the returned value corresponds to the first ISA
806 * enumerated by ::hsa_agent_iterate_isas.
808 * Profile supported by the agent. The type of this attribute is
811 HSA_AGENT_INFO_PROFILE
= 4,
813 * @deprecated Query ::HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES for a given
814 * intruction set architecture supported by the agent instead. If more than
815 * one ISA is supported by the agent, the returned value corresponds to the
816 * first ISA enumerated by ::hsa_agent_iterate_isas.
818 * Default floating-point rounding mode. The type of this attribute is
819 * ::hsa_default_float_rounding_mode_t, but the value
820 * ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT is not allowed.
822 HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE
= 5,
824 * @deprecated Query ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES
825 * for a given intruction set architecture supported by the agent instead. If
826 * more than one ISA is supported by the agent, the returned value corresponds
827 * to the first ISA enumerated by ::hsa_agent_iterate_isas.
829 * A bit-mask of ::hsa_default_float_rounding_mode_t values, representing the
830 * default floating-point rounding modes supported by the agent in the Base
831 * profile. The type of this attribute is uint32_t. The default floating-point
832 * rounding mode (::HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE) bit must not
835 HSA_AGENT_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES
= 23,
837 * @deprecated Query ::HSA_ISA_INFO_FAST_F16_OPERATION for a given intruction
838 * set architecture supported by the agent instead. If more than one ISA is
839 * supported by the agent, the returned value corresponds to the first ISA
840 * enumerated by ::hsa_agent_iterate_isas.
842 * Flag indicating that the f16 HSAIL operation is at least as fast as the
843 * f32 operation in the current agent. The value of this attribute is
844 * undefined if the agent is not a kernel agent. The type of this
847 HSA_AGENT_INFO_FAST_F16_OPERATION
= 24,
849 * @deprecated Query ::HSA_WAVEFRONT_INFO_SIZE for a given wavefront and
850 * intruction set architecture supported by the agent instead. If more than
851 * one ISA is supported by the agent, the returned value corresponds to the
852 * first ISA enumerated by ::hsa_agent_iterate_isas and the first wavefront
853 * enumerated by ::hsa_isa_iterate_wavefronts for that ISA.
855 * Number of work-items in a wavefront. Must be a power of 2 in the range
856 * [1,256]. The value of this attribute is undefined if the agent is not
857 * a kernel agent. The type of this attribute is uint32_t.
859 HSA_AGENT_INFO_WAVEFRONT_SIZE
= 6,
861 * @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_DIM for a given intruction
862 * set architecture supported by the agent instead. If more than one ISA is
863 * supported by the agent, the returned value corresponds to the first ISA
864 * enumerated by ::hsa_agent_iterate_isas.
866 * Maximum number of work-items of each dimension of a work-group. Each
867 * maximum must be greater than 0. No maximum can exceed the value of
868 * ::HSA_AGENT_INFO_WORKGROUP_MAX_SIZE. The value of this attribute is
869 * undefined if the agent is not a kernel agent. The type of this
870 * attribute is uint16_t[3].
872 HSA_AGENT_INFO_WORKGROUP_MAX_DIM
= 7,
874 * @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE for a given intruction
875 * set architecture supported by the agent instead. If more than one ISA is
876 * supported by the agent, the returned value corresponds to the first ISA
877 * enumerated by ::hsa_agent_iterate_isas.
879 * Maximum total number of work-items in a work-group. The value of this
880 * attribute is undefined if the agent is not a kernel agent. The type
881 * of this attribute is uint32_t.
883 HSA_AGENT_INFO_WORKGROUP_MAX_SIZE
= 8,
885 * @deprecated Query ::HSA_ISA_INFO_GRID_MAX_DIM for a given intruction set
886 * architecture supported by the agent instead.
888 * Maximum number of work-items of each dimension of a grid. Each maximum must
889 * be greater than 0, and must not be smaller than the corresponding value in
890 * ::HSA_AGENT_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
891 * ::HSA_AGENT_INFO_GRID_MAX_SIZE. The value of this attribute is undefined
892 * if the agent is not a kernel agent. The type of this attribute is
895 HSA_AGENT_INFO_GRID_MAX_DIM
= 9,
897 * @deprecated Query ::HSA_ISA_INFO_GRID_MAX_SIZE for a given intruction set
898 * architecture supported by the agent instead. If more than one ISA is
899 * supported by the agent, the returned value corresponds to the first ISA
900 * enumerated by ::hsa_agent_iterate_isas.
902 * Maximum total number of work-items in a grid. The value of this attribute
903 * is undefined if the agent is not a kernel agent. The type of this
904 * attribute is uint32_t.
906 HSA_AGENT_INFO_GRID_MAX_SIZE
= 10,
908 * @deprecated Query ::HSA_ISA_INFO_FBARRIER_MAX_SIZE for a given intruction
909 * set architecture supported by the agent instead. If more than one ISA is
910 * supported by the agent, the returned value corresponds to the first ISA
911 * enumerated by ::hsa_agent_iterate_isas.
913 * Maximum number of fbarriers per work-group. Must be at least 32. The value
914 * of this attribute is undefined if the agent is not a kernel agent. The
915 * type of this attribute is uint32_t.
917 HSA_AGENT_INFO_FBARRIER_MAX_SIZE
= 11,
919 * @deprecated The maximum number of queues is not statically determined.
921 * Maximum number of queues that can be active (created but not destroyed) at
922 * one time in the agent. The type of this attribute is uint32_t.
924 HSA_AGENT_INFO_QUEUES_MAX
= 12,
926 * Minimum number of packets that a queue created in the agent
927 * can hold. Must be a power of 2 greater than 0. Must not exceed
928 * the value of ::HSA_AGENT_INFO_QUEUE_MAX_SIZE. The type of this
929 * attribute is uint32_t.
931 HSA_AGENT_INFO_QUEUE_MIN_SIZE
= 13,
933 * Maximum number of packets that a queue created in the agent can
934 * hold. Must be a power of 2 greater than 0. The type of this attribute
937 HSA_AGENT_INFO_QUEUE_MAX_SIZE
= 14,
939 * Type of a queue created in the agent. The type of this attribute is
940 * ::hsa_queue_type32_t.
942 HSA_AGENT_INFO_QUEUE_TYPE
= 15,
944 * @deprecated NUMA information is not exposed anywhere else in the API.
946 * Identifier of the NUMA node associated with the agent. The type of this
947 * attribute is uint32_t.
949 HSA_AGENT_INFO_NODE
= 16,
951 * Type of hardware device associated with the agent. The type of this
952 * attribute is ::hsa_device_type_t.
954 HSA_AGENT_INFO_DEVICE
= 17,
956 * @deprecated Query ::hsa_agent_iterate_caches to retrieve information about
957 * the caches present in a given agent.
959 * Array of data cache sizes (L1..L4). Each size is expressed in bytes. A size
960 * of 0 for a particular level indicates that there is no cache information
961 * for that level. The type of this attribute is uint32_t[4].
963 HSA_AGENT_INFO_CACHE_SIZE
= 18,
965 * @deprecated An agent may support multiple instruction set
966 * architectures. See ::hsa_agent_iterate_isas. If more than one ISA is
967 * supported by the agent, the returned value corresponds to the first ISA
968 * enumerated by ::hsa_agent_iterate_isas.
970 * Instruction set architecture of the agent. The type of this attribute
973 HSA_AGENT_INFO_ISA
= 19,
975 * Bit-mask indicating which extensions are supported by the agent. An
976 * extension with an ID of @p i is supported if the bit at position @p i is
977 * set. The type of this attribute is uint8_t[128].
979 HSA_AGENT_INFO_EXTENSIONS
= 20,
981 * Major version of the HSA runtime specification supported by the
982 * agent. The type of this attribute is uint16_t.
984 HSA_AGENT_INFO_VERSION_MAJOR
= 21,
986 * Minor version of the HSA runtime specification supported by the
987 * agent. The type of this attribute is uint16_t.
989 HSA_AGENT_INFO_VERSION_MINOR
= 22
994 * @brief Get the current value of an attribute for a given agent.
996 * @param[in] agent A valid agent.
998 * @param[in] attribute Attribute to query.
1000 * @param[out] value Pointer to an application-allocated buffer where to store
1001 * the value of the attribute. If the buffer passed by the application is not
1002 * large enough to hold the value of @p attribute, the behavior is undefined.
1004 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1006 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1009 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1011 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
1012 * agent attribute, or @p value is NULL.
1014 hsa_status_t HSA_API
hsa_agent_get_info(
1016 hsa_agent_info_t attribute
,
1020 * @brief Iterate over the available agents, and invoke an
1021 * application-defined callback on every iteration.
1023 * @param[in] callback Callback to be invoked once per agent. The HSA
1024 * runtime passes two arguments to the callback: the agent and the
1025 * application data. If @p callback returns a status other than
1026 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
1027 * ::hsa_iterate_agents returns that status value.
1029 * @param[in] data Application data that is passed to @p callback on every
1030 * iteration. May be NULL.
1032 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1034 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1037 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
1039 hsa_status_t HSA_API
hsa_iterate_agents(
1040 hsa_status_t (*callback
)(hsa_agent_t agent
, void* data
),
1045 // If we do not know the size of an attribute, we need to query it first
1046 // Note: this API will not be in the spec unless needed
1047 hsa_status_t HSA_API hsa_agent_get_info_size(
1049 hsa_agent_info_t attribute,
1052 // Set the value of an agents attribute
1053 // Note: this API will not be in the spec unless needed
1054 hsa_status_t HSA_API hsa_agent_set_info(
1056 hsa_agent_info_t attribute,
1062 * @brief Exception policies applied in the presence of hardware exceptions.
1066 * If a hardware exception is detected, a work-item signals an exception.
1068 HSA_EXCEPTION_POLICY_BREAK
= 1,
1070 * If a hardware exception is detected, a hardware status bit is set.
1072 HSA_EXCEPTION_POLICY_DETECT
= 2
1073 } hsa_exception_policy_t
;
1076 * @deprecated Use ::hsa_isa_get_exception_policies for a given intruction set
1077 * architecture supported by the agent instead. If more than one ISA is
1078 * supported by the agent, this function uses the first value returned by
1079 * ::hsa_agent_iterate_isas.
1081 * @brief Retrieve the exception policy support for a given combination of
1084 * @param[in] agent Agent.
1086 * @param[in] profile Profile.
1088 * @param[out] mask Pointer to a memory location where the HSA runtime stores a
1089 * mask of ::hsa_exception_policy_t values. Must not be NULL.
1091 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1093 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1096 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1098 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is not a valid
1099 * profile, or @p mask is NULL.
1102 hsa_status_t HSA_API HSA_DEPRECATED
hsa_agent_get_exception_policies(
1104 hsa_profile_t profile
,
1108 * @brief Cache handle.
1110 typedef struct hsa_cache_s
{
1112 * Opaque handle. Two handles reference the same object of the enclosing type
1113 * if and only if they are equal.
1119 * @brief Cache attributes.
1123 * The length of the cache name in bytes, not including the NUL terminator.
1124 * The type of this attribute is uint32_t.
1126 HSA_CACHE_INFO_NAME_LENGTH
= 0,
1128 * Human-readable description. The type of this attribute is a NUL-terminated
1129 * character array with the length equal to the value of
1130 * ::HSA_CACHE_INFO_NAME_LENGTH attribute.
1132 HSA_CACHE_INFO_NAME
= 1,
1134 * Cache level. A L1 cache must return a value of 1, a L2 must return a value
1135 * of 2, and so on. The type of this attribute is uint8_t.
1137 HSA_CACHE_INFO_LEVEL
= 2,
1139 * Cache size, in bytes. A value of 0 indicates that there is no size
1140 * information available. The type of this attribute is uint32_t.
1142 HSA_CACHE_INFO_SIZE
= 3
1146 * @brief Get the current value of an attribute for a given cache object.
1148 * @param[in] cache Cache.
1150 * @param[in] attribute Attribute to query.
1152 * @param[out] value Pointer to an application-allocated buffer where to store
1153 * the value of the attribute. If the buffer passed by the application is not
1154 * large enough to hold the value of @p attribute, the behavior is undefined.
1156 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1158 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1161 * @retval ::HSA_STATUS_ERROR_INVALID_CACHE The cache is invalid.
1163 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
1164 * instruction set architecture attribute, or @p value is
1167 hsa_status_t HSA_API
hsa_cache_get_info(
1169 hsa_cache_info_t attribute
,
1173 * @brief Iterate over the memory caches of a given agent, and
1174 * invoke an application-defined callback on every iteration.
1176 * @details Caches are visited in ascending order according to the value of the
1177 * ::HSA_CACHE_INFO_LEVEL attribute.
1179 * @param[in] agent A valid agent.
1181 * @param[in] callback Callback to be invoked once per cache that is present in
1182 * the agent. The HSA runtime passes two arguments to the callback: the cache
1183 * and the application data. If @p callback returns a status other than
1184 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
1185 * that value is returned.
1187 * @param[in] data Application data that is passed to @p callback on every
1188 * iteration. May be NULL.
1190 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1192 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1195 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1197 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
1199 hsa_status_t HSA_API
hsa_agent_iterate_caches(
1201 hsa_status_t (*callback
)(hsa_cache_t cache
, void* data
),
1207 * @brief Query if a given version of an extension is supported by an agent
1209 * @param[in] extension Extension identifier.
1211 * @param[in] agent Agent.
1213 * @param[in] version_major Major version number.
1215 * @param[in] version_minor Minor version number.
1217 * @param[out] result Pointer to a memory location where the HSA runtime stores
1218 * the result of the check. The result is true if the specified version of the
1219 * extension is supported, and false otherwise. The result must be false if
1220 * ::hsa_system_extension_supported returns false for the same extension
1223 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1225 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1228 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1230 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
1231 * extension, or @p result is NULL.
1233 hsa_status_t HSA_API HSA_DEPRECATED
hsa_agent_extension_supported(
1236 uint16_t version_major
,
1237 uint16_t version_minor
,
1241 * @brief Query if a given version of an extension is supported by an agent. All
1242 * minor versions from 0 up to the returned @p version_minor must be supported.
1244 * @param[in] extension Extension identifier.
1246 * @param[in] agent Agent.
1248 * @param[in] version_major Major version number.
1250 * @param[out] version_minor Minor version number.
1252 * @param[out] result Pointer to a memory location where the HSA runtime stores
1253 * the result of the check. The result is true if the specified version of the
1254 * extension is supported, and false otherwise. The result must be false if
1255 * ::hsa_system_extension_supported returns false for the same extension
1258 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1260 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1263 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
1265 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
1266 * extension, or @p version_minor is NULL, or @p result is NULL.
1268 hsa_status_t HSA_API
hsa_agent_major_extension_supported(
1271 uint16_t version_major
,
1272 uint16_t *version_minor
,
1279 /** \defgroup signals Signals
1284 * @brief Signal handle.
1286 typedef struct hsa_signal_s
{
1288 * Opaque handle. Two handles reference the same object of the enclosing type
1289 * if and only if they are equal. The value 0 is reserved.
1295 * @brief Signal value. The value occupies 32 bits in small machine mode, and 64
1296 * bits in large machine mode.
1298 #ifdef HSA_LARGE_MODEL
1299 typedef int64_t hsa_signal_value_t
;
1301 typedef int32_t hsa_signal_value_t
;
1305 * @brief Create a signal.
1307 * @param[in] initial_value Initial value of the signal.
1309 * @param[in] num_consumers Size of @p consumers. A value of 0 indicates that
1310 * any agent might wait on the signal.
1312 * @param[in] consumers List of agents that might consume (wait on) the
1313 * signal. If @p num_consumers is 0, this argument is ignored; otherwise, the
1314 * HSA runtime might use the list to optimize the handling of the signal
1315 * object. If an agent not listed in @p consumers waits on the returned
1316 * signal, the behavior is undefined. The memory associated with @p consumers
1317 * can be reused or freed after the function returns.
1319 * @param[out] signal Pointer to a memory location where the HSA runtime will
1320 * store the newly created signal handle. Must not be NULL.
1322 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1324 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1327 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
1328 * the required resources.
1330 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is NULL, @p
1331 * num_consumers is greater than 0 but @p consumers is NULL, or @p consumers
1332 * contains duplicates.
1334 hsa_status_t HSA_API
hsa_signal_create(
1335 hsa_signal_value_t initial_value
,
1336 uint32_t num_consumers
,
1337 const hsa_agent_t
*consumers
,
1338 hsa_signal_t
*signal
);
1341 * @brief Destroy a signal previous created by ::hsa_signal_create.
1343 * @param[in] signal Signal.
1345 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
1347 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
1350 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL @p signal is invalid.
1352 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The handle in @p signal is 0.
1354 hsa_status_t HSA_API
hsa_signal_destroy(
1355 hsa_signal_t signal
);
1358 * @brief Atomically read the current value of a signal.
1360 * @param[in] signal Signal.
1362 * @return Value of the signal.
1364 hsa_signal_value_t HSA_API
hsa_signal_load_scacquire(
1365 hsa_signal_t signal
);
1368 * @copydoc hsa_signal_load_scacquire
1370 hsa_signal_value_t HSA_API
hsa_signal_load_relaxed(
1371 hsa_signal_t signal
);
1374 * @deprecated Renamed as ::hsa_signal_load_scacquire.
1376 * @copydoc hsa_signal_load_scacquire
1378 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_load_acquire(
1379 hsa_signal_t signal
);
1382 * @brief Atomically set the value of a signal.
1384 * @details If the value of the signal is changed, all the agents waiting
1385 * on @p signal for which @p value satisfies their wait condition are awakened.
1387 * @param[in] signal Signal.
1389 * @param[in] value New signal value.
1391 void HSA_API
hsa_signal_store_relaxed(
1392 hsa_signal_t signal
,
1393 hsa_signal_value_t value
);
1396 * @copydoc hsa_signal_store_relaxed
1398 void HSA_API
hsa_signal_store_screlease(
1399 hsa_signal_t signal
,
1400 hsa_signal_value_t value
);
1403 * @deprecated Renamed as ::hsa_signal_store_screlease.
1405 * @copydoc hsa_signal_store_screlease
1407 void HSA_API HSA_DEPRECATED
hsa_signal_store_release(
1408 hsa_signal_t signal
,
1409 hsa_signal_value_t value
);
1412 * @brief Atomically set the value of a signal without necessarily notifying the
1413 * the agents waiting on it.
1415 * @details The agents waiting on @p signal may not wake up even when the new
1416 * value satisfies their wait condition. If the application wants to update the
1417 * signal and there is no need to notify any agent, invoking this function can
1418 * be more efficient than calling the non-silent counterpart.
1420 * @param[in] signal Signal.
1422 * @param[in] value New signal value.
1424 void HSA_API
hsa_signal_silent_store_relaxed(
1425 hsa_signal_t signal
,
1426 hsa_signal_value_t value
);
1429 * @copydoc hsa_signal_silent_store_relaxed
1431 void HSA_API
hsa_signal_silent_store_screlease(
1432 hsa_signal_t signal
,
1433 hsa_signal_value_t value
);
1436 * @brief Atomically set the value of a signal and return its previous value.
1438 * @details If the value of the signal is changed, all the agents waiting
1439 * on @p signal for which @p value satisfies their wait condition are awakened.
1441 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1442 * behavior is undefined.
1444 * @param[in] value New value.
1446 * @return Value of the signal prior to the exchange.
1449 hsa_signal_value_t HSA_API
hsa_signal_exchange_scacq_screl(
1450 hsa_signal_t signal
,
1451 hsa_signal_value_t value
);
1454 * @deprecated Renamed as ::hsa_signal_exchange_scacq_screl.
1456 * @copydoc hsa_signal_exchange_scacq_screl
1458 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_exchange_acq_rel(
1459 hsa_signal_t signal
,
1460 hsa_signal_value_t value
);
1463 * @copydoc hsa_signal_exchange_scacq_screl
1465 hsa_signal_value_t HSA_API
hsa_signal_exchange_scacquire(
1466 hsa_signal_t signal
,
1467 hsa_signal_value_t value
);
1470 * @deprecated Renamed as ::hsa_signal_exchange_scacquire.
1472 * @copydoc hsa_signal_exchange_scacquire
1474 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_exchange_acquire(
1475 hsa_signal_t signal
,
1476 hsa_signal_value_t value
);
1479 * @copydoc hsa_signal_exchange_scacq_screl
1481 hsa_signal_value_t HSA_API
hsa_signal_exchange_relaxed(
1482 hsa_signal_t signal
,
1483 hsa_signal_value_t value
);
1485 * @copydoc hsa_signal_exchange_scacq_screl
1487 hsa_signal_value_t HSA_API
hsa_signal_exchange_screlease(
1488 hsa_signal_t signal
,
1489 hsa_signal_value_t value
);
1492 * @deprecated Renamed as ::hsa_signal_exchange_screlease.
1494 * @copydoc hsa_signal_exchange_screlease
1496 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_exchange_release(
1497 hsa_signal_t signal
,
1498 hsa_signal_value_t value
);
1501 * @brief Atomically set the value of a signal if the observed value is equal to
1502 * the expected value. The observed value is returned regardless of whether the
1503 * replacement was done.
1505 * @details If the value of the signal is changed, all the agents waiting
1506 * on @p signal for which @p value satisfies their wait condition are awakened.
1508 * @param[in] signal Signal. If @p signal is a queue
1509 * doorbell signal, the behavior is undefined.
1511 * @param[in] expected Value to compare with.
1513 * @param[in] value New value.
1515 * @return Observed value of the signal.
1518 hsa_signal_value_t HSA_API
hsa_signal_cas_scacq_screl(
1519 hsa_signal_t signal
,
1520 hsa_signal_value_t expected
,
1521 hsa_signal_value_t value
);
1525 * @deprecated Renamed as ::hsa_signal_cas_scacq_screl.
1527 * @copydoc hsa_signal_cas_scacq_screl
1529 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_cas_acq_rel(
1530 hsa_signal_t signal
,
1531 hsa_signal_value_t expected
,
1532 hsa_signal_value_t value
);
1535 * @copydoc hsa_signal_cas_scacq_screl
1537 hsa_signal_value_t HSA_API
hsa_signal_cas_scacquire(
1538 hsa_signal_t signal
,
1539 hsa_signal_value_t expected
,
1540 hsa_signal_value_t value
);
1543 * @deprecated Renamed as ::hsa_signal_cas_scacquire.
1545 * @copydoc hsa_signal_cas_scacquire
1547 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_cas_acquire(
1548 hsa_signal_t signal
,
1549 hsa_signal_value_t expected
,
1550 hsa_signal_value_t value
);
1553 * @copydoc hsa_signal_cas_scacq_screl
1555 hsa_signal_value_t HSA_API
hsa_signal_cas_relaxed(
1556 hsa_signal_t signal
,
1557 hsa_signal_value_t expected
,
1558 hsa_signal_value_t value
);
1561 * @copydoc hsa_signal_cas_scacq_screl
1563 hsa_signal_value_t HSA_API
hsa_signal_cas_screlease(
1564 hsa_signal_t signal
,
1565 hsa_signal_value_t expected
,
1566 hsa_signal_value_t value
);
1569 * @deprecated Renamed as ::hsa_signal_cas_screlease.
1571 * @copydoc hsa_signal_cas_screlease
1573 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_cas_release(
1574 hsa_signal_t signal
,
1575 hsa_signal_value_t expected
,
1576 hsa_signal_value_t value
);
1579 * @brief Atomically increment the value of a signal by a given amount.
1581 * @details If the value of the signal is changed, all the agents waiting on
1582 * @p signal for which @p value satisfies their wait condition are awakened.
1584 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1585 * behavior is undefined.
1587 * @param[in] value Value to add to the value of the signal.
1590 void HSA_API
hsa_signal_add_scacq_screl(
1591 hsa_signal_t signal
,
1592 hsa_signal_value_t value
);
1595 * @deprecated Renamed as ::hsa_signal_add_scacq_screl.
1597 * @copydoc hsa_signal_add_scacq_screl
1599 void HSA_API HSA_DEPRECATED
hsa_signal_add_acq_rel(
1600 hsa_signal_t signal
,
1601 hsa_signal_value_t value
);
1604 * @copydoc hsa_signal_add_scacq_screl
1606 void HSA_API
hsa_signal_add_scacquire(
1607 hsa_signal_t signal
,
1608 hsa_signal_value_t value
);
1611 * @deprecated Renamed as ::hsa_signal_add_scacquire.
1613 * @copydoc hsa_signal_add_scacquire
1615 void HSA_API HSA_DEPRECATED
hsa_signal_add_acquire(
1616 hsa_signal_t signal
,
1617 hsa_signal_value_t value
);
1620 * @copydoc hsa_signal_add_scacq_screl
1622 void HSA_API
hsa_signal_add_relaxed(
1623 hsa_signal_t signal
,
1624 hsa_signal_value_t value
);
1627 * @copydoc hsa_signal_add_scacq_screl
1629 void HSA_API
hsa_signal_add_screlease(
1630 hsa_signal_t signal
,
1631 hsa_signal_value_t value
);
1635 * @deprecated Renamed as ::hsa_signal_add_screlease.
1637 * @copydoc hsa_signal_add_screlease
1639 void HSA_API HSA_DEPRECATED
hsa_signal_add_release(
1640 hsa_signal_t signal
,
1641 hsa_signal_value_t value
);
1644 * @brief Atomically decrement the value of a signal by a given amount.
1646 * @details If the value of the signal is changed, all the agents waiting on
1647 * @p signal for which @p value satisfies their wait condition are awakened.
1649 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1650 * behavior is undefined.
1652 * @param[in] value Value to subtract from the value of the signal.
1655 void HSA_API
hsa_signal_subtract_scacq_screl(
1656 hsa_signal_t signal
,
1657 hsa_signal_value_t value
);
1661 * @deprecated Renamed as ::hsa_signal_subtract_scacq_screl.
1663 * @copydoc hsa_signal_subtract_scacq_screl
1665 void HSA_API HSA_DEPRECATED
hsa_signal_subtract_acq_rel(
1666 hsa_signal_t signal
,
1667 hsa_signal_value_t value
);
1670 * @copydoc hsa_signal_subtract_scacq_screl
1672 void HSA_API
hsa_signal_subtract_scacquire(
1673 hsa_signal_t signal
,
1674 hsa_signal_value_t value
);
1677 * @deprecated Renamed as ::hsa_signal_subtract_scacquire.
1679 * @copydoc hsa_signal_subtract_scacquire
1681 void HSA_API HSA_DEPRECATED
hsa_signal_subtract_acquire(
1682 hsa_signal_t signal
,
1683 hsa_signal_value_t value
);
1686 * @copydoc hsa_signal_subtract_scacq_screl
1688 void HSA_API
hsa_signal_subtract_relaxed(
1689 hsa_signal_t signal
,
1690 hsa_signal_value_t value
);
1693 * @copydoc hsa_signal_subtract_scacq_screl
1695 void HSA_API
hsa_signal_subtract_screlease(
1696 hsa_signal_t signal
,
1697 hsa_signal_value_t value
);
1701 * @deprecated Renamed as ::hsa_signal_subtract_screlease.
1703 * @copydoc hsa_signal_subtract_screlease
1705 void HSA_API HSA_DEPRECATED
hsa_signal_subtract_release(
1706 hsa_signal_t signal
,
1707 hsa_signal_value_t value
);
1710 * @brief Atomically perform a bitwise AND operation between the value of a
1711 * signal and a given value.
1713 * @details If the value of the signal is changed, all the agents waiting on
1714 * @p signal for which @p value satisfies their wait condition are awakened.
1716 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1717 * behavior is undefined.
1719 * @param[in] value Value to AND with the value of the signal.
1722 void HSA_API
hsa_signal_and_scacq_screl(
1723 hsa_signal_t signal
,
1724 hsa_signal_value_t value
);
1727 * @deprecated Renamed as ::hsa_signal_and_scacq_screl.
1729 * @copydoc hsa_signal_and_scacq_screl
1731 void HSA_API HSA_DEPRECATED
hsa_signal_and_acq_rel(
1732 hsa_signal_t signal
,
1733 hsa_signal_value_t value
);
1736 * @copydoc hsa_signal_and_scacq_screl
1738 void HSA_API
hsa_signal_and_scacquire(
1739 hsa_signal_t signal
,
1740 hsa_signal_value_t value
);
1743 * @deprecated Renamed as ::hsa_signal_and_scacquire.
1745 * @copydoc hsa_signal_and_scacquire
1747 void HSA_API HSA_DEPRECATED
hsa_signal_and_acquire(
1748 hsa_signal_t signal
,
1749 hsa_signal_value_t value
);
1752 * @copydoc hsa_signal_and_scacq_screl
1754 void HSA_API
hsa_signal_and_relaxed(
1755 hsa_signal_t signal
,
1756 hsa_signal_value_t value
);
1759 * @copydoc hsa_signal_and_scacq_screl
1761 void HSA_API
hsa_signal_and_screlease(
1762 hsa_signal_t signal
,
1763 hsa_signal_value_t value
);
1767 * @deprecated Renamed as ::hsa_signal_and_screlease.
1769 * @copydoc hsa_signal_and_screlease
1771 void HSA_API HSA_DEPRECATED
hsa_signal_and_release(
1772 hsa_signal_t signal
,
1773 hsa_signal_value_t value
);
1776 * @brief Atomically perform a bitwise OR operation between the value of a
1777 * signal and a given value.
1779 * @details If the value of the signal is changed, all the agents waiting on
1780 * @p signal for which @p value satisfies their wait condition are awakened.
1782 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1783 * behavior is undefined.
1785 * @param[in] value Value to OR with the value of the signal.
1787 void HSA_API
hsa_signal_or_scacq_screl(
1788 hsa_signal_t signal
,
1789 hsa_signal_value_t value
);
1793 * @deprecated Renamed as ::hsa_signal_or_scacq_screl.
1795 * @copydoc hsa_signal_or_scacq_screl
1797 void HSA_API HSA_DEPRECATED
hsa_signal_or_acq_rel(
1798 hsa_signal_t signal
,
1799 hsa_signal_value_t value
);
1802 * @copydoc hsa_signal_or_scacq_screl
1804 void HSA_API
hsa_signal_or_scacquire(
1805 hsa_signal_t signal
,
1806 hsa_signal_value_t value
);
1809 * @deprecated Renamed as ::hsa_signal_or_scacquire.
1811 * @copydoc hsa_signal_or_scacquire
1813 void HSA_API HSA_DEPRECATED
hsa_signal_or_acquire(
1814 hsa_signal_t signal
,
1815 hsa_signal_value_t value
);
1818 * @copydoc hsa_signal_or_scacq_screl
1820 void HSA_API
hsa_signal_or_relaxed(
1821 hsa_signal_t signal
,
1822 hsa_signal_value_t value
);
1825 * @copydoc hsa_signal_or_scacq_screl
1827 void HSA_API
hsa_signal_or_screlease(
1828 hsa_signal_t signal
,
1829 hsa_signal_value_t value
);
1832 * @deprecated Renamed as ::hsa_signal_or_screlease.
1834 * @copydoc hsa_signal_or_screlease
1836 void HSA_API HSA_DEPRECATED
hsa_signal_or_release(
1837 hsa_signal_t signal
,
1838 hsa_signal_value_t value
);
1841 * @brief Atomically perform a bitwise XOR operation between the value of a
1842 * signal and a given value.
1844 * @details If the value of the signal is changed, all the agents waiting on
1845 * @p signal for which @p value satisfies their wait condition are awakened.
1847 * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
1848 * behavior is undefined.
1850 * @param[in] value Value to XOR with the value of the signal.
1853 void HSA_API
hsa_signal_xor_scacq_screl(
1854 hsa_signal_t signal
,
1855 hsa_signal_value_t value
);
1859 * @deprecated Renamed as ::hsa_signal_xor_scacq_screl.
1861 * @copydoc hsa_signal_xor_scacq_screl
1863 void HSA_API HSA_DEPRECATED
hsa_signal_xor_acq_rel(
1864 hsa_signal_t signal
,
1865 hsa_signal_value_t value
);
1868 * @copydoc hsa_signal_xor_scacq_screl
1870 void HSA_API
hsa_signal_xor_scacquire(
1871 hsa_signal_t signal
,
1872 hsa_signal_value_t value
);
1875 * @deprecated Renamed as ::hsa_signal_xor_scacquire.
1877 * @copydoc hsa_signal_xor_scacquire
1879 void HSA_API HSA_DEPRECATED
hsa_signal_xor_acquire(
1880 hsa_signal_t signal
,
1881 hsa_signal_value_t value
);
1884 * @copydoc hsa_signal_xor_scacq_screl
1886 void HSA_API
hsa_signal_xor_relaxed(
1887 hsa_signal_t signal
,
1888 hsa_signal_value_t value
);
1891 * @copydoc hsa_signal_xor_scacq_screl
1893 void HSA_API
hsa_signal_xor_screlease(
1894 hsa_signal_t signal
,
1895 hsa_signal_value_t value
);
1898 * @deprecated Renamed as ::hsa_signal_xor_screlease.
1900 * @copydoc hsa_signal_xor_screlease
1902 void HSA_API HSA_DEPRECATED
hsa_signal_xor_release(
1903 hsa_signal_t signal
,
1904 hsa_signal_value_t value
);
1907 * @brief Wait condition operator.
1911 * The two operands are equal.
1913 HSA_SIGNAL_CONDITION_EQ
= 0,
1915 * The two operands are not equal.
1917 HSA_SIGNAL_CONDITION_NE
= 1,
1919 * The first operand is less than the second operand.
1921 HSA_SIGNAL_CONDITION_LT
= 2,
1923 * The first operand is greater than or equal to the second operand.
1925 HSA_SIGNAL_CONDITION_GTE
= 3
1926 } hsa_signal_condition_t
;
1929 * @brief State of the application thread during a signal wait.
1933 * The application thread may be rescheduled while waiting on the signal.
1935 HSA_WAIT_STATE_BLOCKED
= 0,
1937 * The application thread stays active while waiting on a signal.
1939 HSA_WAIT_STATE_ACTIVE
= 1
1944 * @brief Wait until a signal value satisfies a specified condition, or a
1945 * certain amount of time has elapsed.
1947 * @details A wait operation can spuriously resume at any time sooner than the
1948 * timeout (for example, due to system or other external factors) even when the
1949 * condition has not been met.
1951 * The function is guaranteed to return if the signal value satisfies the
1952 * condition at some point in time during the wait, but the value returned to
1953 * the application might not satisfy the condition. The application must ensure
1954 * that signals are used in such way that wait wakeup conditions are not
1955 * invalidated before dependent threads have woken up.
1957 * When the wait operation internally loads the value of the passed signal, it
1958 * uses the memory order indicated in the function name.
1960 * @param[in] signal Signal.
1962 * @param[in] condition Condition used to compare the signal value with @p
1965 * @param[in] compare_value Value to compare with.
1967 * @param[in] timeout_hint Maximum duration of the wait. Specified in the same
1968 * unit as the system timestamp. The operation might block for a shorter or
1969 * longer time even if the condition is not met. A value of UINT64_MAX indicates
1972 * @param[in] wait_state_hint Hint used by the application to indicate the
1973 * preferred waiting state. The actual waiting state is ultimately decided by
1974 * HSA runtime and may not match the provided hint. A value of
1975 * ::HSA_WAIT_STATE_ACTIVE may improve the latency of response to a signal
1976 * update by avoiding rescheduling overhead.
1978 * @return Observed value of the signal, which might not satisfy the specified
1982 hsa_signal_value_t HSA_API
hsa_signal_wait_scacquire(
1983 hsa_signal_t signal
,
1984 hsa_signal_condition_t condition
,
1985 hsa_signal_value_t compare_value
,
1986 uint64_t timeout_hint
,
1987 hsa_wait_state_t wait_state_hint
);
1990 * @copydoc hsa_signal_wait_scacquire
1992 hsa_signal_value_t HSA_API
hsa_signal_wait_relaxed(
1993 hsa_signal_t signal
,
1994 hsa_signal_condition_t condition
,
1995 hsa_signal_value_t compare_value
,
1996 uint64_t timeout_hint
,
1997 hsa_wait_state_t wait_state_hint
);
2000 * @deprecated Renamed as ::hsa_signal_wait_scacquire.
2002 * @copydoc hsa_signal_wait_scacquire
2004 hsa_signal_value_t HSA_API HSA_DEPRECATED
hsa_signal_wait_acquire(
2005 hsa_signal_t signal
,
2006 hsa_signal_condition_t condition
,
2007 hsa_signal_value_t compare_value
,
2008 uint64_t timeout_hint
,
2009 hsa_wait_state_t wait_state_hint
);
2012 * @brief Group of signals.
2014 typedef struct hsa_signal_group_s
{
2016 * Opaque handle. Two handles reference the same object of the enclosing type
2017 * if and only if they are equal.
2020 } hsa_signal_group_t
;
2023 * @brief Create a signal group.
2025 * @param[in] num_signals Number of elements in @p signals. Must not be 0.
2027 * @param[in] signals List of signals in the group. The list must not contain
2028 * any repeated elements. Must not be NULL.
2030 * @param[in] num_consumers Number of elements in @p consumers. Must not be 0.
2032 * @param[in] consumers List of agents that might consume (wait on) the signal
2033 * group. The list must not contain repeated elements, and must be a subset of
2034 * the set of agents that are allowed to wait on all the signals in the
2035 * group. If an agent not listed in @p consumers waits on the returned group,
2036 * the behavior is undefined. The memory associated with @p consumers can be
2037 * reused or freed after the function returns. Must not be NULL.
2039 * @param[out] signal_group Pointer to newly created signal group. Must not be
2042 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2044 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2047 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
2048 * the required resources.
2050 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_signals is 0, @p signals
2051 * is NULL, @p num_consumers is 0, @p consumers is NULL, or @p signal_group is
2054 hsa_status_t HSA_API
hsa_signal_group_create(
2055 uint32_t num_signals
,
2056 const hsa_signal_t
*signals
,
2057 uint32_t num_consumers
,
2058 const hsa_agent_t
*consumers
,
2059 hsa_signal_group_t
*signal_group
);
2062 * @brief Destroy a signal group previous created by ::hsa_signal_group_create.
2064 * @param[in] signal_group Signal group.
2066 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2068 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2071 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP @p signal_group is invalid.
2073 hsa_status_t HSA_API
hsa_signal_group_destroy(
2074 hsa_signal_group_t signal_group
);
2077 * @brief Wait until the value of at least one of the signals in a signal group
2078 * satisfies its associated condition.
2080 * @details The function is guaranteed to return if the value of at least one of
2081 * the signals in the group satisfies its associated condition at some point in
2082 * time during the wait, but the signal value returned to the application may no
2083 * longer satisfy the condition. The application must ensure that signals in the
2084 * group are used in such way that wait wakeup conditions are not invalidated
2085 * before dependent threads have woken up.
2087 * When this operation internally loads the value of the passed signal, it uses
2088 * the memory order indicated in the function name.
2090 * @param[in] signal_group Signal group.
2092 * @param[in] conditions List of conditions. Each condition, and the value at
2093 * the same index in @p compare_values, is used to compare the value of the
2094 * signal at that index in @p signal_group (the signal passed by the application
2095 * to ::hsa_signal_group_create at that particular index). The size of @p
2096 * conditions must not be smaller than the number of signals in @p signal_group;
2097 * any extra elements are ignored. Must not be NULL.
2099 * @param[in] compare_values List of comparison values. The size of @p
2100 * compare_values must not be smaller than the number of signals in @p
2101 * signal_group; any extra elements are ignored. Must not be NULL.
2103 * @param[in] wait_state_hint Hint used by the application to indicate the
2104 * preferred waiting state. The actual waiting state is decided by the HSA runtime
2105 * and may not match the provided hint. A value of ::HSA_WAIT_STATE_ACTIVE may
2106 * improve the latency of response to a signal update by avoiding rescheduling
2109 * @param[out] signal Signal in the group that satisfied the associated
2110 * condition. If several signals satisfied their condition, the function can
2111 * return any of those signals. Must not be NULL.
2113 * @param[out] value Observed value for @p signal, which might no longer satisfy
2114 * the specified condition. Must not be NULL.
2116 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2118 * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP @p signal_group is invalid.
2120 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p conditions is NULL, @p
2121 * compare_values is NULL, @p signal is NULL, or @p value is NULL.
2123 hsa_status_t HSA_API
hsa_signal_group_wait_any_scacquire(
2124 hsa_signal_group_t signal_group
,
2125 const hsa_signal_condition_t
*conditions
,
2126 const hsa_signal_value_t
*compare_values
,
2127 hsa_wait_state_t wait_state_hint
,
2128 hsa_signal_t
*signal
,
2129 hsa_signal_value_t
*value
);
2132 * @copydoc hsa_signal_group_wait_any_scacquire
2134 hsa_status_t HSA_API
hsa_signal_group_wait_any_relaxed(
2135 hsa_signal_group_t signal_group
,
2136 const hsa_signal_condition_t
*conditions
,
2137 const hsa_signal_value_t
*compare_values
,
2138 hsa_wait_state_t wait_state_hint
,
2139 hsa_signal_t
*signal
,
2140 hsa_signal_value_t
*value
);
2144 /** \defgroup memory Memory
2149 * @brief A memory region represents a block of virtual memory with certain
2150 * properties. For example, the HSA runtime represents fine-grained memory in
2151 * the global segment using a region. A region might be associated with more
2154 typedef struct hsa_region_s
{
2156 * Opaque handle. Two handles reference the same object of the enclosing type
2157 * if and only if they are equal.
2165 /** \defgroup queue Queues
2170 * @brief Queue type. Intended to be used for dynamic queue protocol
2175 * Queue supports multiple producers. Use of multiproducer queue mechanics is
2178 HSA_QUEUE_TYPE_MULTI
= 0,
2180 * Queue only supports a single producer. In some scenarios, the application
2181 * may want to limit the submission of AQL packets to a single agent. Queues
2182 * that support a single producer may be more efficient than queues supporting
2183 * multiple producers. Use of multiproducer queue mechanics is not supported.
2185 HSA_QUEUE_TYPE_SINGLE
= 1,
2187 * Queue supports multiple producers and cooperative dispatches. Cooperative
2188 * dispatches are able to use GWS synchronization. Queues of this type may be
2189 * limited in number. The runtime may return the same queue to serve multiple
2190 * ::hsa_queue_create calls when this type is given. Callers must inspect the
2191 * returned queue to discover queue size. Queues of this type are reference
2192 * counted and require a matching number of ::hsa_queue_destroy calls to
2193 * release. Use of multiproducer queue mechanics is required. See
2194 * ::HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES to query agent support for this
2197 HSA_QUEUE_TYPE_COOPERATIVE
= 2
2201 * @brief A fixed-size type used to represent ::hsa_queue_type_t constants.
2203 typedef uint32_t hsa_queue_type32_t
;
2206 * @brief Queue features.
2210 * Queue supports kernel dispatch packets.
2212 HSA_QUEUE_FEATURE_KERNEL_DISPATCH
= 1,
2215 * Queue supports agent dispatch packets.
2217 HSA_QUEUE_FEATURE_AGENT_DISPATCH
= 2
2218 } hsa_queue_feature_t
;
2221 * @brief User mode queue.
2223 * @details The queue structure is read-only and allocated by the HSA runtime,
2224 * but agents can directly modify the contents of the buffer pointed by @a
2225 * base_address, or use HSA runtime APIs to access the doorbell signal.
2228 typedef struct hsa_queue_s
{
2232 hsa_queue_type32_t type
;
2235 * Queue features mask. This is a bit-field of ::hsa_queue_feature_t
2236 * values. Applications should ignore any unknown set bits.
2240 #ifdef HSA_LARGE_MODEL
2242 #elif defined HSA_LITTLE_ENDIAN
2244 * Starting address of the HSA runtime-allocated buffer used to store the AQL
2245 * packets. Must be aligned to the size of an AQL packet.
2249 * Reserved. Must be 0.
2258 * Signal object used by the application to indicate the ID of a packet that
2259 * is ready to be processed. The HSA runtime manages the doorbell signal. If
2260 * the application tries to replace or destroy this signal, the behavior is
2263 * If @a type is ::HSA_QUEUE_TYPE_SINGLE, the doorbell signal value must be
2264 * updated in a monotonically increasing fashion. If @a type is
2265 * ::HSA_QUEUE_TYPE_MULTI, the doorbell signal value can be updated with any
2268 hsa_signal_t doorbell_signal
;
2271 * Maximum number of packets the queue can hold. Must be a power of 2.
2275 * Reserved. Must be 0.
2279 * Queue identifier, which is unique over the lifetime of the application.
2286 * @brief Create a user mode queue.
2288 * @details The HSA runtime creates the queue structure, the underlying packet
2289 * buffer, the completion signal, and the write and read indexes. The initial
2290 * value of the write and read indexes is 0. The type of every packet in the
2291 * buffer is initialized to ::HSA_PACKET_TYPE_INVALID.
2293 * The application should only rely on the error code returned to determine if
2294 * the queue is valid.
2296 * @param[in] agent Agent where to create the queue.
2298 * @param[in] size Number of packets the queue is expected to
2299 * hold. Must be a power of 2 between 1 and the value of
2300 * ::HSA_AGENT_INFO_QUEUE_MAX_SIZE in @p agent. The size of the newly
2301 * created queue is the maximum of @p size and the value of
2302 * ::HSA_AGENT_INFO_QUEUE_MIN_SIZE in @p agent.
2304 * @param[in] type Type of the queue, a bitwise OR of hsa_queue_type_t values.
2305 * If the value of ::HSA_AGENT_INFO_QUEUE_TYPE in @p agent is ::HSA_QUEUE_TYPE_SINGLE,
2306 * then @p type must also be ::HSA_QUEUE_TYPE_SINGLE.
2308 * @param[in] callback Callback invoked by the HSA runtime for every
2309 * asynchronous event related to the newly created queue. May be NULL. The HSA
2310 * runtime passes three arguments to the callback: a code identifying the event
2311 * that triggered the invocation, a pointer to the queue where the event
2312 * originated, and the application data.
2314 * @param[in] data Application data that is passed to @p callback on every
2315 * iteration. May be NULL.
2317 * @param[in] private_segment_size Hint indicating the maximum
2318 * expected private segment usage per work-item, in bytes. There may
2319 * be performance degradation if the application places a kernel
2320 * dispatch packet in the queue and the corresponding private segment
2321 * usage exceeds @p private_segment_size. If the application does not
2322 * want to specify any particular value for this argument, @p
2323 * private_segment_size must be UINT32_MAX. If the queue does not
2324 * support kernel dispatch packets, this argument is ignored.
2326 * @param[in] group_segment_size Hint indicating the maximum expected
2327 * group segment usage per work-group, in bytes. There may be
2328 * performance degradation if the application places a kernel dispatch
2329 * packet in the queue and the corresponding group segment usage
2330 * exceeds @p group_segment_size. If the application does not want to
2331 * specify any particular value for this argument, @p
2332 * group_segment_size must be UINT32_MAX. If the queue does not
2333 * support kernel dispatch packets, this argument is ignored.
2335 * @param[out] queue Memory location where the HSA runtime stores a pointer to
2336 * the newly created queue.
2338 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2340 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2343 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
2344 * the required resources.
2346 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
2348 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE_CREATION @p agent does not
2349 * support queues of the given type.
2351 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is not a power of two,
2352 * @p size is 0, @p type is an invalid queue type, or @p queue is NULL.
2355 hsa_status_t HSA_API
hsa_queue_create(
2358 hsa_queue_type32_t type
,
2359 void (*callback
)(hsa_status_t status
, hsa_queue_t
*source
, void *data
),
2361 uint32_t private_segment_size
,
2362 uint32_t group_segment_size
,
2363 hsa_queue_t
**queue
);
2366 * @brief Create a queue for which the application or a kernel is responsible
2367 * for processing the AQL packets.
2369 * @details The application can use this function to create queues where AQL
2370 * packets are not parsed by the packet processor associated with an agent,
2371 * but rather by a unit of execution running on that agent (for example, a
2372 * thread in the host application).
2374 * The application is responsible for ensuring that all the producers and
2375 * consumers of the resulting queue can access the provided doorbell signal
2376 * and memory region. The application is also responsible for ensuring that the
2377 * unit of execution processing the queue packets supports the indicated
2378 * features (AQL packet types).
2380 * When the queue is created, the HSA runtime allocates the packet buffer using
2381 * @p region, and the write and read indexes. The initial value of the write and
2382 * read indexes is 0, and the type of every packet in the buffer is initialized
2383 * to ::HSA_PACKET_TYPE_INVALID. The value of the @e size, @e type, @e features,
2384 * and @e doorbell_signal fields in the returned queue match the values passed
2385 * by the application.
2387 * @param[in] region Memory region that the HSA runtime should use to allocate
2388 * the AQL packet buffer and any other queue metadata.
2390 * @param[in] size Number of packets the queue is expected to hold. Must be a
2391 * power of 2 greater than 0.
2393 * @param[in] type Queue type.
2395 * @param[in] features Supported queue features. This is a bit-field of
2396 * ::hsa_queue_feature_t values.
2398 * @param[in] doorbell_signal Doorbell signal that the HSA runtime must
2399 * associate with the returned queue. The signal handle must not be 0.
2401 * @param[out] queue Memory location where the HSA runtime stores a pointer to
2402 * the newly created queue. The application should not rely on the value
2403 * returned for this argument but only in the status code to determine if the
2404 * queue is valid. Must not be NULL.
2406 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2408 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2411 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
2412 * the required resources.
2414 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is not a power of two, @p
2415 * size is 0, @p type is an invalid queue type, the doorbell signal handle is
2416 * 0, or @p queue is NULL.
2419 hsa_status_t HSA_API
hsa_soft_queue_create(
2420 hsa_region_t region
,
2422 hsa_queue_type32_t type
,
2424 hsa_signal_t doorbell_signal
,
2425 hsa_queue_t
**queue
);
2428 * @brief Destroy a user mode queue.
2430 * @details When a queue is destroyed, the state of the AQL packets that have
2431 * not been yet fully processed (their completion phase has not finished)
2432 * becomes undefined. It is the responsibility of the application to ensure that
2433 * all pending queue operations are finished if their results are required.
2435 * The resources allocated by the HSA runtime during queue creation (queue
2436 * structure, ring buffer, doorbell signal) are released. The queue should not
2437 * be accessed after being destroyed.
2439 * @param[in] queue Pointer to a queue created using ::hsa_queue_create.
2441 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2443 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2446 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
2448 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
2450 hsa_status_t HSA_API
hsa_queue_destroy(
2451 hsa_queue_t
*queue
);
2454 * @brief Inactivate a queue.
2456 * @details Inactivating the queue aborts any pending executions and prevent any
2457 * new packets from being processed. Any more packets written to the queue once
2458 * it is inactivated will be ignored by the packet processor.
2460 * @param[in] queue Pointer to a queue.
2462 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
2464 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
2467 * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
2469 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
2471 hsa_status_t HSA_API
hsa_queue_inactivate(
2472 hsa_queue_t
*queue
);
2475 * @deprecated Renamed as ::hsa_queue_load_read_index_scacquire.
2477 * @copydoc hsa_queue_load_read_index_scacquire
2479 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_load_read_index_acquire(
2480 const hsa_queue_t
*queue
);
2483 * @brief Atomically load the read index of a queue.
2485 * @param[in] queue Pointer to a queue.
2487 * @return Read index of the queue pointed by @p queue.
2489 uint64_t HSA_API
hsa_queue_load_read_index_scacquire(
2490 const hsa_queue_t
*queue
);
2493 * @copydoc hsa_queue_load_read_index_scacquire
2495 uint64_t HSA_API
hsa_queue_load_read_index_relaxed(
2496 const hsa_queue_t
*queue
);
2499 * @deprecated Renamed as ::hsa_queue_load_write_index_scacquire.
2501 * @copydoc hsa_queue_load_write_index_scacquire
2503 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_load_write_index_acquire(
2504 const hsa_queue_t
*queue
);
2507 * @brief Atomically load the write index of a queue.
2509 * @param[in] queue Pointer to a queue.
2511 * @return Write index of the queue pointed by @p queue.
2513 uint64_t HSA_API
hsa_queue_load_write_index_scacquire(
2514 const hsa_queue_t
*queue
);
2517 * @copydoc hsa_queue_load_write_index_scacquire
2519 uint64_t HSA_API
hsa_queue_load_write_index_relaxed(
2520 const hsa_queue_t
*queue
);
2523 * @brief Atomically set the write index of a queue.
2525 * @details It is recommended that the application uses this function to update
2526 * the write index when there is a single agent submitting work to the queue
2527 * (the queue type is ::HSA_QUEUE_TYPE_SINGLE).
2529 * @param[in] queue Pointer to a queue.
2531 * @param[in] value Value to assign to the write index.
2534 void HSA_API
hsa_queue_store_write_index_relaxed(
2535 const hsa_queue_t
*queue
,
2539 * @deprecated Renamed as ::hsa_queue_store_write_index_screlease.
2541 * @copydoc hsa_queue_store_write_index_screlease
2543 void HSA_API HSA_DEPRECATED
hsa_queue_store_write_index_release(
2544 const hsa_queue_t
*queue
,
2548 * @copydoc hsa_queue_store_write_index_relaxed
2550 void HSA_API
hsa_queue_store_write_index_screlease(
2551 const hsa_queue_t
*queue
,
2555 * @deprecated Renamed as ::hsa_queue_cas_write_index_scacq_screl.
2557 * @copydoc hsa_queue_cas_write_index_scacq_screl
2559 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_cas_write_index_acq_rel(
2560 const hsa_queue_t
*queue
,
2565 * @brief Atomically set the write index of a queue if the observed value is
2566 * equal to the expected value. The application can inspect the returned value
2567 * to determine if the replacement was done.
2569 * @param[in] queue Pointer to a queue.
2571 * @param[in] expected Expected value.
2573 * @param[in] value Value to assign to the write index if @p expected matches
2574 * the observed write index. Must be greater than @p expected.
2576 * @return Previous value of the write index.
2578 uint64_t HSA_API
hsa_queue_cas_write_index_scacq_screl(
2579 const hsa_queue_t
*queue
,
2584 * @deprecated Renamed as ::hsa_queue_cas_write_index_scacquire.
2586 * @copydoc hsa_queue_cas_write_index_scacquire
2588 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_cas_write_index_acquire(
2589 const hsa_queue_t
*queue
,
2594 * @copydoc hsa_queue_cas_write_index_scacq_screl
2596 uint64_t HSA_API
hsa_queue_cas_write_index_scacquire(
2597 const hsa_queue_t
*queue
,
2602 * @copydoc hsa_queue_cas_write_index_scacq_screl
2604 uint64_t HSA_API
hsa_queue_cas_write_index_relaxed(
2605 const hsa_queue_t
*queue
,
2610 * @deprecated Renamed as ::hsa_queue_cas_write_index_screlease.
2612 * @copydoc hsa_queue_cas_write_index_screlease
2614 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_cas_write_index_release(
2615 const hsa_queue_t
*queue
,
2620 * @copydoc hsa_queue_cas_write_index_scacq_screl
2622 uint64_t HSA_API
hsa_queue_cas_write_index_screlease(
2623 const hsa_queue_t
*queue
,
2628 * @deprecated Renamed as ::hsa_queue_add_write_index_scacq_screl.
2630 * @copydoc hsa_queue_add_write_index_scacq_screl
2632 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_add_write_index_acq_rel(
2633 const hsa_queue_t
*queue
,
2637 * @brief Atomically increment the write index of a queue by an offset.
2639 * @param[in] queue Pointer to a queue.
2641 * @param[in] value Value to add to the write index.
2643 * @return Previous value of the write index.
2645 uint64_t HSA_API
hsa_queue_add_write_index_scacq_screl(
2646 const hsa_queue_t
*queue
,
2650 * @deprecated Renamed as ::hsa_queue_add_write_index_scacquire.
2652 * @copydoc hsa_queue_add_write_index_scacquire
2654 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_add_write_index_acquire(
2655 const hsa_queue_t
*queue
,
2659 * @copydoc hsa_queue_add_write_index_scacq_screl
2661 uint64_t HSA_API
hsa_queue_add_write_index_scacquire(
2662 const hsa_queue_t
*queue
,
2666 * @copydoc hsa_queue_add_write_index_scacq_screl
2668 uint64_t HSA_API
hsa_queue_add_write_index_relaxed(
2669 const hsa_queue_t
*queue
,
2673 * @deprecated Renamed as ::hsa_queue_add_write_index_screlease.
2675 * @copydoc hsa_queue_add_write_index_screlease
2677 uint64_t HSA_API HSA_DEPRECATED
hsa_queue_add_write_index_release(
2678 const hsa_queue_t
*queue
,
2682 * @copydoc hsa_queue_add_write_index_scacq_screl
2684 uint64_t HSA_API
hsa_queue_add_write_index_screlease(
2685 const hsa_queue_t
*queue
,
2689 * @brief Atomically set the read index of a queue.
2691 * @details Modifications of the read index are not allowed and result in
2692 * undefined behavior if the queue is associated with an agent for which
2693 * only the corresponding packet processor is permitted to update the read
2696 * @param[in] queue Pointer to a queue.
2698 * @param[in] value Value to assign to the read index.
2701 void HSA_API
hsa_queue_store_read_index_relaxed(
2702 const hsa_queue_t
*queue
,
2706 * @deprecated Renamed as ::hsa_queue_store_read_index_screlease.
2708 * @copydoc hsa_queue_store_read_index_screlease
2710 void HSA_API HSA_DEPRECATED
hsa_queue_store_read_index_release(
2711 const hsa_queue_t
*queue
,
2715 * @copydoc hsa_queue_store_read_index_relaxed
2717 void HSA_API
hsa_queue_store_read_index_screlease(
2718 const hsa_queue_t
*queue
,
2723 /** \defgroup aql Architected Queuing Language
2728 * @brief Packet type.
2732 * Vendor-specific packet.
2734 HSA_PACKET_TYPE_VENDOR_SPECIFIC
= 0,
2736 * The packet has been processed in the past, but has not been reassigned to
2737 * the packet processor. A packet processor must not process a packet of this
2738 * type. All queues support this packet type.
2740 HSA_PACKET_TYPE_INVALID
= 1,
2742 * Packet used by agents for dispatching jobs to kernel agents. Not all
2743 * queues support packets of this type (see ::hsa_queue_feature_t).
2745 HSA_PACKET_TYPE_KERNEL_DISPATCH
= 2,
2747 * Packet used by agents to delay processing of subsequent packets, and to
2748 * express complex dependencies between multiple packets. All queues support
2751 HSA_PACKET_TYPE_BARRIER_AND
= 3,
2753 * Packet used by agents for dispatching jobs to agents. Not all
2754 * queues support packets of this type (see ::hsa_queue_feature_t).
2756 HSA_PACKET_TYPE_AGENT_DISPATCH
= 4,
2758 * Packet used by agents to delay processing of subsequent packets, and to
2759 * express complex dependencies between multiple packets. All queues support
2762 HSA_PACKET_TYPE_BARRIER_OR
= 5
2763 } hsa_packet_type_t
;
2766 * @brief Scope of the memory fence operation associated with a packet.
2770 * No scope (no fence is applied). The packet relies on external fences to
2771 * ensure visibility of memory updates.
2773 HSA_FENCE_SCOPE_NONE
= 0,
2775 * The fence is applied with agent scope for the global segment.
2777 HSA_FENCE_SCOPE_AGENT
= 1,
2779 * The fence is applied across both agent and system scope for the global
2782 HSA_FENCE_SCOPE_SYSTEM
= 2
2783 } hsa_fence_scope_t
;
2786 * @brief Sub-fields of the @a header field that is present in any AQL
2787 * packet. The offset (with respect to the address of @a header) of a sub-field
2788 * is identical to its enumeration constant. The width of each sub-field is
2789 * determined by the corresponding value in ::hsa_packet_header_width_t. The
2790 * offset and the width are expressed in bits.
2794 * Packet type. The value of this sub-field must be one of
2795 * ::hsa_packet_type_t. If the type is ::HSA_PACKET_TYPE_VENDOR_SPECIFIC, the
2796 * packet layout is vendor-specific.
2798 HSA_PACKET_HEADER_TYPE
= 0,
2800 * Barrier bit. If the barrier bit is set, the processing of the current
2801 * packet only launches when all preceding packets (within the same queue) are
2804 HSA_PACKET_HEADER_BARRIER
= 8,
2806 * Acquire fence scope. The value of this sub-field determines the scope and
2807 * type of the memory fence operation applied before the packet enters the
2808 * active phase. An acquire fence ensures that any subsequent global segment
2809 * or image loads by any unit of execution that belongs to a dispatch that has
2810 * not yet entered the active phase on any queue of the same kernel agent,
2811 * sees any data previously released at the scopes specified by the acquire
2812 * fence. The value of this sub-field must be one of ::hsa_fence_scope_t.
2814 HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE
= 9,
2816 * @deprecated Renamed as ::HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE.
2818 HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE
= 9,
2820 * Release fence scope, The value of this sub-field determines the scope and
2821 * type of the memory fence operation applied after kernel completion but
2822 * before the packet is completed. A release fence makes any global segment or
2823 * image data that was stored by any unit of execution that belonged to a
2824 * dispatch that has completed the active phase on any queue of the same
2825 * kernel agent visible in all the scopes specified by the release fence. The
2826 * value of this sub-field must be one of ::hsa_fence_scope_t.
2828 HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE
= 11,
2830 * @deprecated Renamed as ::HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE.
2832 HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE
= 11
2833 } hsa_packet_header_t
;
2836 * @brief Width (in bits) of the sub-fields in ::hsa_packet_header_t.
2839 HSA_PACKET_HEADER_WIDTH_TYPE
= 8,
2840 HSA_PACKET_HEADER_WIDTH_BARRIER
= 1,
2841 HSA_PACKET_HEADER_WIDTH_SCACQUIRE_FENCE_SCOPE
= 2,
2843 * @deprecated Use HSA_PACKET_HEADER_WIDTH_SCACQUIRE_FENCE_SCOPE.
2845 HSA_PACKET_HEADER_WIDTH_ACQUIRE_FENCE_SCOPE
= 2,
2846 HSA_PACKET_HEADER_WIDTH_SCRELEASE_FENCE_SCOPE
= 2,
2848 * @deprecated Use HSA_PACKET_HEADER_WIDTH_SCRELEASE_FENCE_SCOPE.
2850 HSA_PACKET_HEADER_WIDTH_RELEASE_FENCE_SCOPE
= 2
2851 } hsa_packet_header_width_t
;
2854 * @brief Sub-fields of the kernel dispatch packet @a setup field. The offset
2855 * (with respect to the address of @a setup) of a sub-field is identical to its
2856 * enumeration constant. The width of each sub-field is determined by the
2857 * corresponding value in ::hsa_kernel_dispatch_packet_setup_width_t. The
2858 * offset and the width are expressed in bits.
2862 * Number of dimensions of the grid. Valid values are 1, 2, or 3.
2865 HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS
= 0
2866 } hsa_kernel_dispatch_packet_setup_t
;
2869 * @brief Width (in bits) of the sub-fields in
2870 * ::hsa_kernel_dispatch_packet_setup_t.
2873 HSA_KERNEL_DISPATCH_PACKET_SETUP_WIDTH_DIMENSIONS
= 2
2874 } hsa_kernel_dispatch_packet_setup_width_t
;
2877 * @brief AQL kernel dispatch packet
2879 typedef struct hsa_kernel_dispatch_packet_s
{
2881 * Packet header. Used to configure multiple packet parameters such as the
2882 * packet type. The parameters are described by ::hsa_packet_header_t.
2887 * Dispatch setup parameters. Used to configure kernel dispatch parameters
2888 * such as the number of dimensions in the grid. The parameters are described
2889 * by ::hsa_kernel_dispatch_packet_setup_t.
2894 * X dimension of work-group, in work-items. Must be greater than 0.
2896 uint16_t workgroup_size_x
;
2899 * Y dimension of work-group, in work-items. Must be greater than
2900 * 0. If the grid has 1 dimension, the only valid value is 1.
2902 uint16_t workgroup_size_y
;
2905 * Z dimension of work-group, in work-items. Must be greater than
2906 * 0. If the grid has 1 or 2 dimensions, the only valid value is 1.
2908 uint16_t workgroup_size_z
;
2911 * Reserved. Must be 0.
2916 * X dimension of grid, in work-items. Must be greater than 0. Must
2917 * not be smaller than @a workgroup_size_x.
2919 uint32_t grid_size_x
;
2922 * Y dimension of grid, in work-items. Must be greater than 0. If the grid has
2923 * 1 dimension, the only valid value is 1. Must not be smaller than @a
2926 uint32_t grid_size_y
;
2929 * Z dimension of grid, in work-items. Must be greater than 0. If the grid has
2930 * 1 or 2 dimensions, the only valid value is 1. Must not be smaller than @a
2933 uint32_t grid_size_z
;
2936 * Size in bytes of private memory allocation request (per work-item).
2938 uint32_t private_segment_size
;
2941 * Size in bytes of group memory allocation request (per work-group). Must not
2942 * be less than the sum of the group memory used by the kernel (and the
2943 * functions it calls directly or indirectly) and the dynamically allocated
2944 * group segment variables.
2946 uint32_t group_segment_size
;
2949 * Opaque handle to a code object that includes an implementation-defined
2950 * executable code for the kernel.
2952 uint64_t kernel_object
;
2954 #ifdef HSA_LARGE_MODEL
2955 void* kernarg_address
;
2956 #elif defined HSA_LITTLE_ENDIAN
2958 * Pointer to a buffer containing the kernel arguments. May be NULL.
2960 * The buffer must be allocated using ::hsa_memory_allocate, and must not be
2961 * modified once the kernel dispatch packet is enqueued until the dispatch has
2962 * completed execution.
2964 void* kernarg_address
;
2966 * Reserved. Must be 0.
2971 void* kernarg_address
;
2975 * Reserved. Must be 0.
2980 * Signal used to indicate completion of the job. The application can use the
2981 * special signal handle 0 to indicate that no signal is used.
2983 hsa_signal_t completion_signal
;
2985 } hsa_kernel_dispatch_packet_t
;
2988 * @brief Agent dispatch packet.
2990 typedef struct hsa_agent_dispatch_packet_s
{
2992 * Packet header. Used to configure multiple packet parameters such as the
2993 * packet type. The parameters are described by ::hsa_packet_header_t.
2998 * Application-defined function to be performed by the destination agent.
3003 * Reserved. Must be 0.
3007 #ifdef HSA_LARGE_MODEL
3008 void* return_address
;
3009 #elif defined HSA_LITTLE_ENDIAN
3011 * Address where to store the function return values, if any.
3013 void* return_address
;
3015 * Reserved. Must be 0.
3020 void* return_address
;
3024 * Function arguments.
3029 * Reserved. Must be 0.
3034 * Signal used to indicate completion of the job. The application can use the
3035 * special signal handle 0 to indicate that no signal is used.
3037 hsa_signal_t completion_signal
;
3039 } hsa_agent_dispatch_packet_t
;
3042 * @brief Barrier-AND packet.
3044 typedef struct hsa_barrier_and_packet_s
{
3046 * Packet header. Used to configure multiple packet parameters such as the
3047 * packet type. The parameters are described by ::hsa_packet_header_t.
3052 * Reserved. Must be 0.
3057 * Reserved. Must be 0.
3062 * Array of dependent signal objects. Signals with a handle value of 0 are
3063 * allowed and are interpreted by the packet processor as satisfied
3066 hsa_signal_t dep_signal
[5];
3069 * Reserved. Must be 0.
3074 * Signal used to indicate completion of the job. The application can use the
3075 * special signal handle 0 to indicate that no signal is used.
3077 hsa_signal_t completion_signal
;
3079 } hsa_barrier_and_packet_t
;
3082 * @brief Barrier-OR packet.
3084 typedef struct hsa_barrier_or_packet_s
{
3086 * Packet header. Used to configure multiple packet parameters such as the
3087 * packet type. The parameters are described by ::hsa_packet_header_t.
3092 * Reserved. Must be 0.
3097 * Reserved. Must be 0.
3102 * Array of dependent signal objects. Signals with a handle value of 0 are
3103 * allowed and are interpreted by the packet processor as dependencies not
3106 hsa_signal_t dep_signal
[5];
3109 * Reserved. Must be 0.
3114 * Signal used to indicate completion of the job. The application can use the
3115 * special signal handle 0 to indicate that no signal is used.
3117 hsa_signal_t completion_signal
;
3119 } hsa_barrier_or_packet_t
;
3123 /** \addtogroup memory Memory
3128 * @brief Memory segments associated with a region.
3132 * Global segment. Used to hold data that is shared by all agents.
3134 HSA_REGION_SEGMENT_GLOBAL
= 0,
3136 * Read-only segment. Used to hold data that remains constant during the
3137 * execution of a kernel.
3139 HSA_REGION_SEGMENT_READONLY
= 1,
3141 * Private segment. Used to hold data that is local to a single work-item.
3143 HSA_REGION_SEGMENT_PRIVATE
= 2,
3145 * Group segment. Used to hold data that is shared by the work-items of a
3148 HSA_REGION_SEGMENT_GROUP
= 3,
3150 * Kernarg segment. Used to store kernel arguments.
3152 HSA_REGION_SEGMENT_KERNARG
= 4
3153 } hsa_region_segment_t
;
3156 * @brief Global region flags.
3160 * The application can use memory in the region to store kernel arguments, and
3161 * provide the values for the kernarg segment of a kernel dispatch. If this
3162 * flag is set, then ::HSA_REGION_GLOBAL_FLAG_FINE_GRAINED must be set.
3164 HSA_REGION_GLOBAL_FLAG_KERNARG
= 1,
3166 * Updates to memory in this region are immediately visible to all the
3167 * agents under the terms of the HSA memory model. If this
3168 * flag is set, then ::HSA_REGION_GLOBAL_FLAG_COARSE_GRAINED must not be set.
3170 HSA_REGION_GLOBAL_FLAG_FINE_GRAINED
= 2,
3172 * Updates to memory in this region can be performed by a single agent at
3173 * a time. If a different agent in the system is allowed to access the
3174 * region, the application must explicitely invoke ::hsa_memory_assign_agent
3175 * in order to transfer ownership to that agent for a particular buffer.
3177 HSA_REGION_GLOBAL_FLAG_COARSE_GRAINED
= 4
3178 } hsa_region_global_flag_t
;
3181 * @brief Attributes of a memory region.
3185 * Segment where memory in the region can be used. The type of this
3186 * attribute is ::hsa_region_segment_t.
3188 HSA_REGION_INFO_SEGMENT
= 0,
3190 * Flag mask. The value of this attribute is undefined if the value of
3191 * ::HSA_REGION_INFO_SEGMENT is not ::HSA_REGION_SEGMENT_GLOBAL. The type of
3192 * this attribute is uint32_t, a bit-field of ::hsa_region_global_flag_t
3195 HSA_REGION_INFO_GLOBAL_FLAGS
= 1,
3197 * Size of this region, in bytes. The type of this attribute is size_t.
3199 HSA_REGION_INFO_SIZE
= 2,
3201 * Maximum allocation size in this region, in bytes. Must not exceed the value
3202 * of ::HSA_REGION_INFO_SIZE. The type of this attribute is size_t.
3204 * If the region is in the global or readonly segments, this is the maximum
3205 * size that the application can pass to ::hsa_memory_allocate.
3207 * If the region is in the group segment, this is the maximum size (per
3208 * work-group) that can be requested for a given kernel dispatch. If the
3209 * region is in the private segment, this is the maximum size (per work-item)
3210 * that can be requested for a specific kernel dispatch, and must be at least
3213 HSA_REGION_INFO_ALLOC_MAX_SIZE
= 4,
3215 * Maximum size (per work-group) of private memory that can be requested for a
3216 * specific kernel dispatch. Must be at least 65536 bytes. The type of this
3217 * attribute is uint32_t. The value of this attribute is undefined if the
3218 * region is not in the private segment.
3220 HSA_REGION_INFO_ALLOC_MAX_PRIVATE_WORKGROUP_SIZE
= 8,
3222 * Indicates whether memory in this region can be allocated using
3223 * ::hsa_memory_allocate. The type of this attribute is bool.
3225 * The value of this flag is always false for regions in the group and private
3228 HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED
= 5,
3230 * Allocation granularity of buffers allocated by ::hsa_memory_allocate in
3231 * this region. The size of a buffer allocated in this region is a multiple of
3232 * the value of this attribute. The value of this attribute is only defined if
3233 * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED is true for this region. The type
3234 * of this attribute is size_t.
3236 HSA_REGION_INFO_RUNTIME_ALLOC_GRANULE
= 6,
3238 * Alignment of buffers allocated by ::hsa_memory_allocate in this region. The
3239 * value of this attribute is only defined if
3240 * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED is true for this region, and must be
3241 * a power of 2. The type of this attribute is size_t.
3243 HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT
= 7
3244 } hsa_region_info_t
;
3247 * @brief Get the current value of an attribute of a region.
3249 * @param[in] region A valid region.
3251 * @param[in] attribute Attribute to query.
3253 * @param[out] value Pointer to a application-allocated buffer where to store
3254 * the value of the attribute. If the buffer passed by the application is not
3255 * large enough to hold the value of @p attribute, the behavior is undefined.
3257 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3259 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3262 * @retval ::HSA_STATUS_ERROR_INVALID_REGION The region is invalid.
3264 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3265 * region attribute, or @p value is NULL.
3267 hsa_status_t HSA_API
hsa_region_get_info(
3268 hsa_region_t region
,
3269 hsa_region_info_t attribute
,
3273 * @brief Iterate over the memory regions associated with a given agent, and
3274 * invoke an application-defined callback on every iteration.
3276 * @param[in] agent A valid agent.
3278 * @param[in] callback Callback to be invoked once per region that is
3279 * accessible from the agent. The HSA runtime passes two arguments to the
3280 * callback, the region and the application data. If @p callback returns a
3281 * status other than ::HSA_STATUS_SUCCESS for a particular iteration, the
3282 * traversal stops and ::hsa_agent_iterate_regions returns that status value.
3284 * @param[in] data Application data that is passed to @p callback on every
3285 * iteration. May be NULL.
3287 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3289 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3292 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3294 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
3296 hsa_status_t HSA_API
hsa_agent_iterate_regions(
3298 hsa_status_t (*callback
)(hsa_region_t region
, void* data
),
3302 * @brief Allocate a block of memory in a given region.
3304 * @param[in] region Region where to allocate memory from. The region must have
3305 * the ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED flag set.
3307 * @param[in] size Allocation size, in bytes. Must not be zero. This value is
3308 * rounded up to the nearest multiple of ::HSA_REGION_INFO_RUNTIME_ALLOC_GRANULE
3311 * @param[out] ptr Pointer to the location where to store the base address of
3312 * the allocated block. The returned base address is aligned to the value of
3313 * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT in @p region. If the allocation
3314 * fails, the returned value is undefined.
3316 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3318 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3321 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
3322 * the required resources.
3324 * @retval ::HSA_STATUS_ERROR_INVALID_REGION The region is invalid.
3326 * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The host is not allowed to
3327 * allocate memory in @p region, or @p size is greater than the value of
3328 * HSA_REGION_INFO_ALLOC_MAX_SIZE in @p region.
3330 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p size is 0.
3332 hsa_status_t HSA_API
hsa_memory_allocate(hsa_region_t region
,
3337 * @brief Deallocate a block of memory previously allocated using
3338 * ::hsa_memory_allocate.
3340 * @param[in] ptr Pointer to a memory block. If @p ptr does not match a value
3341 * previously returned by ::hsa_memory_allocate, the behavior is undefined.
3343 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3345 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3348 hsa_status_t HSA_API
hsa_memory_free(void* ptr
);
3351 * @brief Copy a block of memory from the location pointed to by @p src to the
3352 * memory block pointed to by @p dst.
3354 * @param[out] dst Buffer where the content is to be copied. If @p dst is in
3355 * coarse-grained memory, the copied data is only visible to the agent currently
3356 * assigned (::hsa_memory_assign_agent) to @p dst.
3358 * @param[in] src A valid pointer to the source of data to be copied. The source
3359 * buffer must not overlap with the destination buffer. If the source buffer is
3360 * in coarse-grained memory then it must be assigned to an agent, from which the
3361 * data will be retrieved.
3363 * @param[in] size Number of bytes to copy. If @p size is 0, no copy is
3364 * performed and the function returns success. Copying a number of bytes larger
3365 * than the size of the buffers pointed by @p dst or @p src results in undefined
3368 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3370 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3373 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
3374 * pointers are NULL.
3376 hsa_status_t HSA_API
hsa_memory_copy(
3382 * @brief Change the ownership of a global, coarse-grained buffer.
3384 * @details The contents of a coarse-grained buffer are visible to an agent
3385 * only after ownership has been explicitely transferred to that agent. Once the
3386 * operation completes, the previous owner cannot longer access the data in the
3389 * An implementation of the HSA runtime is allowed, but not required, to change
3390 * the physical location of the buffer when ownership is transferred to a
3391 * different agent. In general the application must not assume this
3392 * behavior. The virtual location (address) of the passed buffer is never
3395 * @param[in] ptr Base address of a global buffer. The pointer must match an
3396 * address previously returned by ::hsa_memory_allocate. The size of the buffer
3397 * affected by the ownership change is identical to the size of that previous
3398 * allocation. If @p ptr points to a fine-grained global buffer, no operation is
3399 * performed and the function returns success. If @p ptr does not point to
3400 * global memory, the behavior is undefined.
3402 * @param[in] agent Agent that becomes the owner of the buffer. The
3403 * application is responsible for ensuring that @p agent has access to the
3404 * region that contains the buffer. It is allowed to change ownership to an
3405 * agent that is already the owner of the buffer, with the same or different
3406 * access permissions.
3408 * @param[in] access Access permissions requested for the new owner.
3410 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3412 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3415 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3417 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
3418 * the required resources.
3420 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p access is
3421 * not a valid access value.
3423 hsa_status_t HSA_API
hsa_memory_assign_agent(
3426 hsa_access_permission_t access
);
3430 * @brief Register a global, fine-grained buffer.
3432 * @details Registering a buffer serves as an indication to the HSA runtime that
3433 * the memory might be accessed from a kernel agent other than the
3434 * host. Registration is a performance hint that allows the HSA runtime
3435 * implementation to know which buffers will be accessed by some of the kernel
3436 * agents ahead of time.
3438 * Registration is only recommended for buffers in the global segment that have
3439 * not been allocated using the HSA allocator (::hsa_memory_allocate), but an OS
3440 * allocator instead. Registering an OS-allocated buffer in the base profile is
3441 * equivalent to a no-op.
3443 * Registrations should not overlap.
3445 * @param[in] ptr A buffer in global, fine-grained memory. If a NULL pointer is
3446 * passed, no operation is performed. If the buffer has been allocated using
3447 * ::hsa_memory_allocate, or has already been registered, no operation is
3450 * @param[in] size Requested registration size in bytes. A size of 0 is
3451 * only allowed if @p ptr is NULL.
3453 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3455 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3458 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
3459 * the required resources.
3461 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 but @p ptr
3464 hsa_status_t HSA_API
hsa_memory_register(
3470 * @brief Deregister memory previously registered using ::hsa_memory_register.
3472 * @details If the memory interval being deregistered does not match a previous
3473 * registration (start and end addresses), the behavior is undefined.
3475 * @param[in] ptr A pointer to the base of the buffer to be deregistered. If
3476 * a NULL pointer is passed, no operation is performed.
3478 * @param[in] size Size of the buffer to be deregistered.
3480 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3482 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3486 hsa_status_t HSA_API
hsa_memory_deregister(
3493 /** \defgroup instruction-set-architecture Instruction Set Architecture.
3498 * @brief Instruction set architecture.
3500 typedef struct hsa_isa_s
{
3502 * Opaque handle. Two handles reference the same object of the enclosing type
3503 * if and only if they are equal.
3509 * @brief Retrieve a reference to an instruction set architecture handle out of
3512 * @param[in] name Vendor-specific name associated with a a particular
3513 * instruction set architecture. @p name must start with the vendor name and a
3514 * colon (for example, "AMD:"). The rest of the name is vendor-specific. Must be
3515 * a NUL-terminated string.
3517 * @param[out] isa Memory location where the HSA runtime stores the ISA handle
3518 * corresponding to the given name. Must not be NULL.
3520 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3522 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3525 * @retval ::HSA_STATUS_ERROR_INVALID_ISA_NAME The given name does not
3526 * correspond to any instruction set architecture.
3528 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
3529 * allocate the required resources.
3531 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p name is NULL, or @p isa is
3534 hsa_status_t HSA_API
hsa_isa_from_name(
3539 * @brief Iterate over the instruction sets supported by the given agent, and
3540 * invoke an application-defined callback on every iteration. The iterator is
3541 * deterministic: if an agent supports several instruction set architectures,
3542 * they are traversed in the same order in every invocation of this function.
3544 * @param[in] agent A valid agent.
3546 * @param[in] callback Callback to be invoked once per instruction set
3547 * architecture. The HSA runtime passes two arguments to the callback: the
3548 * ISA and the application data. If @p callback returns a status other than
3549 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
3550 * that status value is returned.
3552 * @param[in] data Application data that is passed to @p callback on every
3553 * iteration. May be NULL.
3555 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3557 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3560 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
3562 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
3564 hsa_status_t HSA_API
hsa_agent_iterate_isas(
3566 hsa_status_t (*callback
)(hsa_isa_t isa
, void *data
),
3570 * @brief Instruction set architecture attributes.
3574 * The length of the ISA name in bytes, not including the NUL terminator. The
3575 * type of this attribute is uint32_t.
3577 HSA_ISA_INFO_NAME_LENGTH
= 0,
3579 * Human-readable description. The type of this attribute is character array
3580 * with the length equal to the value of ::HSA_ISA_INFO_NAME_LENGTH attribute.
3582 HSA_ISA_INFO_NAME
= 1,
3586 * Number of call conventions supported by the instruction set architecture.
3587 * Must be greater than zero. The type of this attribute is uint32_t.
3589 HSA_ISA_INFO_CALL_CONVENTION_COUNT
= 2,
3593 * Number of work-items in a wavefront for a given call convention. Must be a
3594 * power of 2 in the range [1,256]. The type of this attribute is uint32_t.
3596 HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONT_SIZE
= 3,
3600 * Number of wavefronts per compute unit for a given call convention. In
3601 * practice, other factors (for example, the amount of group memory used by a
3602 * work-group) may further limit the number of wavefronts per compute
3603 * unit. The type of this attribute is uint32_t.
3605 HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONTS_PER_COMPUTE_UNIT
= 4,
3607 * Machine models supported by the instruction set architecture. The type of
3608 * this attribute is a bool[2]. If the ISA supports the small machine model,
3609 * the element at index ::HSA_MACHINE_MODEL_SMALL is true. If the ISA supports
3610 * the large model, the element at index ::HSA_MACHINE_MODEL_LARGE is true.
3612 HSA_ISA_INFO_MACHINE_MODELS
= 5,
3614 * Profiles supported by the instruction set architecture. The type of this
3615 * attribute is a bool[2]. If the ISA supports the base profile, the element
3616 * at index ::HSA_PROFILE_BASE is true. If the ISA supports the full profile,
3617 * the element at index ::HSA_PROFILE_FULL is true.
3619 HSA_ISA_INFO_PROFILES
= 6,
3621 * Default floating-point rounding modes supported by the instruction set
3622 * architecture. The type of this attribute is a bool[3]. The value at a given
3623 * index is true if the corresponding rounding mode in
3624 * ::hsa_default_float_rounding_mode_t is supported. At least one default mode
3625 * has to be supported.
3627 * If the default mode is supported, then
3628 * ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES must report that
3629 * both the zero and the near roundings modes are supported.
3631 HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES
= 7,
3633 * Default floating-point rounding modes supported by the instruction set
3634 * architecture in the Base profile. The type of this attribute is a
3635 * bool[3]. The value at a given index is true if the corresponding rounding
3636 * mode in ::hsa_default_float_rounding_mode_t is supported. The value at
3637 * index HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT must be false. At least one
3638 * of the values at indexes ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO or
3639 * HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR must be true.
3641 HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES
= 8,
3643 * Flag indicating that the f16 HSAIL operation is at least as fast as the
3644 * f32 operation in the instruction set architecture. The type of this
3645 * attribute is bool.
3647 HSA_ISA_INFO_FAST_F16_OPERATION
= 9,
3649 * Maximum number of work-items of each dimension of a work-group. Each
3650 * maximum must be greater than 0. No maximum can exceed the value of
3651 * ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE. The type of this attribute is
3654 HSA_ISA_INFO_WORKGROUP_MAX_DIM
= 12,
3656 * Maximum total number of work-items in a work-group. The type
3657 * of this attribute is uint32_t.
3659 HSA_ISA_INFO_WORKGROUP_MAX_SIZE
= 13,
3661 * Maximum number of work-items of each dimension of a grid. Each maximum must
3662 * be greater than 0, and must not be smaller than the corresponding value in
3663 * ::HSA_ISA_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
3664 * ::HSA_ISA_INFO_GRID_MAX_SIZE. The type of this attribute is
3667 HSA_ISA_INFO_GRID_MAX_DIM
= 14,
3669 * Maximum total number of work-items in a grid. The type of this
3670 * attribute is uint64_t.
3672 HSA_ISA_INFO_GRID_MAX_SIZE
= 16,
3674 * Maximum number of fbarriers per work-group. Must be at least 32. The
3675 * type of this attribute is uint32_t.
3677 HSA_ISA_INFO_FBARRIER_MAX_SIZE
= 17
3681 * @deprecated The concept of call convention has been deprecated. If the
3682 * application wants to query the value of an attribute for a given instruction
3683 * set architecture, use ::hsa_isa_get_info_alt instead. If the application
3684 * wants to query an attribute that is specific to a given combination of ISA
3685 * and wavefront, use ::hsa_wavefront_get_info.
3687 * @brief Get the current value of an attribute for a given instruction set
3688 * architecture (ISA).
3690 * @param[in] isa A valid instruction set architecture.
3692 * @param[in] attribute Attribute to query.
3694 * @param[in] index Call convention index. Used only for call convention
3695 * attributes, otherwise ignored. Must have a value between 0 (inclusive) and
3696 * the value of the attribute ::HSA_ISA_INFO_CALL_CONVENTION_COUNT (not
3697 * inclusive) in @p isa.
3699 * @param[out] value Pointer to an application-allocated buffer where to store
3700 * the value of the attribute. If the buffer passed by the application is not
3701 * large enough to hold the value of @p attribute, the behavior is undefined.
3703 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3705 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3708 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3711 * @retval ::HSA_STATUS_ERROR_INVALID_INDEX The index is out of range.
3713 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3714 * instruction set architecture attribute, or @p value is
3717 hsa_status_t HSA_API HSA_DEPRECATED
hsa_isa_get_info(
3719 hsa_isa_info_t attribute
,
3724 * @brief Get the current value of an attribute for a given instruction set
3725 * architecture (ISA).
3727 * @param[in] isa A valid instruction set architecture.
3729 * @param[in] attribute Attribute to query.
3731 * @param[out] value Pointer to an application-allocated buffer where to store
3732 * the value of the attribute. If the buffer passed by the application is not
3733 * large enough to hold the value of @p attribute, the behavior is undefined.
3735 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3737 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3740 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3743 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3744 * instruction set architecture attribute, or @p value is
3747 hsa_status_t HSA_API
hsa_isa_get_info_alt(
3749 hsa_isa_info_t attribute
,
3753 * @brief Retrieve the exception policy support for a given combination of
3754 * instruction set architecture and profile.
3756 * @param[in] isa A valid instruction set architecture.
3758 * @param[in] profile Profile.
3760 * @param[out] mask Pointer to a memory location where the HSA runtime stores a
3761 * mask of ::hsa_exception_policy_t values. Must not be NULL.
3763 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3765 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3768 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3771 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is not a valid
3772 * profile, or @p mask is NULL.
3774 hsa_status_t HSA_API
hsa_isa_get_exception_policies(
3776 hsa_profile_t profile
,
3780 * @brief Floating-point types.
3784 * 16-bit floating-point type.
3788 * 32-bit floating-point type.
3792 * 64-bit floating-point type.
3798 * @brief Flush to zero modes.
3804 HSA_FLUSH_MODE_FTZ
= 1,
3806 * Do not flush to zero.
3808 HSA_FLUSH_MODE_NON_FTZ
= 2
3812 * @brief Round methods.
3816 * Single round method.
3818 HSA_ROUND_METHOD_SINGLE
= 1,
3820 * Double round method.
3822 HSA_ROUND_METHOD_DOUBLE
= 2
3823 } hsa_round_method_t
;
3826 * @brief Retrieve the round method (single or double) used to implement the
3827 * floating-point multiply add instruction (mad) for a given combination of
3828 * instruction set architecture, floating-point type, and flush to zero
3831 * @param[in] isa Instruction set architecture.
3833 * @param[in] fp_type Floating-point type.
3835 * @param[in] flush_mode Flush to zero modifier.
3837 * @param[out] round_method Pointer to a memory location where the HSA
3838 * runtime stores the round method used by the implementation. Must not be NULL.
3840 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3842 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3845 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3848 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p fp_type is not a valid
3849 * floating-point type, or @p flush_mode is not a valid flush to zero modifier,
3850 * or @p round_method is NULL.
3852 hsa_status_t HSA_API
hsa_isa_get_round_method(
3854 hsa_fp_type_t fp_type
,
3855 hsa_flush_mode_t flush_mode
,
3856 hsa_round_method_t
*round_method
);
3859 * @brief Wavefront handle
3861 typedef struct hsa_wavefront_s
{
3863 * Opaque handle. Two handles reference the same object of the enclosing type
3864 * if and only if they are equal.
3870 * @brief Wavefront attributes.
3874 * Number of work-items in the wavefront. Must be a power of 2 in the range
3875 * [1,256]. The type of this attribute is uint32_t.
3877 HSA_WAVEFRONT_INFO_SIZE
= 0
3878 } hsa_wavefront_info_t
;
3881 * @brief Get the current value of a wavefront attribute.
3883 * @param[in] wavefront A wavefront.
3885 * @param[in] attribute Attribute to query.
3887 * @param[out] value Pointer to an application-allocated buffer where to store
3888 * the value of the attribute. If the buffer passed by the application is not
3889 * large enough to hold the value of @p attribute, the behavior is undefined.
3891 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3893 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3896 * @retval ::HSA_STATUS_ERROR_INVALID_WAVEFRONT The wavefront is invalid.
3898 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
3899 * wavefront attribute, or @p value is NULL.
3901 hsa_status_t HSA_API
hsa_wavefront_get_info(
3902 hsa_wavefront_t wavefront
,
3903 hsa_wavefront_info_t attribute
,
3907 * @brief Iterate over the different wavefronts supported by an instruction set
3908 * architecture, and invoke an application-defined callback on every iteration.
3910 * @param[in] isa Instruction set architecture.
3912 * @param[in] callback Callback to be invoked once per wavefront that is
3913 * supported by the agent. The HSA runtime passes two arguments to the callback:
3914 * the wavefront handle and the application data. If @p callback returns a
3915 * status other than ::HSA_STATUS_SUCCESS for a particular iteration, the
3916 * traversal stops and that value is returned.
3918 * @param[in] data Application data that is passed to @p callback on every
3919 * iteration. May be NULL.
3921 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3923 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3926 * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
3929 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
3931 hsa_status_t HSA_API
hsa_isa_iterate_wavefronts(
3933 hsa_status_t (*callback
)(hsa_wavefront_t wavefront
, void *data
),
3937 * @deprecated Use ::hsa_agent_iterate_isas to query which instructions set
3938 * architectures are supported by a given agent.
3940 * @brief Check if the instruction set architecture of a code object can be
3941 * executed on an agent associated with another architecture.
3943 * @param[in] code_object_isa Instruction set architecture associated with a
3946 * @param[in] agent_isa Instruction set architecture associated with an agent.
3948 * @param[out] result Pointer to a memory location where the HSA runtime stores
3949 * the result of the check. If the two architectures are compatible, the result
3950 * is true; if they are incompatible, the result is false.
3952 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
3954 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
3957 * @retval ::HSA_STATUS_ERROR_INVALID_ISA @p code_object_isa or @p agent_isa are
3960 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
3962 hsa_status_t HSA_API HSA_DEPRECATED
hsa_isa_compatible(
3963 hsa_isa_t code_object_isa
,
3964 hsa_isa_t agent_isa
,
3970 /** \defgroup executable Executable
3975 * @brief Code object reader handle. A code object reader is used to
3976 * load a code object from file (when created using
3977 * ::hsa_code_object_reader_create_from_file), or from memory (if created using
3978 * ::hsa_code_object_reader_create_from_memory).
3980 typedef struct hsa_code_object_reader_s
{
3982 * Opaque handle. Two handles reference the same object of the enclosing type
3983 * if and only if they are equal.
3986 } hsa_code_object_reader_t
;
3989 * @brief Create a code object reader to operate on a file.
3991 * @param[in] file File descriptor. The file must have been opened by
3992 * application with at least read permissions prior calling this function. The
3993 * file must contain a vendor-specific code object.
3995 * The file is owned and managed by the application; the lifetime of the file
3996 * descriptor must exceed that of any associated code object reader.
3998 * @param[out] code_object_reader Memory location to store the newly created
3999 * code object reader handle. Must not be NULL.
4001 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4003 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4006 * @retval ::HSA_STATUS_ERROR_INVALID_FILE @p file is invalid.
4008 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4009 * allocate the required resources.
4011 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p code_object_reader is NULL.
4013 hsa_status_t HSA_API
hsa_code_object_reader_create_from_file(
4015 hsa_code_object_reader_t
*code_object_reader
);
4018 * @brief Create a code object reader to operate on memory.
4020 * @param[in] code_object Memory buffer that contains a vendor-specific code
4021 * object. The buffer is owned and managed by the application; the lifetime of
4022 * the buffer must exceed that of any associated code object reader.
4024 * @param[in] size Size of the buffer pointed to by @p code_object. Must not be
4027 * @param[out] code_object_reader Memory location to store newly created code
4028 * object reader handle. Must not be NULL.
4030 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4032 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4035 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4036 * allocate the required resources.
4038 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p code_object is NULL, @p size
4039 * is zero, or @p code_object_reader is NULL.
4041 hsa_status_t HSA_API
hsa_code_object_reader_create_from_memory(
4042 const void *code_object
,
4044 hsa_code_object_reader_t
*code_object_reader
);
4047 * @brief Destroy a code object reader.
4049 * @details The code object reader handle becomes invalid after completion of
4050 * this function. Any file or memory used to create the code object read is not
4051 * closed, removed, or deallocated by this function.
4053 * @param[in] code_object_reader Code object reader to destroy.
4055 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4057 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4060 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
4063 hsa_status_t HSA_API
hsa_code_object_reader_destroy(
4064 hsa_code_object_reader_t code_object_reader
);
4067 * @brief Struct containing an opaque handle to an executable, which contains
4068 * ISA for finalized kernels and indirect functions together with the allocated
4069 * global or readonly segment variables they reference.
4071 typedef struct hsa_executable_s
{
4073 * Opaque handle. Two handles reference the same object of the enclosing type
4074 * if and only if they are equal.
4080 * @brief Executable state.
4084 * Executable state, which allows the user to load code objects and define
4085 * external variables. Variable addresses, kernel code handles, and
4086 * indirect function code handles are not available in query operations until
4087 * the executable is frozen (zero always returned).
4089 HSA_EXECUTABLE_STATE_UNFROZEN
= 0,
4091 * Executable state, which allows the user to query variable addresses,
4092 * kernel code handles, and indirect function code handles using query
4093 * operations. Loading new code objects, as well as defining external
4094 * variables, is not allowed in this state.
4096 HSA_EXECUTABLE_STATE_FROZEN
= 1
4097 } hsa_executable_state_t
;
4100 * @deprecated Use ::hsa_executable_create_alt instead, which allows the
4101 * application to specify the default floating-point rounding mode of the
4102 * executable and assumes an unfrozen initial state.
4104 * @brief Create an empty executable.
4106 * @param[in] profile Profile used in the executable.
4108 * @param[in] executable_state Executable state. If the state is
4109 * ::HSA_EXECUTABLE_STATE_FROZEN, the resulting executable is useless because no
4110 * code objects can be loaded, and no variables can be defined.
4112 * @param[in] options Standard and vendor-specific options. Unknown options are
4113 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4114 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4115 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4116 * NUL-terminated string. May be NULL.
4118 * @param[out] executable Memory location where the HSA runtime stores the newly
4119 * created executable handle.
4121 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4123 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4126 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4127 * allocate the required resources.
4129 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is invalid, or
4130 * @p executable is NULL.
4132 hsa_status_t HSA_API HSA_DEPRECATED
hsa_executable_create(
4133 hsa_profile_t profile
,
4134 hsa_executable_state_t executable_state
,
4135 const char *options
,
4136 hsa_executable_t
*executable
);
4139 * @brief Create an empty executable.
4141 * @param[in] profile Profile used in the executable.
4143 * @param[in] default_float_rounding_mode Default floating-point rounding mode
4144 * used in the executable. Allowed rounding modes are near and zero (default is
4147 * @param[in] options Standard and vendor-specific options. Unknown options are
4148 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4149 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4150 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4151 * NUL-terminated string. May be NULL.
4153 * @param[out] executable Memory location where the HSA runtime stores newly
4154 * created executable handle. The initial state of the executable is
4155 * ::HSA_EXECUTABLE_STATE_UNFROZEN.
4157 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4159 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4162 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4163 * allocate the required resources.
4165 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is invalid, or
4166 * @p executable is NULL.
4168 hsa_status_t HSA_API
hsa_executable_create_alt(
4169 hsa_profile_t profile
,
4170 hsa_default_float_rounding_mode_t default_float_rounding_mode
,
4171 const char *options
,
4172 hsa_executable_t
*executable
);
4175 * @brief Destroy an executable.
4177 * @details An executable handle becomes invalid after the executable has been
4178 * destroyed. Code object handles that were loaded into this executable are
4179 * still valid after the executable has been destroyed, and can be used as
4180 * intended. Resources allocated outside and associated with this executable
4181 * (such as external global or readonly variables) can be released after the
4182 * executable has been destroyed.
4184 * Executable should not be destroyed while kernels are in flight.
4186 * @param[in] executable Executable.
4188 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4190 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4193 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4195 hsa_status_t HSA_API
hsa_executable_destroy(
4196 hsa_executable_t executable
);
4199 * @brief Loaded code object handle.
4201 typedef struct hsa_loaded_code_object_s
{
4203 * Opaque handle. Two handles reference the same object of the enclosing type
4204 * if and only if they are equal.
4207 } hsa_loaded_code_object_t
;
4210 * @brief Load a program code object into an executable.
4212 * @details A program code object contains information about resources that are
4213 * accessible by all kernel agents that run the executable, and can be loaded
4214 * at most once into an executable.
4216 * If the program code object uses extensions, the implementation must support
4217 * them for this operation to return successfully.
4219 * @param[in] executable Executable.
4221 * @param[in] code_object_reader A code object reader that holds the program
4222 * code object to load. If a code object reader is destroyed before all the
4223 * associated executables are destroyed, the behavior is undefined.
4225 * @param[in] options Standard and vendor-specific options. Unknown options are
4226 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4227 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4228 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4229 * NUL-terminated string. May be NULL.
4231 * @param[out] loaded_code_object Pointer to a memory location where the HSA
4232 * runtime stores the loaded code object handle. May be NULL.
4234 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4236 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4239 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4240 * allocate the required resources.
4242 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4244 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE The executable is frozen.
4246 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
4249 * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS The program code object is
4250 * not compatible with the executable or the implementation (for example, the
4251 * code object uses an extension that is not supported by the implementation).
4253 hsa_status_t HSA_API
hsa_executable_load_program_code_object(
4254 hsa_executable_t executable
,
4255 hsa_code_object_reader_t code_object_reader
,
4256 const char *options
,
4257 hsa_loaded_code_object_t
*loaded_code_object
);
4260 * @brief Load an agent code object into an executable.
4262 * @details The agent code object contains all defined agent
4263 * allocation variables, functions, indirect functions, and kernels in a given
4264 * program for a given instruction set architecture.
4266 * Any module linkage declaration must have been defined either by a define
4267 * variable or by loading a code object that has a symbol with module linkage
4270 * The default floating-point rounding mode of the code object associated with
4271 * @p code_object_reader must match that of the executable
4272 * (::HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE), or be default (in which
4273 * case the value of ::HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE is used).
4274 * If the agent code object uses extensions, the implementation and the agent
4275 * must support them for this operation to return successfully.
4277 * @param[in] executable Executable.
4279 * @param[in] agent Agent to load code object for. A code object can be loaded
4280 * into an executable at most once for a given agent. The instruction set
4281 * architecture of the code object must be supported by the agent.
4283 * @param[in] code_object_reader A code object reader that holds the code object
4284 * to load. If a code object reader is destroyed before all the associated
4285 * executables are destroyed, the behavior is undefined.
4287 * @param[in] options Standard and vendor-specific options. Unknown options are
4288 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4289 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4290 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4291 * NUL-terminated string. May be NULL.
4293 * @param[out] loaded_code_object Pointer to a memory location where the HSA
4294 * runtime stores the loaded code object handle. May be NULL.
4296 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4298 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4301 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4302 * allocate the required resources.
4304 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4306 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE The executable is frozen.
4308 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
4310 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
4313 * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS The code object read by @p
4314 * code_object_reader is not compatible with the agent (for example, the agent
4315 * does not support the instruction set architecture of the code object), the
4316 * executable (for example, there is a default floating-point mode mismatch
4317 * between the two), or the implementation.
4319 hsa_status_t HSA_API
hsa_executable_load_agent_code_object(
4320 hsa_executable_t executable
,
4322 hsa_code_object_reader_t code_object_reader
,
4323 const char *options
,
4324 hsa_loaded_code_object_t
*loaded_code_object
);
4327 * @brief Freeze the executable.
4329 * @details No modifications to executable can be made after freezing: no code
4330 * objects can be loaded to the executable, and no external variables can be
4331 * defined. Freezing the executable does not prevent querying the executable's
4332 * attributes. The application must define all the external variables in an
4333 * executable before freezing it.
4335 * @param[in] executable Executable.
4337 * @param[in] options Standard and vendor-specific options. Unknown options are
4338 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4339 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4340 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4341 * NUL-terminated string. May be NULL.
4343 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4345 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4348 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4350 * @retval ::HSA_STATUS_ERROR_VARIABLE_UNDEFINED One or more variables are
4351 * undefined in the executable.
4353 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is already frozen.
4355 hsa_status_t HSA_API
hsa_executable_freeze(
4356 hsa_executable_t executable
,
4357 const char *options
);
4360 * @brief Executable attributes.
4364 * Profile this executable is created for. The type of this attribute is
4367 HSA_EXECUTABLE_INFO_PROFILE
= 1,
4369 * Executable state. The type of this attribute is ::hsa_executable_state_t.
4371 HSA_EXECUTABLE_INFO_STATE
= 2,
4373 * Default floating-point rounding mode specified when executable was created.
4374 * The type of this attribute is ::hsa_default_float_rounding_mode_t.
4376 HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE
= 3
4377 } hsa_executable_info_t
;
4380 * @brief Get the current value of an attribute for a given executable.
4382 * @param[in] executable Executable.
4384 * @param[in] attribute Attribute to query.
4386 * @param[out] value Pointer to an application-allocated buffer where to store
4387 * the value of the attribute. If the buffer passed by the application is not
4388 * large enough to hold the value of @p attribute, the behavior is undefined.
4390 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4392 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4395 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4397 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
4398 * executable attribute, or @p value is NULL.
4400 hsa_status_t HSA_API
hsa_executable_get_info(
4401 hsa_executable_t executable
,
4402 hsa_executable_info_t attribute
,
4406 * @brief Define an external global variable with program allocation.
4408 * @details This function allows the application to provide the definition
4409 * of a variable in the global segment memory with program allocation. The
4410 * variable must be defined before loading a code object into an executable.
4411 * In addition, code objects loaded must not define the variable.
4413 * @param[in] executable Executable. Must not be in frozen state.
4415 * @param[in] variable_name Name of the variable. The Programmer's Reference
4416 * Manual describes the standard name mangling scheme.
4418 * @param[in] address Address where the variable is defined. This address must
4419 * be in global memory and can be read and written by any agent in the
4420 * system. The application cannot deallocate the buffer pointed by @p address
4421 * before @p executable is destroyed.
4423 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4425 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4428 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4429 * allocate the required resources.
4431 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4433 * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
4436 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
4439 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
4441 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
4443 hsa_status_t HSA_API
hsa_executable_global_variable_define(
4444 hsa_executable_t executable
,
4445 const char *variable_name
,
4449 * @brief Define an external global variable with agent allocation.
4451 * @details This function allows the application to provide the definition
4452 * of a variable in the global segment memory with agent allocation. The
4453 * variable must be defined before loading a code object into an executable.
4454 * In addition, code objects loaded must not define the variable.
4456 * @param[in] executable Executable. Must not be in frozen state.
4458 * @param[in] agent Agent for which the variable is being defined.
4460 * @param[in] variable_name Name of the variable. The Programmer's Reference
4461 * Manual describes the standard name mangling scheme.
4463 * @param[in] address Address where the variable is defined. This address must
4464 * have been previously allocated using ::hsa_memory_allocate in a global region
4465 * that is only visible to @p agent. The application cannot deallocate the
4466 * buffer pointed by @p address before @p executable is destroyed.
4468 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4470 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4473 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4474 * allocate the required resources.
4476 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4478 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT @p agent is invalid.
4480 * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
4483 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
4486 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
4488 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
4490 hsa_status_t HSA_API
hsa_executable_agent_global_variable_define(
4491 hsa_executable_t executable
,
4493 const char *variable_name
,
4497 * @brief Define an external readonly variable.
4499 * @details This function allows the application to provide the definition
4500 * of a variable in the readonly segment memory. The variable must be defined
4501 * before loading a code object into an executable. In addition, code objects
4502 * loaded must not define the variable.
4504 * @param[in] executable Executable. Must not be in frozen state.
4506 * @param[in] agent Agent for which the variable is being defined.
4508 * @param[in] variable_name Name of the variable. The Programmer's Reference
4509 * Manual describes the standard name mangling scheme.
4511 * @param[in] address Address where the variable is defined. This address must
4512 * have been previously allocated using ::hsa_memory_allocate in a readonly
4513 * region associated with @p agent. The application cannot deallocate the buffer
4514 * pointed by @p address before @p executable is destroyed.
4516 * @param[in] address Address where the variable is defined. The buffer pointed
4517 * by @p address is owned by the application, and cannot be deallocated before
4518 * @p executable is destroyed.
4520 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4522 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4525 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
4526 * allocate the required resources.
4528 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE Executable is invalid.
4530 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT @p agent is invalid.
4532 * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
4535 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
4538 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
4540 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
4542 hsa_status_t HSA_API
hsa_executable_readonly_variable_define(
4543 hsa_executable_t executable
,
4545 const char *variable_name
,
4549 * @brief Validate an executable. Checks that all code objects have matching
4550 * machine model, profile, and default floating-point rounding mode. Checks that
4551 * all declarations have definitions. Checks declaration-definition
4552 * compatibility (see the HSA Programming Reference Manual for compatibility
4553 * rules). Invoking this function is equivalent to invoking
4554 * ::hsa_executable_validate_alt with no options.
4556 * @param[in] executable Executable. Must be in frozen state.
4558 * @param[out] result Memory location where the HSA runtime stores the
4559 * validation result. If the executable passes validation, the result is 0.
4561 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4563 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4566 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE @p executable is invalid.
4568 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
4570 hsa_status_t HSA_API
hsa_executable_validate(
4571 hsa_executable_t executable
,
4575 * @brief Validate an executable. Checks that all code objects have matching
4576 * machine model, profile, and default floating-point rounding mode. Checks that
4577 * all declarations have definitions. Checks declaration-definition
4578 * compatibility (see the HSA Programming Reference Manual for compatibility
4581 * @param[in] executable Executable. Must be in frozen state.
4583 * @param[in] options Standard and vendor-specific options. Unknown options are
4584 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
4585 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
4586 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
4587 * NUL-terminated string. May be NULL.
4589 * @param[out] result Memory location where the HSA runtime stores the
4590 * validation result. If the executable passes validation, the result is 0.
4592 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4594 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4597 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE @p executable is invalid.
4599 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
4601 hsa_status_t HSA_API
hsa_executable_validate_alt(
4602 hsa_executable_t executable
,
4603 const char *options
,
4607 * @brief Executable symbol handle.
4609 * The lifetime of an executable object symbol matches that of the executable
4610 * associated with it. An operation on a symbol whose associated executable has
4611 * been destroyed results in undefined behavior.
4613 typedef struct hsa_executable_symbol_s
{
4615 * Opaque handle. Two handles reference the same object of the enclosing type
4616 * if and only if they are equal.
4619 } hsa_executable_symbol_t
;
4622 * @deprecated Use ::hsa_executable_get_symbol_by_name instead.
4624 * @brief Get the symbol handle for a given a symbol name.
4626 * @param[in] executable Executable.
4628 * @param[in] module_name Module name. Must be NULL if the symbol has
4631 * @param[in] symbol_name Symbol name.
4633 * @param[in] agent Agent associated with the symbol. If the symbol is
4634 * independent of any agent (for example, a variable with program
4635 * allocation), this argument is ignored.
4637 * @param[in] call_convention Call convention associated with the symbol. If the
4638 * symbol does not correspond to an indirect function, this argument is ignored.
4640 * @param[out] symbol Memory location where the HSA runtime stores the symbol
4643 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4645 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4648 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4650 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
4651 * that matches @p symbol_name.
4653 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
4654 * @p symbol is NULL.
4656 hsa_status_t HSA_API HSA_DEPRECATED
hsa_executable_get_symbol(
4657 hsa_executable_t executable
,
4658 const char *module_name
,
4659 const char *symbol_name
,
4661 int32_t call_convention
,
4662 hsa_executable_symbol_t
*symbol
);
4665 * @brief Retrieve the symbol handle corresponding to a given a symbol name.
4667 * @param[in] executable Executable.
4669 * @param[in] symbol_name Symbol name. Must be a NUL-terminated character
4670 * array. The Programmer's Reference Manual describes the standard name mangling
4673 * @param[in] agent Pointer to the agent for which the symbol with the given
4674 * name is defined. If the symbol corresponding to the given name has program
4675 * allocation, @p agent must be NULL.
4677 * @param[out] symbol Memory location where the HSA runtime stores the symbol
4678 * handle. Must not be NULL.
4680 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4682 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4685 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
4687 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
4688 * that matches @p symbol_name.
4690 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or @p
4693 hsa_status_t HSA_API
hsa_executable_get_symbol_by_name(
4694 hsa_executable_t executable
,
4695 const char *symbol_name
,
4696 const hsa_agent_t
*agent
,
4697 hsa_executable_symbol_t
*symbol
);
4700 * @brief Symbol type.
4706 HSA_SYMBOL_KIND_VARIABLE
= 0,
4710 HSA_SYMBOL_KIND_KERNEL
= 1,
4712 * Indirect function.
4714 HSA_SYMBOL_KIND_INDIRECT_FUNCTION
= 2
4715 } hsa_symbol_kind_t
;
4718 * @brief Linkage type of a symbol.
4724 HSA_SYMBOL_LINKAGE_MODULE
= 0,
4728 HSA_SYMBOL_LINKAGE_PROGRAM
= 1
4729 } hsa_symbol_linkage_t
;
4732 * @brief Allocation type of a variable.
4738 HSA_VARIABLE_ALLOCATION_AGENT
= 0,
4740 * Program allocation.
4742 HSA_VARIABLE_ALLOCATION_PROGRAM
= 1
4743 } hsa_variable_allocation_t
;
4746 * @brief Memory segment associated with a variable.
4750 * Global memory segment.
4752 HSA_VARIABLE_SEGMENT_GLOBAL
= 0,
4754 * Readonly memory segment.
4756 HSA_VARIABLE_SEGMENT_READONLY
= 1
4757 } hsa_variable_segment_t
;
4760 * @brief Executable symbol attributes.
4764 * The kind of the symbol. The type of this attribute is ::hsa_symbol_kind_t.
4766 HSA_EXECUTABLE_SYMBOL_INFO_TYPE
= 0,
4768 * The length of the symbol name in bytes, not including the NUL terminator.
4769 * The type of this attribute is uint32_t.
4771 HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH
= 1,
4773 * The name of the symbol. The type of this attribute is character array with
4774 * the length equal to the value of ::HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH
4777 HSA_EXECUTABLE_SYMBOL_INFO_NAME
= 2,
4781 * The length of the module name in bytes (not including the NUL terminator)
4782 * to which this symbol belongs if this symbol has module linkage, otherwise 0
4783 * is returned. The type of this attribute is uint32_t.
4785 HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME_LENGTH
= 3,
4789 * The module name to which this symbol belongs if this symbol has module
4790 * linkage, otherwise an empty string is returned. The type of this attribute
4791 * is character array with the length equal to the value of
4792 * ::HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME_LENGTH attribute.
4794 HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME
= 4,
4798 * Agent associated with this symbol. If the symbol is a variable, the
4799 * value of this attribute is only defined if
4800 * ::HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALLOCATION is
4801 * ::HSA_VARIABLE_ALLOCATION_AGENT. The type of this attribute is hsa_agent_t.
4803 HSA_EXECUTABLE_SYMBOL_INFO_AGENT
= 20,
4805 * The address of the variable. The value of this attribute is undefined if
4806 * the symbol is not a variable. The type of this attribute is uint64_t.
4808 * If executable's state is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0 is
4811 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS
= 21,
4813 * The linkage kind of the symbol. The type of this attribute is
4814 * ::hsa_symbol_linkage_t.
4816 HSA_EXECUTABLE_SYMBOL_INFO_LINKAGE
= 5,
4818 * Indicates whether the symbol corresponds to a definition. The type of this
4819 * attribute is bool.
4821 HSA_EXECUTABLE_SYMBOL_INFO_IS_DEFINITION
= 17,
4825 * The allocation kind of the variable. The value of this attribute is
4826 * undefined if the symbol is not a variable. The type of this attribute is
4827 * ::hsa_variable_allocation_t.
4829 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALLOCATION
= 6,
4833 * The segment kind of the variable. The value of this attribute is undefined
4834 * if the symbol is not a variable. The type of this attribute is
4835 * ::hsa_variable_segment_t.
4837 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SEGMENT
= 7,
4841 * Alignment of the symbol in memory. The value of this attribute is undefined
4842 * if the symbol is not a variable. The type of this attribute is uint32_t.
4844 * The current alignment of the variable in memory may be greater than the
4845 * value specified in the source program variable declaration.
4847 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALIGNMENT
= 8,
4851 * Size of the variable. The value of this attribute is undefined if
4852 * the symbol is not a variable. The type of this attribute is uint32_t.
4854 * A value of 0 is returned if the variable is an external variable and has an
4855 * unknown dimension.
4857 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SIZE
= 9,
4861 * Indicates whether the variable is constant. The value of this attribute is
4862 * undefined if the symbol is not a variable. The type of this attribute is
4865 HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_IS_CONST
= 10,
4867 * Kernel object handle, used in the kernel dispatch packet. The value of this
4868 * attribute is undefined if the symbol is not a kernel. The type of this
4869 * attribute is uint64_t.
4871 * If the state of the executable is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0
4874 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT
= 22,
4876 * Size of kernarg segment memory that is required to hold the values of the
4877 * kernel arguments, in bytes. Must be a multiple of 16. The value of this
4878 * attribute is undefined if the symbol is not a kernel. The type of this
4879 * attribute is uint32_t.
4881 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE
= 11,
4883 * Alignment (in bytes) of the buffer used to pass arguments to the kernel,
4884 * which is the maximum of 16 and the maximum alignment of any of the kernel
4885 * arguments. The value of this attribute is undefined if the symbol is not a
4886 * kernel. The type of this attribute is uint32_t.
4888 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT
= 12,
4890 * Size of static group segment memory required by the kernel (per
4891 * work-group), in bytes. The value of this attribute is undefined
4892 * if the symbol is not a kernel. The type of this attribute is uint32_t.
4894 * The reported amount does not include any dynamically allocated group
4895 * segment memory that may be requested by the application when a kernel is
4898 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE
= 13,
4900 * Size of static private, spill, and arg segment memory required by
4901 * this kernel (per work-item), in bytes. The value of this attribute is
4902 * undefined if the symbol is not a kernel. The type of this attribute is
4905 * If the value of ::HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK is
4906 * true, the kernel may use more private memory than the reported value, and
4907 * the application must add the dynamic call stack usage to @a
4908 * private_segment_size when populating a kernel dispatch packet.
4910 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE
= 14,
4912 * Dynamic callstack flag. The value of this attribute is undefined if the
4913 * symbol is not a kernel. The type of this attribute is bool.
4915 * If this flag is set (the value is true), the kernel uses a dynamically
4916 * sized call stack. This can happen if recursive calls, calls to indirect
4917 * functions, or the HSAIL alloca instruction are present in the kernel.
4919 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK
= 15,
4923 * Call convention of the kernel. The value of this attribute is undefined if
4924 * the symbol is not a kernel. The type of this attribute is uint32_t.
4926 HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_CALL_CONVENTION
= 18,
4928 * Indirect function object handle. The value of this attribute is undefined
4929 * if the symbol is not an indirect function, or the associated agent does
4930 * not support the Full Profile. The type of this attribute depends on the
4931 * machine model: the type is uint32_t for small machine model, and uint64_t
4934 * If the state of the executable is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0
4937 HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_OBJECT
= 23,
4941 * Call convention of the indirect function. The value of this attribute is
4942 * undefined if the symbol is not an indirect function, or the associated
4943 * agent does not support the Full Profile. The type of this attribute is
4946 HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION
= 16
4947 } hsa_executable_symbol_info_t
;
4950 * @brief Get the current value of an attribute for a given executable symbol.
4952 * @param[in] executable_symbol Executable symbol.
4954 * @param[in] attribute Attribute to query.
4956 * @param[out] value Pointer to an application-allocated buffer where to store
4957 * the value of the attribute. If the buffer passed by the application is not
4958 * large enough to hold the value of @p attribute, the behavior is undefined.
4960 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4962 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4965 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE_SYMBOL The executable symbol is
4968 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
4969 * executable symbol attribute, or @p value is NULL.
4971 hsa_status_t HSA_API
hsa_executable_symbol_get_info(
4972 hsa_executable_symbol_t executable_symbol
,
4973 hsa_executable_symbol_info_t attribute
,
4979 * @brief Iterate over the symbols in a executable, and invoke an
4980 * application-defined callback on every iteration.
4982 * @param[in] executable Executable.
4984 * @param[in] callback Callback to be invoked once per executable symbol. The
4985 * HSA runtime passes three arguments to the callback: the executable, a symbol,
4986 * and the application data. If @p callback returns a status other than
4987 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
4988 * ::hsa_executable_iterate_symbols returns that status value.
4990 * @param[in] data Application data that is passed to @p callback on every
4991 * iteration. May be NULL.
4993 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
4995 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
4998 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5000 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5002 hsa_status_t HSA_API HSA_DEPRECATED
hsa_executable_iterate_symbols(
5003 hsa_executable_t executable
,
5004 hsa_status_t (*callback
)(hsa_executable_t exec
,
5005 hsa_executable_symbol_t symbol
,
5010 * @brief Iterate over the kernels, indirect functions, and agent allocation
5011 * variables in an executable for a given agent, and invoke an application-
5012 * defined callback on every iteration.
5014 * @param[in] executable Executable.
5016 * @param[in] agent Agent.
5018 * @param[in] callback Callback to be invoked once per executable symbol. The
5019 * HSA runtime passes three arguments to the callback: the executable, a symbol,
5020 * and the application data. If @p callback returns a status other than
5021 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
5022 * ::hsa_executable_iterate_symbols returns that status value.
5024 * @param[in] data Application data that is passed to @p callback on every
5025 * iteration. May be NULL.
5027 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5029 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5032 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5034 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5036 hsa_status_t HSA_API
hsa_executable_iterate_agent_symbols(
5037 hsa_executable_t executable
,
5039 hsa_status_t (*callback
)(hsa_executable_t exec
,
5041 hsa_executable_symbol_t symbol
,
5046 * @brief Iterate over the program allocation variables in an executable, and
5047 * invoke an application-defined callback on every iteration.
5049 * @param[in] executable Executable.
5051 * @param[in] callback Callback to be invoked once per executable symbol. The
5052 * HSA runtime passes three arguments to the callback: the executable, a symbol,
5053 * and the application data. If @p callback returns a status other than
5054 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
5055 * ::hsa_executable_iterate_symbols returns that status value.
5057 * @param[in] data Application data that is passed to @p callback on every
5058 * iteration. May be NULL.
5060 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5062 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5065 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5067 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5069 hsa_status_t HSA_API
hsa_executable_iterate_program_symbols(
5070 hsa_executable_t executable
,
5071 hsa_status_t (*callback
)(hsa_executable_t exec
,
5072 hsa_executable_symbol_t symbol
,
5079 /** \defgroup code-object Code Objects (deprecated).
5086 * @brief Struct containing an opaque handle to a code object, which contains
5087 * ISA for finalized kernels and indirect functions together with information
5088 * about the global or readonly segment variables they reference.
5090 typedef struct hsa_code_object_s
{
5092 * Opaque handle. Two handles reference the same object of the enclosing type
5093 * if and only if they are equal.
5096 } hsa_code_object_t
;
5101 * @brief Application data handle that is passed to the serialization
5102 * and deserialization functions.
5104 typedef struct hsa_callback_data_s
{
5109 } hsa_callback_data_t
;
5114 * @brief Serialize a code object. Can be used for offline finalization,
5115 * install-time finalization, disk code caching, etc.
5117 * @param[in] code_object Code object.
5119 * @param[in] alloc_callback Callback function for memory allocation. Must not
5120 * be NULL. The HSA runtime passes three arguments to the callback: the
5121 * allocation size, the application data, and a pointer to a memory location
5122 * where the application stores the allocation result. The HSA runtime invokes
5123 * @p alloc_callback once to allocate a buffer that contains the serialized
5124 * version of @p code_object. If the callback returns a status code other than
5125 * ::HSA_STATUS_SUCCESS, this function returns the same code.
5127 * @param[in] callback_data Application data that is passed to @p
5128 * alloc_callback. May be NULL.
5130 * @param[in] options Standard and vendor-specific options. Unknown options are
5131 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
5132 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
5133 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
5134 * NUL-terminated string. May be NULL.
5136 * @param[out] serialized_code_object Memory location where the HSA runtime
5137 * stores a pointer to the serialized code object. Must not be NULL.
5139 * @param[out] serialized_code_object_size Memory location where the HSA runtime
5140 * stores the size (in bytes) of @p serialized_code_object. The returned value
5141 * matches the allocation size passed by the HSA runtime to @p
5142 * alloc_callback. Must not be NULL.
5144 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5146 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5149 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
5150 * allocate the required resources.
5152 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5154 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p alloc_callback, @p
5155 * serialized_code_object, or @p serialized_code_object_size are NULL.
5157 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_serialize(
5158 hsa_code_object_t code_object
,
5159 hsa_status_t (*alloc_callback
)(size_t size
,
5160 hsa_callback_data_t data
,
5162 hsa_callback_data_t callback_data
,
5163 const char *options
,
5164 void **serialized_code_object
,
5165 size_t *serialized_code_object_size
);
5170 * @brief Deserialize a code object.
5172 * @param[in] serialized_code_object A serialized code object. Must not be NULL.
5174 * @param[in] serialized_code_object_size The size (in bytes) of @p
5175 * serialized_code_object. Must not be 0.
5177 * @param[in] options Standard and vendor-specific options. Unknown options are
5178 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
5179 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
5180 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
5181 * NUL-terminated string. May be NULL.
5183 * @param[out] code_object Memory location where the HSA runtime stores the
5184 * deserialized code object.
5186 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5188 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5191 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
5192 * allocate the required resources.
5194 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p serialized_code_object, or @p
5195 * code_object are NULL, or @p serialized_code_object_size is 0.
5197 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_deserialize(
5198 void *serialized_code_object
,
5199 size_t serialized_code_object_size
,
5200 const char *options
,
5201 hsa_code_object_t
*code_object
);
5206 * @brief Destroy a code object.
5208 * @details The lifetime of a code object must exceed that of any executable
5209 * where it has been loaded. If an executable that loaded @p code_object has not
5210 * been destroyed, the behavior is undefined.
5212 * @param[in] code_object Code object. The handle becomes invalid after it has
5215 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5217 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5220 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5222 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_destroy(
5223 hsa_code_object_t code_object
);
5228 * @brief Code object type.
5232 * Produces code object that contains ISA for all kernels and indirect
5233 * functions in HSA source.
5235 HSA_CODE_OBJECT_TYPE_PROGRAM
= 0
5236 } hsa_code_object_type_t
;
5241 * @brief Code object attributes.
5245 * The version of the code object. The type of this attribute is a
5246 * NUL-terminated char[64]. The name must be at most 63 characters long (not
5247 * including the NUL terminator) and all array elements not used for the name
5250 HSA_CODE_OBJECT_INFO_VERSION
= 0,
5252 * Type of code object. The type of this attribute is
5253 * ::hsa_code_object_type_t.
5255 HSA_CODE_OBJECT_INFO_TYPE
= 1,
5257 * Instruction set architecture this code object is produced for. The type of
5258 * this attribute is ::hsa_isa_t.
5260 HSA_CODE_OBJECT_INFO_ISA
= 2,
5262 * Machine model this code object is produced for. The type of this attribute
5263 * is ::hsa_machine_model_t.
5265 HSA_CODE_OBJECT_INFO_MACHINE_MODEL
= 3,
5267 * Profile this code object is produced for. The type of this attribute is
5270 HSA_CODE_OBJECT_INFO_PROFILE
= 4,
5272 * Default floating-point rounding mode used when the code object is
5273 * produced. The type of this attribute is
5274 * ::hsa_default_float_rounding_mode_t.
5276 HSA_CODE_OBJECT_INFO_DEFAULT_FLOAT_ROUNDING_MODE
= 5
5277 } hsa_code_object_info_t
;
5282 * @brief Get the current value of an attribute for a given code object.
5284 * @param[in] code_object Code object.
5286 * @param[in] attribute Attribute to query.
5288 * @param[out] value Pointer to an application-allocated buffer where to store
5289 * the value of the attribute. If the buffer passed by the application is not
5290 * large enough to hold the value of @p attribute, the behavior is undefined.
5292 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5294 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5297 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5299 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
5300 * code object attribute, or @p value is NULL.
5302 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_get_info(
5303 hsa_code_object_t code_object
,
5304 hsa_code_object_info_t attribute
,
5310 * @brief Load code object into the executable.
5312 * @details Every global or readonly variable that is external must be defined
5313 * before loading the code object. An internal global or readonly variable is
5314 * allocated once the code object, that is being loaded, references this
5315 * variable and this variable is not allocated.
5317 * Any module linkage declaration must have been defined either by a define
5318 * variable or by loading a code object that has a symbol with module linkage
5321 * @param[in] executable Executable.
5323 * @param[in] agent Agent to load code object for. The agent must support the
5324 * default floating-point rounding mode used by @p code_object.
5326 * @param[in] code_object Code object to load. The lifetime of the code object
5327 * must exceed that of the executable: if @p code_object is destroyed before @p
5328 * executable, the behavior is undefined.
5330 * @param[in] options Standard and vendor-specific options. Unknown options are
5331 * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
5332 * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
5333 * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
5334 * NUL-terminated string. May be NULL.
5336 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5338 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5341 * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
5342 * allocate the required resources.
5344 * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
5346 * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
5348 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5350 * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS @p agent is not compatible
5351 * with @p code_object (for example, @p agent does not support the default
5352 * floating-point rounding mode specified by @p code_object), or @p code_object
5353 * is not compatible with @p executable (for example, @p code_object and @p
5354 * executable have different machine models or profiles).
5356 * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
5358 hsa_status_t HSA_API HSA_DEPRECATED
hsa_executable_load_code_object(
5359 hsa_executable_t executable
,
5361 hsa_code_object_t code_object
,
5362 const char *options
);
5367 * @brief Code object symbol handle.
5369 * The lifetime of a code object symbol matches that of the code object
5370 * associated with it. An operation on a symbol whose associated code object has
5371 * been destroyed results in undefined behavior.
5373 typedef struct hsa_code_symbol_s
{
5375 * Opaque handle. Two handles reference the same object of the enclosing type
5376 * if and only if they are equal.
5379 } hsa_code_symbol_t
;
5384 * @brief Get the symbol handle within a code object for a given a symbol name.
5386 * @param[in] code_object Code object.
5388 * @param[in] symbol_name Symbol name.
5390 * @param[out] symbol Memory location where the HSA runtime stores the symbol
5393 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5395 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5398 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5400 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
5401 * that matches @p symbol_name.
5403 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
5404 * @p symbol is NULL.
5406 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_get_symbol(
5407 hsa_code_object_t code_object
,
5408 const char *symbol_name
,
5409 hsa_code_symbol_t
*symbol
);
5414 * @brief Get the symbol handle within a code object for a given a symbol name.
5416 * @param[in] code_object Code object.
5418 * @param[in] module_name Module name. Must be NULL if the symbol has
5421 * @param[in] symbol_name Symbol name.
5423 * @param[out] symbol Memory location where the HSA runtime stores the symbol
5426 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5428 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5431 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5433 * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
5434 * that matches @p symbol_name.
5436 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
5437 * @p symbol is NULL.
5439 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_get_symbol_from_name(
5440 hsa_code_object_t code_object
,
5441 const char *module_name
,
5442 const char *symbol_name
,
5443 hsa_code_symbol_t
*symbol
);
5448 * @brief Code object symbol attributes.
5452 * The type of the symbol. The type of this attribute is ::hsa_symbol_kind_t.
5454 HSA_CODE_SYMBOL_INFO_TYPE
= 0,
5456 * The length of the symbol name in bytes, not including the NUL terminator.
5457 * The type of this attribute is uint32_t.
5459 HSA_CODE_SYMBOL_INFO_NAME_LENGTH
= 1,
5461 * The name of the symbol. The type of this attribute is character array with
5462 * the length equal to the value of ::HSA_CODE_SYMBOL_INFO_NAME_LENGTH
5465 HSA_CODE_SYMBOL_INFO_NAME
= 2,
5467 * The length of the module name in bytes (not including the NUL terminator)
5468 * to which this symbol belongs if this symbol has module linkage, otherwise 0
5469 * is returned. The type of this attribute is uint32_t.
5471 HSA_CODE_SYMBOL_INFO_MODULE_NAME_LENGTH
= 3,
5473 * The module name to which this symbol belongs if this symbol has module
5474 * linkage, otherwise an empty string is returned. The type of this attribute
5475 * is character array with the length equal to the value of
5476 * ::HSA_CODE_SYMBOL_INFO_MODULE_NAME_LENGTH attribute.
5478 HSA_CODE_SYMBOL_INFO_MODULE_NAME
= 4,
5480 * The linkage kind of the symbol. The type of this attribute is
5481 * ::hsa_symbol_linkage_t.
5483 HSA_CODE_SYMBOL_INFO_LINKAGE
= 5,
5485 * Indicates whether the symbol corresponds to a definition. The type of this
5486 * attribute is bool.
5488 HSA_CODE_SYMBOL_INFO_IS_DEFINITION
= 17,
5490 * The allocation kind of the variable. The value of this attribute is
5491 * undefined if the symbol is not a variable. The type of this attribute is
5492 * ::hsa_variable_allocation_t.
5494 HSA_CODE_SYMBOL_INFO_VARIABLE_ALLOCATION
= 6,
5496 * The segment kind of the variable. The value of this attribute is
5497 * undefined if the symbol is not a variable. The type of this attribute is
5498 * ::hsa_variable_segment_t.
5500 HSA_CODE_SYMBOL_INFO_VARIABLE_SEGMENT
= 7,
5502 * Alignment of the symbol in memory. The value of this attribute is undefined
5503 * if the symbol is not a variable. The type of this attribute is uint32_t.
5505 * The current alignment of the variable in memory may be greater than the
5506 * value specified in the source program variable declaration.
5508 HSA_CODE_SYMBOL_INFO_VARIABLE_ALIGNMENT
= 8,
5510 * Size of the variable. The value of this attribute is undefined if the
5511 * symbol is not a variable. The type of this attribute is uint32_t.
5513 * A size of 0 is returned if the variable is an external variable and has an
5514 * unknown dimension.
5516 HSA_CODE_SYMBOL_INFO_VARIABLE_SIZE
= 9,
5518 * Indicates whether the variable is constant. The value of this attribute is
5519 * undefined if the symbol is not a variable. The type of this attribute is
5522 HSA_CODE_SYMBOL_INFO_VARIABLE_IS_CONST
= 10,
5524 * Size of kernarg segment memory that is required to hold the values of the
5525 * kernel arguments, in bytes. Must be a multiple of 16. The value of this
5526 * attribute is undefined if the symbol is not a kernel. The type of this
5527 * attribute is uint32_t.
5529 HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE
= 11,
5531 * Alignment (in bytes) of the buffer used to pass arguments to the kernel,
5532 * which is the maximum of 16 and the maximum alignment of any of the kernel
5533 * arguments. The value of this attribute is undefined if the symbol is not a
5534 * kernel. The type of this attribute is uint32_t.
5536 HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT
= 12,
5538 * Size of static group segment memory required by the kernel (per
5539 * work-group), in bytes. The value of this attribute is undefined
5540 * if the symbol is not a kernel. The type of this attribute is uint32_t.
5542 * The reported amount does not include any dynamically allocated group
5543 * segment memory that may be requested by the application when a kernel is
5546 HSA_CODE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE
= 13,
5548 * Size of static private, spill, and arg segment memory required by
5549 * this kernel (per work-item), in bytes. The value of this attribute is
5550 * undefined if the symbol is not a kernel. The type of this attribute is
5553 * If the value of ::HSA_CODE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK is true,
5554 * the kernel may use more private memory than the reported value, and the
5555 * application must add the dynamic call stack usage to @a
5556 * private_segment_size when populating a kernel dispatch packet.
5558 HSA_CODE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE
= 14,
5560 * Dynamic callstack flag. The value of this attribute is undefined if the
5561 * symbol is not a kernel. The type of this attribute is bool.
5563 * If this flag is set (the value is true), the kernel uses a dynamically
5564 * sized call stack. This can happen if recursive calls, calls to indirect
5565 * functions, or the HSAIL alloca instruction are present in the kernel.
5567 HSA_CODE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK
= 15,
5569 * Call convention of the kernel. The value of this attribute is undefined if
5570 * the symbol is not a kernel. The type of this attribute is uint32_t.
5572 HSA_CODE_SYMBOL_INFO_KERNEL_CALL_CONVENTION
= 18,
5574 * Call convention of the indirect function. The value of this attribute is
5575 * undefined if the symbol is not an indirect function. The type of this
5576 * attribute is uint32_t.
5578 HSA_CODE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION
= 16
5579 } hsa_code_symbol_info_t
;
5584 * @brief Get the current value of an attribute for a given code symbol.
5586 * @param[in] code_symbol Code symbol.
5588 * @param[in] attribute Attribute to query.
5590 * @param[out] value Pointer to an application-allocated buffer where to store
5591 * the value of the attribute. If the buffer passed by the application is not
5592 * large enough to hold the value of @p attribute, the behavior is undefined.
5594 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5596 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5599 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_SYMBOL The code symbol is invalid.
5601 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
5602 * code symbol attribute, or @p value is NULL.
5604 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_symbol_get_info(
5605 hsa_code_symbol_t code_symbol
,
5606 hsa_code_symbol_info_t attribute
,
5612 * @brief Iterate over the symbols in a code object, and invoke an
5613 * application-defined callback on every iteration.
5615 * @param[in] code_object Code object.
5617 * @param[in] callback Callback to be invoked once per code object symbol. The
5618 * HSA runtime passes three arguments to the callback: the code object, a
5619 * symbol, and the application data. If @p callback returns a status other than
5620 * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
5621 * ::hsa_code_object_iterate_symbols returns that status value.
5623 * @param[in] data Application data that is passed to @p callback on every
5624 * iteration. May be NULL.
5626 * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
5628 * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
5631 * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
5633 * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
5635 hsa_status_t HSA_API HSA_DEPRECATED
hsa_code_object_iterate_symbols(
5636 hsa_code_object_t code_object
,
5637 hsa_status_t (*callback
)(hsa_code_object_t code_object
,
5638 hsa_code_symbol_t symbol
,
5645 } // end extern "C" block
5648 #endif // header guard