Main entry point for the vector addition sample.
()
| 156 | |
| 157 | |
| 158 | def main(): |
| 159 | """ |
| 160 | Main entry point for the vector addition sample. |
| 161 | """ |
| 162 | import argparse |
| 163 | |
| 164 | parser = argparse.ArgumentParser(description="Vector Addition using CUDA Core API") |
| 165 | parser.add_argument( |
| 166 | "--elements", |
| 167 | type=int, |
| 168 | default=50000, |
| 169 | help="Number of elements in vectors (default: 50000)", |
| 170 | ) |
| 171 | parser.add_argument( |
| 172 | "--device", type=int, default=0, help="CUDA device ID (default: 0)" |
| 173 | ) |
| 174 | parser.add_argument( |
| 175 | "--no-verify", action="store_true", help="Skip result verification" |
| 176 | ) |
| 177 | |
| 178 | args = parser.parse_args() |
| 179 | |
| 180 | if args.elements <= 0: |
| 181 | print("Error: Number of elements must be positive") |
| 182 | return 1 |
| 183 | |
| 184 | success = vector_add_cuda_core( |
| 185 | num_elements=args.elements, device_id=args.device, verify=not args.no_verify |
| 186 | ) |
| 187 | |
| 188 | if success: |
| 189 | print("\nDone") |
| 190 | return 0 |
| 191 | else: |
| 192 | return 1 |
| 193 | |
| 194 | |
| 195 | if __name__ == "__main__": |
no test coverage detected