Skip to content

[Engine] Build the flag-order test with MSVC - #7438

Open
macintog wants to merge 1 commit into
Niko1221:mainfrom
macintog:codex/up-cuda-flag-order-v0223
Open

macintog wants to merge 1 commit into
Niko1221:mainfrom
macintog:codex/up-cuda-flag-order-v0223

Conversation

@macintog

Copy link
Copy Markdown
Contributor

Problem and result

A plain Windows MSVC + CUDA build fails in flag_order_test, even with -DSTRATA_BUILD_TESTS=OFF. The test reads a flag with GCC atomics that MSVC does not provide. With the MSVC read in this patch, I built and linked the test target on Windows.

Related discussion

The test covers the copy-order bug reported in #5093 and fixed in #5096.

Approach

On MSVC, the test includes <intrin.h> and rd() reads the writable 32-bit flag with _InterlockedCompareExchange(p, 0, 0), an atomic read with a full barrier. GCC and Clang, including clang-cl, keep the existing helper.

CMake registers the target under if(STRATA_ENABLE_CUDA AND NOT STRATA_HIP_GFX906), outside STRATA_BUILD_TESTS and without EXCLUDE_FROM_ALL (engine/cmake/strata_gpu_engine.cmake:867-879). Setup and packaging skip it because they build named engine targets. Gating the test on STRATA_BUILD_TESTS would also avoid the failure in tests-off builds.

Validation

Passed:

  • On base 3142b66b9, cmake --build <build> --target flag_order_test compiled and linked the patched test in Release on Windows with MSVC 19.44, CUDA 12.8.61 and -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=ON -DCMAKE_CUDA_ARCHITECTURES=86-real.
  • On an earlier revision with the same helper, before the explicit <intrin.h> include, ctest -R flag_order passed in 1.77 s on an RTX 3080 Ti under Windows.
  • The patch rebased cleanly onto v0.2.23 (4560d0379). The patched test is byte-identical to the one I built, and its CMake condition is the same.

Failed: Stock MSVC + CUDA 12.8 reported __atomic_load_n and __ATOMIC_SEQ_CST undefined at engine/tests/core/flag_order_test.cu:31.

Not run: Compilation or GPU execution after the rebase, GPU execution with the explicit include, an all-target MSVC build, or a HIP build. HIP compiles this file with Clang.

Limits

Only the test source changes. Engine and release binaries are unaffected.

With CUDA 12.8 and MSVC 19.44 the test failed to compile at the GNU atomic load. Read its mapped 32-bit test words with the MSVC interlocked intrinsic. On an RTX 3080 Ti the ordering checks, including the negative control and two graph replays, then passed in 1.77 seconds.
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.

1 participant