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

Add nvrtc_cli tool #105

Merged
merged 3 commits into from
Nov 2, 2022
Merged

Add nvrtc_cli tool #105

merged 3 commits into from
Nov 2, 2022

Conversation

benbarsdell
Copy link
Member

This allows NVRTC to be driven via a nvrtc_cli executable that operates identically to nvcc (for the subset of functionality supported by NVRTC).

This is useful for testing, and we also plan to integrate it into the godbolt.org Compiler Explorer.

Includes a script for testing basic functionality of the tool.

- This allows NVRTC to be driven via a nvrtc_cli executable that
  operates identically to nvcc (for the subset of functionality
  supported by NVRTC).
- This is useful for testing, and we also plan to integrate it into
  the godbolt.org Compiler Explorer.
- Includes a script for testing basic functionality of the tool.
}

#if CUDART_VERSION >= 11010
size_t cubin_size;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering if you can make a run-time check for the nvrtc library version as well here and for the get NVVM below, to make this more robust? Else this will break if compiled with a toolkit that's newer than the the libnvrtc.so. May be a situation we don't care about.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's using regular dynamic linking, so it will crash with symbol lookup error: ./nvrtc_cli: undefined symbol: nvrtcGetNVVMSize at startup, regardless of whether there is a runtime check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I realize that (as that is what happened to me when I initially tested this 😄 ). This is what got me thinking if it was worth doing something smarter with dlopen etc. was worth it.

}

nvrtcResult get_supported_archs(std::vector<int>* supported_archs) {
#if CUDART_VERSION >= 11020
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment here about checking version at run-time. For pre 11.0 that is a trivial change, since one doesn't have to mess with the presence (or not) or a shared library function.

} else if (sarg == "-ptx" || sarg == "--ptx") {
output_ptx = true;
} else if (sarg == "-cubin" || sarg == "--cubin") {
#if CUDART_VERSION >= 11010
Copy link
Collaborator

Choose a reason for hiding this comment

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

And this should be run-time here as well. Should be trivial in this case.

@maddyscientist
Copy link
Collaborator

Just wondering about getting this old PR. @benbarsdell can you make the trivial changes I noted above and we can get this merged? (we can just ignore my run-time checking for now)

@benbarsdell
Copy link
Member Author

Sorry it took so long to get to this. I've added nvrtc_cli to make all.

@maddyscientist
Copy link
Collaborator

I'd prefer less CUDART_VERSION usage, but since this has been open for a long time, and long since merged into compiler-explorer, I'm happy to just approve and merge this.

@maddyscientist maddyscientist merged commit 0d0954e into master Nov 2, 2022
@maddyscientist maddyscientist deleted the add-nvrtc-cli-tool branch November 2, 2022 03:28
@benbarsdell
Copy link
Member Author

Maybe I misunderstood, I'm having trouble thinking this through. Some of them need to be compile time checks, and those won't gain anything by adding runtime checks. Will other parts benefit from having runtime checks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants