File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 4141
4242#ifdef _MSC_VER
4343#include < intrin.h>
44- #pragma intrinsic(_BitScanForward64)
4544#include < windows.h>
4645#include < comdef.h>
4746#include < tchar.h>
@@ -7426,9 +7425,19 @@ int32 PCM::mapNUMANodeToSocket(uint32 numa_node_id) const
74267425
74277426 if (mask != 0 )
74287427 {
7428+ auto BitScanForward64 = [](unsigned long * Index, uint64_t Mask)
7429+ {
7430+ if (Mask == 0 ) return 0 ;
7431+
7432+ // Magic numbers for LSB (chess engine style)
7433+ static const uint64_t magic = 0x03f79d71b4cb0a89ULL ;
7434+ uint64_t isolated = Mask & -Mask; // Rightmost set bit
7435+ *Index = (unsigned long )(((isolated * magic) >> 58 ));
7436+ };
7437+
74297438 // Find first set bit (first processor in this NUMA node within this group)
74307439 DWORD bitPosition = 0 ;
7431- _BitScanForward64 (&bitPosition, mask);
7440+ BitScanForward64 (&bitPosition, mask);
74327441
74337442 // On Windows, we need to find the logical processor ID that corresponds to
74347443 // this bit position in this group. We iterate through topology to find a match.
You can’t perform that action at this time.
0 commit comments