Charm++ Tutorial Presented by: Lukasz Wesolowski Pritish Jetley 1
Overview � Introduction – Characteristics of a Parallel Language – Virtualization – Message Driven Execution � Charm++ features – Chares and Chare Arrays – Parameter Marshalling – Structured Dagger Construct – Adaptive MPI – Load Balancing � Tools – Parallel Debugger – Projections – LiveViz � Conclusion 2
Outline � Introduction � Charm++ features – Chares and Chare Arrays – Parameter Marshalling � Structured Dagger Construct � Adaptive MPI � Tools – Parallel Debugger – Projections � Load Balancing � LiveViz � Conclusion 3
Characteristics of a Parallel Language � Developing a parallel application involves: – decomposition – mapping – scheduling – machine-dependent expression � Each task is either automated by the system or assigned to the programmer 4
Charm++ vs. MPI Charm++ MPI Portabiliity X X Scheduling X Mapping X Decomposition 5
Virtualization: Object-based Decomposition � Divide the computation into a large number of pieces – Independent of number of processors – Typically larger than number of processors � Let the system map objects to processors 6
Object-based Parallelization User is only concerned with interaction between objects System implementation User View 7
Message-Driven Execution � Objects communicate asynchronously through remote method invocation � Encourages non-deterministic execution � Benefits: – Communication latency tolerance – Logical structure for scheduling 8
Message-Driven Execution in Charm++ CkExit() x y Objects y->f() ?? Scheduler Scheduler Message Q Message Q 9
Other Charm++ Characteristics � Methods execute one at a time � No need for locks � Expressing flow of control may be difficult 10
Outline � Introduction � Charm++ features – Chares and Chare Arrays – Parameter Marshalling � Structured Dagger Construct � Adaptive MPI � Tools – Parallel Debugger – Projections � Load Balancing � LiveViz � Conclusion 11
Chares – Concurrent Objects � Can be dynamically created on any available processor � Can be accessed from remote processors � Send messages to each other asynchronously � Contain “entry methods” 12
“Hello World” ��������������� ��������������� ��������������� ��������������� ����������������� ����������������� ����������������� ����������������� ��������� ��������� ��������� ��������� ������������ ������������ ������������! ������������ ! ! ! ���������� ������� ���������� ���������� ���������� �������������"�#�$���� �������������"�#�$���������� �������������"�#�$���� �������������"�#�$���� ������ ������� ������ � � � #�$���"� #�$���"� ��������� �������� ��������� ��������� ��������� #�$���"� #�$���"� ��������������������� ��������������������� ��������������������� ��������������������� ����� �������������������� ����� ����� ����� � � � � �� ������%% ������%% ������%% ������%% &�����'���� &�����'����! &�����'���� &�����'���� ! ! ! �� %%����� %%����� %%����� %%����� ��()����� ��()����� ��()����� ��()����� � � � � Generates: �� �� �� �� hello.decl.h ��������� ��������� ����������� �����������! ! ��������� ��������� ����������� ����������� ! ! hello.def.h 13
Compile and run the program Compiling • charmc <options> <source file> • -o, -g, -language, -module, -tracemode pgm: pgm.ci pgm.h pgm.C charmc pgm.ci Example Nodelist File: charmc pgm.C group main ++shell ssh charmc –o pgm pgm.o –language charm++ host Host1 host Host2 To run a CHARM++ program named ``pgm'' on four processors, type: charmrun pgm +p4 <params> Nodelist file (for network architecture) • list of machines to run the program • host <hostname> <qualifiers> 14
Charm++ solution: Proxy classes � Proxy class generated for each chare class – For instance, CProxy_Y is the proxy class generated for chare class Y. – Proxy objects know where the real object is – Methods invoked on this object simply put the data in an “envelope” and send it out to the destination � Given a proxy p, you can invoke methods – p.method(msg); 15
Chare Arrays • Array of Objects of the same kind • Each one communicates with the next one • Individual chares – cumbersome and not practical Chare Array: – with a single global name for the collection – each member addressed by an index – mapping of element objects to processors handled by the system 16
Chare Arrays A A A A A User’s view [0] [1] [2] [3] [..] System view A A [0] [1] A A [0] [1] 17
Recommend
More recommend