conv-core/isomalloc.c File Reference

Go to the source code of this file.

Data Structures

struct  CmiIsomallocBlock
struct  _slotblock
struct  _slotset
struct  memRegion_t
struct  _slotmsg
struct  slotOP

Typedefs

typedef CmiIsomallocBlock CmiIsomallocBlock
typedef size_t memRange_t
typedef _slotblock slotblock
typedef _slotset slotset
typedef _slotmsg slotmsg
typedef slotOP slotOP
typedef CmiIsomallocBlockList Slot

Functions

static int read_randomflag (void)
static void * block2pointer (CmiIsomallocBlock *blockHeader)
static CmiIsomallocBlockpointer2block (void *heapBlock)
static void * slot2addr (CmiInt8 slot)
static int slot2pe (CmiInt8 slot)
static CmiInt8 pe2slot (int pe)
static int length2slots (int nBytes)
static slotsetnew_slotset (CmiInt8 startslot, CmiInt8 nslots)
static CmiInt8 get_slots (slotset *ss, CmiInt8 nslots)
static void add_slots (slotset *ss, CmiInt8 sslot, CmiInt8 nslots)
static void grab_slots (slotset *ss, CmiInt8 sslot, CmiInt8 nslots)
static void free_slots (slotset *ss, CmiInt8 sslot, CmiInt8 nslots)
static void print_slots (slotset *ss)
static void * disabled_map (int nBytes)
static void disabled_unmap (void *bk)
static void disable_isomalloc (const char *why)
static void * call_mmap_fixed (void *addr, size_t len)
static void * call_mmap_anywhere (size_t len)
static void call_munmap (void *addr, size_t len)
static int init_map (char **argv)
 CpvStaticDeclare (int, zerofd)
static void * call_mmap (void *addr, size_t len, int flags)
 Maps this address with these flags.
static CmiIsomallocBlockmap_slots (CmiInt8 slot, CmiInt8 nslots)
 maps the virtual memory associated with slot using mmap
static void unmap_slots (CmiInt8 slot, CmiInt8 nslots)
static void map_failed (CmiInt8 s, CmiInt8 n)
 CpvStaticDeclare (slotset *, myss)
static void * __cur_stack_frame (void)
static void * __static_data_loc (void)
static int pointer_lt (const char *a, const char *b)
static int pointer_ge (const char *a, const char *b)
static char * pmin (char *a, char *b)
static char * pmax (char *a, char *b)
static int bad_location (char *loc)
static memRange_t divide_range (memRange_t len, int n)
static int partially_good (char *start, memRange_t len, int n)
static int good_range (char *start, memRange_t len, int n)
static void check_range (char *start, char *end, memRegion_t *max)
static memRegion_t find_free_region (memRegion_t *used, int nUsed, int atLeast)
static int find_largest_free_region (memRegion_t *destRegion)
static void init_ranges (char **argv)
static slotmsgprepare_slotmsg (CmiInt8 slot, CmiInt8 nslots)
static void grab_remote (slotmsg *msg)
static void free_remote (slotmsg *msg)
static void init_comm (char **argv)
static void one_slotOP (const slotOP *op, int pe, CmiInt8 s, CmiInt8 n)
static void all_slotOP (const slotOP *op, CmiInt8 s, CmiInt8 n)
void * CmiIsomalloc (int size)
void CmiIsomallocPup (pup_er p, void **blockPtrPtr)
void CmiIsomallocFree (void *blockPtr)
CmiInt8 CmiIsomallocLength (void *block)
int CmiIsomallocInRange (void *addr)
void CmiIsomallocInit (char **argv)
static char * Slot_toUser (Slot *s)
static SlotSlot_fmUser (void *s)
CmiIsomallocBlockListCmiIsomallocBlockListNew (void)
void CmiIsomallocBlockListPup (pup_er p, CmiIsomallocBlockList **lp)
void CmiIsomallocBlockListDelete (CmiIsomallocBlockList *l)
void * CmiIsomallocBlockListMalloc (CmiIsomallocBlockList *l, int nBytes)
void CmiIsomallocBlockListFree (void *block)

Variables

static int _sync_iso = 0
static size_t slotsize
static CmiInt8 numslots = 0
static char * isomallocStart = NULL
static char * isomallocEnd = NULL
static int disabled_map_warned = 0
static const memRange_t meg = 1024u*1024u
static const memRange_t gig = 1024u*1024u*1024u
static int grab_remote_idx
static int free_remote_idx
static slotOP grabOP
static slotOP freeOP


Typedef Documentation

typedef struct CmiIsomallocBlock CmiIsomallocBlock

Definition at line 50 of file isomalloc.c.

typedef size_t memRange_t

Definition at line 61 of file isomalloc.c.

typedef struct _slotblock slotblock

typedef struct _slotset slotset

typedef struct _slotmsg slotmsg

typedef struct slotOP slotOP

Definition at line 836 of file isomalloc.c.

typedef CmiIsomallocBlockList Slot

Definition at line 1002 of file isomalloc.c.


Function Documentation

static int read_randomflag ( void   )  [static]

Definition at line 30 of file isomalloc.c.

References CmiLock(), CmiUnlock(), and smp_mutex.

Referenced by CmiIsomallocInit().

static void* block2pointer ( CmiIsomallocBlock blockHeader  )  [static]

Definition at line 53 of file isomalloc.c.

Referenced by CmiIsomalloc(), and CmiIsomallocPup().

static CmiIsomallocBlock* pointer2block ( void *  heapBlock  )  [static]

Definition at line 56 of file isomalloc.c.

Referenced by CmiIsomallocFree(), CmiIsomallocLength(), and CmiIsomallocPup().

static void* slot2addr ( CmiInt8  slot  )  [static]

Definition at line 76 of file isomalloc.c.

References isomallocStart, and slotsize.

Referenced by map_failed(), map_slots(), and unmap_slots().

static int slot2pe ( CmiInt8  slot  )  [static]

Definition at line 79 of file isomalloc.c.

References numslots.

Referenced by all_slotOP().

static CmiInt8 pe2slot ( int  pe  )  [static]

Definition at line 82 of file isomalloc.c.

References numslots.

Referenced by init_ranges(), and one_slotOP().

static int length2slots ( int  nBytes  )  [static]

Definition at line 86 of file isomalloc.c.

References slotsize.

Referenced by CmiIsomalloc(), CmiIsomallocFree(), and CmiIsomallocPup().

static slotset* new_slotset ( CmiInt8  startslot,
CmiInt8  nslots 
) [static]

Definition at line 108 of file isomalloc.c.

References _slotset::buf, _slotset::emptyslots, malloc_reentrant(), _slotset::maxbuf, _slotblock::nslots, and _slotblock::startslot.

Referenced by init_ranges().

static CmiInt8 get_slots ( slotset ss,
CmiInt8  nslots 
) [static]

Definition at line 128 of file isomalloc.c.

References _slotset::buf, _slotset::emptyslots, _slotset::maxbuf, _slotblock::nslots, and _slotblock::startslot.

Referenced by CmiIsomalloc().

static void add_slots ( slotset ss,
CmiInt8  sslot,
CmiInt8  nslots 
) [static]

Definition at line 141 of file isomalloc.c.

References _slotset::buf, _slotset::maxbuf, and _slotblock::nslots.

Referenced by grab_slots().

static void grab_slots ( slotset ss,
CmiInt8  sslot,
CmiInt8  nslots 
) [static]

Definition at line 179 of file isomalloc.c.

References add_slots(), _slotset::buf, _slotset::emptyslots, _slotset::maxbuf, _slotblock::nslots, and _slotblock::startslot.

Referenced by CmiIsomalloc(), grab_remote(), and init_comm().

static void free_slots ( slotset ss,
CmiInt8  sslot,
CmiInt8  nslots 
) [static]

Definition at line 208 of file isomalloc.c.

References _slotset::buf, _slotset::emptyslots, _slotset::maxbuf, _slotblock::nslots, and _slotblock::startslot.

Referenced by free_remote(), and init_comm().

static void print_slots ( slotset ss  )  [static]

Definition at line 250 of file isomalloc.c.

References _slotset::buf, CmiMyPe(), CmiPrintf(), _slotset::emptyslots, _slotset::maxbuf, _slotblock::nslots, and _slotblock::startslot.

static void* disabled_map ( int  nBytes  )  [static]

Definition at line 268 of file isomalloc.c.

References CmiError(), CmiMyPe(), disabled_map_warned, and malloc().

Referenced by CmiIsomalloc().

static void disabled_unmap ( void *  bk  )  [static]

Definition at line 278 of file isomalloc.c.

References free().

Referenced by CmiIsomallocFree().

static void disable_isomalloc ( const char *  why  )  [static]

