Skip to Content.
Sympa Menu

charm - Re: [charm] how to suspend/resume a chare ?

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

Re: [charm] how to suspend/resume a chare ?


Chronological Thread 
  • From: Christian Perez <christian.perez AT inria.fr>
  • To: gzheng AT illinois.edu
  • Cc: Filippo Gioachin <gioachin AT uiuc.edu>, "kale AT illinois.edu" <kale AT illinois.edu>, "charm AT cs.uiuc.edu" <charm AT cs.uiuc.edu>, "Kale, Laxmikant V" <kale AT cs.uiuc.edu>, Gengbin Zheng <zhenggb AT gmail.com>
  • Subject: Re: [charm] how to suspend/resume a chare ?
  • Date: Wed, 26 May 2010 13:37:32 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>
  • Organization: INRIA/LIP

On 05/25/2010 07:22 PM, Gengbin Zheng wrote:
Is the caller of connect() a thread (I mean is connect() a threaded
entry function)?
It is not a threaded charm method: when I tried to turn it into a [threaded] entry
method it I've got an error when invoking JNI method from this chare. I shall investigate it later.
another way of doing this without using thread is to send component_B
proxy to component_A, and let component_A directly send its proxy to
component_B.
That is the alternative solution: the good news is that it works(*),
the not-so-good news is that it make the mapping between components
and charm objects a litte more complex.

(*) I need to use a hack that seems weird to me:

Chare component_A : SimpleInterface {
void set_s(CProxy_SetSimpleInterface& pssi, CProxy_SimpleInterface& psi) {
pssi.set_si(psi);
}

works while the following version does not work (psi is changed to thishandle)


Chare component_A : SimpleInterface {
void set_s(CProxy_SetSimpleInterface& pssi, CProxy_SimpleInterface& psi) {
pssi.set_si(thishandle);
}

psi is obtained from a call to CProxy_component_A::ckNew.

Question: how can I create a Proxy from within a chare?

I tried

pssi.set_si(CProxy_SimpleInterface(thishandle));

but it fails with the same error :

[0] Assertion "n<len" failed in file cklists.h line 221.
------------- Processor 0 Exiting: Called CmiAbort ------------
Reason:
[0] Stack Traceback:
[0:0] CmiAbort+0x89 [0x506ff2]
[0:1] __cmi_assert+0x4b [0x514a0c]
[0:2] _ZN5CkVecIPvEixEm+0x36 [0x49c7a8]
[0:3] /opt/usr/stow/ULCMi/libexec/Charm-launcher [0x4966f9]
[0:4] _Z15_processHandlerPvP11CkCoreState+0x30d [0x49712e]
[0:5] CmiHandleMessage+0x84 [0x50f5f1]
[0:6] CsdSchedulePoll+0x96 [0x50fb5f]
[0:7] CsdScheduler+0x23 [0x50f8bf]
[0:8] CthStandinCode+0xe [0x50fc5a]
[0:9] CthStartThread+0x59 [0x4830b7]
[0:10] /lib/libc.so.6 [0x7f98d9aaf370]
Fatal error on PE 0>

Thanks for your help!

I am still open for any suggestion for making the first version (with suspend) working.

Christian

Gengbin

On Tue, May 25, 2010 at 11:02 AM, Christian Perez
<christian.perez AT inria.fr>
wrote:
Ok ... here are the ugly details:

We have a JAVA code that interprets an assembly of components, which in this
case are implemented in Charm++.
The mainchare creates a second chare (called RT) that launched the JVM in an
entry method start, which is
not threaded (I have problem with the JVM if it is not in the main thread
:<)

The JAVA code needs to create/connect/execute components. Hence, the java
code invokes JNI methods to call C++ code.
The creation turns to be easy (it is a simple call to ckNew).
My current problem is with the 'connect'.

Logically, the connection operation should be as simple as:
type_of_P p = component_a->get_ref_of_port_P()
component_b->set_ref_of_port_U(p)

My current version is in term of ci file is:

chare type_of_P { ... }

chare Component_A : type_of_P {
entry void get_ref_of_port_P(const CkCallbackResumeThread& cb) {
m_si * m = new m_si(); m->ckid=thishandle; } // see def of m_si below
}

chare Component_B {
entry [sync] void set_ref_of_port_U(CkChareID& ckid);

I am using a message to send back a reference to something of type_of_P

message m_si {
CkChareID ckid;
}

And the implementation in the jni 'connect' method:

m_si* m;
component_A.get_ref_of_port_P(CkCallbackResumeThread((void*&)m));
component_B.set_ref_of_port_u(m->ckid);


Thus, there are in fact two questions:
- how to correctly implement the connect method (called by JAVA) ?
- how to get& pass a reference of type 'type_of_P' ? (I got error when
CProxy_type_of_P proxy(m->ckid))

Does it make sense?

Christian

On 05/25/2010 05:20 PM, Kale, Laxmikant V wrote:

Why not use the sync method solution? (and I assume you declared m1 to be
threaded).



(And to understand your problem, a little more detail will be useful. Who
created the callback? (m1 or m2)? Etc. Showing code fragment omitting all
but the relevant calls will be good.)



With sync method, it’d look like this



M1() { ……; proxy.m2(); … }

M2(){… }



In .ci: m1 is threaded and m2 is sync.



--

Laxmikant Kale http://charm.cs.uiuc.edu

Professor, Computer Science
kale AT illinois.edu

201 N. Goodwin Avenue Ph: (217) 244-0094

Urbana, IL 61801-2302 FAX: (217) 265-6582





From:
charm-bounces AT cs.uiuc.edu

[mailto:charm-bounces AT cs.uiuc.edu]
On Behalf
Of Christian Perez
Sent: Tuesday, May 25, 2010 10:00 AM
To: Filippo Gioachin
Cc:
charm AT cs.uiuc.edu
Subject: Re: [charm] how to suspend/resume a chare ?



Hello,

CkCallbackResumeThread() seems to be the perfect answer for one process ...
but it fails when using several processes :
<<
Fatal error on PE 1> Called thread_delay on different processor than where
callback was created
Is there a standard mechanism to solve this issue or should I use an ad-hoc
solution by forcing the
creation of a local chare?

My strong constraint is that m1 can not be spitted in two :(

Christian

On 05/24/2010 11:01 PM, Filippo Gioachin wrote:

Christian,



for your purposes, I would suggest looking at the manual on section 3.2.1
(Entry Method Attributes) regarding "threaded" and "sync" entry methods. A
combination of the two (m1 threaded and m2 sync) should solve your problem.

Additionally, callbacks are very useful to resume threads as well; 3.15.2
shows how CkCallbackResumeThread can be used to resume m1().

Please remember that other entry methods may run while m1 is suspended,
including other m1 methods.



Filippo



On Thu, May 20, 2010 at 03:58, Christian
Perez<christian.perez AT inria.fr>
wrote:

Hello,

I'd like to know how to block a thread. Here is a simple version of what
I'd like to do:

Chare A:
m1() {
do some computation
invoke method m2 on chare B
wait for the completion of method m2
do something else
}

I've tried to use some callback mechanism but the problem is that
I can not split m1 in two :(

So, is there a wait to suspend the execution (and also how to resume it) ?

Thank you!

Christian Perez

_______________________________________________
charm mailing list
charm AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/charm


--
Filippo Gioachin
PhD Candidate
Department of Computer Science
University of Illinois at Urbana-Champaign
Ph: +1-217-333-4764



_______________________________________________
charm mailing list
charm AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/charm







Archive powered by MHonArc 2.6.16.

Top of Page