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

Fix a collection of issues related to Windows/MSVC #45

Merged
merged 13 commits into from
Mar 4, 2020

Conversation

benbarsdell
Copy link
Member

Fixes issues found in #43 (along with a few other minor things that were noticed along the way).

The main fixes relate to: min/max macros, __cplusplus macro, dlfcn dependency, incompatible size_t definition, and incorrect name demangling.

Full details are in the commit messages.

- These may be defined by windows.h and cause `std::min/max` to break.
- Since we require C++11 now, these are no longer needed.
- This also avoids the problem of MSVC not correctly defining
  __cplusplus.
- Unused __constant__ variables could cause the same code-bloat
  problems as __device__ variables (though they are less common).
- Can be re-enabled by defining JITIFY_ENABLE_EMBEDDED_FILES to 1.
- This is a rarely-used feature and only works with GCC on Linux.
  Disabling it avoids having a hard dependency dlfcn, which is not
  always available on Windows. It also avoids needing to link with
  -ldl.
- The global-namespace versions of these are actually built into
  NVRTC. Providing our own duplicate definitions caused errors in MSVC
  because they conflicted with the NVRTC-provided definitions. We only
  need to provide the std:: versions of them.
- PTX name mangling always follows the Itanium64 ABI scheme, even
  under MSVC. This means we can't use the platform-specific demangler
  for creating the map of __constant__/__device__ symbols.
- The nvrtcGetLoweredName function would work except that it requires
  all names to have been added via nvrtcAddNameExpression _before_
  compilation, which is not feasible/convenient with our API.
- This commit adds a simple custom demangler that supports nested
  namespace-scope variable names in the PTX (Itanium64) mangling
  format.
- Only namespace-scope variable names need to be supported because
  __device__/__constant__ variables are only allowed at
  namespace-scope or function scope (if static), and the latter cannot
  be directly addressed from outside the function.
- This used to fail on Windows under MSVC but should work now.
Copy link
Collaborator

@maddyscientist maddyscientist left a comment

Choose a reason for hiding this comment

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

Approving. This looks solid. I suggest we hold off merging this until @mondus confirms that this pull fixes his outstanding issues.

@benbarsdell benbarsdell merged commit 214dc51 into master Mar 4, 2020
@benbarsdell benbarsdell deleted the hotfix/more-msvc-issues branch July 31, 2020 11:57
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