Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

CUB 1.15.0 compilation errors if included after Windows.h #422

Closed
ptheywood opened this issue Jan 18, 2022 · 1 comment · Fixed by #423
Closed

CUB 1.15.0 compilation errors if included after Windows.h #422

ptheywood opened this issue Jan 18, 2022 · 1 comment · Fixed by #423
Assignees
Labels
compiler: msvc Specific to the MSVC compiler P1: should have Necessary, but not critical. repro: verified The provided repro has been validated. type: bug: functional Does not work as intended.
Milestone

Comments

@ptheywood
Copy link

If Windows.h is included prior to cub/cub.cuh under MSVC compilation will fail with the following:

D:/a/jitify-cub-1.15-MSVC-demo/jitify-cub-1.15-MSVC-demo/build/_deps/thrust-src/dependencies/cub\cub/device/dispatch/dispatch_segmented_sort.cuh(338): error : invalid combination of type specifiers [D:\a\jitify-cub-1.15-MSVC-demo\jitify-cub-1.15-MSVC-demo\build\jitify-before-cub.vcxproj]
D:/a/jitify-cub-1.15-MSVC-demo/jitify-cub-1.15-MSVC-demo/build/_deps/thrust-src/dependencies/cub\cub/device/dispatch/dispatch_segmented_sort.cuh(338): error : expected an identifier [D:\a\jitify-cub-1.15-MSVC-demo\jitify-cub-1.15-MSVC-demo\build\jitify-before-cub.vcxproj]
D:/a/jitify-cub-1.15-MSVC-demo/jitify-cub-1.15-MSVC-demo/build/_deps/thrust-src/dependencies/cub\cub/device/dispatch/dispatch_segmented_sort.cuh(379): error : expected a member name [D:\a\jitify-cub-1.15-MSVC-demo\jitify-cub-1.15-MSVC-demo\build\jitify-before-cub.vcxproj]

This impacts the use of NVIDIA/Jitify and NVRTC.
nvrtc.h conditionally includes Windows.h if NVRTC_GET_TYPE_NAME is defined to a non-zero value (as used in Jitify).

This only occurs since CUB 1.15.0 with multiple CUDA versions, and only if Windows.h is included prior to CUB.

It is not due to the min/max macros (checked via -DNOMINMAX).

I've created a repository to reproduce this, and demonstrate this through GitHub Actions:

https://github.com/ptheywood/cub-1.15-windows.h-demo

The minimal example to reproduce this is:

#if defined(_WIN32)
    #include <Windows.h>
#endif
#include <cub/cub.cuh>
int main(int argc, char* argv[]) {
    return EXIT_SUCCESS;
}

GitHub Action run with logs valid for 90 days (?): https://github.com/ptheywood/cub-1.15-windows.h-demo/runs/4851931940?check_suite_focus=true

The CUDA 11.6 + CUB 1.15.0 log has been archived at https://gist.github.com/ptheywood/87b821860931bf6a2c700bbe3803d3f4 for longer term storage.

@gevtushenko
Copy link
Collaborator

It would seem that windows.h defines a macro called small, which happens to be a name of a variable in the new segmented sort:

  __shared__ union
  {
    // ...
    typename SmallAgentWarpMergeSortT::TempStorage small[segments_per_small_block];
  } temp_storage;

Fix consists of renaming this member. I'll create a PR later today.

@gevtushenko gevtushenko self-assigned this Jan 18, 2022
@alliepiper alliepiper added type: bug: functional Does not work as intended. compiler: msvc Specific to the MSVC compiler P1: should have Necessary, but not critical. repro: verified The provided repro has been validated. labels Jan 18, 2022
@alliepiper alliepiper added this to the 1.16.0 milestone Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler: msvc Specific to the MSVC compiler P1: should have Necessary, but not critical. repro: verified The provided repro has been validated. type: bug: functional Does not work as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants