()
| 101 | |
| 102 | |
| 103 | def main(): |
| 104 | print("=" * 60) |
| 105 | print("Parallel Histogram with Atomics (cuda.core)") |
| 106 | print("=" * 60) |
| 107 | |
| 108 | # Initialize device using cuda.core |
| 109 | device = Device(0) |
| 110 | device.set_current() |
| 111 | print(f"\nDevice: {device.name}") |
| 112 | print(f"Compute Capability: {device.compute_capability}") |
| 113 | |
| 114 | # Create stream using cuda.core |
| 115 | stream = device.create_stream() |
| 116 | |
| 117 | # Make CuPy use the same stream for correct ordering (avoids null-stream sync) |
| 118 | cp.cuda.Stream.from_external(stream).use() |
| 119 | |
| 120 | try: |
| 121 | _run_histogram(device, stream) |
| 122 | finally: |
| 123 | cp.cuda.Stream.null.use() # Restore CuPy to default stream before closing |
| 124 | stream.close() |
| 125 | |
| 126 | |
| 127 | def _run_histogram(device, stream): |
no test coverage detected