fix Windows support for exectuable search and test running#394
Open
jhpohovey wants to merge 10 commits intoNVIDIA:masterfrom
Open
fix Windows support for exectuable search and test running#394jhpohovey wants to merge 10 commits intoNVIDIA:masterfrom
jhpohovey wants to merge 10 commits intoNVIDIA:masterfrom
Conversation
…s in case cuInit fails
…KED_CALL macro which returned prematurely
… with error in case of LOADLIBRARY failureas initialize of function pointers in case of LOADLIBRARY failure will fail
…IT_crash Fix null pointer reference issue with cuda driver API function pointer.
373b2e9 to
de2ad6a
Compare
Author
|
fixing noisy diff caused by LF vs CRLF difference in above |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
run_tests.py, when run like in the following snippet, doesn't work on Windows (read: normal Windows, not WSL or a Docker container running in Windows) because of two issues:cuda-samples/README.md
Lines 331 to 335 in c94ff36
1.
os.access(path, os. X_OK)is ineffective on WindowsOn Linux, this checks the executable permission bit and works completely fine. But on Windows, it returns
Truefor most things- including.mdfiles, directories, etc (primarily due to lots of Posix-like things that don't map quite exactly). This causes the script to try running thousands of non-executable files.The underlying implementation of
os.accessunfolds to:https://github.com/python/cpython/blob/fddc24e4c85467f14075e94fd0d23d928ceb535f/Modules/posixmodule.c?plain=1#L3764-L3780
where executability isn't checked (see python/cpython#46780).
2.
./executablesyntax doesn't work in subprocess on non-Unix-like machinesThe original code used
cmd = [f"./{exe_name}"], but Windows (Power Shell and Command Prompt), unlike *nix-based platforms, doesn't understand the./syntax insubprocess.run()withoutshell=True(usingshell=Truewould spawn e.g., a cmd.exe for every single test run, which is likely not preferable if it could be done without). There are also some hypothetical security concerns from injection whenshell=True.Solution
.exefilter on Windows. Yes there are other file-types in Windows that are executable, like.bator.cmd, but their inclusion (or lack thereof) is generally irrelevant since the CMake process isn't compiling anything into batch or command scripts../prefix. This works everywhere without needing shell interpretation - Windows can executeC:\path\to\program.exedirectly, and Linux handles/path/to/programthe same way.Changes
find_executables(): Skip non-.exefiles on Windows.run_single_test_instance(): Useexecutable.resolve()instead off"./{exe_name}".Testing
simpleP2P,streamOrderedAllocationP2P,conjugateGradientMultiDeviceCG, andsimpleCUFFTskipped due to testing on a 1-GPU system). The test ofsimpleAWBarrierhangs and hits timeout after 5min, both with and without these changes (not that changes to a.pyfile should impact compilation either way; this is likely a driver+platform specific issue on my end).Since this change modifies the test runner itself rather than the samples, the tests running+passing validates that the runner correctly discovers and executes the sample executables on Windows. Before this fix, the script would fail immediately trying to execute non-executable files, if it were to discover them at all.