\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 \charmpp{} 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 \kw{TempoChare}, \kw{TempoGroup}
\footnote{Currently, a nodegroup variety of \tempo{} object does not exist, 
though it will be added in future.},
and \kw{TempoArray} respectively. This inheritance also needs to be
specified in the \charmpp{} interface file. Thus, a chare \uw{C} in module
\uw{M} that needs to receive a tagged message directed to it in entry \uw{E}, 
needs to inherit from \kw{TempoChare} as shown below:

\begin{alltt}
// 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 *);
\};
...
\end{alltt}

The code for entry method \uw{E} can contain a call to \kw{ckTempoRecv}
to block for a tagged message. Any ordinary chare can send a tagged
message to a \tempo{} object using \kw{ckTempoSend} static method of 
\kw{TempoChare}.

\kw{TempoGroup} and \kw{TempoArray} provide additional static methods to
send tagged messages to individual elements, as well as broadcast. In
addition, \kw{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:

\begin{alltt}
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);
\};
\end{alltt}

\begin{alltt}
// 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);
\};
\end{alltt}

\begin{alltt}
// 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);
\};
\end{alltt}

All the {\tt ckSend*} methods have versions that send messages with one tag or
with two tags. A wild card tag (\kw{TEMPO\_ANY} may be in specified in 
\kw{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: \kw{TEMPO\_MAX}, \kw{TEMPO\_MIN}, \kw{TEMPO\_SUM}, and 
\kw{TEMPO\_PROD}.
Reduction data types can be specified using integer constants: 
\kw{TEMPO\_FLOAT}, \kw{TEMPO\_INT}, and \kw{TEMPO\_DOUBLE}. 
The \uw{root} parameter in \kw{ckTempoReduce},
and the \uw{sender} parameter in \kw{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
\uw{outbuf}\footnote{\uw{outbuf} and \uw{inbuf} can be the same.} 
In case of a broadcast, \uw{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 {\tt charm++.h}.
There is no need to include any other file to use \tempo{}.
