Debian Codegraph @

tests/unit_tests/synthetic/libraries/cudevice2hipdevice_12080.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 #if CUDA_VERSION >= 12080
12 // CHECK: #include "hip/hip_fp4.h"
13 #include "cuda_fp4.h"
14 // CHECK-NOT: #include "hip/hip_fp4.h"
15 // CHECK-NOT: #include "cuda_fp4.h"
16 #endif
17
18 int main() {
19 printf("24.12080, CUDA Device API to HIP Device API synthetic test\n");
20
21 double dx = 0.0f;
22 float fx = 0.0f;
23 double2 d2 = { 0.0f, 0.0f };
24 float2 f2 = { 0.0f, 0.0f };
25 __half_raw hrx = { 0 };
26 __half2_raw h2rx = { 0, 0 };
27
28 // CHECK: hipRoundMode RoundMode;
29 cudaRoundMode RoundMode;
30
31 #if CUDA_VERSION >= 11000
32 // CHECK: __hip_bfloat16_raw bf16r = { 0 };
33 __nv_bfloat16_raw bf16r = { 0 };
34
35 // CHECK: __hip_bfloat162_raw bf162r = { 0, 0 };
36 __nv_bfloat162_raw bf162r = { 0, 0 };
37 #endif
38
39 #if CUDA_VERSION >= 12080
40 // CHECK: __hip_fp4_storage_t fp4_storage_t;
41 // CHECK-NEXT: __hip_fp4x2_storage_t fp4x2_storage_t;
42 // CHECK-NEXT: __hip_fp4x4_storage_t fp4x4_storage_t;
43 // CHECK-NEXT: __hip_fp4_interpretation_t fp4_interpretation_t;
44 // CHECK-NEXT: __hip_fp4_interpretation_t fp4_interpretation = __HIP_E2M1;
45 // CHECK-NEXT: __hip_fp4_e2m1 fp4_e2m1;
46 // CHECK-NEXT: __hip_fp4x2_e2m1 fp4x2_e2m1;
47 // CHECK-NEXT: __hip_fp4x4_e2m1 fp4x4_e2m1;
48 __nv_fp4_storage_t fp4_storage_t;
49 __nv_fp4x2_storage_t fp4x2_storage_t;
50 __nv_fp4x4_storage_t fp4x4_storage_t;
51 __nv_fp4_interpretation_t fp4_interpretation_t;
52 __nv_fp4_interpretation_t fp4_interpretation = __NV_E2M1;
53 __nv_fp4_e2m1 fp4_e2m1;
54 __nv_fp4x2_e2m1 fp4x2_e2m1;
55 __nv_fp4x4_e2m1 fp4x4_e2m1;
56
57 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t __nv_cvt_double_to_fp4(const double x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
58 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4_storage_t __hip_cvt_double_to_fp4(const double x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
59 // CHECK: fp4_storage_t = __hip_cvt_double_to_fp4(dx, fp4_interpretation_t, RoundMode);
60 fp4_storage_t = __nv_cvt_double_to_fp4(dx, fp4_interpretation_t, RoundMode);
61
62 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t __nv_cvt_double2_to_fp4x2(const double2 x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
63 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4x2_storage_t __hip_cvt_double2_to_fp4x2(const double2 x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
64 // CHECK: fp4x2_storage_t = __hip_cvt_double2_to_fp4x2(d2, fp4_interpretation_t, RoundMode);
65 fp4x2_storage_t = __nv_cvt_double2_to_fp4x2(d2, fp4_interpretation_t, RoundMode);
66
67 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t __nv_cvt_float_to_fp4(const float x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
68 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4_storage_t __hip_cvt_float_to_fp4(const float x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
69 // CHECK: fp4_storage_t = __hip_cvt_float_to_fp4(fx, fp4_interpretation_t, RoundMode);
70 fp4_storage_t = __nv_cvt_float_to_fp4(fx, fp4_interpretation_t, RoundMode);
71
72 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t __nv_cvt_float2_to_fp4x2(const float2 x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
73 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4x2_storage_t __hip_cvt_float2_to_fp4x2(const float2 x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
74 // CHECK: fp4x2_storage_t = __hip_cvt_float2_to_fp4x2(f2, fp4_interpretation_t, RoundMode);
75 fp4x2_storage_t = __nv_cvt_float2_to_fp4x2(f2, fp4_interpretation_t, RoundMode);
76
77 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t __nv_cvt_bfloat16raw_to_fp4(const __nv_bfloat16_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
78 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4_storage_t __hip_cvt_bfloat16raw_to_fp4(const __hip_bfloat16_raw x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
79 // CHECK: fp4_storage_t = __hip_cvt_bfloat16raw_to_fp4(bf16r, fp4_interpretation_t, RoundMode);
80 fp4_storage_t = __nv_cvt_bfloat16raw_to_fp4(bf16r, fp4_interpretation_t, RoundMode);
81
82 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t __nv_cvt_bfloat16raw2_to_fp4x2(const __nv_bfloat162_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
83 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4x2_storage_t __hip_cvt_bfloat16raw2_to_fp4x2(const __hip_bfloat162_raw x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
84 // CHECK: fp4x2_storage_t = __hip_cvt_bfloat16raw2_to_fp4x2(bf162r, fp4_interpretation_t, RoundMode);
85 fp4x2_storage_t = __nv_cvt_bfloat16raw2_to_fp4x2(bf162r, fp4_interpretation_t, RoundMode);
86
87 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4_storage_t __nv_cvt_halfraw_to_fp4(const __half_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
88 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4_storage_t __hip_cvt_halfraw_to_fp4(const __half_raw x, const __hip_fp4_interpretation_t, const enum hipRoundMode );
89 // CHECK: fp4_storage_t = __hip_cvt_halfraw_to_fp4(hrx, fp4_interpretation_t, RoundMode);
90 fp4_storage_t = __nv_cvt_halfraw_to_fp4(hrx, fp4_interpretation_t, RoundMode);
91
92 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __nv_fp4x2_storage_t __nv_cvt_halfraw2_to_fp4x2(const __half2_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding);
93 // HIP: __FP4_HOST_DEVICE_STATIC__ __hip_fp4x2_storage_t __hip_cvt_halfraw2_to_fp4x2(const __half2_raw x, const __hip_fp4_interpretation_t, const enum hipRoundMode);
94 // CHECK: fp4x2_storage_t = __hip_cvt_halfraw2_to_fp4x2(h2rx, fp4_interpretation_t, RoundMode);
95 fp4x2_storage_t = __nv_cvt_halfraw2_to_fp4x2(h2rx, fp4_interpretation_t, RoundMode);
96
97 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __half_raw __nv_cvt_fp4_to_halfraw(const __nv_fp4_storage_t x, const __nv_fp4_interpretation_t fp4_interpretation);
98 // HIP: __FP4_HOST_DEVICE_STATIC__ __half_raw __hip_cvt_fp4_to_halfraw(const __hip_fp4_storage_t x, const __hip_fp4_interpretation_t);
99 // CHECK: hrx = __hip_cvt_fp4_to_halfraw(fp4_storage_t, fp4_interpretation_t);
100 hrx = __nv_cvt_fp4_to_halfraw(fp4_storage_t, fp4_interpretation_t);
101
102 // CUDA: __CUDA_HOSTDEVICE_FP4_DECL__ __half2_raw __nv_cvt_fp4x2_to_halfraw2(const __nv_fp4x2_storage_t x, const __nv_fp4_interpretation_t fp4_interpretation);
103 // HIP: __FP4_HOST_DEVICE_STATIC__ __half2_raw __hip_cvt_fp4x2_to_halfraw2(const __hip_fp4x2_storage_t x, const __hip_fp4_interpretation_t);
104 // CHECK: h2rx = __hip_cvt_fp4x2_to_halfraw2(fp4x2_storage_t, fp4_interpretation_t);
105 h2rx = __nv_cvt_fp4x2_to_halfraw2(fp4x2_storage_t, fp4_interpretation_t);
106 #endif
107
108 return 0;
109 }