@@ -69,39 +69,40 @@ def test_launch_invalid_values(init_cuda):
69
69
70
70
# Parametrize: (python_type, cpp_type, init_value)
71
71
PARAMS = (
72
- (bool , ' bool' , True ),
73
- (float , ' double' , 2.718 ),
74
- (np .bool , ' bool' , True ),
75
- (np .int8 , ' signed char' , - 42 ),
76
- (np .int16 , ' signed short' , - 1234 ),
77
- (np .int32 , ' signed int' , - 123456 ),
78
- (np .int64 , ' signed long long' , - 123456789 ),
79
- (np .uint8 , ' unsigned char' , 42 ),
80
- (np .uint16 , ' unsigned short' , 1234 ),
81
- (np .uint32 , ' unsigned int' , 123456 ),
82
- (np .uint64 , ' unsigned long long' , 123456789 ),
83
- (np .float32 , ' float' , 3.14 ),
84
- (np .float64 , ' double' , 2.718 ),
85
- (ctypes .c_bool , ' bool' , True ),
86
- (ctypes .c_int8 , ' signed char' , - 42 ),
87
- (ctypes .c_int16 , ' signed short' , - 1234 ),
88
- (ctypes .c_int32 , ' signed int' , - 123456 ),
89
- (ctypes .c_int64 , ' signed long long' , - 123456789 ),
90
- (ctypes .c_uint8 , ' unsigned char' , 42 ),
91
- (ctypes .c_uint16 , ' unsigned short' , 1234 ),
92
- (ctypes .c_uint32 , ' unsigned int' , 123456 ),
93
- (ctypes .c_uint64 , ' unsigned long long' , 123456789 ),
94
- (ctypes .c_float , ' float' , 3.14 ),
95
- (ctypes .c_double , ' double' , 2.718 ),
72
+ (bool , " bool" , True ),
73
+ (float , " double" , 2.718 ),
74
+ (np .bool , " bool" , True ),
75
+ (np .int8 , " signed char" , - 42 ),
76
+ (np .int16 , " signed short" , - 1234 ),
77
+ (np .int32 , " signed int" , - 123456 ),
78
+ (np .int64 , " signed long long" , - 123456789 ),
79
+ (np .uint8 , " unsigned char" , 42 ),
80
+ (np .uint16 , " unsigned short" , 1234 ),
81
+ (np .uint32 , " unsigned int" , 123456 ),
82
+ (np .uint64 , " unsigned long long" , 123456789 ),
83
+ (np .float32 , " float" , 3.14 ),
84
+ (np .float64 , " double" , 2.718 ),
85
+ (ctypes .c_bool , " bool" , True ),
86
+ (ctypes .c_int8 , " signed char" , - 42 ),
87
+ (ctypes .c_int16 , " signed short" , - 1234 ),
88
+ (ctypes .c_int32 , " signed int" , - 123456 ),
89
+ (ctypes .c_int64 , " signed long long" , - 123456789 ),
90
+ (ctypes .c_uint8 , " unsigned char" , 42 ),
91
+ (ctypes .c_uint16 , " unsigned short" , 1234 ),
92
+ (ctypes .c_uint32 , " unsigned int" , 123456 ),
93
+ (ctypes .c_uint64 , " unsigned long long" , 123456789 ),
94
+ (ctypes .c_float , " float" , 3.14 ),
95
+ (ctypes .c_double , " double" , 2.718 ),
96
96
)
97
97
if os .environ .get ("CUDA_PATH" ):
98
98
PARAMS += (
99
- (np .float16 , ' half' , 0.78 ),
100
- (np .complex64 , ' cuda::std::complex<float>' , 1 + 2j ),
101
- (np .complex128 , ' cuda::std::complex<double>' , - 3 - 4j ),
102
- (complex , ' cuda::std::complex<double>' , 5 - 7j ),
99
+ (np .float16 , " half" , 0.78 ),
100
+ (np .complex64 , " cuda::std::complex<float>" , 1 + 2j ),
101
+ (np .complex128 , " cuda::std::complex<double>" , - 3 - 4j ),
102
+ (complex , " cuda::std::complex<double>" , 5 - 7j ),
103
103
)
104
104
105
+
105
106
@pytest .mark .parametrize ("python_type, cpp_type, init_value" , PARAMS )
106
107
def test_launch_scalar_argument (python_type , cpp_type , init_value ):
107
108
dev = Device ()
@@ -127,13 +128,16 @@ def test_launch_scalar_argument(python_type, cpp_type, init_value):
127
128
# Compile and force instantiation for this type
128
129
arch = "" .join (f"{ i } " for i in dev .compute_capability )
129
130
if os .environ .get ("CUDA_PATH" ):
130
- include_path = str (pathlib .Path (os .environ ["CUDA_PATH" ]) / pathlib .Path ("include" ))
131
- code = r"""
131
+ include_path = str (pathlib .Path (os .environ ["CUDA_PATH" ]) / pathlib .Path ("include" ))
132
+ code = (
133
+ r"""
132
134
#include <cuda_fp16.h>
133
135
#include <cuda/std/complex>
134
- """ + code
136
+ """
137
+ + code
138
+ )
135
139
else :
136
- include_path = None
140
+ include_path = None
137
141
pro_opts = ProgramOptions (std = "c++11" , arch = f"sm_{ arch } " , include_path = include_path )
138
142
prog = Program (code , code_type = "c++" , options = pro_opts )
139
143
ker_name = f"write_scalar<{ cpp_type } >"
0 commit comments