-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathhsa.h
5647 lines (5322 loc) · 183 KB
/
hsa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
////////////////////////////////////////////////////////////////////////////////
//
// The University of Illinois/NCSA
// Open Source License (NCSA)
//
// Copyright (c) 2014-2015, Advanced Micro Devices, Inc. All rights reserved.
//
// Developed by:
//
// AMD Research and AMD HSA Software Development
//
// Advanced Micro Devices, Inc.
//
// www.amd.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal with the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimers.
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimers in
// the documentation and/or other materials provided with the distribution.
// - Neither the names of Advanced Micro Devices, Inc,
// nor the names of its contributors may be used to endorse or promote
// products derived from this Software without specific prior written
// permission.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS WITH THE SOFTWARE.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef HSA_RUNTIME_INC_HSA_H_
#define HSA_RUNTIME_INC_HSA_H_
#include <stddef.h> /* size_t */
#include <stdint.h> /* uintXX_t */
#ifndef __cplusplus
#include <stdbool.h> /* bool */
#endif /* __cplusplus */
// Placeholder for calling convention and import/export macros
#ifndef HSA_CALL
#define HSA_CALL
#endif
#ifndef HSA_EXPORT_DECORATOR
#ifdef __GNUC__
#define HSA_EXPORT_DECORATOR __attribute__ ((visibility ("default")))
#else
#define HSA_EXPORT_DECORATOR
#endif
#endif
#define HSA_API_EXPORT HSA_EXPORT_DECORATOR HSA_CALL
#define HSA_API_IMPORT HSA_CALL
#if !defined(HSA_API) && defined(HSA_EXPORT)
#define HSA_API HSA_API_EXPORT
#else
#define HSA_API HSA_API_IMPORT
#endif
// Detect and set large model builds.
#undef HSA_LARGE_MODEL
#if defined(__LP64__) || defined(_M_X64)
#define HSA_LARGE_MODEL
#endif
// Try to detect CPU endianness
#if !defined(LITTLEENDIAN_CPU) && !defined(BIGENDIAN_CPU)
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \
defined(_M_X64)
#define LITTLEENDIAN_CPU
#endif
#endif
#undef HSA_LITTLE_ENDIAN
#if defined(LITTLEENDIAN_CPU)
#define HSA_LITTLE_ENDIAN
#elif defined(BIGENDIAN_CPU)
#else
#error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
#endif
#ifndef HSA_DEPRECATED
#define HSA_DEPRECATED
//#ifdef __GNUC__
//#define HSA_DEPRECATED __attribute__((deprecated))
//#else
//#define HSA_DEPRECATED __declspec(deprecated)
//#endif
#endif
#define HSA_VERSION_1_0 1
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** \defgroup status Runtime Notifications
* @{
*/
/**
* @brief Status codes.
*/
typedef enum {
/**
* The function has been executed successfully.
*/
HSA_STATUS_SUCCESS = 0x0,
/**
* A traversal over a list of elements has been interrupted by the
* application before completing.
*/
HSA_STATUS_INFO_BREAK = 0x1,
/**
* A generic error has occurred.
*/
HSA_STATUS_ERROR = 0x1000,
/**
* One of the actual arguments does not meet a precondition stated in the
* documentation of the corresponding formal argument.
*/
HSA_STATUS_ERROR_INVALID_ARGUMENT = 0x1001,
/**
* The requested queue creation is not valid.
*/
HSA_STATUS_ERROR_INVALID_QUEUE_CREATION = 0x1002,
/**
* The requested allocation is not valid.
*/
HSA_STATUS_ERROR_INVALID_ALLOCATION = 0x1003,
/**
* The agent is invalid.
*/
HSA_STATUS_ERROR_INVALID_AGENT = 0x1004,
/**
* The memory region is invalid.
*/
HSA_STATUS_ERROR_INVALID_REGION = 0x1005,
/**
* The signal is invalid.
*/
HSA_STATUS_ERROR_INVALID_SIGNAL = 0x1006,
/**
* The queue is invalid.
*/
HSA_STATUS_ERROR_INVALID_QUEUE = 0x1007,
/**
* The HSA runtime failed to allocate the necessary resources. This error
* may also occur when the HSA runtime needs to spawn threads or create
* internal OS-specific events.
*/
HSA_STATUS_ERROR_OUT_OF_RESOURCES = 0x1008,
/**
* The AQL packet is malformed.
*/
HSA_STATUS_ERROR_INVALID_PACKET_FORMAT = 0x1009,
/**
* An error has been detected while releasing a resource.
*/
HSA_STATUS_ERROR_RESOURCE_FREE = 0x100A,
/**
* An API other than ::hsa_init has been invoked while the reference count
* of the HSA runtime is 0.
*/
HSA_STATUS_ERROR_NOT_INITIALIZED = 0x100B,
/**
* The maximum reference count for the object has been reached.
*/
HSA_STATUS_ERROR_REFCOUNT_OVERFLOW = 0x100C,
/**
* The arguments passed to a functions are not compatible.
*/
HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS = 0x100D,
/**
* The index is invalid.
*/
HSA_STATUS_ERROR_INVALID_INDEX = 0x100E,
/**
* The instruction set architecture is invalid.
*/
HSA_STATUS_ERROR_INVALID_ISA = 0x100F,
/**
* The instruction set architecture name is invalid.
*/
HSA_STATUS_ERROR_INVALID_ISA_NAME = 0x1017,
/**
* The code object is invalid.
*/
HSA_STATUS_ERROR_INVALID_CODE_OBJECT = 0x1010,
/**
* The executable is invalid.
*/
HSA_STATUS_ERROR_INVALID_EXECUTABLE = 0x1011,
/**
* The executable is frozen.
*/
HSA_STATUS_ERROR_FROZEN_EXECUTABLE = 0x1012,
/**
* There is no symbol with the given name.
*/
HSA_STATUS_ERROR_INVALID_SYMBOL_NAME = 0x1013,
/**
* The variable is already defined.
*/
HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED = 0x1014,
/**
* The variable is undefined.
*/
HSA_STATUS_ERROR_VARIABLE_UNDEFINED = 0x1015,
/**
* An HSAIL operation resulted in a hardware exception.
*/
HSA_STATUS_ERROR_EXCEPTION = 0x1016,
/**
* The code object symbol is invalid.
*/
HSA_STATUS_ERROR_INVALID_CODE_SYMBOL = 0x1018,
/**
* The executable symbol is invalid.
*/
HSA_STATUS_ERROR_INVALID_EXECUTABLE_SYMBOL = 0x1019,
/**
* The file descriptor is invalid.
*/
HSA_STATUS_ERROR_INVALID_FILE = 0x1020,
/**
* The code object reader is invalid.
*/
HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER = 0x1021,
/**
* The cache is invalid.
*/
HSA_STATUS_ERROR_INVALID_CACHE = 0x1022,
/**
* The wavefront is invalid.
*/
HSA_STATUS_ERROR_INVALID_WAVEFRONT = 0x1023,
/**
* The signal group is invalid.
*/
HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP = 0x1024,
/**
* The HSA runtime is not in the configuration state.
*/
HSA_STATUS_ERROR_INVALID_RUNTIME_STATE = 0x1025,
/**
* The queue received an error that may require process termination.
*/
HSA_STATUS_ERROR_FATAL = 0x1026
} hsa_status_t;
/**
* @brief Query additional information about a status code.
*
* @param[in] status Status code.
*
* @param[out] status_string A NUL-terminated string that describes the error
* status.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p status is an invalid
* status code, or @p status_string is NULL.
*/
hsa_status_t HSA_API hsa_status_string(
hsa_status_t status,
const char ** status_string);
/** @} */
/** \defgroup common Common Definitions
* @{
*/
/**
* @brief Three-dimensional coordinate.
*/
typedef struct hsa_dim3_s {
/**
* X dimension.
*/
uint32_t x;
/**
* Y dimension.
*/
uint32_t y;
/**
* Z dimension.
*/
uint32_t z;
} hsa_dim3_t;
/**
* @brief Access permissions.
*/
typedef enum {
/**
* Read-only access.
*/
HSA_ACCESS_PERMISSION_RO = 1,
/**
* Write-only access.
*/
HSA_ACCESS_PERMISSION_WO = 2,
/**
* Read and write access.
*/
HSA_ACCESS_PERMISSION_RW = 3
} hsa_access_permission_t;
/**
* @brief POSIX file descriptor.
*/
typedef int hsa_file_t;
/** @} **/
/** \defgroup initshutdown Initialization and Shut Down
* @{
*/
/**
* @brief Initialize the HSA runtime.
*
* @details Initializes the HSA runtime if it is not already initialized, and
* increases the reference counter associated with the HSA runtime for the
* current process. Invocation of any HSA function other than ::hsa_init results
* in undefined behavior if the current HSA runtime reference counter is less
* than one.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
* the required resources.
*
* @retval ::HSA_STATUS_ERROR_REFCOUNT_OVERFLOW The HSA runtime reference
* count reaches INT32_MAX.
*/
hsa_status_t HSA_API hsa_init();
/**
* @brief Shut down the HSA runtime.
*
* @details Decreases the reference count of the HSA runtime instance. When the
* reference count reaches 0, the HSA runtime is no longer considered valid
* but the application might call ::hsa_init to initialize the HSA runtime
* again.
*
* Once the reference count of the HSA runtime reaches 0, all the resources
* associated with it (queues, signals, agent information, etc.) are
* considered invalid and any attempt to reference them in subsequent API calls
* results in undefined behavior. When the reference count reaches 0, the HSA
* runtime may release resources associated with it.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
*/
hsa_status_t HSA_API hsa_shut_down();
/** @} **/
/** \defgroup agentinfo System and Agent Information
* @{
*/
/**
* @brief Endianness. A convention used to interpret the bytes making up a data
* word.
*/
typedef enum {
/**
* The least significant byte is stored in the smallest address.
*/
HSA_ENDIANNESS_LITTLE = 0,
/**
* The most significant byte is stored in the smallest address.
*/
HSA_ENDIANNESS_BIG = 1
} hsa_endianness_t;
/**
* @brief Machine model. A machine model determines the size of certain data
* types in HSA runtime and an agent.
*/
typedef enum {
/**
* Small machine model. Addresses use 32 bits.
*/
HSA_MACHINE_MODEL_SMALL = 0,
/**
* Large machine model. Addresses use 64 bits.
*/
HSA_MACHINE_MODEL_LARGE = 1
} hsa_machine_model_t;
/**
* @brief Profile. A profile indicates a particular level of feature
* support. For example, in the base profile the application must use the HSA
* runtime allocator to reserve shared virtual memory, while in the full profile
* any host pointer can be shared across all the agents.
*/
typedef enum {
/**
* Base profile.
*/
HSA_PROFILE_BASE = 0,
/**
* Full profile.
*/
HSA_PROFILE_FULL = 1
} hsa_profile_t;
/**
* @brief System attributes.
*/
typedef enum {
/**
* Major version of the HSA runtime specification supported by the
* implementation. The type of this attribute is uint16_t.
*/
HSA_SYSTEM_INFO_VERSION_MAJOR = 0,
/**
* Minor version of the HSA runtime specification supported by the
* implementation. The type of this attribute is uint16_t.
*/
HSA_SYSTEM_INFO_VERSION_MINOR = 1,
/**
* Current timestamp. The value of this attribute monotonically increases at a
* constant rate. The type of this attribute is uint64_t.
*/
HSA_SYSTEM_INFO_TIMESTAMP = 2,
/**
* Timestamp value increase rate, in Hz. The timestamp (clock) frequency is
* in the range 1-400MHz. The type of this attribute is uint64_t.
*/
HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY = 3,
/**
* Maximum duration of a signal wait operation. Expressed as a count based on
* the timestamp frequency. The type of this attribute is uint64_t.
*/
HSA_SYSTEM_INFO_SIGNAL_MAX_WAIT = 4,
/**
* Endianness of the system. The type of this attribute is ::hsa_endianness_t.
*/
HSA_SYSTEM_INFO_ENDIANNESS = 5,
/**
* Machine model supported by the HSA runtime. The type of this attribute is
* ::hsa_machine_model_t.
*/
HSA_SYSTEM_INFO_MACHINE_MODEL = 6,
/**
* Bit-mask indicating which extensions are supported by the
* implementation. An extension with an ID of @p i is supported if the bit at
* position @p i is set. The type of this attribute is uint8_t[128].
*/
HSA_SYSTEM_INFO_EXTENSIONS = 7,
/**
* String containing the ROCr build identifier.
*/
HSA_AMD_SYSTEM_INFO_BUILD_VERSION = 0x200
} hsa_system_info_t;
/**
* @brief Get the current value of a system attribute.
*
* @param[in] attribute Attribute to query.
*
* @param[out] value Pointer to an application-allocated buffer where to store
* the value of the attribute. If the buffer passed by the application is not
* large enough to hold the value of @p attribute, the behavior is undefined.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
* system attribute, or @p value is NULL.
*/
hsa_status_t HSA_API hsa_system_get_info(
hsa_system_info_t attribute,
void* value);
/**
* @brief HSA extensions.
*/
typedef enum {
/**
* Finalizer extension.
*/
HSA_EXTENSION_FINALIZER = 0,
/**
* Images extension.
*/
HSA_EXTENSION_IMAGES = 1,
/**
* Performance counter extension.
*/
HSA_EXTENSION_PERFORMANCE_COUNTERS = 2,
/**
* Profiling events extension.
*/
HSA_EXTENSION_PROFILING_EVENTS = 3,
/**
* Extension count.
*/
HSA_EXTENSION_STD_LAST = 3,
/**
* First AMD extension number.
*/
HSA_AMD_FIRST_EXTENSION = 0x200,
/**
* Profiler extension.
*/
HSA_EXTENSION_AMD_PROFILER = 0x200,
/**
* Loader extension.
*/
HSA_EXTENSION_AMD_LOADER = 0x201,
/**
* AqlProfile extension.
*/
HSA_EXTENSION_AMD_AQLPROFILE = 0x202,
/**
* Last AMD extension.
*/
HSA_AMD_LAST_EXTENSION = 0x202
} hsa_extension_t;
/**
* @brief Query the name of a given extension.
*
* @param[in] extension Extension identifier. If the extension is not supported
* by the implementation (see ::HSA_SYSTEM_INFO_EXTENSIONS), the behavior
* is undefined.
*
* @param[out] name Pointer to a memory location where the HSA runtime stores
* the extension name. The extension name is a NUL-terminated string.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
* extension, or @p name is NULL.
*/
hsa_status_t HSA_API hsa_extension_get_name(
uint16_t extension,
const char **name);
/**
* @deprecated
*
* @brief Query if a given version of an extension is supported by the HSA
* implementation.
*
* @param[in] extension Extension identifier.
*
* @param[in] version_major Major version number.
*
* @param[in] version_minor Minor version number.
*
* @param[out] result Pointer to a memory location where the HSA runtime stores
* the result of the check. The result is true if the specified version of the
* extension is supported, and false otherwise.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
* extension, or @p result is NULL.
*/
hsa_status_t HSA_API HSA_DEPRECATED hsa_system_extension_supported(
uint16_t extension,
uint16_t version_major,
uint16_t version_minor,
bool* result);
/**
* @brief Query if a given version of an extension is supported by the HSA
* implementation. All minor versions from 0 up to the returned @p version_minor
* must be supported by the implementation.
*
* @param[in] extension Extension identifier.
*
* @param[in] version_major Major version number.
*
* @param[out] version_minor Minor version number.
*
* @param[out] result Pointer to a memory location where the HSA runtime stores
* the result of the check. The result is true if the specified version of the
* extension is supported, and false otherwise.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
* extension, or @p version_minor is NULL, or @p result is NULL.
*/
hsa_status_t HSA_API hsa_system_major_extension_supported(
uint16_t extension,
uint16_t version_major,
uint16_t *version_minor,
bool* result);
/**
* @deprecated
*
* @brief Retrieve the function pointers corresponding to a given version of an
* extension. Portable applications are expected to invoke the extension API
* using the returned function pointers
*
* @details The application is responsible for verifying that the given version
* of the extension is supported by the HSA implementation (see
* ::hsa_system_extension_supported). If the given combination of extension,
* major version, and minor version is not supported by the implementation, the
* behavior is undefined.
*
* @param[in] extension Extension identifier.
*
* @param[in] version_major Major version number for which to retrieve the
* function pointer table.
*
* @param[in] version_minor Minor version number for which to retrieve the
* function pointer table.
*
* @param[out] table Pointer to an application-allocated function pointer table
* that is populated by the HSA runtime. Must not be NULL. The memory associated
* with table can be reused or freed after the function returns.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
* extension, or @p table is NULL.
*/
hsa_status_t HSA_API HSA_DEPRECATED hsa_system_get_extension_table(
uint16_t extension,
uint16_t version_major,
uint16_t version_minor,
void *table);
/**
* @brief Retrieve the function pointers corresponding to a given major version
* of an extension. Portable applications are expected to invoke the extension
* API using the returned function pointers.
*
* @details The application is responsible for verifying that the given major
* version of the extension is supported by the HSA implementation (see
* ::hsa_system_major_extension_supported). If the given combination of extension
* and major version is not supported by the implementation, the behavior is
* undefined. Additionally if the length doesn't allow space for a full minor
* version, it is implementation defined if only some of the function pointers for
* that minor version get written.
*
* @param[in] extension Extension identifier.
*
* @param[in] version_major Major version number for which to retrieve the
* function pointer table.
*
* @param[in] table_length Size in bytes of the function pointer table to be
* populated. The implementation will not write more than this many bytes to the
* table.
*
* @param[out] table Pointer to an application-allocated function pointer table
* that is populated by the HSA runtime. Must not be NULL. The memory associated
* with table can be reused or freed after the function returns.
*
* @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
*
* @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
* initialized.
*
* @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
* extension, or @p table is NULL.
*/
hsa_status_t HSA_API hsa_system_get_major_extension_table(
uint16_t extension,
uint16_t version_major,
size_t table_length,
void *table);
/**
* @brief Struct containing an opaque handle to an agent, a device that participates in
* the HSA memory model. An agent can submit AQL packets for execution, and
* may also accept AQL packets for execution (agent dispatch packets or kernel
* dispatch packets launching HSAIL-derived binaries).
*/
typedef struct hsa_agent_s {
/**
* Opaque handle. Two handles reference the same object of the enclosing type
* if and only if they are equal.
*/
uint64_t handle;
} hsa_agent_t;
/**
* @brief Agent features.
*/
typedef enum {
/**
* The agent supports AQL packets of kernel dispatch type. If this
* feature is enabled, the agent is also a kernel agent.
*/
HSA_AGENT_FEATURE_KERNEL_DISPATCH = 1,
/**
* The agent supports AQL packets of agent dispatch type.
*/
HSA_AGENT_FEATURE_AGENT_DISPATCH = 2
} hsa_agent_feature_t;
/**
* @brief Hardware device type.
*/
typedef enum {
/**
* CPU device.
*/
HSA_DEVICE_TYPE_CPU = 0,
/**
* GPU device.
*/
HSA_DEVICE_TYPE_GPU = 1,
/**
* DSP device.
*/
HSA_DEVICE_TYPE_DSP = 2
} hsa_device_type_t;
/**
* @brief Default floating-point rounding mode.
*/
typedef enum {
/**
* Use a default floating-point rounding mode specified elsewhere.
*/
HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT = 0,
/**
* Operations that specify the default floating-point mode are rounded to zero
* by default.
*/
HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO = 1,
/**
* Operations that specify the default floating-point mode are rounded to the
* nearest representable number and that ties should be broken by selecting
* the value with an even least significant bit.
*/
HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR = 2
} hsa_default_float_rounding_mode_t;
/**
* @brief Agent attributes.
*/
typedef enum {
/**
* Agent name. The type of this attribute is a NUL-terminated char[64]. The
* name must be at most 63 characters long (not including the NUL terminator)
* and all array elements not used for the name must be NUL.
*/
HSA_AGENT_INFO_NAME = 0,
/**
* Name of vendor. The type of this attribute is a NUL-terminated char[64].
* The name must be at most 63 characters long (not including the NUL
* terminator) and all array elements not used for the name must be NUL.
*/
HSA_AGENT_INFO_VENDOR_NAME = 1,
/**
* Agent capability. The type of this attribute is ::hsa_agent_feature_t.
*/
HSA_AGENT_INFO_FEATURE = 2,
/**
* @deprecated Query ::HSA_ISA_INFO_MACHINE_MODELS for a given intruction set
* architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Machine model supported by the agent. The type of this attribute is
* ::hsa_machine_model_t.
*/
HSA_AGENT_INFO_MACHINE_MODEL = 3,
/**
* @deprecated Query ::HSA_ISA_INFO_PROFILES for a given intruction set
* architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Profile supported by the agent. The type of this attribute is
* ::hsa_profile_t.
*/
HSA_AGENT_INFO_PROFILE = 4,
/**
* @deprecated Query ::HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES for a given
* intruction set architecture supported by the agent instead. If more than
* one ISA is supported by the agent, the returned value corresponds to the
* first ISA enumerated by ::hsa_agent_iterate_isas.
*
* Default floating-point rounding mode. The type of this attribute is
* ::hsa_default_float_rounding_mode_t, but the value
* ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT is not allowed.
*/
HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 5,
/**
* @deprecated Query ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES
* for a given intruction set architecture supported by the agent instead. If
* more than one ISA is supported by the agent, the returned value corresponds
* to the first ISA enumerated by ::hsa_agent_iterate_isas.
*
* A bit-mask of ::hsa_default_float_rounding_mode_t values, representing the
* default floating-point rounding modes supported by the agent in the Base
* profile. The type of this attribute is uint32_t. The default floating-point
* rounding mode (::HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE) bit must not
* be set.
*/
HSA_AGENT_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES = 23,
/**
* @deprecated Query ::HSA_ISA_INFO_FAST_F16_OPERATION for a given intruction
* set architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Flag indicating that the f16 HSAIL operation is at least as fast as the
* f32 operation in the current agent. The value of this attribute is
* undefined if the agent is not a kernel agent. The type of this
* attribute is bool.
*/
HSA_AGENT_INFO_FAST_F16_OPERATION = 24,
/**
* @deprecated Query ::HSA_WAVEFRONT_INFO_SIZE for a given wavefront and
* intruction set architecture supported by the agent instead. If more than
* one ISA is supported by the agent, the returned value corresponds to the
* first ISA enumerated by ::hsa_agent_iterate_isas and the first wavefront
* enumerated by ::hsa_isa_iterate_wavefronts for that ISA.
*
* Number of work-items in a wavefront. Must be a power of 2 in the range
* [1,256]. The value of this attribute is undefined if the agent is not
* a kernel agent. The type of this attribute is uint32_t.
*/
HSA_AGENT_INFO_WAVEFRONT_SIZE = 6,
/**
* @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_DIM for a given intruction
* set architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Maximum number of work-items of each dimension of a work-group. Each
* maximum must be greater than 0. No maximum can exceed the value of
* ::HSA_AGENT_INFO_WORKGROUP_MAX_SIZE. The value of this attribute is
* undefined if the agent is not a kernel agent. The type of this
* attribute is uint16_t[3].
*/
HSA_AGENT_INFO_WORKGROUP_MAX_DIM = 7,
/**
* @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE for a given intruction
* set architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Maximum total number of work-items in a work-group. The value of this
* attribute is undefined if the agent is not a kernel agent. The type
* of this attribute is uint32_t.
*/
HSA_AGENT_INFO_WORKGROUP_MAX_SIZE = 8,
/**
* @deprecated Query ::HSA_ISA_INFO_GRID_MAX_DIM for a given intruction set
* architecture supported by the agent instead.
*
* Maximum number of work-items of each dimension of a grid. Each maximum must
* be greater than 0, and must not be smaller than the corresponding value in
* ::HSA_AGENT_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
* ::HSA_AGENT_INFO_GRID_MAX_SIZE. The value of this attribute is undefined
* if the agent is not a kernel agent. The type of this attribute is
* ::hsa_dim3_t.
*/
HSA_AGENT_INFO_GRID_MAX_DIM = 9,
/**
* @deprecated Query ::HSA_ISA_INFO_GRID_MAX_SIZE for a given intruction set
* architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Maximum total number of work-items in a grid. The value of this attribute
* is undefined if the agent is not a kernel agent. The type of this
* attribute is uint32_t.
*/
HSA_AGENT_INFO_GRID_MAX_SIZE = 10,
/**
* @deprecated Query ::HSA_ISA_INFO_FBARRIER_MAX_SIZE for a given intruction
* set architecture supported by the agent instead. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Maximum number of fbarriers per work-group. Must be at least 32. The value
* of this attribute is undefined if the agent is not a kernel agent. The
* type of this attribute is uint32_t.
*/
HSA_AGENT_INFO_FBARRIER_MAX_SIZE = 11,
/**
* @deprecated The maximum number of queues is not statically determined.
*
* Maximum number of queues that can be active (created but not destroyed) at
* one time in the agent. The type of this attribute is uint32_t.
*/
HSA_AGENT_INFO_QUEUES_MAX = 12,
/**
* Minimum number of packets that a queue created in the agent
* can hold. Must be a power of 2 greater than 0. Must not exceed
* the value of ::HSA_AGENT_INFO_QUEUE_MAX_SIZE. The type of this
* attribute is uint32_t.
*/
HSA_AGENT_INFO_QUEUE_MIN_SIZE = 13,
/**
* Maximum number of packets that a queue created in the agent can
* hold. Must be a power of 2 greater than 0. The type of this attribute
* is uint32_t.
*/
HSA_AGENT_INFO_QUEUE_MAX_SIZE = 14,
/**
* Type of a queue created in the agent. The type of this attribute is
* ::hsa_queue_type32_t.
*/
HSA_AGENT_INFO_QUEUE_TYPE = 15,
/**
* @deprecated NUMA information is not exposed anywhere else in the API.
*
* Identifier of the NUMA node associated with the agent. The type of this
* attribute is uint32_t.
*/
HSA_AGENT_INFO_NODE = 16,
/**
* Type of hardware device associated with the agent. The type of this
* attribute is ::hsa_device_type_t.
*/
HSA_AGENT_INFO_DEVICE = 17,
/**
* @deprecated Query ::hsa_agent_iterate_caches to retrieve information about
* the caches present in a given agent.
*
* Array of data cache sizes (L1..L4). Each size is expressed in bytes. A size
* of 0 for a particular level indicates that there is no cache information
* for that level. The type of this attribute is uint32_t[4].
*/
HSA_AGENT_INFO_CACHE_SIZE = 18,
/**
* @deprecated An agent may support multiple instruction set
* architectures. See ::hsa_agent_iterate_isas. If more than one ISA is
* supported by the agent, the returned value corresponds to the first ISA
* enumerated by ::hsa_agent_iterate_isas.
*
* Instruction set architecture of the agent. The type of this attribute
* is ::hsa_isa_t.
*/
HSA_AGENT_INFO_ISA = 19,
/**
* Bit-mask indicating which extensions are supported by the agent. An
* extension with an ID of @p i is supported if the bit at position @p i is
* set. The type of this attribute is uint8_t[128].
*/
HSA_AGENT_INFO_EXTENSIONS = 20,
/**
* Major version of the HSA runtime specification supported by the
* agent. The type of this attribute is uint16_t.
*/
HSA_AGENT_INFO_VERSION_MAJOR = 21,
/**
* Minor version of the HSA runtime specification supported by the
* agent. The type of this attribute is uint16_t.
*/