Definition at line 283 of file isomalloc.c.

References CmiMyPe(), CmiPrintf(), isomallocEnd, and isomallocStart.

Referenced by CmiIsomallocInit(), and init_ranges().

static void * call_mmap_fixed ( void *  addr,
size_t  len 
) [static]

Definition at line 294 of file isomalloc.c.

References CmiAbort().

Referenced by bad_location(), and map_slots().

static void * call_mmap_anywhere ( size_t  len  )  [static]

Definition at line 297 of file isomalloc.c.

References CmiAbort().

Referenced by find_largest_free_region().

static void call_munmap ( void *  addr,
size_t  len 
) [static]

Definition at line 300 of file isomalloc.c.

References CmiAbort().

Referenced by bad_location(), find_largest_free_region(), map_slots(), and unmap_slots().

static int init_map ( char **  argv  )  [static]

Definition at line 305 of file isomalloc.c.

Referenced by CmiIsomallocInit().

CpvStaticDeclare ( int  ,
zerofd   
)

static void* call_mmap ( void *  addr,
size_t  len,
int  flags 
) [static]

Maps this address with these flags.

Definition at line 323 of file isomalloc.c.

static CmiIsomallocBlock* map_slots ( CmiInt8  slot,
CmiInt8  nslots 
) [static]

maps the virtual memory associated with slot using mmap

Definition at line 371 of file isomalloc.c.

References call_mmap_fixed(), call_munmap(), CmiMyPe(), CmiPrintf(), slot2addr(), and slotsize.

Referenced by CmiIsomalloc(), and CmiIsomallocPup().

static void unmap_slots ( CmiInt8  slot,
CmiInt8  nslots 
) [static]

Definition at line 404 of file isomalloc.c.

References call_munmap(), CmiMyPe(), CmiPrintf(), slot2addr(), and slotsize.

Referenced by CmiIsomallocFree(), and CmiIsomallocPup().

static void map_failed ( CmiInt8  s,
CmiInt8  n 
) [static]

Definition at line 414 of file isomalloc.c.

References CmiAbort(), CmiError(), slot2addr(), and slotsize.

Referenced by CmiIsomalloc(), and CmiIsomallocPup().

CpvStaticDeclare ( slotset ,
myss   
)

static void* __cur_stack_frame ( void   )  [static]

Definition at line 436 of file isomalloc.c.

Referenced by find_largest_free_region().

static void* __static_data_loc ( void   )  [static]

Definition at line 443 of file isomalloc.c.

Referenced by find_largest_free_region().

static int pointer_lt ( const char *  a,
const char *  b 
) [static]

Definition at line 452 of file isomalloc.c.

Referenced by CmiIsomallocInRange(), find_free_region(), pmax(), and pmin().

static int pointer_ge ( const char *  a,
const char *  b 
) [static]

Definition at line 455 of file isomalloc.c.

Referenced by CmiIsomallocInRange().

static char* pmin ( char *  a,
char *  b 
) [static]

Definition at line 459 of file isomalloc.c.

References pointer_lt().

Referenced by check_range(), and find_free_region().

static char* pmax ( char *  a,
char *  b 
) [static]

Definition at line 460 of file isomalloc.c.

References pointer_lt().

Referenced by find_free_region().

static int bad_location ( char *  loc  )  [static]

Definition at line 468 of file isomalloc.c.

References call_mmap_fixed(), call_munmap(), CmiMyPe(), CmiPrintf(), and slotsize.

Referenced by good_range(), and partially_good().

static memRange_t divide_range ( memRange_t  len,
int  n 
) [static]

Definition at line 482 of file isomalloc.c.

References n.

Referenced by check_range(), good_range(), and partially_good().

static int partially_good ( char *  start,
memRange_t  len,
int  n 
) [static]

Definition at line 487 of file isomalloc.c.

References bad_location(), divide_range(), and n.

Referenced by check_range().

static int good_range ( char *  start,
memRange_t  len,
int  n 
) [static]

Definition at line 497 of file isomalloc.c.

References bad_location(), divide_range(), and n.

Referenced by check_range().

static void check_range ( char *  start,
char *  end,
memRegion_t max 
) [static]

Definition at line 509 of file isomalloc.c.

References CmiMyPe(), CmiPrintf(), divide_range(), good_range(), max(), n, partially_good(), and pmin().

Referenced by find_free_region().

static memRegion_t find_free_region ( memRegion_t used,
int  nUsed,
int  atLeast 
) [static]

