[MLton-commit] r6445
spoons at mlton.org
spoons at mlton.org
Mon Mar 3 07:31:16 PST 2008
Additional controls used in parallel runtime.
Control the number of processors, processor affinity,
processor-local allocation, as well as space profiling.
----------------------------------------------------------------------
U mlton/branches/shared-heap-multicore/runtime/gc/controls.h
U mlton/branches/shared-heap-multicore/runtime/gc/init.c
----------------------------------------------------------------------
Modified: mlton/branches/shared-heap-multicore/runtime/gc/controls.h
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/controls.h 2008-03-03 15:29:30 UTC (rev 6444)
+++ mlton/branches/shared-heap-multicore/runtime/gc/controls.h 2008-03-03 15:31:16 UTC (rev 6445)
@@ -32,6 +32,8 @@
float nursery;
float ramSlop;
float threadShrink;
+ /* Limit available memory as a function of _max_live_. */
+ float available;
};
struct GC_controls {
@@ -41,6 +43,10 @@
bool mayProcessAtMLton;
bool messages; /* Print a message at the start and end of each gc. */
size_t oldGenArraySize; /* Arrays larger are allocated in old gen, if possible. */
+ size_t allocChunkSize; /* Minimum size reserved for any allocation request. */
+ int32_t affinityBase; /* First processor to use when setting affinity */
+ int32_t affinityStride; /* Number of processors between first and second */
+ bool restrictAvailableSize; /* Use smaller heaps to improve space profiling accuracy */
struct GC_ratios ratios;
bool rusageMeasureGC;
bool summary; /* Print a summary of gc info when program exits. */
Modified: mlton/branches/shared-heap-multicore/runtime/gc/init.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/init.c 2008-03-03 15:29:30 UTC (rev 6444)
+++ mlton/branches/shared-heap-multicore/runtime/gc/init.c 2008-03-03 15:31:16 UTC (rev 6445)
@@ -34,6 +34,16 @@
return f;
}
+static int32_t stringToInt (char *s) {
+ char *endptr;
+ int i;
+
+ i = strtol (s, &endptr, 10);
+ if (s == endptr)
+ die ("Invalid @MLton int: %s.", s);
+ return i;
+}
+
static size_t stringToBytes (char *s) {
double d;
char *endptr;
@@ -119,8 +129,35 @@
#if (defined (__MINGW32__))
fprintf (stderr, "Warning: MinGW doesn't support gc-summary.\n");
#else
- s->controls.summary = TRUE;
+ s->controls->summary = TRUE;
#endif
+ } else if (0 == strcmp (arg, "alloc-chunk")) {
+ i++;
+ if (i == argc)
+ die ("@MLton alloc-chunk missing argument.");
+ s->controls->allocChunkSize = stringToBytes (argv[i++]);
+ unless (GC_HEAP_LIMIT_SLOP < s->controls->allocChunkSize)
+ die ("@MLton alloc-chunk argument must be greater than slop.");
+ } else if (0 == strcmp (arg, "affinity-base")) {
+ i++;
+ if (i == argc)
+ die ("@MLton affinity-base missing argument.");
+ s->controls->affinityBase = stringToInt (argv[i++]);
+ } else if (0 == strcmp (arg, "affinity-stride")) {
+ i++;
+ if (i == argc)
+ die ("@MLton affinity-stride missing argument.");
+ s->controls->affinityStride = stringToInt (argv[i++]);
+ } else if (0 == strcmp (arg, "restrict-available")) {
+ i++;
+ s->controls->restrictAvailableSize = TRUE;
+ } else if (0 == strcmp (arg, "available-ratio")) {
+ i++;
+ if (i == argc)
+ die ("@MLton available-ratio missing argument.");
+ s->controls->ratios.available = stringToFloat (argv[i++]);
+ unless (1.0 < s->controls->ratios.available)
+ die ("@MLton available-ratio argument must be greater than 1.0.");
} else if (0 == strcmp (arg, "grow-ratio")) {
i++;
if (i == argc)
@@ -203,6 +240,15 @@
} else if (0 == strcmp (arg, "use-mmap")) {
i++;
GC_setCygwinUseMmap (TRUE);
+ } else if (0 == strcmp (arg, "number-processors")) {
+ i++;
+ if (i == argc)
+ die ("@MLton number-processors missing argument.");
+ if (!s->amOriginal)
+ die ("@MLton number-processors incompatible with loaded worlds.");
+ s->numberOfProcs = stringToFloat (argv[i++]);
+ /* Turn off loaded worlds -- they are unsuppoed in multi-proc mode */
+ s->controls->mayLoadWorld = FALSE;
} else if (0 == strcmp (arg, "--")) {
i++;
done = TRUE;
More information about the MLton-commit
mailing list