charm AT lists.siebelschool.illinois.edu
Subject: Charm++ parallel programming system
List archive
- From: Nicolas Bock <nicolasbock AT gmail.com>
- To: Eric Bohm <ebohm AT illinois.edu>
- Cc: charm AT cs.uiuc.edu
- Subject: Re: [charm] Building a linked list of chares?
- Date: Thu, 6 Jun 2013 09:23:22 -0600
- List-archive: <http://lists.cs.uiuc.edu/pipermail/charm/>
- List-id: CHARM parallel programming system <charm.cs.uiuc.edu>
Hi Eric,
thanks for the reply. I think I found a solution, after I got over my confusion between Java and C++ :)
void append (const int ID)
{
if(next != NULL) { next->append(ID); }
else
{
next = new CProxy_LinkedListNode();
*next = CProxy_LinkedListNode::ckNew();
next->set(ID);
}
}
seems to work.
Thanks for the help,
nick
On Wed, Jun 5, 2013 at 4:47 PM, Eric Bohm <ebohm AT illinois.edu> wrote:
The missing concept here is that a chare is a parallel object which may be local or remote. When you ckNew a chare, you get back a proxy ID for the chare which you can make use as a handle to issue remote procedure calls, not a pointer to the chare itself.
The CkArray collection has been provided as parallel aware infrastructure to manage collections of chares, perhaps it would be simpler to consider a custom index scheme for a CkArray that matches the iteration method you intended in your linked list?
On 06/05/2013 04:56 PM, Nicolas Bock wrote:
Hi list,
this question may have an obvious answer, but my C++ skills are so rusty that it's not obvious to me right now...
I would like to build a linked list of chares. I envision something like the inlined code. However, I am getting a compiler error, saying that:
test.cc: In member function 'void LinkedListNode::append(int)':test.cc:28:45: error: cannot convert 'CkChareID' to 'CProxy_LinkedListNode*' in assignment
I guess I am not understanding how chares are instantiated. What does the ckNew() method do? Do I have to throw in a new operator?
Thanks already,
nick
mainmodule linkedList{mainchare Main{entry Main (CkArgMsg *msg);};
chare LinkedListNode{entry LinkedListNode ();entry void set (const int ID);entry void append (const int ID);};};
test.cc:
#include "linkedList.decl.h"
class LinkedListNode : public CBase_LinkedListNode{private:
int ID;CProxy_LinkedListNode *next;
public:
LinkedListNode (){ID = -1;next = NULL;}
void set (const int ID){this->ID = ID;}
void append (const int ID){if(next != NULL) { next->append(ID); }else{next = CProxy_LinkedListNode::ckNew();next->set(ID);}}};
class Main : public CBase_Main{private:
CProxy_LinkedListNode first;
public:
Main (CkArgMsg *msg){first = CProxy_LinkedListNode::ckNew();first.set(0);for(int i = 1; i < 10; i++){first.append(i);}}};
#include "linkedList.def.h"
_______________________________________________ charm mailing list charm AT cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/charm
_______________________________________________
charm mailing list
charm AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/charm
- [charm] Building a linked list of chares?, Nicolas Bock, 06/05/2013
- Re: [charm] Building a linked list of chares?, Eric Bohm, 06/05/2013
- Re: [charm] Building a linked list of chares?, Nicolas Bock, 06/06/2013
- Re: [charm] Building a linked list of chares?, Eric Bohm, 06/05/2013
Archive powered by MHonArc 2.6.16.