Definition at line 572 of file isomalloc.c.

References check_range(), max(), pmax(), pmin(), and pointer_lt().

Referenced by find_largest_free_region().

static int find_largest_free_region ( memRegion_t destRegion  )  [static]

Definition at line 603 of file isomalloc.c.

References __cur_stack_frame(), __static_data_loc(), call_mmap_anywhere(), call_munmap(), CmiMyPe(), CmiPrintf(), errno, find_free_region(), free(), memRegion_t::len, malloc(), p, memRegion_t::start, type, and memRegion_t::type.

Referenced by init_ranges().

static void init_ranges ( char **  argv  )  [static]

Definition at line 678 of file isomalloc.c.

References _sync_iso, CmiAbort(), CmiBarrier(), CmiMyPe(), CmiMyRank(), CmiNodeAllBarrier(), CmiPrintf(), disable_isomalloc(), find_largest_free_region(), isomallocEnd, isomallocStart, memRegion_t::len, new_slotset(), numslots, pe2slot(), printf(), s, sleep(), slotsize, and memRegion_t::start.

Referenced by CmiIsomallocInit().

static slotmsg* prepare_slotmsg ( CmiInt8  slot,
CmiInt8  nslots 
) [static]

Definition at line 808 of file isomalloc.c.

References CmiAlloc(), CmiMyPe(), _slotmsg::nslots, _slotmsg::pe, and _slotmsg::slot.

Referenced by one_slotOP().

static void grab_remote ( slotmsg msg  )  [static]

Definition at line 817 of file isomalloc.c.

References CmiFree(), grab_slots(), _slotmsg::nslots, and _slotmsg::slot.

Referenced by init_comm().

static void free_remote ( slotmsg msg  )  [static]

Definition at line 823 of file isomalloc.c.

References CmiFree(), free_slots(), _slotmsg::nslots, and _slotmsg::slot.

Referenced by init_comm().

static void init_comm ( char **  argv  )  [static]

Definition at line 839 of file isomalloc.c.

References CmiRegisterHandler(), free_remote(), free_remote_idx, free_slots(), freeOP, grab_remote(), grab_remote_idx, grab_slots(), grabOP, slotOP::local, and slotOP::remote.

Referenced by CmiIsomallocInit().

static void one_slotOP ( const slotOP op,
int  pe,
CmiInt8  s,
CmiInt8  n 
) [static]

Definition at line 851 of file isomalloc.c.

References CmiMyPe(), Converse::CmiSyncSendAndFree(), freeOP, slotOP::local, pe2slot(), prepare_slotmsg(), and slotOP::remote.

Referenced by all_slotOP().

static void all_slotOP ( const slotOP op,
CmiInt8  s,
CmiInt8  n 
) [static]

Definition at line 876 of file isomalloc.c.

References one_slotOP(), and slot2pe().

Referenced by CmiIsomallocFree(), and CmiIsomallocPup().

void* CmiIsomalloc ( int  size  ) 

Definition at line 885 of file isomalloc.c.

References block2pointer(), CmiAbort(), CmiError(), CmiMyPe(), disabled_map(), get_slots(), grab_slots(), isomallocStart, CmiIsomallocBlock::length, length2slots(), map_failed(), map_slots(), n, s, size, and CmiIsomallocBlock::slot.

Referenced by CtgGlobalStruct::allocate(), CmiIsomallocBlockListMalloc(), CmiIsomallocBlockListNew(), and CthAllocateStack().

void CmiIsomallocPup ( pup_er  p,
void **  blockPtrPtr 
)

Definition at line 906 of file isomalloc.c.

References all_slotOP(), block2pointer(), CmiAbort(), grabOP, isomallocStart, CmiIsomallocBlock::length, length, length2slots(), map_failed(), map_slots(), n, pointer2block(), pup_bytes(), pup_isDeleting(), pup_isRestarting(), pup_isUnpacking(), pup_isUserlevel(), s, CmiIsomallocBlock::slot, and unmap_slots().

Referenced by CmiIsomallocBlockListPup(), CthPupBase(), and CtgGlobalStruct::pup().

void CmiIsomallocFree ( void *  blockPtr  ) 

Definition at line 946 of file isomalloc.c.

References all_slotOP(), disabled_unmap(), freeOP, isomallocStart, CmiIsomallocBlock::length, length2slots(), n, pointer2block(), s, CmiIsomallocBlock::slot, and unmap_slots().

