Skip to Content.
Sympa Menu

charm - [charm] Problems with sending messages across address-space boundary

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

[charm] Problems with sending messages across address-space boundary


Chronological Thread 
  • From: Elena Williams <elena.williams1 AT gmail.com>
  • To: charm AT cs.uiuc.edu
  • Subject: [charm] Problems with sending messages across address-space boundary
  • Date: Thu, 11 Aug 2011 19:43:02 +0100
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>

Dear Charm Developers,

When using my own variable-size message type, MsgType (inheriting from CMessage_MsgType), the contents of the message is lost when sent to another processor.

Is it the case that I must override the default serialization methods generated by the CHARM++ interface translator, regardless of what the data structure being packed is?

In order for my code to compile I need include my msgType.h file in each of the implementation files for my chare arrays. This doesn't seem correct to me? If I don't include msgType.h, I get the following errors:

hash.C:42:18: error: invalid use of incomplete type ‘struct MsgType’
msgType.decl.h:10:7: error: forward declaration of ‘struct MsgType’
... similar for  worker.C ...

Any help with this would be much appreciated - I have copied relevant parts of my code files below for information,

Thanks

Elly

Makefile
CHARMDIR = $(HOME)/charm-6.2
CHARMC = $(CHARMDIR)/bin/charmc $(OPTS)

default: all
all: gen

gen : main.o msgType.o hash.o worker.o info.o user.o timer.o
$(CHARMC) -language charm++ -g -Wall -o gen main.o msgType.o hash.o worker.o info.o user.o timer.o

main.o : main.C common.h main.h main.decl.h main.def.h msgType.decl.h hash.decl.h worker.decl.h
$(CHARMC) -g -Wall -c main.C

main.decl.h main.def.h : main.ci
$(CHARMC) main.ci

msgType.o : msgType.C msgType.h msgType.decl.h msgType.def.h
$(CHARMC) -g -Wall -c msgType.C

msgType.decl.h msgType.def.h : msgType.ci
$(CHARMC) msgType.ci

hash.o : hash.C common.h dyna.h msgType.h hash.h hash.decl.h hash.def.h main.decl.h worker.decl.h msgType.decl.h
$(CHARMC) -g -Wall -c hash.C

hash.decl.h hash.def.h : hash.ci
$(CHARMC) hash.ci

worker.o : worker.C common.h dyna.h queue.h user.h info.h timer.h element.h full.h msgType.h worker.h worker.decl.h worker.def.h main.decl.h hash.decl.h msgType.decl.h
$(CHARMC) -g -Wall -c worker.C

worker.decl.h worker.def.h : worker.ci
$(CHARMC) worker.ci

info.o : info.C common.h dyna.h info.h
$(CHARMC) -g -Wall -c info.C

user.o : user.C common.h user.h
$(CHARMC) -g -Wall -c user.C

timer.o : timer.C common.h timer.h
$(CHARMC) -g -Wall -c timer.C

clean:
rm -f *.decl.h *.def.h *.o
rm -f gen charmrun

main.ci
mainmodule main {
...
  extern module msgType;
  extern module hash;
  extern module worker;
  
...
};
main.C
#include "main.decl.h"
#include "main.h"
#include "msgType.decl.h"
#include "worker.decl.h"
#include "hash.decl.h"
#include "common.h"
...
#include "main.def.h"

msgType.ci
module msgType {
  message MsgType {
    int fresh[];
    unsigned long long targets[];
  };
};

msgType.C
#include "msgType.decl.h"
#include "msgType.h"
//nothing else in this file
#include "msgType.def.h"

msgType.h
#ifndef MSGTYPE_H
#define MSGTYPE_H

class MsgType : public CMessage_MsgType {
  int sender;
  int length;
  int *fresh;
  unsigned long long *targets;
  friend class CMessage_MsgType;
 public:
  MsgType(int s,int l,int *f,unsigned long long *t):sender(s),length(l),fresh(f),targets(t){}
  inline int getSender() const { return sender; }
  inline int getLength() const { return length; }
  inline unsigned long long getTarget(int i) const { return targets[i]; }
  inline int getFresh(int i) const { return fresh[i]; }
  inline void setFresh(int i) { fresh[i] = 1; }
};

#endif

hash.ci
module hash {

       extern module msgType;

       array [1D] StateHashTable{
            entry StateHashTable();
    entry void registerStates(MsgType *msg);
             ...
};
};


hash.C
#include "hash.decl.h"
#include "common.h"
#include "dyna.h"
#include "msgType.h"
#include "hash.h"
#include "main.decl.h"
#include "worker.decl.h"
#include "msgType.decl.h"
...
void StateHashTable::registerStates(MsgType *msg) {
  int count = msg->getLength();
  unsigned long long id;
  for(int i = 0; i < count; i++){
    id = msg->getTarget(i);
    if(registerState(id))
      msg->setFresh(i);
  }
  workerProxy[msg->getSender()].update(msg);
}
...
#include "hash.def.h"

worker.ci
module worker {

  extern module msgType;

       array [1D] Worker{
            entry Worker();
    entry void start();
    entry void update(MsgType *msg);
};
};

worker.C
#include "worker.decl.h"
#include "common.h"
#include "dyna.h"
#include "queue.h"
#include "user.h"
#include "info.h"
#include "timer.h"
#include "element.h"
#include "full.h"
#include "msgType.h"
#include "worker.h"
#include "main.decl.h"
#include "hash.decl.h"
#include "msgType.decl.h"
...
void Worker::sendStates(int index){
  QueueEntry<FullState> *current = potentialStacks[index]->getIndex((msgCentre->getPendingStateCount(index)));
  int l = msgCentre->getQueueingStateCount(index);
  int *fresh = new int[l];
  unsigned long long *targets = new unsigned long long[l];
  int element = 0;
  while(current) {
    fresh[element] = 0;
    targets[element] = current->getItem()->getID();
    element++;
    current = current->getNext();
  }
  MsgType *msgptr = new (l,l,0) MsgType(thisIndex,l,fresh,targets);

  hashProxy[index].registerStates(msgptr);
  msgCentre->sentMsg(index);
}
...
#include "worker.def.h"










Archive powered by MHonArc 2.6.16.

Top of Page