This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
nvidia_hip_runtime_api.h
3754 lines (3297 loc) · 170 KB
/
nvidia_hip_runtime_api.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
/*
Copyright (c) 2015 - 2022 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in 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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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
AUTHORS 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 IN
THE SOFTWARE.
*/
#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_API_H
#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_API_H
#include <cuda_runtime_api.h>
#include <cuda.h>
#include <cuda_profiler_api.h>
#include <cuda_fp16.h>
#include <cuda_gl_interop.h>
#include <stdio.h>
#define CUDA_9000 9000
#define CUDA_10010 10010
#define CUDA_10020 10020
#define CUDA_11010 11010
#define CUDA_11020 11020
#define CUDA_11030 11030
#define CUDA_11040 11040
#define CUDA_11060 11060
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
#define __dparm(x) = x
#else
#define __dparm(x)
#endif
// Add Deprecated Support for CUDA Mapped HIP APIs
#if defined(__DOXYGEN_ONLY__) || defined(HIP_ENABLE_DEPRECATED)
#define __HIP_DEPRECATED
#elif defined(_MSC_VER)
#define __HIP_DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
#define __HIP_DEPRECATED __attribute__((deprecated))
#else
#define __HIP_DEPRECATED
#endif
// Add Deprecated Support for CUDA Mapped HIP APIs
#if defined(__DOXYGEN_ONLY__) || defined(HIP_ENABLE_DEPRECATED)
#define __HIP_DEPRECATED_MSG(msg)
#elif defined(_MSC_VER)
#define __HIP_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
#elif defined(__GNUC__)
#define __HIP_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
#else
#define __HIP_DEPRECATED_MSG(msg)
#endif
// TODO -move to include/hip_runtime_api.h as a common implementation.
/**
* Memory copy types
*
*/
typedef enum cudaMemcpyKind hipMemcpyKind;
#define hipMemcpyHostToHost cudaMemcpyHostToHost
#define hipMemcpyHostToDevice cudaMemcpyHostToDevice
#define hipMemcpyDeviceToHost cudaMemcpyDeviceToHost
#define hipMemcpyDeviceToDevice cudaMemcpyDeviceToDevice
#define hipMemcpyDefault cudaMemcpyDefault
typedef enum hipMemoryAdvise {
hipMemAdviseSetReadMostly,
hipMemAdviseUnsetReadMostly,
hipMemAdviseSetPreferredLocation,
hipMemAdviseUnsetPreferredLocation,
hipMemAdviseSetAccessedBy,
hipMemAdviseUnsetAccessedBy
} hipMemoryAdvise;
// hipDataType
#define hipDataType cudaDataType
#define HIP_R_16F CUDA_R_16F
#define HIP_C_16F CUDA_C_16F
#define HIP_R_16BF CUDA_R_16BF
#define HIP_C_16BF CUDA_C_16BF
#define HIP_R_32F CUDA_R_32F
#define HIP_C_32F CUDA_C_32F
#define HIP_R_64F CUDA_R_64F
#define HIP_C_64F CUDA_C_64F
#define HIP_R_4I CUDA_R_4I
#define HIP_C_4I CUDA_C_4I
#define HIP_R_4U CUDA_R_4U
#define HIP_C_4U CUDA_C_4U
#define HIP_R_8I CUDA_R_8I
#define HIP_C_8I CUDA_C_8I
#define HIP_R_8U CUDA_R_8U
#define HIP_C_8U CUDA_C_8U
#define HIP_R_16I CUDA_R_16I
#define HIP_C_16I CUDA_C_16I
#define HIP_R_16U CUDA_R_16U
#define HIP_C_16U CUDA_C_16U
#define HIP_R_32I CUDA_R_32I
#define HIP_C_32I CUDA_C_32I
#define HIP_R_32U CUDA_R_32U
#define HIP_C_32U CUDA_C_32U
#define HIP_R_64I CUDA_R_64I
#define HIP_C_64I CUDA_C_64I
#define HIP_R_64U CUDA_R_64U
#define HIP_C_64U CUDA_C_64U
// hip stream operation masks
#define STREAM_OPS_WAIT_MASK_32 0xFFFFFFFF
#define STREAM_OPS_WAIT_MASK_64 0xFFFFFFFFFFFFFFFF
// stream operation flags
#define hipStreamWaitValueGte CU_STREAM_WAIT_VALUE_GEQ
#define hipStreamWaitValueEq CU_STREAM_WAIT_VALUE_EQ
#define hipStreamWaitValueAnd CU_STREAM_WAIT_VALUE_AND
#define hipStreamWaitValueNor CU_STREAM_WAIT_VALUE_NOR
// hipLibraryPropertyType
#define hipLibraryPropertyType libraryPropertyType
#define HIP_LIBRARY_MAJOR_VERSION MAJOR_VERSION
#define HIP_LIBRARY_MINOR_VERSION MINOR_VERSION
#define HIP_LIBRARY_PATCH_LEVEL PATCH_LEVEL
#define HIP_ARRAY_DESCRIPTOR CUDA_ARRAY_DESCRIPTOR
#define HIP_ARRAY3D_DESCRIPTOR CUDA_ARRAY3D_DESCRIPTOR
//hipArray_Format
#define HIP_AD_FORMAT_UNSIGNED_INT8 CU_AD_FORMAT_UNSIGNED_INT8
#define HIP_AD_FORMAT_UNSIGNED_INT16 CU_AD_FORMAT_UNSIGNED_INT16
#define HIP_AD_FORMAT_UNSIGNED_INT32 CU_AD_FORMAT_UNSIGNED_INT32
#define HIP_AD_FORMAT_SIGNED_INT8 CU_AD_FORMAT_SIGNED_INT8
#define HIP_AD_FORMAT_SIGNED_INT16 CU_AD_FORMAT_SIGNED_INT16
#define HIP_AD_FORMAT_SIGNED_INT32 CU_AD_FORMAT_SIGNED_INT32
#define HIP_AD_FORMAT_HALF CU_AD_FORMAT_HALF
#define HIP_AD_FORMAT_FLOAT CU_AD_FORMAT_FLOAT
// hipArray_Format
#define hipArray_Format CUarray_format
inline static CUarray_format hipArray_FormatToCUarray_format(
hipArray_Format format) {
switch (format) {
case HIP_AD_FORMAT_UNSIGNED_INT8:
return CU_AD_FORMAT_UNSIGNED_INT8;
case HIP_AD_FORMAT_UNSIGNED_INT16:
return CU_AD_FORMAT_UNSIGNED_INT16;
case HIP_AD_FORMAT_UNSIGNED_INT32:
return CU_AD_FORMAT_UNSIGNED_INT32;
case HIP_AD_FORMAT_SIGNED_INT8:
return CU_AD_FORMAT_SIGNED_INT8;
case HIP_AD_FORMAT_SIGNED_INT16:
return CU_AD_FORMAT_SIGNED_INT16;
case HIP_AD_FORMAT_SIGNED_INT32:
return CU_AD_FORMAT_SIGNED_INT32;
case HIP_AD_FORMAT_HALF:
return CU_AD_FORMAT_HALF;
case HIP_AD_FORMAT_FLOAT:
return CU_AD_FORMAT_FLOAT;
default:
return CU_AD_FORMAT_UNSIGNED_INT8;
}
}
#define HIP_TR_ADDRESS_MODE_WRAP CU_TR_ADDRESS_MODE_WRAP
#define HIP_TR_ADDRESS_MODE_CLAMP CU_TR_ADDRESS_MODE_CLAMP
#define HIP_TR_ADDRESS_MODE_MIRROR CU_TR_ADDRESS_MODE_MIRROR
#define HIP_TR_ADDRESS_MODE_BORDER CU_TR_ADDRESS_MODE_BORDER
// hipAddress_mode
#define hipAddress_mode CUaddress_mode
inline static CUaddress_mode hipAddress_modeToCUaddress_mode(
hipAddress_mode mode) {
switch (mode) {
case HIP_TR_ADDRESS_MODE_WRAP:
return CU_TR_ADDRESS_MODE_WRAP;
case HIP_TR_ADDRESS_MODE_CLAMP:
return CU_TR_ADDRESS_MODE_CLAMP;
case HIP_TR_ADDRESS_MODE_MIRROR:
return CU_TR_ADDRESS_MODE_MIRROR;
case HIP_TR_ADDRESS_MODE_BORDER:
return CU_TR_ADDRESS_MODE_BORDER;
default:
return CU_TR_ADDRESS_MODE_WRAP;
}
}
#define HIP_TR_FILTER_MODE_POINT CU_TR_FILTER_MODE_POINT
#define HIP_TR_FILTER_MODE_LINEAR CU_TR_FILTER_MODE_LINEAR
// hipFilter_mode
#define hipFilter_mode CUfilter_mode
inline static CUfilter_mode hipFilter_mode_enumToCUfilter_mode(
hipFilter_mode mode) {
switch (mode) {
case HIP_TR_FILTER_MODE_POINT:
return CU_TR_FILTER_MODE_POINT;
case HIP_TR_FILTER_MODE_LINEAR:
return CU_TR_FILTER_MODE_LINEAR;
default:
return CU_TR_FILTER_MODE_POINT;
}
}
//hipResourcetype
#define HIP_RESOURCE_TYPE_ARRAY CU_RESOURCE_TYPE_ARRAY
#define HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY CU_RESOURCE_TYPE_MIPMAPPED_ARRAY
#define HIP_RESOURCE_TYPE_LINEAR CU_RESOURCE_TYPE_LINEAR
#define HIP_RESOURCE_TYPE_PITCH2D CU_RESOURCE_TYPE_PITCH2D
// hipResourcetype
#define hipResourcetype CUresourcetype
inline static CUresourcetype hipResourcetype_enumToCUresourcetype(
hipResourcetype resType) {
switch (resType) {
case HIP_RESOURCE_TYPE_ARRAY:
return CU_RESOURCE_TYPE_ARRAY;
case HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY:
return CU_RESOURCE_TYPE_MIPMAPPED_ARRAY;
case HIP_RESOURCE_TYPE_LINEAR:
return CU_RESOURCE_TYPE_LINEAR;
case HIP_RESOURCE_TYPE_PITCH2D:
return CU_RESOURCE_TYPE_PITCH2D;
default:
return CU_RESOURCE_TYPE_ARRAY;
}
}
// hipStreamPerThread
#define hipStreamPerThread ((cudaStream_t)2)
#define hipTexRef CUtexref
#define hiparray CUarray
typedef CUmipmappedArray hipMipmappedArray_t;
#define HIP_TRSA_OVERRIDE_FORMAT CU_TRSA_OVERRIDE_FORMAT
#define HIP_TRSF_READ_AS_INTEGER CU_TRSF_READ_AS_INTEGER
#define HIP_TRSF_NORMALIZED_COORDINATES CU_TRSF_NORMALIZED_COORDINATES
#define HIP_TRSF_SRGB CU_TRSF_SRGB
// hipTextureAddressMode
typedef enum cudaTextureAddressMode hipTextureAddressMode;
#define hipAddressModeWrap cudaAddressModeWrap
#define hipAddressModeClamp cudaAddressModeClamp
#define hipAddressModeMirror cudaAddressModeMirror
#define hipAddressModeBorder cudaAddressModeBorder
// hipTextureFilterMode
typedef enum cudaTextureFilterMode hipTextureFilterMode;
#define hipFilterModePoint cudaFilterModePoint
#define hipFilterModeLinear cudaFilterModeLinear
// hipTextureReadMode
typedef enum cudaTextureReadMode hipTextureReadMode;
#define hipReadModeElementType cudaReadModeElementType
#define hipReadModeNormalizedFloat cudaReadModeNormalizedFloat
// hipChannelFormatKind
typedef enum cudaChannelFormatKind hipChannelFormatKind;
#define hipChannelFormatKindSigned cudaChannelFormatKindSigned
#define hipChannelFormatKindUnsigned cudaChannelFormatKindUnsigned
#define hipChannelFormatKindFloat cudaChannelFormatKindFloat
#define hipChannelFormatKindNone cudaChannelFormatKindNone
// hipMemRangeAttribute
typedef enum cudaMemRangeAttribute hipMemRangeAttribute;
#define hipMemRangeAttributeReadMostly cudaMemRangeAttributeReadMostly
#define hipMemRangeAttributePreferredLocation cudaMemRangeAttributePreferredLocation
#define hipMemRangeAttributeAccessedBy cudaMemRangeAttributeAccessedBy
#define hipMemRangeAttributeLastPrefetchLocation cudaMemRangeAttributeLastPrefetchLocation
#define hipSurfaceBoundaryMode cudaSurfaceBoundaryMode
#define hipBoundaryModeZero cudaBoundaryModeZero
#define hipBoundaryModeTrap cudaBoundaryModeTrap
#define hipBoundaryModeClamp cudaBoundaryModeClamp
// hipFuncCache
#define hipFuncCachePreferNone cudaFuncCachePreferNone
#define hipFuncCachePreferShared cudaFuncCachePreferShared
#define hipFuncCachePreferL1 cudaFuncCachePreferL1
#define hipFuncCachePreferEqual cudaFuncCachePreferEqual
// hipResourceType
#define hipResourceType cudaResourceType
#define hipResourceTypeArray cudaResourceTypeArray
#define hipResourceTypeMipmappedArray cudaResourceTypeMipmappedArray
#define hipResourceTypeLinear cudaResourceTypeLinear
#define hipResourceTypePitch2D cudaResourceTypePitch2D
//
// hipErrorNoDevice.
// hipResourceViewFormat
typedef enum cudaResourceViewFormat hipResourceViewFormat;
#define hipResViewFormatNone cudaResViewFormatNone
#define hipResViewFormatUnsignedChar1 cudaResViewFormatUnsignedChar1
#define hipResViewFormatUnsignedChar2 cudaResViewFormatUnsignedChar2
#define hipResViewFormatUnsignedChar4 cudaResViewFormatUnsignedChar4
#define hipResViewFormatSignedChar1 cudaResViewFormatSignedChar1
#define hipResViewFormatSignedChar2 cudaResViewFormatSignedChar2
#define hipResViewFormatSignedChar4 cudaResViewFormatSignedChar4
#define hipResViewFormatUnsignedShort1 cudaResViewFormatUnsignedShort1
#define hipResViewFormatUnsignedShort2 cudaResViewFormatUnsignedShort2
#define hipResViewFormatUnsignedShort4 cudaResViewFormatUnsignedShort4
#define hipResViewFormatSignedShort1 cudaResViewFormatSignedShort1
#define hipResViewFormatSignedShort2 cudaResViewFormatSignedShort2
#define hipResViewFormatSignedShort4 cudaResViewFormatSignedShort4
#define hipResViewFormatUnsignedInt1 cudaResViewFormatUnsignedInt1
#define hipResViewFormatUnsignedInt2 cudaResViewFormatUnsignedInt2
#define hipResViewFormatUnsignedInt4 cudaResViewFormatUnsignedInt4
#define hipResViewFormatSignedInt1 cudaResViewFormatSignedInt1
#define hipResViewFormatSignedInt2 cudaResViewFormatSignedInt2
#define hipResViewFormatSignedInt4 cudaResViewFormatSignedInt4
#define hipResViewFormatHalf1 cudaResViewFormatHalf1
#define hipResViewFormatHalf2 cudaResViewFormatHalf2
#define hipResViewFormatHalf4 cudaResViewFormatHalf4
#define hipResViewFormatFloat1 cudaResViewFormatFloat1
#define hipResViewFormatFloat2 cudaResViewFormatFloat2
#define hipResViewFormatFloat4 cudaResViewFormatFloat4
#define hipResViewFormatUnsignedBlockCompressed1 cudaResViewFormatUnsignedBlockCompressed1
#define hipResViewFormatUnsignedBlockCompressed2 cudaResViewFormatUnsignedBlockCompressed2
#define hipResViewFormatUnsignedBlockCompressed3 cudaResViewFormatUnsignedBlockCompressed3
#define hipResViewFormatUnsignedBlockCompressed4 cudaResViewFormatUnsignedBlockCompressed4
#define hipResViewFormatSignedBlockCompressed4 cudaResViewFormatSignedBlockCompressed4
#define hipResViewFormatUnsignedBlockCompressed5 cudaResViewFormatUnsignedBlockCompressed5
#define hipResViewFormatSignedBlockCompressed5 cudaResViewFormatSignedBlockCompressed5
#define hipResViewFormatUnsignedBlockCompressed6H cudaResViewFormatUnsignedBlockCompressed6H
#define hipResViewFormatSignedBlockCompressed6H cudaResViewFormatSignedBlockCompressed6H
#define hipResViewFormatUnsignedBlockCompressed7 cudaResViewFormatUnsignedBlockCompressed7
//! Flags that can be used with hipEventCreateWithFlags:
#define hipEventDefault cudaEventDefault
#define hipEventBlockingSync cudaEventBlockingSync
#define hipEventDisableTiming cudaEventDisableTiming
#define hipEventInterprocess cudaEventInterprocess
#define hipEventReleaseToDevice 0 /* no-op on CUDA platform */
#define hipEventReleaseToSystem 0 /* no-op on CUDA platform */
#define hipHostMallocDefault cudaHostAllocDefault
#define hipHostMallocPortable cudaHostAllocPortable
#define hipHostMallocMapped cudaHostAllocMapped
#define hipHostMallocWriteCombined cudaHostAllocWriteCombined
#define hipHostMallocCoherent 0x0
#define hipHostMallocNonCoherent 0x0
#define hipMemAttachGlobal cudaMemAttachGlobal
#define hipMemAttachHost cudaMemAttachHost
#define hipMemAttachSingle cudaMemAttachSingle
#define hipHostRegisterDefault cudaHostRegisterDefault
#define hipHostRegisterPortable cudaHostRegisterPortable
#define hipHostRegisterMapped cudaHostRegisterMapped
#define hipHostRegisterIoMemory cudaHostRegisterIoMemory
#define hipHostRegisterReadOnly cudaHostRegisterReadOnly
#define HIP_LAUNCH_PARAM_BUFFER_POINTER CU_LAUNCH_PARAM_BUFFER_POINTER
#define HIP_LAUNCH_PARAM_BUFFER_SIZE CU_LAUNCH_PARAM_BUFFER_SIZE
#define HIP_LAUNCH_PARAM_END CU_LAUNCH_PARAM_END
#define hipLimitPrintfFifoSize cudaLimitPrintfFifoSize
#define hipLimitMallocHeapSize cudaLimitMallocHeapSize
#define hipLimitStackSize cudaLimitStackSize
#define hipIpcMemLazyEnablePeerAccess cudaIpcMemLazyEnablePeerAccess
#define hipOccupancyDefault cudaOccupancyDefault
#define hipOccupancyDisableCachingOverride cudaOccupancyDisableCachingOverride
#define hipCooperativeLaunchMultiDeviceNoPreSync \
cudaCooperativeLaunchMultiDeviceNoPreSync
#define hipCooperativeLaunchMultiDeviceNoPostSync \
cudaCooperativeLaunchMultiDeviceNoPostSync
// enum CUjit_option redefines
#define HIPRTC_JIT_MAX_REGISTERS CU_JIT_MAX_REGISTERS
#define HIPRTC_JIT_THREADS_PER_BLOCK CU_JIT_THREADS_PER_BLOCK
#define HIPRTC_JIT_WALL_TIME CU_JIT_WALL_TIME
#define HIPRTC_JIT_INFO_LOG_BUFFER CU_JIT_INFO_LOG_BUFFER
#define HIPRTC_JIT_INFO_LOG_BUFFER_SIZE_BYTES CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES
#define HIPRTC_JIT_ERROR_LOG_BUFFER CU_JIT_ERROR_LOG_BUFFER
#define HIPRTC_JIT_ERROR_LOG_BUFFER_SIZE_BYTES CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES
#define HIPRTC_JIT_OPTIMIZATION_LEVEL CU_JIT_OPTIMIZATION_LEVEL
#define HIPRTC_JIT_TARGET_FROM_HIPCONTEXT CU_JIT_TARGET_FROM_CUCONTEXT
#define HIPRTC_JIT_TARGET CU_JIT_TARGET
#define HIPRTC_JIT_FALLBACK_STRATEGY CU_JIT_FALLBACK_STRATEGY
#define HIPRTC_JIT_GENERATE_DEBUG_INFO CU_JIT_GENERATE_DEBUG_INFO
#define HIPRTC_JIT_LOG_VERBOSE CU_JIT_LOG_VERBOSE
#define HIPRTC_JIT_GENERATE_LINE_INFO CU_JIT_GENERATE_LINE_INFO
#define HIPRTC_JIT_CACHE_MODE CU_JIT_CACHE_MODE
#define HIPRTC_JIT_NEW_SM3X_OPT CU_JIT_NEW_SM3X_OPT
#define HIPRTC_JIT_FAST_COMPILE CU_JIT_FAST_COMPILE
#define HIPRTC_JIT_NUM_OPTIONS CU_JIT_NUM_OPTIONS
typedef cudaEvent_t hipEvent_t;
typedef cudaStream_t hipStream_t;
typedef cudaIpcEventHandle_t hipIpcEventHandle_t;
typedef cudaIpcMemHandle_t hipIpcMemHandle_t;
typedef enum cudaLimit hipLimit_t;
typedef enum cudaFuncAttribute hipFuncAttribute;
typedef enum cudaFuncCache hipFuncCache_t;
typedef CUcontext hipCtx_t;
typedef enum cudaSharedMemConfig hipSharedMemConfig;
typedef CUfunc_cache hipFuncCache;
typedef CUjit_option hipJitOption;
typedef CUdevice hipDevice_t;
typedef enum cudaDeviceP2PAttr hipDeviceP2PAttr;
#define hipDevP2PAttrPerformanceRank cudaDevP2PAttrPerformanceRank
#define hipDevP2PAttrAccessSupported cudaDevP2PAttrAccessSupported
#define hipDevP2PAttrNativeAtomicSupported cudaDevP2PAttrNativeAtomicSupported
#define hipDevP2PAttrHipArrayAccessSupported cudaDevP2PAttrCudaArrayAccessSupported
#define hipFuncAttributeMaxDynamicSharedMemorySize cudaFuncAttributeMaxDynamicSharedMemorySize
#define hipFuncAttributePreferredSharedMemoryCarveout cudaFuncAttributePreferredSharedMemoryCarveout
typedef CUmodule hipModule_t;
typedef CUfunction hipFunction_t;
typedef CUdeviceptr hipDeviceptr_t;
typedef struct cudaArray hipArray;
typedef struct cudaArray* hipArray_t;
typedef struct cudaArray* hipArray_const_t;
typedef struct cudaFuncAttributes hipFuncAttributes;
typedef struct cudaLaunchParams hipLaunchParams;
typedef CUDA_LAUNCH_PARAMS hipFunctionLaunchParams;
#define hipFunction_attribute CUfunction_attribute
#define hipPointer_attribute CUpointer_attribute
#define hip_Memcpy2D CUDA_MEMCPY2D
#define HIP_MEMCPY3D CUDA_MEMCPY3D
#define hipMemcpy3DParms cudaMemcpy3DParms
#define hipArrayDefault cudaArrayDefault
#define hipArrayLayered cudaArrayLayered
#define hipArraySurfaceLoadStore cudaArraySurfaceLoadStore
#define hipArrayCubemap cudaArrayCubemap
#define hipArrayTextureGather cudaArrayTextureGather
typedef cudaTextureObject_t hipTextureObject_t;
typedef cudaSurfaceObject_t hipSurfaceObject_t;
#define hipTextureType1D cudaTextureType1D
#define hipTextureType1DLayered cudaTextureType1DLayered
#define hipTextureType2D cudaTextureType2D
#define hipTextureType2DLayered cudaTextureType2DLayered
#define hipTextureType3D cudaTextureType3D
#define hipDeviceScheduleAuto cudaDeviceScheduleAuto
#define hipDeviceScheduleSpin cudaDeviceScheduleSpin
#define hipDeviceScheduleYield cudaDeviceScheduleYield
#define hipDeviceScheduleBlockingSync cudaDeviceScheduleBlockingSync
#define hipDeviceScheduleMask cudaDeviceScheduleMask
#define hipDeviceMapHost cudaDeviceMapHost
#define hipDeviceLmemResizeToMax cudaDeviceLmemResizeToMax
#define hipCpuDeviceId cudaCpuDeviceId
#define hipInvalidDeviceId cudaInvalidDeviceId
typedef struct cudaExtent hipExtent;
typedef struct cudaPitchedPtr hipPitchedPtr;
typedef struct cudaPos hipPos;
#define make_hipExtent make_cudaExtent
#define make_hipPos make_cudaPos
#define make_hipPitchedPtr make_cudaPitchedPtr
// Flags that can be used with hipStreamCreateWithFlags
#define hipStreamDefault cudaStreamDefault
#define hipStreamNonBlocking cudaStreamNonBlocking
typedef cudaMemPool_t hipMemPool_t;
typedef enum cudaMemPoolAttr hipMemPoolAttr;
#define hipMemPoolReuseFollowEventDependencies cudaMemPoolReuseFollowEventDependencies
#define hipMemPoolReuseAllowOpportunistic cudaMemPoolReuseAllowOpportunistic
#define hipMemPoolReuseAllowInternalDependencies cudaMemPoolReuseAllowInternalDependencies
#define hipMemPoolAttrReleaseThreshold cudaMemPoolAttrReleaseThreshold
#define hipMemPoolAttrReservedMemCurrent cudaMemPoolAttrReservedMemCurrent
#define hipMemPoolAttrReservedMemHigh cudaMemPoolAttrReservedMemHigh
#define hipMemPoolAttrUsedMemCurrent cudaMemPoolAttrUsedMemCurrent
#define hipMemPoolAttrUsedMemHigh cudaMemPoolAttrUsedMemHigh
typedef struct cudaMemLocation hipMemLocation;
typedef struct cudaMemPoolProps hipMemPoolProps;
typedef struct cudaMemAccessDesc hipMemAccessDesc;
typedef enum cudaMemAccessFlags hipMemAccessFlags;
#define hipMemAccessFlagsProtNone cudaMemAccessFlagsProtNone
#define hipMemAccessFlagsProtRead cudaMemAccessFlagsProtRead
#define hipMemAccessFlagsProtReadWrite cudaMemAccessFlagsProtReadWrite
typedef enum cudaMemAllocationHandleType hipMemAllocationHandleType;
typedef struct cudaMemPoolPtrExportData hipMemPoolPtrExportData;
typedef struct cudaChannelFormatDesc hipChannelFormatDesc;
typedef struct cudaResourceDesc hipResourceDesc;
typedef struct cudaTextureDesc hipTextureDesc;
typedef struct cudaResourceViewDesc hipResourceViewDesc;
typedef CUDA_RESOURCE_DESC HIP_RESOURCE_DESC;
typedef CUDA_TEXTURE_DESC HIP_TEXTURE_DESC;
typedef CUDA_RESOURCE_VIEW_DESC HIP_RESOURCE_VIEW_DESC;
// adding code for hipmemSharedConfig
#define hipSharedMemBankSizeDefault cudaSharedMemBankSizeDefault
#define hipSharedMemBankSizeFourByte cudaSharedMemBankSizeFourByte
#define hipSharedMemBankSizeEightByte cudaSharedMemBankSizeEightByte
//Function Attributes
#define HIP_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK
#define HIP_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES
#define HIP_FUNC_ATTRIBUTE_CONST_SIZE_BYTES CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES
#define HIP_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES
#define HIP_FUNC_ATTRIBUTE_NUM_REGS CU_FUNC_ATTRIBUTE_NUM_REGS
#define HIP_FUNC_ATTRIBUTE_PTX_VERSION CU_FUNC_ATTRIBUTE_PTX_VERSION
#define HIP_FUNC_ATTRIBUTE_BINARY_VERSION CU_FUNC_ATTRIBUTE_BINARY_VERSION
#define HIP_FUNC_ATTRIBUTE_CACHE_MODE_CA CU_FUNC_ATTRIBUTE_CACHE_MODE_CA
#define HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES
#define HIP_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT
#define HIP_FUNC_ATTRIBUTE_MAX CU_FUNC_ATTRIBUTE_MAX
//Pointer Attributes
#define HIP_POINTER_ATTRIBUTE_CONTEXT CU_POINTER_ATTRIBUTE_CONTEXT
#define HIP_POINTER_ATTRIBUTE_MEMORY_TYPE CU_POINTER_ATTRIBUTE_MEMORY_TYPE
#define HIP_POINTER_ATTRIBUTE_DEVICE_POINTER CU_POINTER_ATTRIBUTE_DEVICE_POINTER
#define HIP_POINTER_ATTRIBUTE_HOST_POINTER CU_POINTER_ATTRIBUTE_HOST_POINTER
#define HIP_POINTER_ATTRIBUTE_P2P_TOKENS CU_POINTER_ATTRIBUTE_P2P_TOKENS
#define HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS CU_POINTER_ATTRIBUTE_SYNC_MEMOPS
#define HIP_POINTER_ATTRIBUTE_BUFFER_ID CU_POINTER_ATTRIBUTE_BUFFER_ID
#define HIP_POINTER_ATTRIBUTE_IS_MANAGED CU_POINTER_ATTRIBUTE_IS_MANAGED
#define HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL
#define HIP_POINTER_ATTRIBUTE_IS_LEGACY_HIP_IPC_CAPABLE CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE
#define HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR CU_POINTER_ATTRIBUTE_RANGE_START_ADDR
#define HIP_POINTER_ATTRIBUTE_RANGE_SIZE CU_POINTER_ATTRIBUTE_RANGE_SIZE
#define HIP_POINTER_ATTRIBUTE_MAPPED CU_POINTER_ATTRIBUTE_MAPPED
#define HIP_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES CU_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES
#define HIP_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE CU_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE
#define HIP_POINTER_ATTRIBUTE_ACCESS_FLAGS CU_POINTER_ATTRIBUTE_ACCESS_FLAGS
#define HIP_POINTER_ATTRIBUTE_MEMPOOL_HANDLE CU_POINTER_ATTRIBUTE_MEMPOOL_HANDLE
typedef enum cudaGraphInstantiateFlags hipGraphInstantiateFlags;
#define hipGraphInstantiateFlagAutoFreeOnLaunch cudaGraphInstantiateFlagAutoFreeOnLaunch
#define hipGraphInstantiateFlagUpload cudaGraphInstantiateFlagUpload
#define hipGraphInstantiateFlagDeviceLaunch cudaGraphInstantiateFlagDeviceLaunch
#define hipGraphInstantiateFlagUseNodePriority cudaGraphInstantiateFlagUseNodePriority
#if CUDA_VERSION >= CUDA_9000
#define __shfl(...) __shfl_sync(0xffffffff, __VA_ARGS__)
#define __shfl_up(...) __shfl_up_sync(0xffffffff, __VA_ARGS__)
#define __shfl_down(...) __shfl_down_sync(0xffffffff, __VA_ARGS__)
#define __shfl_xor(...) __shfl_xor_sync(0xffffffff, __VA_ARGS__)
#endif // CUDA_VERSION >= CUDA_9000
inline static hipError_t hipCUDAErrorTohipError(cudaError_t cuError) {
switch (cuError) {
case cudaSuccess:
return hipSuccess;
case cudaErrorProfilerDisabled:
return hipErrorProfilerDisabled;
case cudaErrorProfilerNotInitialized:
return hipErrorProfilerNotInitialized;
case cudaErrorProfilerAlreadyStarted:
return hipErrorProfilerAlreadyStarted;
case cudaErrorProfilerAlreadyStopped:
return hipErrorProfilerAlreadyStopped;
case cudaErrorInsufficientDriver:
return hipErrorInsufficientDriver;
case cudaErrorUnsupportedLimit:
return hipErrorUnsupportedLimit;
case cudaErrorPeerAccessUnsupported:
return hipErrorPeerAccessUnsupported;
case cudaErrorInvalidGraphicsContext:
return hipErrorInvalidGraphicsContext;
case cudaErrorSharedObjectSymbolNotFound:
return hipErrorSharedObjectSymbolNotFound;
case cudaErrorSharedObjectInitFailed:
return hipErrorSharedObjectInitFailed;
case cudaErrorOperatingSystem:
return hipErrorOperatingSystem;
case cudaErrorIllegalState:
return hipErrorIllegalState;
case cudaErrorSetOnActiveProcess:
return hipErrorSetOnActiveProcess;
case cudaErrorIllegalAddress:
return hipErrorIllegalAddress;
case cudaErrorInvalidSymbol:
return hipErrorInvalidSymbol;
case cudaErrorMissingConfiguration:
return hipErrorMissingConfiguration;
case cudaErrorMemoryAllocation:
return hipErrorOutOfMemory;
case cudaErrorInitializationError:
return hipErrorNotInitialized;
case cudaErrorLaunchFailure:
return hipErrorLaunchFailure;
case cudaErrorCooperativeLaunchTooLarge:
return hipErrorCooperativeLaunchTooLarge;
case cudaErrorPriorLaunchFailure:
return hipErrorPriorLaunchFailure;
case cudaErrorLaunchOutOfResources:
return hipErrorLaunchOutOfResources;
case cudaErrorInvalidDeviceFunction:
return hipErrorInvalidDeviceFunction;
case cudaErrorInvalidConfiguration:
return hipErrorInvalidConfiguration;
case cudaErrorInvalidDevice:
return hipErrorInvalidDevice;
case cudaErrorInvalidValue:
return hipErrorInvalidValue;
case cudaErrorInvalidPitchValue:
return hipErrorInvalidPitchValue;
case cudaErrorInvalidDevicePointer:
return hipErrorInvalidDevicePointer;
case cudaErrorInvalidMemcpyDirection:
return hipErrorInvalidMemcpyDirection;
case cudaErrorInvalidResourceHandle:
return hipErrorInvalidHandle;
case cudaErrorNotReady:
return hipErrorNotReady;
case cudaErrorNoDevice:
return hipErrorNoDevice;
case cudaErrorPeerAccessAlreadyEnabled:
return hipErrorPeerAccessAlreadyEnabled;
case cudaErrorPeerAccessNotEnabled:
return hipErrorPeerAccessNotEnabled;
case cudaErrorContextIsDestroyed:
return hipErrorContextIsDestroyed;
case cudaErrorHostMemoryAlreadyRegistered:
return hipErrorHostMemoryAlreadyRegistered;
case cudaErrorHostMemoryNotRegistered:
return hipErrorHostMemoryNotRegistered;
case cudaErrorMapBufferObjectFailed:
return hipErrorMapFailed;
case cudaErrorAssert:
return hipErrorAssert;
case cudaErrorNotSupported:
return hipErrorNotSupported;
case cudaErrorCudartUnloading:
return hipErrorDeinitialized;
case cudaErrorInvalidKernelImage:
return hipErrorInvalidImage;
case cudaErrorUnmapBufferObjectFailed:
return hipErrorUnmapFailed;
case cudaErrorNoKernelImageForDevice:
return hipErrorNoBinaryForGpu;
case cudaErrorECCUncorrectable:
return hipErrorECCNotCorrectable;
case cudaErrorDeviceAlreadyInUse:
return hipErrorContextAlreadyInUse;
case cudaErrorInvalidPtx:
return hipErrorInvalidKernelFile;
case cudaErrorLaunchTimeout:
return hipErrorLaunchTimeOut;
#if CUDA_VERSION >= CUDA_10010
case cudaErrorInvalidSource:
return hipErrorInvalidSource;
case cudaErrorFileNotFound:
return hipErrorFileNotFound;
case cudaErrorSymbolNotFound:
return hipErrorNotFound;
case cudaErrorArrayIsMapped:
return hipErrorArrayIsMapped;
case cudaErrorNotMappedAsPointer:
return hipErrorNotMappedAsPointer;
case cudaErrorNotMappedAsArray:
return hipErrorNotMappedAsArray;
case cudaErrorNotMapped:
return hipErrorNotMapped;
case cudaErrorAlreadyAcquired:
return hipErrorAlreadyAcquired;
case cudaErrorAlreadyMapped:
return hipErrorAlreadyMapped;
#endif
#if CUDA_VERSION >= CUDA_10020
case cudaErrorDeviceUninitialized:
return hipErrorInvalidContext;
#endif
case cudaErrorStreamCaptureUnsupported:
return hipErrorStreamCaptureUnsupported;
case cudaErrorStreamCaptureInvalidated:
return hipErrorStreamCaptureInvalidated;
case cudaErrorStreamCaptureMerge:
return hipErrorStreamCaptureMerge;
case cudaErrorStreamCaptureUnmatched:
return hipErrorStreamCaptureUnmatched;
case cudaErrorStreamCaptureUnjoined:
return hipErrorStreamCaptureUnjoined;
case cudaErrorStreamCaptureIsolation:
return hipErrorStreamCaptureIsolation;
case cudaErrorStreamCaptureImplicit:
return hipErrorStreamCaptureImplicit;
case cudaErrorCapturedEvent:
return hipErrorCapturedEvent;
case cudaErrorStreamCaptureWrongThread:
return hipErrorStreamCaptureWrongThread;
case cudaErrorGraphExecUpdateFailure:
return hipErrorGraphExecUpdateFailure;
case cudaErrorUnknown:
default:
return hipErrorUnknown; // Note - translated error.
}
}
inline static hipError_t hipCUResultTohipError(CUresult cuError) {
switch (cuError) {
case CUDA_SUCCESS:
return hipSuccess;
case CUDA_ERROR_OUT_OF_MEMORY:
return hipErrorOutOfMemory;
case CUDA_ERROR_INVALID_VALUE:
return hipErrorInvalidValue;
case CUDA_ERROR_INVALID_DEVICE:
return hipErrorInvalidDevice;
case CUDA_ERROR_DEINITIALIZED:
return hipErrorDeinitialized;
case CUDA_ERROR_NO_DEVICE:
return hipErrorNoDevice;
case CUDA_ERROR_INVALID_CONTEXT:
return hipErrorInvalidContext;
case CUDA_ERROR_NOT_INITIALIZED:
return hipErrorNotInitialized;
case CUDA_ERROR_INVALID_HANDLE:
return hipErrorInvalidHandle;
case CUDA_ERROR_MAP_FAILED:
return hipErrorMapFailed;
case CUDA_ERROR_PROFILER_DISABLED:
return hipErrorProfilerDisabled;
case CUDA_ERROR_PROFILER_NOT_INITIALIZED:
return hipErrorProfilerNotInitialized;
case CUDA_ERROR_PROFILER_ALREADY_STARTED:
return hipErrorProfilerAlreadyStarted;
case CUDA_ERROR_PROFILER_ALREADY_STOPPED:
return hipErrorProfilerAlreadyStopped;
case CUDA_ERROR_INVALID_IMAGE:
return hipErrorInvalidImage;
case CUDA_ERROR_CONTEXT_ALREADY_CURRENT:
return hipErrorContextAlreadyCurrent;
case CUDA_ERROR_UNMAP_FAILED:
return hipErrorUnmapFailed;
case CUDA_ERROR_ARRAY_IS_MAPPED:
return hipErrorArrayIsMapped;
case CUDA_ERROR_ALREADY_MAPPED:
return hipErrorAlreadyMapped;
case CUDA_ERROR_NO_BINARY_FOR_GPU:
return hipErrorNoBinaryForGpu;
case CUDA_ERROR_ALREADY_ACQUIRED:
return hipErrorAlreadyAcquired;
case CUDA_ERROR_NOT_MAPPED:
return hipErrorNotMapped;
case CUDA_ERROR_NOT_MAPPED_AS_ARRAY:
return hipErrorNotMappedAsArray;
case CUDA_ERROR_NOT_MAPPED_AS_POINTER:
return hipErrorNotMappedAsPointer;
case CUDA_ERROR_ECC_UNCORRECTABLE:
return hipErrorECCNotCorrectable;
case CUDA_ERROR_UNSUPPORTED_LIMIT:
return hipErrorUnsupportedLimit;
case CUDA_ERROR_CONTEXT_ALREADY_IN_USE:
return hipErrorContextAlreadyInUse;
case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED:
return hipErrorPeerAccessUnsupported;
case CUDA_ERROR_INVALID_PTX:
return hipErrorInvalidKernelFile;
case CUDA_ERROR_INVALID_GRAPHICS_CONTEXT:
return hipErrorInvalidGraphicsContext;
case CUDA_ERROR_INVALID_SOURCE:
return hipErrorInvalidSource;
case CUDA_ERROR_FILE_NOT_FOUND:
return hipErrorFileNotFound;
case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND:
return hipErrorSharedObjectSymbolNotFound;
case CUDA_ERROR_SHARED_OBJECT_INIT_FAILED:
return hipErrorSharedObjectInitFailed;
case CUDA_ERROR_OPERATING_SYSTEM:
return hipErrorOperatingSystem;
case CUDA_ERROR_ILLEGAL_STATE:
return hipErrorIllegalState;
case CUDA_ERROR_NOT_FOUND:
return hipErrorNotFound;
case CUDA_ERROR_NOT_READY:
return hipErrorNotReady;
case CUDA_ERROR_ILLEGAL_ADDRESS:
return hipErrorIllegalAddress;
case CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES:
return hipErrorLaunchOutOfResources;
case CUDA_ERROR_LAUNCH_TIMEOUT:
return hipErrorLaunchTimeOut;
case CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED:
return hipErrorPeerAccessAlreadyEnabled;
case CUDA_ERROR_PEER_ACCESS_NOT_ENABLED:
return hipErrorPeerAccessNotEnabled;
case CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE:
return hipErrorSetOnActiveProcess;
case CUDA_ERROR_CONTEXT_IS_DESTROYED:
return hipErrorContextIsDestroyed;
case CUDA_ERROR_ASSERT:
return hipErrorAssert;
case CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED:
return hipErrorHostMemoryAlreadyRegistered;
case CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED:
return hipErrorHostMemoryNotRegistered;
case CUDA_ERROR_LAUNCH_FAILED:
return hipErrorLaunchFailure;
case CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE:
return hipErrorCooperativeLaunchTooLarge;
case CUDA_ERROR_NOT_SUPPORTED:
return hipErrorNotSupported;
case CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED:
return hipErrorStreamCaptureUnsupported;
case CUDA_ERROR_STREAM_CAPTURE_INVALIDATED:
return hipErrorStreamCaptureInvalidated;
case CUDA_ERROR_STREAM_CAPTURE_MERGE:
return hipErrorStreamCaptureMerge;
case CUDA_ERROR_STREAM_CAPTURE_UNMATCHED:
return hipErrorStreamCaptureUnmatched;
case CUDA_ERROR_STREAM_CAPTURE_UNJOINED:
return hipErrorStreamCaptureUnjoined;
case CUDA_ERROR_STREAM_CAPTURE_ISOLATION:
return hipErrorStreamCaptureIsolation;
case CUDA_ERROR_STREAM_CAPTURE_IMPLICIT:
return hipErrorStreamCaptureImplicit;
case CUDA_ERROR_CAPTURED_EVENT:
return hipErrorCapturedEvent;
case CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD:
return hipErrorStreamCaptureWrongThread;
case CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE:
return hipErrorGraphExecUpdateFailure;
case CUDA_ERROR_UNKNOWN:
default:
return hipErrorUnknown; // Note - translated error.
}
}
inline static CUresult hipErrorToCUResult(hipError_t hError) {
switch (hError) {
case hipSuccess:
return CUDA_SUCCESS;
case hipErrorOutOfMemory:
return CUDA_ERROR_OUT_OF_MEMORY;
case hipErrorInvalidValue:
return CUDA_ERROR_INVALID_VALUE;
case hipErrorInvalidDevice:
return CUDA_ERROR_INVALID_DEVICE;
case hipErrorDeinitialized:
return CUDA_ERROR_DEINITIALIZED;
case hipErrorNoDevice:
return CUDA_ERROR_NO_DEVICE;
case hipErrorInvalidContext:
return CUDA_ERROR_INVALID_CONTEXT;
case hipErrorNotInitialized:
return CUDA_ERROR_NOT_INITIALIZED;
case hipErrorInvalidHandle:
return CUDA_ERROR_INVALID_HANDLE;
case hipErrorMapFailed:
return CUDA_ERROR_MAP_FAILED;
case hipErrorProfilerDisabled:
return CUDA_ERROR_PROFILER_DISABLED;
case hipErrorProfilerNotInitialized:
return CUDA_ERROR_PROFILER_NOT_INITIALIZED;
case hipErrorProfilerAlreadyStarted:
return CUDA_ERROR_PROFILER_ALREADY_STARTED;
case hipErrorProfilerAlreadyStopped:
return CUDA_ERROR_PROFILER_ALREADY_STOPPED;
case hipErrorInvalidImage:
return CUDA_ERROR_INVALID_IMAGE;
case hipErrorContextAlreadyCurrent:
return CUDA_ERROR_CONTEXT_ALREADY_CURRENT;
case hipErrorUnmapFailed:
return CUDA_ERROR_UNMAP_FAILED;
case hipErrorArrayIsMapped:
return CUDA_ERROR_ARRAY_IS_MAPPED;
case hipErrorAlreadyMapped:
return CUDA_ERROR_ALREADY_MAPPED;
case hipErrorNoBinaryForGpu:
return CUDA_ERROR_NO_BINARY_FOR_GPU;
case hipErrorAlreadyAcquired:
return CUDA_ERROR_ALREADY_ACQUIRED;
case hipErrorNotMapped:
return CUDA_ERROR_NOT_MAPPED;
case hipErrorNotMappedAsArray:
return CUDA_ERROR_NOT_MAPPED_AS_ARRAY;
case hipErrorNotMappedAsPointer:
return CUDA_ERROR_NOT_MAPPED_AS_POINTER;
case hipErrorECCNotCorrectable:
return CUDA_ERROR_ECC_UNCORRECTABLE;
case hipErrorUnsupportedLimit:
return CUDA_ERROR_UNSUPPORTED_LIMIT;
case hipErrorContextAlreadyInUse:
return CUDA_ERROR_CONTEXT_ALREADY_IN_USE;
case hipErrorPeerAccessUnsupported:
return CUDA_ERROR_PEER_ACCESS_UNSUPPORTED;
case hipErrorInvalidKernelFile:
return CUDA_ERROR_INVALID_PTX;
case hipErrorInvalidGraphicsContext:
return CUDA_ERROR_INVALID_GRAPHICS_CONTEXT;
case hipErrorInvalidSource:
return CUDA_ERROR_INVALID_SOURCE;
case hipErrorFileNotFound:
return CUDA_ERROR_FILE_NOT_FOUND;
case hipErrorSharedObjectSymbolNotFound:
return CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND;
case hipErrorSharedObjectInitFailed:
return CUDA_ERROR_SHARED_OBJECT_INIT_FAILED;
case hipErrorOperatingSystem:
return CUDA_ERROR_OPERATING_SYSTEM;
case hipErrorIllegalState:
return CUDA_ERROR_ILLEGAL_STATE;
case hipErrorNotFound:
return CUDA_ERROR_NOT_FOUND;
case hipErrorNotReady:
return CUDA_ERROR_NOT_READY;
case hipErrorIllegalAddress:
return CUDA_ERROR_ILLEGAL_ADDRESS;
case hipErrorLaunchOutOfResources:
return CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES;
case hipErrorLaunchTimeOut:
return CUDA_ERROR_LAUNCH_TIMEOUT;
case hipErrorPeerAccessAlreadyEnabled:
return CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED;
case hipErrorPeerAccessNotEnabled:
return CUDA_ERROR_PEER_ACCESS_NOT_ENABLED;
case hipErrorSetOnActiveProcess:
return CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE;
case hipErrorContextIsDestroyed:
return CUDA_ERROR_CONTEXT_IS_DESTROYED;
case hipErrorAssert:
return CUDA_ERROR_ASSERT;
case hipErrorHostMemoryAlreadyRegistered:
return CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED;
case hipErrorHostMemoryNotRegistered:
return CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED;
case hipErrorLaunchFailure:
return CUDA_ERROR_LAUNCH_FAILED;
case hipErrorCooperativeLaunchTooLarge:
return CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE;
case hipErrorNotSupported:
return CUDA_ERROR_NOT_SUPPORTED;
case hipErrorStreamCaptureUnsupported:
return CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED;
case hipErrorStreamCaptureInvalidated:
return CUDA_ERROR_STREAM_CAPTURE_INVALIDATED;
case hipErrorStreamCaptureMerge:
return CUDA_ERROR_STREAM_CAPTURE_MERGE;
case hipErrorStreamCaptureUnmatched:
return CUDA_ERROR_STREAM_CAPTURE_UNMATCHED;
case hipErrorStreamCaptureUnjoined:
return CUDA_ERROR_STREAM_CAPTURE_UNJOINED;
case hipErrorStreamCaptureIsolation:
return CUDA_ERROR_STREAM_CAPTURE_ISOLATION;
case hipErrorStreamCaptureImplicit:
return CUDA_ERROR_STREAM_CAPTURE_IMPLICIT;
case hipErrorCapturedEvent:
return CUDA_ERROR_CAPTURED_EVENT;
case hipErrorStreamCaptureWrongThread:
return CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD;
case hipErrorGraphExecUpdateFailure:
return CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE;
case hipErrorUnknown:
default:
return CUDA_ERROR_UNKNOWN; // Note - translated error.
}
}
inline static cudaError_t hipErrorToCudaError(hipError_t hError) {
switch (hError) {
case hipSuccess:
return cudaSuccess;
case hipErrorOutOfMemory:
return cudaErrorMemoryAllocation;
case hipErrorProfilerDisabled:
return cudaErrorProfilerDisabled;
case hipErrorProfilerNotInitialized:
return cudaErrorProfilerNotInitialized;
case hipErrorProfilerAlreadyStarted:
return cudaErrorProfilerAlreadyStarted;
case hipErrorProfilerAlreadyStopped:
return cudaErrorProfilerAlreadyStopped;
case hipErrorInvalidConfiguration:
return cudaErrorInvalidConfiguration;
case hipErrorLaunchOutOfResources:
return cudaErrorLaunchOutOfResources;
case hipErrorInvalidValue:
return cudaErrorInvalidValue;
case hipErrorInvalidPitchValue:
return cudaErrorInvalidPitchValue;
case hipErrorInvalidHandle:
return cudaErrorInvalidResourceHandle;
case hipErrorInvalidDevice:
return cudaErrorInvalidDevice;
case hipErrorInvalidMemcpyDirection:
return cudaErrorInvalidMemcpyDirection;
case hipErrorInvalidDevicePointer:
return cudaErrorInvalidDevicePointer;
case hipErrorNotInitialized: