Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
charm [2012/01/05 16:31] – [Exemple : HelloWorld] admincharm [2012/01/05 16:36] (Version actuelle) – [Exemple : HelloWorld] admin
Ligne 15: Ligne 15:
 ======Exemple : HelloWorld ====== ======Exemple : HelloWorld ======
  
-** Interface**\\ +{{:arrayhelloworld.tar.gz|}}
-<file C hello.c> +
-module hello {+
  
-  array [1D] Hello { +===== Exemple d'une exécution =====
-    entry Hello(); +
-    entry void sayHi(int); +
-  }; +
- +
-};  +
-</file> +
- +
-**Header file**\\ +
-<file C 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__  +
-</file> +
- +
-<file C 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"  +
-</file>+
  
 +<code bash>
 +$ charmrun +p3 ./hello 10
 +Running "Hello World" with 10 elements using 3 processors.
 +"Hello" from Hello chare # 0 on processor 0 (told by -1).
 +"Hello" from Hello chare # 1 on processor 1 (told by 0).
 +"Hello" from Hello chare # 2 on processor 2 (told by 1).
 +"Hello" from Hello chare # 3 on processor 0 (told by 2).
 +"Hello" from Hello chare # 4 on processor 1 (told by 3).
 +"Hello" from Hello chare # 5 on processor 2 (told by 4).
 +"Hello" from Hello chare # 6 on processor 0 (told by 5).
 +"Hello" from Hello chare # 7 on processor 1 (told by 6).
 +"Hello" from Hello chare # 9 on processor 0 (told by 8).
 +"Hello" from Hello chare # 8 on processor 2 (told by 7). 
 +</code>
 ======Liens  ====== ======Liens  ======
  
 http://charm.cs.uiuc.edu/manuals/html/charm++/ http://charm.cs.uiuc.edu/manuals/html/charm++/
  • charm.1325781111.txt.gz
  • Dernière modification : 2015/02/25 08:45
  • (modification externe)