Skip to content

Commit a497788

Browse files
authored
[SYCL][E2E] Fix CUDA include and lib paths. (#14118)
`cuda_dev_kit` is not set properly in [test-e2e/lit.cfg.py](https://github.com/intel/llvm/blob/sycl/sycl/test-e2e/lit.cfg.py) due to invalid CUDA paths. Fixing the paths showed errors in [14115](#14115) and [14116](#14116) which are XFAILed. The patch fixes the failure of [cuda_queue_priority.cpp](https://github.com/intel/llvm/blob/sycl/sycl/test-e2e/Plugin/cuda_queue_priority.cpp) on Windows / CUDA.
1 parent d7bc4fc commit a497788

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

sycl/test-e2e/Plugin/cuda_queue_priority.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// REQUIRES: gpu, cuda
2-
1+
// REQUIRES: gpu, cuda, cuda_dev_kit
32
// RUN: %{build} %cuda_options -o %t.out
43
// RUN: %{run} %t.out
54
//

sycl/test-e2e/Plugin/interop-cuda-experimental.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %{build} %cuda_options -o %t.out
44
// RUN: %{run} %t.out
55

6+
// An issue has been reported in https://github.com/intel/llvm/issues/14116
7+
// XFAIL: *
8+
69
#define SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL 1
710
#include <sycl/backend.hpp>
811
#include <sycl/detail/core.hpp>

sycl/test-e2e/Plugin/interop-experimental-single-TU-SYCL-CUDA-compilation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// RUN: %{build} %cuda_options -lcudart -lcuda -x cuda -o %t.out
33
// RUN: %{run} %t.out
44

5+
// An issue has been reported in https://github.com/intel/llvm/issues/14115
6+
// XFAIL: *
7+
58
#include <cuda.h>
69
#include <sycl/detail/core.hpp>
710

sycl/test-e2e/lit.cfg.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,60 @@
464464
)
465465

466466
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+
467510
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")
468521

469522
# FIXME: This needs to be made per-device as well, possibly with a helper.
470523
if "hip:gpu" in config.sycl_devices and config.hip_platform == "AMD":

0 commit comments

Comments
 (0)