Native Windows (without WSL2)¶
Status: native Windows works for the CPU – Serial, OpenMP, the
popsPython module (import pops,System,AmrSystem), DSL production (.dll, bit-identical results) and compilation of custom C++ (adc_cases.common.native). The GPU stays on WSL2 (Kokkos CUDA is not supported natively on Windows).
This page complements the WSL2 guide. WSL2 remains the simplest path and the only one that covers the GPU. The native path is useful if you want to avoid WSL2 for CPU work.
Toolchain¶
Visual Studio 2022 (MSVC,
cl.exe, C++23 via/std:c++20//std:c++latest) + CMake.LLVM/clang-cl (
winget install LLVM.LLVM) only for OpenMP: MSVC keeps_OPENMP=2.0even with/openmp:llvm, so Kokkos OpenMP (>=3.0) requires clang-cl (which reports 5.1).Python (Miniforge recommended) +
numpy,pybind11.Any compilation at runtime (DSL
production,adc_cases.common.native) launchescl/clang-cl: launch Python from an “x64 Native Tools” prompt (vcvars) to haveINCLUDE/LIB.
Python module _pops¶
cmake -S adc_cpp -B build-pywin -G "Visual Studio 17 2022" -A x64 ^
-DPOPS_BUILD_PYTHON=ON -DPOPS_USE_KOKKOS=ON -DKokkos_ROOT=...\kokkos-shared ^
-DPython_EXECUTABLE=...\python.exe -DCMAKE_CXX_FLAGS="/DPOPS_EXPORT_BUILDING_MODULE /DNOMINMAX /bigobj"
cmake --build build-pywin --config Release --target _pops
/DPOPS_EXPORT_BUILDING_MODULE exports the System methods (__declspec(dllexport), see
export.hpp) -> produces the import library _pops.lib against which the DSL .dll links. Copy
_pops.cp3XX-win_amd64.pyd, _pops.lib and kokkos*.dll next to python/pops/.
import pops
pops.doctor()
print(pops.parallel_info())
DSL production (.dll) and adc_cases¶
pops.compile(case, backend=Production()) compiles a .dll (cl/clang-cl, /LD, linked to
kokkoscore.lib + _pops.lib) that the bound runtime loads (LoadLibraryW) – no Unix
RTLD_GLOBAL, the _pops symbols are resolved at link time via _pops.lib. Validated bit-identical to the
brick path. adc_cases.common.native.build_shared produces standalone .dll files (ctypes) in the
same way.
Warning: The custom
.cppfiles of the cases must export their entry points as__declspec(dllexport)on Windows (extern "C"alone does not export under/LD).
Notable differences vs Linux¶
Topic |
Linux/WSL2 |
Native Windows |
|---|---|---|
Dynamic loading |
|
|
Kokkos cross- |
symbols via |
Kokkos as a shared DLL ( |
OpenMP |
gcc/clang |
clang-cl (MSVC |
DSL compilation at runtime |
g++/clang on the |
|
GPU CUDA |
yes (WSL2, sm_86) |
no (Kokkos CUDA not supported natively) -> use WSL2 |
Limitations¶
Native CUDA GPU: not available (Kokkos has no native CUDA support on Windows – neither VS+CUDA, nor nvcc-as-CXX for lack of a Windows
nvcc_wrapper). The GPU goes through WSL2. CMake refuses this combination early: configuring withKokkos_ENABLE_CUDA=ONon Windows stops at a fatal error pointing to WSL2 (no broken half-build deep in the Kokkos configure). Refs ADC-168.CMake industrialization (shared Kokkos option, install of the import libs, clang-cl presets) to finalize so that these builds are reproducible from a single command.