Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create NVRTCC, a utility for running tests under NVRTC #494

Merged
merged 31 commits into from
Oct 31, 2023

Conversation

wmaxey
Copy link
Member

@wmaxey wmaxey commented Sep 26, 2023

Description

Closes #465

This PR allows us to test NVRTC just like any other compiler. It provides compile time feedback and enables negative compilation tests. e.g. compile.pass, .fail, or possibly even weird XFAIL cases.

TODO:

  • Implement NVRTCC
  • Connect to lit
  • Document / update CI to build the libcudacxx project before executing lit.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@wmaxey wmaxey requested review from a team as code owners September 26, 2023 23:54
@wmaxey wmaxey requested review from alliepiper and ericniebler and removed request for a team September 26, 2023 23:54
@wmaxey wmaxey marked this pull request as draft September 26, 2023 23:57
@wmaxey wmaxey self-assigned this Sep 27, 2023
@wmaxey
Copy link
Member Author

wmaxey commented Sep 29, 2023

Current status on Windows:

PS C:\> lit -sv -j20 .\cccl\libcudacxx\.upstream-tests\test -Dcompute_archs=80
...
Failed Tests (2):
  libcu++ :: std/containers/views/mdspan/mdspan.extents.cons/array.pass.cpp
  libcu++ :: std/containers/views/mdspan/mdspan.extents.cons/span.pass.cpp


Testing Time: 276.21s
  Unsupported      :  459
  Passed           : 1257
  Expectedly Failed:    5
  Failed           :    2

@wmaxey
Copy link
Member Author

wmaxey commented Sep 29, 2023

We can now build NVRTC tests with -Dexecutor='NoopExecutor()' to disable execution if we wanted to, though I believe it still requires a GPU or the CUDA driver installed. Not sure which.

@wmaxey wmaxey changed the title Draft: Create NVRTCC, a utility for running tests under NVRTC Create NVRTCC, a utility for running tests under NVRTC Sep 29, 2023
@wmaxey wmaxey marked this pull request as ready for review September 29, 2023 19:49
@wmaxey wmaxey requested a review from a team as a code owner September 29, 2023 19:49
@wmaxey wmaxey requested review from jarmak-nv and removed request for a team September 29, 2023 19:49

// Start by parsing arguments and building the configuration
std::string c_arg{};
for (auto a = g_argv; a < g_argv + g_argc; a++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snarky suggestion: std::regex. I'm not even mad, I'm impressed. However, would it be easier to just use an existing lib like cxxopts for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as we discussed. Pulling in dependencies where we might need to be building in 'weird places' makes me not want to use them... STL-only seems safest from a 'will work almost anywhere' standpoint.

// Load the input file and execute
if (execute) {
fprintf(stderr, "Executing %s with %i threads\r\n", executionConfig.builds[0].c_str(), executionConfig.rc.threadCount);
load_and_run_gpu_code(executionConfig.builds[0], executionConfig.rc);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Instead of needing to pass the produced fatbin to nvrtcc in order to execute the program, couldn't nvrtcc just produce a binary that does this step for you?

Basically, it would store the fatbin in the binary, and in the main() it would do load_and_run_gpu_code(/*stored fatbin*/).

That way, nvrtcc would work even more like a regular compiler in that it outputs a normal binary that can be executed just like ./a.out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially what the old script did. It produced a binary with the raw test stored inside and compiled it during execution. Every test was recompiled into the same hosting application. It bought us the 'works like a binary thing' but failed for giving us negative testing with .fail.cpp tests.

It might be possible to do this. It would get rid of needing to use the PrefixExecutor() for tests. I'll make a PR after this one with the documentation in mind.

Problematically it may try to enable more features than required.
This change adds an output file created during build.
It contains information required for launching on GPU.
Fix unsupported nvcc/nvrtc mixup.
* Some files require including `cuda/std/cassert` instead.
  * Which shouldn't be an issue...
@wmaxey wmaxey requested a review from griwes October 24, 2023 23:56
Copy link
Contributor

@miscco miscco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean its not pretty, but in that context nothing is.

Great work on improving our test coverage 🎉

@wmaxey wmaxey merged commit d95eba2 into NVIDIA:main Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Build a proxy NVRTC command line utility that can act as if it were a "real" compiler.
3 participants