|
464 | 464 | )
|
465 | 465 |
|
466 | 466 | if "cuda:gpu" in config.sycl_devices:
|
| 467 | + if "CUDA_PATH" not in os.environ: |
| 468 | + if platform.system() == "Windows": |
| 469 | + cuda_root = r"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA" |
| 470 | + cuda_versions = [] |
| 471 | + if os.path.exists(cuda_root): |
| 472 | + for entry in os.listdir(cuda_root): |
| 473 | + if os.path.isdir( |
| 474 | + os.path.join(cuda_root, entry) |
| 475 | + ) and entry.startswith("v"): |
| 476 | + version = entry[1:] # Remove the leading 'v' |
| 477 | + if re.match( |
| 478 | + r"^\d+\.\d+$", version |
| 479 | + ): # Match version pattern like 12.3 |
| 480 | + cuda_versions.append(version) |
| 481 | + latest_cuda_version = max( |
| 482 | + cuda_versions, key=lambda v: [int(i) for i in v.split(".")] |
| 483 | + ) |
| 484 | + os.environ["CUDA_PATH"] = os.path.join( |
| 485 | + cuda_root, f"v{latest_cuda_version}" |
| 486 | + ) |
| 487 | + else: |
| 488 | + cuda_root = "/usr/local" |
| 489 | + cuda_versions = [] |
| 490 | + if os.path.exists(cuda_root): |
| 491 | + for entry in os.listdir(cuda_root): |
| 492 | + if os.path.isdir( |
| 493 | + os.path.join(cuda_root, entry) |
| 494 | + ) and entry.startswith("cuda-"): |
| 495 | + version = entry.split("-")[1] |
| 496 | + if re.match( |
| 497 | + r"^\d+\.\d+$", version |
| 498 | + ): # Match version pattern like 12.3 |
| 499 | + cuda_versions.append(version) |
| 500 | + latest_cuda_version = max( |
| 501 | + cuda_versions, key=lambda v: [int(i) for i in v.split(".")] |
| 502 | + ) |
| 503 | + os.environ["CUDA_PATH"] = os.path.join( |
| 504 | + cuda_root, f"cuda-{latest_cuda_version}" |
| 505 | + ) |
| 506 | + |
| 507 | + if "CUDA_PATH" not in os.environ: |
| 508 | + lit_config.error("Cannot run tests for CUDA without valid CUDA_PATH.") |
| 509 | + |
467 | 510 | llvm_config.with_system_environment("CUDA_PATH")
|
| 511 | + if platform.system() == "Windows": |
| 512 | + config.cuda_libs_dir = ( |
| 513 | + '"' + os.path.join(os.environ["CUDA_PATH"], r"lib\x64") + '"' |
| 514 | + ) |
| 515 | + config.cuda_include = ( |
| 516 | + '"' + os.path.join(os.environ["CUDA_PATH"], "include") + '"' |
| 517 | + ) |
| 518 | + else: |
| 519 | + config.cuda_libs_dir = os.path.join(os.environ["CUDA_PATH"], r"lib64") |
| 520 | + config.cuda_include = os.path.join(os.environ["CUDA_PATH"], "include") |
468 | 521 |
|
469 | 522 | # FIXME: This needs to be made per-device as well, possibly with a helper.
|
470 | 523 | if "hip:gpu" in config.sycl_devices and config.hip_platform == "AMD":
|
|
0 commit comments