X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FCapability.c;h=8cfcba0b88c34fc6e3ad4c7b865041ff62b0601f;hp=0e4d5a6a30594e6e8d8e52d8d3b1626bc7dcb226;hb=03a58fc9816fbd5df44adb9d77afdbf9944cc120;hpb=b645ce0909ac697a3dd33dd4825e844cf0a8ff5c diff --git a/rts/Capability.c b/rts/Capability.c index 0e4d5a6..8cfcba0 100644 --- a/rts/Capability.c +++ b/rts/Capability.c @@ -84,30 +84,33 @@ findSpark (Capability *cap) return 0; } - // first try to get a spark from our own pool. - // We should be using reclaimSpark(), because it works without - // needing any atomic instructions: - // spark = reclaimSpark(cap->sparks); - // However, measurements show that this makes at least one benchmark - // slower (prsa) and doesn't affect the others. - spark = tryStealSpark(cap); - if (spark != NULL) { - cap->sparks_converted++; - - // Post event for running a spark from capability's own pool. - traceSchedEvent(cap, EVENT_RUN_SPARK, cap->r.rCurrentTSO, 0); - - return spark; - } + do { + retry = rtsFalse; - if (n_capabilities == 1) { return NULL; } // makes no sense... + // first try to get a spark from our own pool. + // We should be using reclaimSpark(), because it works without + // needing any atomic instructions: + // spark = reclaimSpark(cap->sparks); + // However, measurements show that this makes at least one benchmark + // slower (prsa) and doesn't affect the others. + spark = tryStealSpark(cap); + if (spark != NULL) { + cap->sparks_converted++; - debugTrace(DEBUG_sched, - "cap %d: Trying to steal work from other capabilities", - cap->no); + // Post event for running a spark from capability's own pool. + traceSchedEvent(cap, EVENT_RUN_SPARK, cap->r.rCurrentTSO, 0); - do { - retry = rtsFalse; + return spark; + } + if (!emptySparkPoolCap(cap)) { + retry = rtsTrue; + } + + if (n_capabilities == 1) { return NULL; } // makes no sense... + + debugTrace(DEBUG_sched, + "cap %d: Trying to steal work from other capabilities", + cap->no); /* visit cap.s 0..n-1 in sequence until a theft succeeds. We could start at a random place instead of 0 as well. */