sc_ShmMessageGrp - Man Page

The ShmMessageGrp class is an implementation of MessageGrp that allows multiple process to be started that communicate with shared memory.

Synopsis

#include <messshm.h>

Inherits sc::intMessageGrp.

Public Member Functions

ShmMessageGrp ()
Reads the number of processors from environmental variable NUMPROC.
ShmMessageGrp (const Ref< KeyVal > &)
The ShmMessageGrp KeyVal constructor takes a single keyword that specifies the number of processors.
ShmMessageGrp (int nprocs)
Initialize ShmMessageGrp to use nprocs processors.
void sync ()
Synchronize all of the processors.
Ref< MessageGrp > clone (void)
Returns a copy of this MessageGrp specialization that provides an independent communication context.

Public Member Functions inherited from sc::intMessageGrp
void raw_send (int target, const void *data, int nbyte)
void raw_recv (int sender, void *data, int nbyte)
void raw_sendt (int target, int type, const void *data, int nbyte)
void raw_recvt (int type, void *data, int nbyte)
int probet (int)
Ask if a given typed message has been received.
int leftover_ctl_bits ()

Public Member Functions inherited from sc::MessageGrp
MessageGrp (const Ref< KeyVal > &)
int n ()
Returns the number of processors.
int me ()
Returns my processor number. In the range [0,n()).
virtual void send (int target, const double *data, int ndata)
Send messages sequentially to the target processor.
virtual void send (int target, const unsigned int *data, int ndata)
virtual void send (int target, const int *data, int ndata)
virtual void send (int target, const char *data, int nbyte)
virtual void send (int target, const unsigned char *data, int nbyte)
virtual void send (int target, const signed char *data, int nbyte)
virtual void send (int target, const short *data, int ndata)
virtual void send (int target, const long *data, int ndata)
virtual void send (int target, const float *data, int ndata)
void send (int target, double data)
void send (int target, int data)
virtual void sendt (int target, int type, const double *data, int ndata)
Send typed messages to the target processor.
virtual void sendt (int target, int type, const unsigned int *data, int ndata)
virtual void sendt (int target, int type, const int *data, int ndata)
virtual void sendt (int target, int type, const char *data, int nbyte)
virtual void sendt (int target, int type, const unsigned char *data, int nbyte)
virtual void sendt (int target, int type, const signed char *data, int nbyte)
virtual void sendt (int target, int type, const short *data, int ndata)
virtual void sendt (int target, int type, const long *data, int ndata)
virtual void sendt (int target, int type, const float *data, int ndata)
void sendt (int target, int type, double data)
void sendt (int target, int type, int data)
virtual void recv (int sender, double *data, int ndata)
Receive messages sent sequentually from the sender.
virtual void recv (int sender, unsigned int *data, int ndata)
virtual void recv (int sender, int *data, int ndata)
virtual void recv (int sender, char *data, int nbyte)
virtual void recv (int sender, unsigned char *data, int nbyte)
virtual void recv (int sender, signed char *data, int nbyte)
virtual void recv (int sender, short *data, int ndata)
virtual void recv (int sender, long *data, int ndata)
virtual void recv (int sender, float *data, int ndata)
void recv (int sender, double &data)
void recv (int sender, int &data)
virtual void recvt (int type, double *data, int ndata)
Receive messages sent by type.
virtual void recvt (int type, unsigned int *data, int ndata)
virtual void recvt (int type, int *data, int ndata)
virtual void recvt (int type, char *data, int nbyte)
virtual void recvt (int type, unsigned char *data, int nbyte)
virtual void recvt (int type, signed char *data, int nbyte)
virtual void recvt (int type, short *data, int ndata)
virtual void recvt (int type, long *data, int ndata)
virtual void recvt (int type, float *data, int ndata)
void recvt (int type, double &data)
void recvt (int type, int &data)
virtual void bcast (double *data, int ndata, int from=0)
Do broadcasts of various types of data.
virtual void bcast (unsigned int *data, int ndata, int from=0)
virtual void bcast (int *data, int ndata, int from=0)
virtual void bcast (char *data, int nbyte, int from=0)
virtual void bcast (unsigned char *data, int nbyte, int from=0)
virtual void bcast (signed char *data, int nbyte, int from=0)
virtual void bcast (short *data, int ndata, int from=0)
virtual void bcast (long *data, int ndata, int from=0)
virtual void bcast (float *data, int ndata, int from=0)
virtual void raw_bcast (void *data, int nbyte, int from=0)
void bcast (double &data, int from=0)
void bcast (int &data, int from=0)
virtual void raw_collect (const void *part, const int *lengths, void *whole, int bytes_per_datum=1)
Collect data distributed on the nodes to a big array replicated on each node.
void collect (const double *part, const int *lengths, double *whole)
virtual void sum (double *data, int n, double *=0, int target=-1)
Global sum reduction.
virtual void sum (unsigned int *data, int n, unsigned int *=0, int target=-1)
virtual void sum (int *data, int n, int *=0, int target=-1)
virtual void sum (char *data, int n, char *=0, int target=-1)
virtual void sum (unsigned char *data, int n, unsigned char *=0, int target=-1)
virtual void sum (signed char *data, int n, signed char *=0, int target=-1)
void sum (double &data)
void sum (int &data)
virtual void max (double *data, int n, double *=0, int target=-1)
Global maximization.
virtual void max (int *data, int n, int *=0, int target=-1)
virtual void max (unsigned int *data, int n, unsigned int *=0, int target=-1)
virtual void max (char *data, int n, char *=0, int target=-1)
virtual void max (unsigned char *data, int n, unsigned char *=0, int target=-1)
virtual void max (signed char *data, int n, signed char *=0, int target=-1)
void max (double &data)
void max (int &data)
virtual void min (double *data, int n, double *=0, int target=-1)
Global minimization.
virtual void min (int *data, int n, int *=0, int target=-1)
virtual void min (unsigned int *data, int n, unsigned int *=0, int target=-1)
virtual void min (char *data, int n, char *=0, int target=-1)
virtual void min (unsigned char *data, int n, unsigned char *=0, int target=-1)
virtual void min (signed char *data, int n, signed char *=0, int target=-1)
void min (double &data)
void min (int &data)
virtual void reduce (double *, int n, GrpReduce< double > &, double *scratch=0, int target=-1)
Global generic reduction.
virtual void reduce (int *, int n, GrpReduce< int > &, int *scratch=0, int target=-1)
virtual void reduce (unsigned int *, int n, GrpReduce< unsigned int > &, unsigned int *scratch=0, int target=-1)
virtual void reduce (char *, int n, GrpReduce< char > &, char *scratch=0, int target=-1)
virtual void reduce (unsigned char *, int n, GrpReduce< unsigned char > &, unsigned char *scratch=0, int target=-1)
virtual void reduce (signed char *, int n, GrpReduce< signed char > &, signed char *scratch=0, int target=-1)
virtual void reduce (short *, int n, GrpReduce< short > &, short *scratch=0, int target=-1)
virtual void reduce (float *, int n, GrpReduce< float > &, float *scratch=0, int target=-1)
virtual void reduce (long *, int n, GrpReduce< long > &, long *scratch=0, int target=-1)
void reduce (double &data, GrpReduce< double > &r)
void reduce (int &data, GrpReduce< int > &r)
Ref< MachineTopology > topology ()
Return the MachineTopology object.
int classdesc_to_index (const ClassDesc *)
Each message group maintains an association of ClassDesc with a global index so SavableState information can be sent between nodes without needing to send the classname and look up the ClassDesc with each transfer.
const ClassDesc * index_to_classdesc (int)
int nclass () const

Public Member Functions inherited from sc::DescribedClass
DescribedClass (const DescribedClass &)
DescribedClass & operator= (const DescribedClass &)
ClassDesc * class_desc () const  throw ()
This returns the unique pointer to the ClassDesc corresponding to the given type_info object.
const char * class_name () const
Return the name of the object's exact type.
int class_version () const
Return the version of the class.
virtual void print (std::ostream &=ExEnv::out0()) const
Print the object.

Public Member Functions inherited from sc::RefCount
int lock_ptr () const
Lock this object.
int unlock_ptr () const
Unlock this object.
void use_locks (bool inVal)
start and stop using locks on this object
refcount_t nreference () const
Return the reference count.
refcount_t reference ()
Increment the reference count and return the new count.
refcount_t dereference ()
Decrement the reference count and return the new count.
int managed () const
void unmanage ()
Turn off the reference counting mechanism for this object.
int managed () const
Return 1 if the object is managed. Otherwise return 0.

Public Member Functions inherited from sc::Identity
Identifier identifier ()
Return the Identifier for this argument.

Protected Member Functions

void basic_send (int target, int type, const void *data, int nbyte)
Must be implemented by specializations.
void basic_recv (int type, void *data, int nbyte)
Must be implemented by specializations.
int basic_probe (int type)
Must be implemented by specializations.
void initialize (int nprocs)
void initialize ()
msgbuf_t * NEXT_MESSAGE (msgbuf_t *m)
void get_change (int node)
void put_change (int node)
void wait_for_write (int node)
void release_write (int node)
void print_buffer (int node, int me)

Protected Member Functions inherited from sc::intMessageGrp
int msgtype_typ (int msgtype)
int typ_msgtype (int usrtype)
int seq_msgtype (int source, int seq)
intMessageGrp (const Ref< KeyVal > &)
void initialize (int me, int n, int nbits)

Protected Member Functions inherited from sc::MessageGrp
void initialize (int me, int n)
The classdesc_to_index_ and index_to_classdesc_ arrays cannot be initialized by the MessageGrp CTOR, because the MessageGrp specialization has not yet been initialized and communication is not available.

Protected Member Functions inherited from sc::RefCount
RefCount (const RefCount &)
RefCount & operator= (const RefCount &)

Protected Attributes

commbuf_t * commbuf [MAXPROCS]
int shmid
int semid
int change_semid
void * sharedmem
struct sembuf semdec
struct sembuf seminc

Protected Attributes inherited from sc::intMessageGrp
int msgtype_nbit
int ctl_nbit
int seq_nbit
int typ_nbit
int src_nbit
int ctl_mask
int seq_mask
int typ_mask
int src_mask
int ctl_shift
int seq_shift
int typ_shift
int src_shift
int * source_seq
int * target_seq

Protected Attributes inherited from sc::MessageGrp
Ref< MachineTopology > topology_
int debug_

Additional Inherited Members

Static Public Member Functions inherited from sc::MessageGrp

static void set_default_messagegrp (const Ref< MessageGrp > &)
The default message group contains the primary message group to be used by an application.
static MessageGrp * get_default_messagegrp ()
Returns the default message group.
static MessageGrp * initial_messagegrp (int &argc, char **&argv)
Create a message group.

Detailed Description

The ShmMessageGrp class is an implementation of MessageGrp that allows multiple process to be started that communicate with shared memory.

This only provides improved performance if you have multiple CPU's in a symmetric multiprocessor configuration. Nonetheless, it is quite useful on a single CPU for tracking down bugs.

Constructor & Destructor Documentation

sc::ShmMessageGrp::ShmMessageGrp (const Ref< KeyVal > & )

The ShmMessageGrp KeyVal constructor takes a single keyword that specifies the number of processors. Here is an example of a ParsedKeyVal input that creates a ShmMessageGrp that runs on four processors:

message<ShmMessageGrp>: n = 4

Member Function Documentation

int sc::ShmMessageGrp::basic_probe (int type) [protected], [virtual]

Must be implemented by specializations.

Implements sc::intMessageGrp.

void sc::ShmMessageGrp::basic_recv (int type, void * data, int nbyte) [protected], [virtual]

Must be implemented by specializations.

Implements sc::intMessageGrp.

void sc::ShmMessageGrp::basic_send (int target, int type, const void * data, int nbyte) [protected], [virtual]

Must be implemented by specializations.

Implements sc::intMessageGrp.

Ref< MessageGrp > sc::ShmMessageGrp::clone (void ) [virtual]

Returns a copy of this MessageGrp specialization that provides an independent communication context.

Implements sc::MessageGrp.

void sc::ShmMessageGrp::sync () [virtual]

Synchronize all of the processors.

Reimplemented from sc::MessageGrp.

Author

Generated automatically by Doxygen for MPQC from the source code.

Info

Version 2.3.1 MPQC