# HG changeset patch # User Merten Sach # Date 1316450588 -7200 # Node ID 2c8f3cf6c058af7cf21b0e05afc0d85f209b69d2 # Parent 99798e4438a628b15153dc950cb4a589f419f0b5 Free memory calculation diff -r 99798e4438a6 -r 2c8f3cf6c058 MasterLoop.c --- a/MasterLoop.c Mon Sep 19 16:12:01 2011 +0200 +++ b/MasterLoop.c Mon Sep 19 18:43:08 2011 +0200 @@ -107,7 +107,7 @@ // So, just make this an endless loop, and do assembly function at end // that saves its own return addr, then jumps to core_loop. while(1) - { + { //============================= MEASUREMENT STUFF ======================== #ifdef MEAS__TIME_MASTER //Total Master time includes one coreloop time -- just assume the core diff -r 99798e4438a6 -r 2c8f3cf6c058 VMS.c --- a/VMS.c Mon Sep 19 16:12:01 2011 +0200 +++ b/VMS.c Mon Sep 19 18:43:08 2011 +0200 @@ -114,6 +114,7 @@ _VMSMasterEnv->interMasterRequestsSentBy[i] = NULL; } _VMSMasterEnv->currentMasterProcrID = 0; + _VMSMasterEnv->amtOfOutstandingMem = NUM_CORES*MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE; //============================= MEASUREMENT STUFF ======================== #ifdef MEAS__TIME_MALLOC diff -r 99798e4438a6 -r 2c8f3cf6c058 vmalloc.c --- a/vmalloc.c Mon Sep 19 16:12:01 2011 +0200 +++ b/vmalloc.c Mon Sep 19 18:43:08 2011 +0200 @@ -15,6 +15,7 @@ #include #include "VMS.h" +#include "vmalloc.h" #include "Histogram/Histogram.h" #define MAX_UINT64 0xFFFFFFFFFFFFFFFF @@ -106,7 +107,7 @@ { //Find the approppiate container because we do not know it uint64 containerIdx = ((uintptr_t)chunk->prevChunkInFreeList - (uintptr_t)freeLists->bigChunks) >> 3; - if(containerIdx < (uint32)64) + if(containerIdx < (uint64)64) freeLists->bigChunksSearchVector[0] &= ~((uint64)1 << containerIdx); if(containerIdx < 128 && containerIdx >=64) freeLists->bigChunksSearchVector[1] &= ~((uint64)1 << (containerIdx-64)); @@ -251,9 +252,10 @@ else foundChunk = removeSmallChunk(freeLists, freeListIdx); + _VMSMasterEnv->amtOfOutstandingMem -= getChunkSize(foundChunk) + sizeof(MallocProlog); returnChunk = (MallocPrologAllocated*)foundChunk; returnChunk->prevChunkInFreeList = NULL;//indicates elem currently allocated - returnChunk->procrID = procrID; + returnChunk->procrID = procrID; return returnChunk + 1; } @@ -267,6 +269,7 @@ foundChunk = removeChunk(freeLists, containerIdx); //Mark as allocated + _VMSMasterEnv->amtOfOutstandingMem -= getChunkSize(foundChunk) + sizeof(MallocProlog); returnChunk = (MallocPrologAllocated*)foundChunk; returnChunk->prevChunkInFreeList = NULL;//indicates elem currently allocated returnChunk->procrID = procrID; @@ -372,6 +375,7 @@ MallocArrays* freeLists = _VMSMasterEnv->freeLists[procrID]; MallocProlog *chunkToFree = (MallocProlog*)ptrToFree - 1; uint32 containerIdx; + _VMSMasterEnv->amtOfOutstandingMem += getChunkSize(chunkToFree) + sizeof(MallocProlog); //Check for free neighbors if(chunkToFree->nextLowerInMem)