Referenced by CmiIsomallocBlockListDelete(), CmiIsomallocBlockListFree(), and CthThreadBaseFree().

CmiInt8 CmiIsomallocLength ( void *  block  ) 

Definition at line 962 of file isomalloc.c.

References CmiIsomallocBlock::length, and pointer2block().

Referenced by meta_realloc().

int CmiIsomallocInRange ( void *  addr  ) 

Definition at line 968 of file isomalloc.c.

References isomallocEnd, isomallocStart, pointer_ge(), and pointer_lt().

Referenced by checkAddress(), meta_free(), and meta_realloc().

static char* Slot_toUser ( Slot s  )  [static]

Definition at line 1005 of file isomalloc.c.

References s.

Referenced by checkSlot(), CmiIsomallocBlockListMalloc(), freeSlot(), printSlot(), setSlot(), and slotAbort().

static Slot* Slot_fmUser ( void *  s  )  [static]

Definition at line 1006 of file isomalloc.c.

Referenced by CmiIsomallocBlockListFree(), CmiMemoryMarkBlock(), and meta_realloc().

CmiIsomallocBlockList* CmiIsomallocBlockListNew ( void   ) 

Definition at line 1010 of file isomalloc.c.

References CmiIsomalloc().

Referenced by ArmciVirtualProcessor::ArmciVirtualProcessor(), and TCharm::TCharm().

void CmiIsomallocBlockListPup ( pup_er  p,
CmiIsomallocBlockList **  lp 
)

Definition at line 1023 of file isomalloc.c.

References CmiAbort(), CmiIsomallocPup(), Slot::next, pup_isDeleting(), and pup_isUnpacking().

Referenced by ArmciVirtualProcessor::pup(), and TCharm::pupThread().

void CmiIsomallocBlockListDelete ( CmiIsomallocBlockList l  ) 

Definition at line 1058 of file isomalloc.c.

References CmiIsomallocFree(), and Slot::next.

Referenced by TCharm::clear(), ArmciVirtualProcessor::~ArmciVirtualProcessor(), and TCharm::~TCharm().

void* CmiIsomallocBlockListMalloc ( CmiIsomallocBlockList l,
int  nBytes 
)

Definition at line 1071 of file isomalloc.c.

References CmiIsomalloc(), n, CmiIsomallocBlockList::next, CmiIsomallocBlockList::prev, and Slot_toUser().

Referenced by ArmciVirtualProcessor::BlockMalloc(), and meta_malloc().

void CmiIsomallocBlockListFree ( void *  block  ) 

Definition at line 1084 of file isomalloc.c.

References CmiAbort(), CmiIsomallocFree(), n, and Slot_fmUser().

Referenced by ARMCI_Free(), and meta_free().


Variable Documentation

int _sync_iso = 0 [static]

Definition at line 28 of file isomalloc.c.

Referenced by CmiIsomallocInit(), and init_ranges().

size_t slotsize [static]

Definition at line 64 of file isomalloc.c.

Referenced by bad_location(), init_ranges(), length2slots(), map_failed(), map_slots(), slot2addr(), and unmap_slots().

CmiInt8 numslots = 0 [static]

Definition at line 67 of file isomalloc.c.

Referenced by init_ranges(), pe2slot(), and slot2pe().

char* isomallocStart = NULL [static]

Definition at line 72 of file isomalloc.c.

Referenced by CmiIsomalloc(), CmiIsomallocFree(), CmiIsomallocInRange(), CmiIsomallocPup(), disable_isomalloc(), init_ranges(), and slot2addr().

char* isomallocEnd = NULL [static]

Definition at line 73 of file isomalloc.c.

Referenced by CmiIsomallocInRange(), disable_isomalloc(), and init_ranges().

int disabled_map_warned = 0 [static]

Definition at line 267 of file isomalloc.c.

Referenced by disabled_map().

const memRange_t meg = 1024u*1024u [static]

Definition at line 462 of file isomalloc.c.

const memRange_t gig = 1024u*1024u*1024u [static]

Definition at line 463 of file isomalloc.c.

int grab_remote_idx [static]

Definition at line 828 of file isomalloc.c.

Referenced by init_comm().

int free_remote_idx [static]

Definition at line 828 of file isomalloc.c.

Referenced by init_comm().

slotOP grabOP [static]

Definition at line 837 of file isomalloc.c.

Referenced by CmiIsomallocPup(), and init_comm().