Skip to content

Fix MSVC thread-local storage probe - #35

Open
ZHBHFUT wants to merge 1 commit into
KarypisLab:mainfrom
ZHBHFUT:fix-msvc-tls-probe-20260908
Open

ZHBHFUT wants to merge 1 commit into
KarypisLab:mainfrom
ZHBHFUT:fix-msvc-tls-probe-20260908

Conversation

@ZHBHFUT

@ZHBHFUT ZHBHFUT commented Sep 8, 2026

Copy link
Copy Markdown

The MSVC TLS probe currently compiles extern __thread int x; without the __thread=__declspec(thread) definition accumulated in GK_COPTIONS. The probe fails with C2054/C2085, so conf/gkbuild.cmake appends an empty -D__thread= even when the linked GKlib uses real TLS.

Make the probe self-contained for MSVC and define/read a TLS variable so that the test checks actual TLS access instead of an unused declaration. Other compilers retain __thread.

The same issue has existing METIS proposals: KarypisLab/METIS#74 and KarypisLab/METIS#114. This PR fixes the matching probe in ParMETIS.

Validation on Windows x64/MSVC with MS-MPI:

  • Original probe: HAVE_THREADLOCALSTORAGE=FALSE, final flags contain both -D__thread=__declspec(thread) and -D__thread=.
  • Patched probe: HAVE_THREADLOCALSTORAGE=TRUE, no empty override.
  • Rebuilt vcpkg ParMETIS 2023-03-26 and METIS 2025-07-04 with the same probe fix and unchanged GKlib/MPI dependencies.
  • Standalone 40x40 undirected-grid consumer using ParMETIS_V3_PartKway: original Release/MPI2 crashes at METIS_PartGraphKway -> setjmp; patched Debug/Release with MPI2/MPI4 pass. A repeated-call regression also verifies every partition ID, nonempty coverage, and the reported edge cut against the gathered partition.

The runtime crash is specifically caused by METIS reading GKlib TLS signal buffers as ordinary globals. Both projects contain the defective detection; this change makes ParMETIS agree with GKlib as well. No partitioning algorithm changes. Non-Windows builds were not run.

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