X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FStorage.c;h=e44348f5f4a2a5414ee3e0001554a1287279e597;hb=2846bc8a8a6a02851dd62e2c04be358902eee204;hp=a1076eb0eecb0a45fa94129fc174bc6c5b4702e0;hpb=a3a331064b5020f77bf676a3d4eb74650ae7b8c3;p=ghc-hetmet.git diff --git a/ghc/rts/Storage.c b/ghc/rts/Storage.c index a1076eb..e44348f 100644 --- a/ghc/rts/Storage.c +++ b/ghc/rts/Storage.c @@ -56,7 +56,7 @@ step *nurseries = NULL; /* array of nurseries, >1 only if SMP */ * simultaneous access by two STG threads. */ #ifdef SMP -Mutex sm_mutex = INIT_MUTEX_VAR; +Mutex sm_mutex; #endif /* @@ -129,6 +129,8 @@ initStorage( void ) initMutex(&sm_mutex); #endif + ACQUIRE_SM_LOCK; + /* allocate generation info array */ generations = (generation *)stgMallocBytes(RtsFlags.GcFlags.generations * sizeof(struct generation_), @@ -172,7 +174,7 @@ initStorage( void ) } #ifdef SMP - n_nurseries = RtsFlags.ParFlags.nNodes; + n_nurseries = n_capabilities; nurseries = stgMallocBytes (n_nurseries * sizeof(struct step_), "initStorage: nurseries"); #else @@ -220,7 +222,7 @@ initStorage( void ) #ifdef SMP if (RtsFlags.GcFlags.generations == 1) { errorBelch("-G1 is incompatible with SMP"); - stg_exit(1); + stg_exit(EXIT_FAILURE); } #endif @@ -250,6 +252,8 @@ initStorage( void ) mp_set_memory_functions(stgAllocForGMP, stgReallocForGMP, stgDeallocForGMP); IF_DEBUG(gc, statDescribeGens()); + + RELEASE_SM_LOCK; } void @@ -625,7 +629,7 @@ tidyAllocateLists (void) -------------------------------------------------------------------------- */ StgPtr -allocateLocal( StgRegTable *reg, nat n ) +allocateLocal (Capability *cap, nat n) { bdescr *bd; StgPtr p; @@ -652,36 +656,36 @@ allocateLocal( StgRegTable *reg, nat n ) /* small allocation (rCurrentAlloc; + bd = cap->r.rCurrentAlloc; if (bd == NULL || bd->free + n > bd->start + BLOCK_SIZE_W) { // The CurrentAlloc block is full, we need to find another // one. First, we try taking the next block from the // nursery: - bd = reg->rCurrentNursery->link; + bd = cap->r.rCurrentNursery->link; if (bd == NULL || bd->free + n > bd->start + BLOCK_SIZE_W) { // The nursery is empty, or the next block is already // full: allocate a fresh block (we can't fail here). ACQUIRE_SM_LOCK; bd = allocBlock(); - reg->rNursery->n_blocks++; + cap->r.rNursery->n_blocks++; RELEASE_SM_LOCK; bd->gen_no = 0; - bd->step = g0s0; + bd->step = cap->r.rNursery; bd->flags = 0; } else { // we have a block in the nursery: take it and put // it at the *front* of the nursery list, and use it // to allocate() from. - reg->rCurrentNursery->link = bd->link; + cap->r.rCurrentNursery->link = bd->link; if (bd->link != NULL) { - bd->link->u.back = reg->rCurrentNursery; + bd->link->u.back = cap->r.rCurrentNursery; } } - dbl_link_onto(bd, ®->rNursery->blocks); - reg->rCurrentAlloc = bd; - IF_DEBUG(sanity, checkNurserySanity(reg->rNursery)); + dbl_link_onto(bd, &cap->r.rNursery->blocks); + cap->r.rCurrentAlloc = bd; + IF_DEBUG(sanity, checkNurserySanity(cap->r.rNursery)); } } p = bd->free; @@ -777,9 +781,9 @@ stgAllocForGMP (size_t size_in_bytes) /* allocate and fill it in. */ #if defined(SMP) - arr = (StgArrWords *)allocateLocal(&(myCapability()->r), total_size_in_words); + arr = (StgArrWords *)allocateLocal(myTask()->cap, total_size_in_words); #else - arr = (StgArrWords *)allocateLocal(&MainCapability.r, total_size_in_words); + arr = (StgArrWords *)allocateLocal(&MainCapability, total_size_in_words); #endif SET_ARR_HDR(arr, &stg_ARR_WORDS_info, CCCS, data_size_in_words); @@ -976,6 +980,11 @@ memInventory(void) /* count the blocks we current have */ for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + for (i = 0; i < n_capabilities; i++) { + for (bd = capabilities[i].mut_lists[g]; bd != NULL; bd = bd->link) { + total_blocks += bd->blocks; + } + } for (bd = generations[g].mut_list; bd != NULL; bd = bd->link) { total_blocks += bd->blocks; }