4. TEMPO Library

TEMPO (Threaded Message Passing Objects) provides a simple way to communicate between threaded methods of objects. Using TEMPO, chares, groups, and arrays can have threads associated with them. Any CHARM++ object can send a tagged message to a TEMPO Object, and a threaded method in a TEMPO Object can block on a specific tagged message.

In order to use TEMPO functionalities, chares, groups, and arrays need to inherit from TEMPO objects called TempoChare, TempoGroup 4.1, and TempoArray respectively. This inheritance also needs to be specified in the CHARM++ interface file. Thus, a chare C in module M that needs to receive a tagged message directed to it in entry E, needs to inherit from TempoChare as shown below:

// file.ci
module M {
 ...
 chare C : TempoChare {
   entry C(void);
   entry [threaded] void E(Msg *); // note use of threaded
 };
 ...
}

// file.h
#include "file.decl.h"
...
class C : public TempoChare { // TempoChare inherits from Chare already
 public:
  C(void);
  E(Msg *);
};
...

The code for entry method E can contain a call to ckTempoRecv to block for a tagged message. Any ordinary chare can send a tagged message to a TEMPO object using ckTempoSend static method of TempoChare.

TempoGroup and TempoArray provide additional static methods to send tagged messages to individual elements, as well as broadcast. In addition, TempoArray provides methods to perform ``reduction'' over all the elements of an array. Currently supported reduction operations are max, min, sum, and product over datatypes float, int, and double. The signatures of these methods are given below:

class TempoChare : public Chare, public ... {
  void ckTempoRecv(int tag, void *buffer, int buflen);
  void ckTempoRecv(int tag1, int tag2, void *buffer, int buflen);
  static void ckTempoSend(int tag1, int tag2, void *buffer,int buflen,
                          CkChareID cid);
  static void ckTempoSend(int tag, void *buffer,int buflen, CkChareID cid);
  int ckTempoProbe(int tag1, int tag2);
  int ckTempoProbe(int tag);
};

// TempoGroup includes all the TempoChare methods

class TempoGroup : public Group, public ... {
  static void ckTempoBcast(int tag, void *buffer, int buflen, CkGroupID grpid);
  static void ckTempoSendBranch(int tag1, int tag2, void *buffer, int buflen,
                                CkGroupID grpid, int processor);
  static void ckTempoSendBranch(int tag, void *buffer, int buflen,
                                CkGroupID grpid, int processor);
  void ckTempoBcast(int sender, int tag, void *buffer, int buflen);
  void ckTempoSendBranch(int tag1, int tag2, void *buffer, int buflen,
                         int processor);
  void ckTempoSendBranch(int tag, void *buffer, int buflen, int processor);
};

// TempoArray includes all the TempoChare methods

class TempoArray : public ArrayElement, public Tempo {
  static void ckTempoSendElem(int tag1, int tag2, void *buffer, int buflen,
                              CkArrayID aid, int idx);
  static void ckTempoSendElem(int tag, void *buffer, int buflen,
                              CkArrayID aid, int idx);
  void ckTempoSendElem(int tag1, int tag2, void *buffer, int buflen, int idx);
  void ckTempoSendElem(int tag, void *buffer, int buflen, int idx);
  void ckTempoBarrier(void);
  void ckTempoBcast(int sender, int tag, void *buffer, int buflen);
  void ckTempoReduce(int root, int op, void *inbuf, void *outbuf, int count,
                     int type);
  void ckTempoAllReduce(int op,void *inbuf,void *outbuf,int count,int type);
};

All the ckSend* methods have versions that send messages with one tag or with two tags. A wild card tag (TEMPO_ANY may be in specified in ckTempoRecv that matches with any tag. All the tags must range between 0 and 1024. All the other tags have other uses in the system. Reduction operations are indicated by integer constants. They are: TEMPO_MAX, TEMPO_MIN, TEMPO_SUM, and TEMPO_PROD. Reduction data types can be specified using integer constants: TEMPO_FLOAT, TEMPO_INT, and TEMPO_DOUBLE. The root parameter in ckTempoReduce, and the sender parameter in ckTempoBcast indicate whether the calling element is the root of the collective operation or not. In case of a reduction, the root element is returned the result of the reduction operation in outbuf4.2 In case of a broadcast, buffer on the sender contains the message to be sent to other elements. For each of the send methods, the specified message buffer could be reused once the method returns.

All the TEMPO include files are automatically includes from charm++.h. There is no need to include any other file to use TEMPO.

November 23, 2009
Charm Homepage