Ceci est une ancienne révision du document !
CHARM++
From Wikipedia, the free encyclopedia
Charm++ is a parallel object-oriented programming language based on C++ and developed in the Parallel Programming Laboratory at the University of Illinois. Charm++ is designed with the goal of enhancing programmer productivity by providing a high-level abstraction of a parallel program while at the same time delivering good performance on a wide variety of underlying hardware platforms. Programs written in Charm++ are decomposed into a number of cooperating message-driven objects called chares. When a programmer invokes a method on an object, the Charm++ runtime system sends a message to the invoked object, which may reside on the local processor or on a remote processor in a parallel computation. This message triggers the execution of code within the chare to handle the message asynchronously.
Utilisation
Il faut tout d'abord charger les modules nécessaires :
module load ompi charm++
Accès aux commandes telles que : charmc et charmrun
Exemple : HelloWorld
** Interface**
- hello.c
module hello { array [1D] Hello { entry Hello(); entry void sayHi(int); }; };
Header file
- hello.h
#ifndef __HELLO_H__ #define __HELLO_H__ class Hello : public CBase_Hello { public: /// Constructors /// Hello(); Hello(CkMigrateMessage *msg); /// Entry Methods /// void sayHi(int from); }; #endif //__HELLO_H__
- hello.C
#include "hello.decl.h" #include "hello.h" #include "main.decl.h" extern /* readonly */ CProxy_Main mainProxy; extern /* readonly */ int numElements; Hello::Hello() { // Nothing to do when the Hello chare object is created. // This is where member variables would be initialized // just like in a C++ class constructor. } // Constructor needed for chare object migration (ignore for now) // NOTE: This constructor does not need to appear in the ".ci" file Hello::Hello(CkMigrateMessage *msg) { } void Hello ::sayHi(int from) { // Have this chare object say hello to the user. CkPrintf("\"Hello\" from Hello chare # %d on " "processor %d (told by %d).\n", thisIndex, CkMyPe(), from); // Tell the next chare object in this array of chare objects // to also say hello. If this is the last chare object in // the array of chare objects, then tell the main chare // object to exit the program. if (thisIndex < (numElements - 1)) thisProxy[thisIndex + 1].sayHi(thisIndex); else mainProxy.done(); } #include "hello.def.h"