MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / main

Function main

python/1_GettingStarted/simplePrint/simplePrint.py:246–283  ·  view source on GitHub ↗

Main function demonstrating printing from CUDA kernels using both approaches

()

Source from the content-addressed store, hash-verified

244
245
246def main():
247 """Main function demonstrating printing from CUDA kernels using both approaches"""
248
249 print("Simple Print - Printing from CUDA Kernels")
250 print("Demonstrating both CUDA C++ and Numba CUDA approaches")
251 print()
252 # Initialize device
253 device = Device()
254 device.set_current()
255
256 # Get device properties
257 print(f"Device: {device.name}")
258 print(f"Compute Capability: sm_{device.arch}")
259 print()
260
261 # Value to pass to both kernels
262 test_value = 10
263
264 # Run CUDA C++ kernel
265 result = run_cuda_cpp_kernel(device, test_value)
266 if result != 0:
267 return result
268
269 # Run Numba kernel if available
270 if NUMBA_AVAILABLE:
271 result = run_numba_kernel(device, test_value)
272 if result != 0:
273 return result
274 else:
275 print("\n" + "=" * 70)
276 print("Numba CUDA example skipped (numba not installed)")
277 print("To run the Numba example: pip install numba")
278 print("=" * 70)
279
280 print("\n" + "=" * 70)
281 print("Done! Both kernel approaches demonstrated successfully.")
282 print("=" * 70)
283 return 0
284
285
286if __name__ == "__main__":

Callers 1

simplePrint.pyFile · 0.70

Calls 2

run_cuda_cpp_kernelFunction · 0.85
run_numba_kernelFunction · 0.85

Tested by

no test coverage detected