summaryrefslogtreecommitdiff
path: root/rts/win32/OSMem.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/win32/OSMem.c')
-rw-r--r--rts/win32/OSMem.c30
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(