Debian Codegraph @

tests/unit_tests/synthetic/libraries/cudevice2hipdevice_before_11080_after_12011.cu

raw
1 // RUN: %run_test hipify "%s" "%t" %hipify_args 3 --amap --skip-excluded-preprocessor-conditional-blocks --experimental %clang_args -ferror-limit=500
2
3 // CHECK: #include <hip/hip_runtime.h>
4 #include <cuda_runtime.h>
5 #include <stdio.h>
6 // CHECK: #include "hip/hip_fp8.h"
7 #include "cuda_fp8.h"
8 // CHECK-NOT: #include "hip/hip_fp8.h"
9 // CHECK-NOT: #include "cuda_fp8.h"
10
11 int main() {
12 printf("24.before_11080_after_12011, CUDA Device API to HIP Device API synthetic test\n");
13
14 short int shi = 0;
15 unsigned short int ushi = 0;
16
17 #if CUDA_VERSION >= 11000
18 // CHECK: __hip_bfloat16 bf16 = { 0 };
19 __nv_bfloat16 bf16 = { 0 };
20 // CHECK: __hip_bfloat16 _bf16 = { 0.0f };
21 // CHECK-NEXT: __hip_bfloat16 bf16a = { 0.0f };
22 // CHECK-NEXT: __hip_bfloat16 bf16b = { 0.0f };
23 __nv_bfloat16 _bf16 = { 0.0f };
24 __nv_bfloat16 bf16a = { 0.0f };
25 __nv_bfloat16 bf16b = { 0.0f };
26
27 // CHECK: __hip_bfloat162 bf162 = { 0, 0 };
28 // CHECK-NEXT: __hip_bfloat162 bf162a = { 0, 0 };
29 // CHECK-NEXT: __hip_bfloat162 bf162b = { 0, 0 };
30 __nv_bfloat162 bf162 = { 0, 0 };
31 __nv_bfloat162 bf162a = { 0, 0 };
32 __nv_bfloat162 bf162b = { 0, 0 };
33
34 #if CUDA_VERSION < 11080 || CUDA_VERSION >= 12020
35 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __bfloat162bfloat162(const __nv_bfloat16 a);
36 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __bfloat162bfloat162(const __hip_bfloat16 a);
37 // CHECK: bf162 = __bfloat162bfloat162(_bf16);
38 bf162 = __bfloat162bfloat162(_bf16);
39
40 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __lows2bfloat162(const __nv_bfloat162 a, const __nv_bfloat162 b);
41 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __lows2bfloat162(const __hip_bfloat162 a, const __hip_bfloat162 b);
42 // CHECK: bf162 = __lows2bfloat162(bf162a, bf162b);
43 bf162 = __lows2bfloat162(bf162a, bf162b);
44
45 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __highs2bfloat162(const __nv_bfloat162 a, const __nv_bfloat162 b);
46 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __highs2bfloat162(const __hip_bfloat162 a, const __hip_bfloat162 b);
47 // CHECK: bf162 = __highs2bfloat162(bf162a, bf162b);
48 bf162 = __highs2bfloat162(bf162a, bf162b);
49
50 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat16 __high2bfloat16(const __nv_bfloat162 a);
51 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __high2bfloat16(const __hip_bfloat162 a);
52 // CHECK: _bf16 = __high2bfloat16(bf162a);
53 _bf16 = __high2bfloat16(bf162a);
54
55 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __hmax2(const __nv_bfloat162 a, const __nv_bfloat162 b);
56 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hmax2(const __hip_bfloat162 a, const __hip_bfloat162 b);
57 // CHECK: bf162 = __hmax2(bf162a, bf162b);
58 bf162 = __hmax2(bf162a, bf162b);
59
60 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __hmin2(const __nv_bfloat162 a, const __nv_bfloat162 b);
61 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __hmin2(const __hip_bfloat162 a, const __hip_bfloat162 b);
62 // CHECK: bf162 = __hmin2(bf162a, bf162b);
63 bf162 = __hmin2(bf162a, bf162b);
64
65 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat16 __low2bfloat16(const __nv_bfloat162 a);
66 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __low2bfloat16(const __hip_bfloat162 a);
67 // CHECK: _bf16 = __low2bfloat16(bf162a);
68 _bf16 = __low2bfloat16(bf162a);
69
70 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __halves2bfloat162(const __nv_bfloat16 a, const __nv_bfloat16 b);
71 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __halves2bfloat162(const __hip_bfloat16 a, const __hip_bfloat16 b);
72 // CHECK: bf162 = __halves2bfloat162(bf16a, bf16b);
73 bf162 = __halves2bfloat162(bf16a, bf16b);
74
75 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __low2bfloat162(const __nv_bfloat162 a);
76 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __low2bfloat162(const __hip_bfloat162 a);
77 // CHECK: bf162 = __low2bfloat162(bf162a);
78 bf162 = __low2bfloat162(bf162a);
79
80 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat162 __high2bfloat162(const __nv_bfloat162 a);
81 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat162 __high2bfloat162(const __hip_bfloat162 a);
82 // CHECK: bf162 = __high2bfloat162(bf162a);
83 bf162 = __high2bfloat162(bf162a);
84
85 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ short int __bfloat16_as_short(const __nv_bfloat16 h);
86 // HIP: __BF16_HOST_DEVICE_STATIC__ short int __bfloat16_as_short(const __hip_bfloat16 h);
87 // CHECK: shi = __bfloat16_as_short(_bf16);
88 shi = __bfloat16_as_short(_bf16);
89
90 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ unsigned short int __bfloat16_as_ushort(const __nv_bfloat16 h);
91 // HIP: __BF16_HOST_DEVICE_STATIC__ unsigned short int __bfloat16_as_ushort(const __hip_bfloat16 h);
92 // CHECK: ushi = __bfloat16_as_ushort(_bf16);
93 ushi = __bfloat16_as_ushort(_bf16);
94
95 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat16 __short_as_bfloat16(const short int i);
96 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __short_as_bfloat16(const short int a);
97 // CHECK: _bf16 = __short_as_bfloat16(shi);
98 _bf16 = __short_as_bfloat16(shi);
99
100 // CUDA: __CUDA_HOSTDEVICE_BF16_DECL__ __nv_bfloat16 __ushort_as_bfloat16(const unsigned short int i);
101 // HIP: __BF16_HOST_DEVICE_STATIC__ __hip_bfloat16 __ushort_as_bfloat16(const unsigned short int a);
102 // CHECK: _bf16 = __ushort_as_bfloat16(ushi);
103 _bf16 = __ushort_as_bfloat16(ushi);
104 #endif
105
106 #endif
107
108 return 0;
109 }