88#
99# ################################################################################
1010
11+ # /// script
12+ # dependencies = ["cuda_bindings>13.2.1", "numpy"]
13+ # ///
14+
1115import ctypes
1216import platform
1317import sys
1418
1519import numpy as np
16- from common import common
17- from common .helper_cuda import check_cuda_errors
1820
1921from cuda .bindings import driver as cuda
2022from cuda .bindings import runtime as cudart
23+ from cuda .bindings ._example_helpers import KernelHelper , check_cuda_errors , requirement_not_met
2124
2225simplep2p = """\
2326 extern "C"
3235
3336
3437def main ():
35- import pytest
36-
3738 if platform .system () == "Darwin" :
38- pytest . skip ("simpleP2P is not supported on Mac OSX" )
39+ requirement_not_met ("simpleP2P is not supported on Mac OSX" )
3940
4041 if platform .machine () == "armv7l" :
41- pytest . skip ("simpleP2P is not supported on ARMv7" )
42+ requirement_not_met ("simpleP2P is not supported on ARMv7" )
4243
4344 if platform .machine () == "aarch64" :
44- pytest . skip ("simpleP2P is not supported on aarch64" )
45+ requirement_not_met ("simpleP2P is not supported on aarch64" )
4546
4647 if platform .machine () == "sbsa" :
47- pytest . skip ("simpleP2P is not supported on sbsa" )
48+ requirement_not_met ("simpleP2P is not supported on sbsa" )
4849
4950 # Number of GPUs
5051 print ("Checking for multiple GPUs..." )
5152 gpu_n = check_cuda_errors (cudart .cudaGetDeviceCount ())
5253 print (f"CUDA-capable device count: { gpu_n } " )
5354
5455 if gpu_n < 2 :
55- pytest . skip ("Two or more GPUs with Peer-to-Peer access capability are required" )
56+ requirement_not_met ("Two or more GPUs with Peer-to-Peer access capability are required" )
5657
5758 prop = [check_cuda_errors (cudart .cudaGetDeviceProperties (i )) for i in range (gpu_n )]
5859 # Check possibility for peer access
@@ -83,7 +84,7 @@ def main():
8384 break
8485
8586 if p2p_capable_gp_us [0 ] == - 1 or p2p_capable_gp_us [1 ] == - 1 :
86- pytest . skip ("Peer to Peer access is not available amongst GPUs in the system" )
87+ requirement_not_met ("Peer to Peer access is not available amongst GPUs in the system" )
8788
8889 # Use first pair of p2p capable GPUs detected
8990 gpuid = [p2p_capable_gp_us [0 ], p2p_capable_gp_us [1 ]]
@@ -158,7 +159,7 @@ def main():
158159 _simple_kernel = [None ] * 2
159160 kernel_args = [None ] * 2
160161
161- kernel_helper [1 ] = common . KernelHelper (simplep2p , gpuid [1 ])
162+ kernel_helper [1 ] = KernelHelper (simplep2p , gpuid [1 ])
162163 _simple_kernel [1 ] = kernel_helper [1 ].get_function (b"SimpleKernel" )
163164 kernel_args [1 ] = ((g0 , g1 ), (ctypes .c_void_p , ctypes .c_void_p ))
164165 check_cuda_errors (
@@ -183,7 +184,7 @@ def main():
183184 # output to the GPU 0 buffer
184185 print (f"Run kernel on GPU{ gpuid [0 ]} , taking source data from GPU{ gpuid [1 ]} and writing to GPU{ gpuid [0 ]} ..." )
185186 check_cuda_errors (cudart .cudaSetDevice (gpuid [0 ]))
186- kernel_helper [0 ] = common . KernelHelper (simplep2p , gpuid [0 ])
187+ kernel_helper [0 ] = KernelHelper (simplep2p , gpuid [0 ])
187188 _simple_kernel [0 ] = kernel_helper [0 ].get_function (b"SimpleKernel" )
188189 kernel_args [0 ] = ((g1 , g0 ), (ctypes .c_void_p , ctypes .c_void_p ))
189190 check_cuda_errors (
0 commit comments