Skip to Content.
Sympa Menu

charm - [charm] out of memory error when unpacking a message with my own static unpack routine

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

[charm] out of memory error when unpacking a message with my own static unpack routine


Chronological Thread 
  • From: Elena Williams <elena.williams1 AT gmail.com>
  • To: charm AT cs.uiuc.edu
  • Subject: [charm] out of memory error when unpacking a message with my own static unpack routine
  • Date: Fri, 2 Sep 2011 16:44:48 +0100
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>

Dear Charm Developers,

I am getting the error: *Fatal error on PE 1> Could not malloc() 8 bytes--are we out of memory?* when my unpack routine gets called. I don't think I can actually be out of memory as this code works fine on a single processor and it only happens when I call CkAllocBuffer. Have you seen this error before or are you able to give me any advice / pointers on where I might be going wrong?

I have included my stack traceback below along with the relevant source code.

Any help would be much appreciated,

Thanks

Elly

camelot01% ./charmrun ./gen +p2
Charm++: scheduler running in netpoll mode.
Charm++> Running on 2 unique compute nodes (4-way SMP).
Charm++> Cpu topology info:
PE to node map: 0 1 
Node to PE map:
Chip #0: 0 
Chip #1: 1 
Charm++> cpu topology info is gathered in 0.001 seconds.
Running "Simple Charm State Generator" on 2 processors.
Packing StateMsg: size 2564
Unpacking StateMsg: size less dynamically created stuff 40
------------- Processor 1 Exiting: Called CmiAbort ------------
Reason: Could not malloc() 8 bytes--are we out of memory?
[1] Stack Traceback:
  [1:0] CmiAbort+0x55  [0x4f88f5]
  [1:1] CmiOutOfMemory+0x45  [0x46cd25]
  [1:2] malloc+0x48  [0x46cde8]
  [1:3] _Znwm+0x2a  [0x2aaaaad73fea]
  [1:4] _Znam+0x9  [0x2aaaaad740f9]
  [1:5] _ZN8StateMsgC1ERPc+0xc8  [0x454ec8]
  [1:6] _ZN8StateMsg6unpackEPv+0x5c  [0x45526c]
  [1:7] _Z15CkUnpackMessagePP8envelope+0xb4  [0x47a244]
  [1:8] _Z15_processHandlerPvP11CkCoreState+0xd3d  [0x48466d]
  [1:9] CmiHandleMessage+0x5d  [0x4fd19d]
  [1:10] CsdScheduleForever+0x3c  [0x4fd35c]
  [1:11] CsdScheduler+0x25  [0x4fd5a5]
  [1:12] ConverseInit+0xf8f  [0x4fbc1f]
  [1:13] main+0x2c  [0x48780c]
  [1:14] __libc_start_main+0xd3  [0x2aaaab1344f3]
  [1:15] __gxx_personality_v0+0xba  [0x45409a]
Fatal error on PE 1> Could not malloc() 8 bytes--are we out of memory?

main.h:
#ifndef _MAIN_H
#define _MAIN_H
#include "main.decl.h"

class StateMsg : public CMessage_StateMsg {
  long numStates;
  long sizeFullStates;
  long sizeState;
  FullState **states;
  friend class CMessage_StateMsg;
 public:
  int ttl;
  StateMsg(long n, long ss);
  StateMsg(FullState* t);
  StateMsg(char *&b);
  ~StateMsg();
...
  static void *pack(StateMsg *);
  static StateMsg  *unpack(void *);
};

main.C:
StateMsg::StateMsg(long n, long ss){
  ttl = CkNumPes();
  numStates = n;
  sizeFullStates = 0;
  sizeState = ss;
  states = new FullState* [n];
}

StateMsg::StateMsg(FullState* t){
  ttl = CkNumPes();
  numStates = 1;
  sizeState = t->size();
  sizeFullStates = t->getSize();
  states = new FullState* [numStates];
  states[0] = t;;
}

StateMsg::StateMsg(char *&b){
  memcpy(&ttl,b,sizeof(int));
  memcpy(&numStates,b,sizeof(long)); b += sizeof(long);
  memcpy(&sizeFullStates,b,sizeof(long)); b += sizeof(long);
  memcpy(&sizeState,b,sizeof(long)); b += sizeof(long);
  states = new FullState* [numStates];
  for(int i=0; i<numStates; i++){
    states[i] = new FullState(b);
  }
}

StateMsg::~StateMsg(){
  delete[] states;
}

void* StateMsg::pack(StateMsg* m){

  int i,j,idata, count;
  unsigned long long ldata;
  void* pdata;
  long size = sizeof(int) + (3 * sizeof(long)); //preamble of buffer dedicated to the ttl, numStates, sizeFullStates, sizeState                                         
  size += m->sizeFullStates; //states array                                                                                                                             

  #ifdef VERBOSE_MSG
  CkPrintf("Packing StateMsg: size %d\n",size);
  #endif

  char *p = (char *) CkAllocBuffer(m, size);
  char *t = p;

  //ttl                                                                                                                                                                 
  memcpy(t,&m->ttl,sizeof(int)); t += sizeof(int);

  //numStates                                                                                                                                                           
  memcpy(t,&m->numStates,sizeof(long)); t += sizeof(long);

  //sizeFullStates                                                                                                                                                      
  memcpy(t,&m->sizeFullStates,sizeof(long)); t += sizeof(long);

  //sizeState                                                                                                                                                           
  memcpy(t,&m->sizeState,sizeof(long)); t += sizeof(long);

  for(i=0; i<m->numStates; i++){ //states                                                                                                                               
     //current state vector                                                                                                                                             
    memcpy(t,m->states[i]->getCurrent(),m->sizeState); t += m->sizeState;

    //unsigned long long id                                                                                                                                             
    ldata = m->states[i]->getID(); pdata = &ldata;
    memcpy(t,pdata,sizeof(unsigned long long)); t += sizeof(unsigned long long);

    //int numberEnabled                                                                                                                                                 
    count = m->states[i]->getNumberEnabled(); pdata = &count;
    memcpy(t,pdata,sizeof(int)); t += sizeof(int);

    //int* enabledTrans                                                                                                                                                 
    for(j=0; j<count; j++, t+=sizeof(int)){
      idata = m->states[i]->getEnabledTrans(j); pdata = &idata;
      memcpy(t,pdata,sizeof(int));
    }
    delete m->states[i];                                                                            
  }
  delete m;
  return p;
}

StateMsg* StateMsg::unpack(void *buf){
  char *in = (char *) buf;
  #ifdef VERBOSE_MSG
  CkPrintf("Unpacking StateMsg: size less dynamically created stuff %d\n",sizeof(StateMsg));
  #endif
  StateMsg *t = (StateMsg*)CkAllocBuffer(buf,sizeof(StateMsg)); <-------------- this line is causing me problems
  t = new ((void*)t) StateMsg(in);
  CkFreeMsg(buf);
  return t;
}




  • [charm] out of memory error when unpacking a message with my own static unpack routine, Elena Williams, 09/02/2011

Archive powered by MHonArc 2.6.16.

Top of Page