Error C3028 in GROMACS 2025 when building on Windows with CUDA

GROMACS version: 2025.0
GROMACS modification: No

I’m trying to build GROMACS with CUDA support on Windows, using MSVC toolchain.

I have revert CMake version to 3.30.5.
I’ve setup CUDA 12.4.1, and I have Visual Studio 2022.
(in fact I’am using GitHub Actions Windows Runner, see this for more detail about installed packages)

The cmake command is

cmake .. "-DCMAKE_INSTALL_PREFIX=C:/GROMACS2025" "-DCMAKE_PREFIX_PATH=C:/FFTW;C:/OpenBLAS" "-DGMX_SIMD=AVX2_256" "-DGMX_GPU=CUDA" "-DGMX_HWLOC=ON" -G "Visual Studio 17 2022" -A "x64"
cmake --build . --target INSTALL --config Release -- "-maxCpuCount" "-p:CL_MPCount=3"

And it gave the following error message:

D:\a\GROMACS-Windows\GROMACS-Windows\gromacs-2025.0\src\gromacs\mdlib\lincs_gpu.cpp(322): error C3028: 'gmx::LincsGpu::maxCoupledConstraints_': only a variable or static data member can be used in a data-sharing clause [D:\a\GROMACS-Windows\GROMACS-Windows-\gromacs-2025.0\build\src\gromacs\libgromacs.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.4.targets(799,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\bin\nvcc.exe"  --use-local-env -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64" -x cu   -I (too many, ignored) -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4\include"     --keep-dir libgromacs\x64\Release -use_fast_math -maxrregcount=0   --machine 64 --compile -cudart static -std=c++17 --generate-code=arch=compute_50,code=[compute_50,sm_50] --generate-code=arch=compute_52,code=[compute_52,sm_52] --generate-code=arch=compute_60,code=[compute_60,sm_60] --generate-code=arch=compute_61,code=[compute_61,sm_61] --generate-code=arch=compute_70,code=[compute_70,sm_70] --generate-code=arch=compute_75,code=[compute_75,sm_75] --generate-code=arch=compute_80,code=[compute_80,sm_80] --generate-code=arch=compute_86,code=[compute_86,sm_86] --generate-code=arch=compute_89,code=[compute_89,sm_89] --generate-code=arch=compute_90,code=[compute_90,sm_90] --generate-code=arch=compute_53,code=[compute_53,sm_53] --generate-code=arch=compute_90,code=[compute_90,sm_90] -Wno-deprecated-gpu-targets -Xptxas=-warn-double-usage -Xptxas=-Werror -diag-suppress=177 -Xcompiler="/EHsc -Ob2 -openmp /EHsc"   -D_WINDOWS -DNDEBUG -DWIN32 -DHAVE_CONFIG_H -DTMPI_EXPORTS -DTMPI_USE_VISIBILITY -DGMX_DOUBLE=0 -DNOMINMAX -DUSE_STD_INTTYPES_H -DMUPARSER_STATIC -D"CMAKE_INTDIR=\"Release\"" -D_MBCS -DWIN32 -D_WINDOWS -DNDEBUG -DHAVE_CONFIG_H -DTMPI_EXPORTS -DTMPI_USE_VISIBILITY -DGMX_DOUBLE=0 -DNOMINMAX -DUSE_STD_INTTYPES_H -DMUPARSER_STATIC -D"CMAKE_INTDIR=\"Release\"" -Xcompiler "/EHsc /W1 /nologo /O2 /FS   /MD " -Xcompiler "/FdD:\a\GROMACS-Windows\GROMACS-Windows\gromacs-2025.0\build\lib\Release\gromacs.pdb" -o libgromacs.dir\Release\lincs_gpu.obj "D:\a\GROMACS-Windows\GROMACS-Windows\gromacs-2025.0\src\gromacs\mdlib\lincs_gpu.cpp"" exited with code 2. [D:\a\GROMACS-Windows\GROMACS-Windows\gromacs-2025.0\build\src\gromacs\libgromacs.vcxproj]

This error C3028, according to Microsoft’s document, is an error when compiled with MSVC.

No this issue when compiling GROMACS 2024.3~2024.5.

I think these lines of code need fix.

Hi!

Yes, a bug in our code. Thanks for reporting.

Microsoft only supports OpenMP 2.0 which was released in March 2002, so I’d say they could have been doing better job too, but well.

I made an issue: MSVC + CUDA + OpenMP compilation failure (#5294) · Issues · GROMACS / GROMACS · GitLab

Since none of the core team has a Windows machine with an NVIDIA GPU, would you be able to help with testing the fix (or maybe even doing the fix yourself, I referenced a very similar patch in the issue)?

EDIT: Ah, you have GitHub CI set up. Nice. Still, your help here would be appreciated if you’re familiar with Windows development environment.

Open the lincs_gpu.cpp file and navigate to line 322. Look for how maxCoupledConstraints_ is being used. It might be incorrectly declared or used in a way that is not compatible with CUDA’s data-sharing clauses.

I am not that familiar with developing on Windows.
I might try the solution mentioned in the GitLab issue #5294. But it will take more time.
And for some reason, my region is restricted by GitLab, so I can’t reply to the message in GitLab’s issue, I can only report it in this thread.

If you are interested in the GitHub CI I created, you can see more in GITHUB /KaneGreen/GROMACS-Windows-Builder/blob/master/.github/workflows/build_cuda.yml

Besides, I’m trying to build on Windows with CUDA, not using MSVC, but using Clang. But this is difficult.

There’s no reason it cannot work, but it’s likely a much more complicated way.

Okay, no worries. This fix should be straightforward, so we’ll fix it eventually by 2025.1. You GitHub action is a nice aid in testing.

Yes. I mean the Clang-way is more complicated, not “cannot work”.

I do this in my spare time. So, I need more days to do it.

1 Like

Hi!

The fix is now merged and will be part of GROMACS 2025.1.

Thanks.
I have tested it on GitHub Actions and it compiled successfully.
( GITHUB /KaneGreen/GROMACS-Windows-Builder/actions/runs/13431056591 )

1 Like