This is an archive of the discontinued LLVM Phabricator instance.

[clang-repl][CUDA] Add an unit test for interactive CUDA
Needs ReviewPublic

Authored by argentite on Jun 1 2023, 10:21 AM.

Details

Reviewers
v.g.vassilev
Summary

This tests interactive CUDA support in clang interpreter and should pass
in case CUDA runtime is not available or no GPUs are available.

Diff Detail

Event Timeline

argentite created this revision.Jun 1 2023, 10:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 10:21 AM
argentite requested review of this revision.Jun 1 2023, 10:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 10:21 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tra added a subscriber: tra.Jun 1 2023, 10:32 AM
tra added inline comments.
clang/unittests/Interpreter/InteractiveCudaTest.cpp
93

This could be a bit of a problem.

There may be multiple CUDA SDK versions that may be installed on a system at any given time and the libcudart.so you pick here may not be the one you want.
E.g it may be from a recent CUDA version which is not supported by NVIDIA drivers yet.

I think you may need a way to let the user override CUDA SDK (or libcudart.so) location explicitly. I guess they could do that via LD_LIBRARY_PATH, but for the CUDA compilation in general, knowing CUDA SDK path is essential, as it does affect various compilation options set by the driver.

argentite added inline comments.Jun 1 2023, 10:36 AM
clang/unittests/Interpreter/InteractiveCudaTest.cpp
93

Yes, this probably would be an issue. It is currently possible to override the CUDA path with a command line argument in clang-repl. But I am not sure what we can do inside a test.

tra added inline comments.Jun 1 2023, 10:47 AM
clang/unittests/Interpreter/InteractiveCudaTest.cpp
93

To me it looks like CUDA location should be detected/set at the configuration time and then propagated to the individual tests that need that info.
CMake has cuda detection mechanisms that could be used for that purpose.
They are a bit of a pain to use in practice (I'm still not sure what's the reliable way to do it), but it's as close to the 'standard' way of doing it as we have at the moment.
I believe libc and mlir subtrees in LLVM are already using this mechanism. E.g https://github.com/llvm/llvm-project/blob/main/libc/utils/gpu/loader/CMakeLists.txt#L16

@argentite what is the fate of this patch? Should we move forward with it?

argentite edited the summary of this revision. (Show Details)
argentite added inline comments.Aug 24 2023, 10:56 AM
clang/unittests/Interpreter/InteractiveCudaTest.cpp
93

This version uses CMake to detect the paths as in the example above. I guess this would tie the test to the build system but it should probably be fine for most cases. Unfortunately I don't think we can use the same trick for determining the path in ClangREPL because the interpreter is likely to run on a different system.