diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /rts/win32/OSMem.c | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'rts/win32/OSMem.c')
-rw-r--r-- | rts/win32/OSMem.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c index c67b95be82..c62ee3b7a4 100644 --- a/rts/win32/OSMem.c +++ b/rts/win32/OSMem.c @@ -458,7 +458,7 @@ void *osReserveHeapMemory (void *startAddress, W_ *len) sysErrorBelch( "osReserveHeapMemory: VirtualAlloc MEM_RESERVE %llu bytes \ at address %p bytes failed", - len + MBLOCK_SIZE, startAddress); + *len + MBLOCK_SIZE, startAddress); } stg_exit(EXIT_FAILURE); } @@ -499,6 +499,11 @@ void osReleaseHeapMemory (void) #endif +bool osBuiltWithNumaSupport(void) +{ + return true; +} + bool osNumaAvailable(void) { return osNumaNodes() > 1; @@ -510,9 +515,18 @@ uint32_t osNumaNodes(void) static ULONG numNumaNodes = 0; /* Cache the amount of NUMA nodes. */ - if (!numNumaNodes && !GetNumaHighestNodeNumber(&numNumaNodes)) + if (!numNumaNodes) { - numNumaNodes = 1; + if (GetNumaHighestNodeNumber(&numNumaNodes)) + { + // GetNumaHighestNodeNumber returns the highest node number + // i.e: 0 for a non-NUMA system, and >0 for a NUMA system, so add a 1. + numNumaNodes += 1; + } + else + { + numNumaNodes = 1; + } } return numNumaNodes; @@ -520,12 +534,12 @@ uint32_t osNumaNodes(void) uint64_t osNumaMask(void) { - uint64_t numaMask; - if (!GetNumaNodeProcessorMask(0, &numaMask)) - { - return 1; + // the concept of a numa node mask (c.f. numa_get_mems_allowed on POSIX) + // doesn't exist on Windows. Thus, all nodes are allowed. + if (osNumaNodes() > sizeof(StgWord)*8) { + barf("osNumaMask: too many NUMA nodes (%d)", osNumaNodes()); } - return numaMask; + return (1 << osNumaNodes()) - 1; } void osBindMBlocksToNode( |