@@ -18,6 +18,7 @@ use vortex_array::arrays::PrimitiveArray;
1818use vortex_array:: buffer:: BufferHandle ;
1919use vortex_cub:: filter:: CubFilterable ;
2020use vortex_cub:: filter:: cudaStream_t;
21+ use vortex_cuda_macros:: cuda_tests;
2122use vortex_dtype:: NativePType ;
2223use vortex_dtype:: match_each_native_simd_ptype;
2324use vortex_error:: VortexResult ;
@@ -167,93 +168,96 @@ where
167168 ) ) )
168169}
169170
170- #[ cfg ( test ) ]
171+ #[ cuda_tests ]
171172mod tests {
172-
173- use vortex_cuda_macros:: cuda_tests;
174-
175- #[ cuda_tests]
176- mod cuda {
177- use super :: * ;
178-
179- #[ rstest]
180- #[ case:: i32_sparse(
173+ use rstest:: rstest;
174+ use vortex_array:: IntoArray ;
175+ use vortex_array:: arrays:: FilterArray ;
176+ use vortex_array:: assert_arrays_eq;
177+ use vortex_error:: VortexExpect ;
178+ use vortex_session:: VortexSession ;
179+
180+ use super :: * ;
181+ use crate :: CanonicalCudaExt ;
182+ use crate :: session:: CudaSession ;
183+
184+ #[ rstest]
185+ #[ case:: i32_sparse(
181186 PrimitiveArray :: from_iter( [ 1i32 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) ,
182187 Mask :: from_iter( [ true , false , true , false , true , false , true , false ] )
183188 ) ]
184- #[ case:: i32_dense(
189+ #[ case:: i32_dense(
185190 PrimitiveArray :: from_iter( [ 10i32 , 20 , 30 , 40 , 50 ] ) ,
186191 Mask :: from_iter( [ true , true , true , false , true ] )
187192 ) ]
188- #[ case:: i64_large(
193+ #[ case:: i64_large(
189194 PrimitiveArray :: from_iter( ( 0 ..1000i64 ) . collect:: <Vec <_>>( ) ) ,
190195 Mask :: from_iter( ( 0 ..1000 ) . map( |i| i % 3 == 0 ) )
191196 ) ]
192- #[ case:: f64_values(
197+ #[ case:: f64_values(
193198 PrimitiveArray :: from_iter( [ 1.1f64 , 2.2 , 3.3 , 4.4 , 5.5 ] ) ,
194199 Mask :: from_iter( [ false , true , false , true , false ] )
195200 ) ]
196- #[ case:: u8_all_true(
201+ #[ case:: u8_all_true(
197202 PrimitiveArray :: from_iter( [ 1u8 , 2 , 3 , 4 , 5 ] ) ,
198203 Mask :: from_iter( [ true , true , true , true , true ] )
199204 ) ]
200- #[ case:: u32_all_false(
205+ #[ case:: u32_all_false(
201206 PrimitiveArray :: from_iter( [ 1u32 , 2 , 3 , 4 , 5 ] ) ,
202207 Mask :: from_iter( [ false , false , false , false , false ] )
203208 ) ]
204- #[ tokio:: test]
205- async fn test_gpu_filter (
206- #[ case] input : PrimitiveArray ,
207- #[ case] mask : Mask ,
208- ) -> VortexResult < ( ) > {
209- let mut cuda_ctx = CudaSession :: create_execution_ctx ( & VortexSession :: empty ( ) )
210- . vortex_expect ( "failed to create CUDA execution context" ) ;
209+ #[ tokio:: test]
210+ async fn test_gpu_filter (
211+ #[ case] input : PrimitiveArray ,
212+ #[ case] mask : Mask ,
213+ ) -> VortexResult < ( ) > {
214+ let mut cuda_ctx = CudaSession :: create_execution_ctx ( & VortexSession :: empty ( ) )
215+ . vortex_expect ( "failed to create CUDA execution context" ) ;
211216
212- let filter_array = FilterArray :: try_new ( input. clone ( ) . into_array ( ) , mask. clone ( ) ) ?;
217+ let filter_array = FilterArray :: try_new ( input. clone ( ) . into_array ( ) , mask. clone ( ) ) ?;
213218
214- let cpu_result = filter_array. to_canonical ( ) ?. into_array ( ) ;
219+ let cpu_result = filter_array. to_canonical ( ) ?. into_array ( ) ;
215220
216- let gpu_result = FilterExecutor
217- . execute ( filter_array. into_array ( ) , & mut cuda_ctx)
218- . await
219- . vortex_expect ( "GPU filter failed" )
220- . into_host ( )
221- . await ?
222- . into_array ( ) ;
221+ let gpu_result = FilterExecutor
222+ . execute ( filter_array. into_array ( ) , & mut cuda_ctx)
223+ . await
224+ . vortex_expect ( "GPU filter failed" )
225+ . into_host ( )
226+ . await ?
227+ . into_array ( ) ;
223228
224- assert_arrays_eq ! ( cpu_result, gpu_result) ;
229+ assert_arrays_eq ! ( cpu_result, gpu_result) ;
225230
226- Ok ( ( ) )
227- }
231+ Ok ( ( ) )
232+ }
228233
229- #[ tokio:: test]
230- async fn test_gpu_filter_large_array ( ) -> VortexResult < ( ) > {
231- let mut cuda_ctx = CudaSession :: create_execution_ctx ( & VortexSession :: empty ( ) )
232- . vortex_expect ( "failed to create CUDA execution context" ) ;
234+ #[ tokio:: test]
235+ async fn test_gpu_filter_large_array ( ) -> VortexResult < ( ) > {
236+ let mut cuda_ctx = CudaSession :: create_execution_ctx ( & VortexSession :: empty ( ) )
237+ . vortex_expect ( "failed to create CUDA execution context" ) ;
233238
234- // Create a large array to test multi-block execution
235- let data: Vec < i32 > = ( 0 ..100_000 ) . collect ( ) ;
236- let input = PrimitiveArray :: from_iter ( data) ;
239+ // Create a large array to test multi-block execution
240+ let data: Vec < i32 > = ( 0 ..100_000 ) . collect ( ) ;
241+ let input = PrimitiveArray :: from_iter ( data) ;
237242
238- // Select every 7th element
239- let mask = Mask :: from_iter ( ( 0 ..100_000 ) . map ( |i| i % 7 == 0 ) ) ;
243+ // Select every 7th element
244+ let mask = Mask :: from_iter ( ( 0 ..100_000 ) . map ( |i| i % 7 == 0 ) ) ;
240245
241- let filter_array = FilterArray :: try_new ( input. into_array ( ) , mask) ?;
246+ let filter_array = FilterArray :: try_new ( input. into_array ( ) , mask) ?;
242247
243- let cpu_result = filter_array. to_canonical ( ) ?. into_array ( ) ;
248+ let cpu_result = filter_array. to_canonical ( ) ?. into_array ( ) ;
244249
245- let gpu_result = FilterExecutor
246- . execute ( filter_array. into_array ( ) , & mut cuda_ctx)
247- . await
248- . vortex_expect ( "GPU filter failed" )
249- . into_host ( )
250- . await ?
251- . into_array ( ) ;
250+ let gpu_result = FilterExecutor
251+ . execute ( filter_array. into_array ( ) , & mut cuda_ctx)
252+ . await
253+ . vortex_expect ( "GPU filter failed" )
254+ . into_host ( )
255+ . await ?
256+ . into_array ( ) ;
252257
253- assert_eq ! ( cpu_result. len( ) , gpu_result. len( ) ) ;
254- assert_arrays_eq ! ( cpu_result, gpu_result) ;
258+ assert_eq ! ( cpu_result. len( ) , gpu_result. len( ) ) ;
259+ assert_arrays_eq ! ( cpu_result, gpu_result) ;
255260
256- Ok ( ( ) )
257- }
261+ Ok ( ( ) )
258262 }
259263}
0 commit comments