MPQC  3.0.0-alpha
sc::MemoryGrp Class Referenceabstract

The MemoryGrp abstract class provides a way of accessing distributed memory in a parallel machine. More...

#include <util/group/memory.h>

Inheritance diagram for sc::MemoryGrp:
sc::DescribedClass sc::RefCount sc::MemoryGrpRegion sc::MsgMemoryGrp sc::ProcMemoryGrp sc::ActiveMsgMemoryGrp sc::RDMAMemoryGrp sc::ShmMemoryGrp sc::MTMPIMemoryGrp sc::ARMCIMemoryGrp

Public Member Functions

 MemoryGrp (const Ref< KeyVal > &)
 
int me () const
 Returns who I am.
 
int n () const
 Returns how many nodes there are.
 
virtual void set_localsize (size_t)=0
 Set the size of locally held memory. More...
 
size_t localsize ()
 Returns the amount of memory residing locally on me().
 
virtual void * localdata ()=0
 Returns a pointer to the local data.
 
distsize_t localoffset ()
 Returns the global offset to this node's memory.
 
int size (int node)
 Returns the amount of memory residing on node.
 
distsize_t offset (int node)
 Returns the global offset to node's memory.
 
distsize_t totalsize ()
 Returns the sum of all memory allocated on all nodes.
 
virtual void activate ()
 Activate is called before the memory is to be used.
 
virtual void deactivate ()
 Deactivate is called after the memory has been used.
 
virtual void * obtain_writeonly (distsize_t offset, size_t size)=0
 This gives write access to the memory location. No locking is done.
 
virtual void * obtain_readwrite (distsize_t offset, size_t size)=0
 Only one thread can have an unreleased obtain_readwrite at a time. More...
 
virtual void * obtain_readonly (distsize_t offset, size_t size)=0
 This gives read access to the memory location. No locking is done.
 
virtual void release_readonly (void *data, distsize_t offset, size_t size)=0
 This is called when read access is no longer needed.
 
virtual void release_writeonly (void *data, distsize_t offset, size_t size)=0
 This is called when write access is no longer needed.
 
virtual void release_readwrite (void *data, distsize_t offset, size_t size)=0
 This is called when read/write access is no longer needed. More...
 
virtual void write (const void *data, distsize_t offset, size_t size)
 This is used to write data directly. More...
 
virtual void sum_reduction (double *data, distsize_t doffset, size_t dsize)
 Perform a sum reduction on double data. More...
 
virtual void sum_reduction_on_node (double *data, size_t doffset, size_t dsize, int node=-1)
 Perform a sum reduction on double data localized to a single node. More...
 
virtual void sync ()=0
 Synchronizes all the nodes. More...
 
virtual void * malloc_local (size_t nbyte)
 Allocate data that will be accessed locally only. More...
 
double * malloc_local_double (size_t ndouble)
 Allocate double data that will be accessed locally only. More...
 
virtual void free_local (void *&data)
 Free data that was allocated with malloc_local, and set the pointer to 0.
 
void free_local_double (double *&data)
 Free data that was allocated with malloc_local_double, and set the pointer to 0

 
virtual void catchup ()
 Processes outstanding requests. More...
 
virtual Ref< MemoryGrpclone (void)
 Returns a copy of this MemoryGrp specialization that provides an independent communication context. More...
 
virtual void print (std::ostream &o=ExEnv::out0()) const
 Prints out information about the object.
 
- Public Member Functions inherited from sc::DescribedClass
 DescribedClass (const DescribedClass &)
 
DescribedClassoperator= (const DescribedClass &)
 
ClassDescclass_desc () const MPQC__NOEXCEPT
 This returns the unique pointer to the ClassDesc corresponding to the given type_info object. More...
 
const char * class_name () const
 Return the name of the object's exact type.
 
int class_version () const
 Return the version of the class.
 
Ref< DescribedClassref ()
 Return this object wrapped up in a Ref smart pointer. More...
 
- Public Member Functions inherited from sc::RefCount
size_t identifier () const
 Return the unique identifier for this object that can be compared for different objects of different types. More...
 
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. More...
 

Static Public Member Functions

static MemoryGrpinitial_memorygrp (int &argc, char **argv)
 Create a memory group. More...
 
static MemoryGrpinitial_memorygrp ()
 Create a memory group. More...
 
static void set_default_memorygrp (const Ref< MemoryGrp > &)
 The default memory group contains the primary memory group to be used by an application.
 
static MemoryGrpget_default_memorygrp ()
 Returns the default memory group. More...
 

Protected Member Functions

void obtain_local_lock (size_t start, size_t fence)
 
void release_local_lock (size_t start, size_t fence)
 
- Protected Member Functions inherited from sc::RefCount
 RefCount (const RefCount &)
 
RefCountoperator= (const RefCount &)
 

Protected Attributes

int me_
 
int n_
 
distsize_t * offsets_
 
int debug_
 

Detailed Description

The MemoryGrp abstract class provides a way of accessing distributed memory in a parallel machine.

Several specializations are available. For one processor, ProcMemoryGrp provides a simple stub implementation. Parallel specializations include ShmMemoryGrp, MTMPIMemoryGrp, and ARMCIMemoryGrp. The particular specializations that work depend highly on the target hardware and software environment.

Member Function Documentation

◆ catchup()

virtual void sc::MemoryGrp::catchup ( )
virtual

Processes outstanding requests.

Some memory group implementations don't have access to real shared memory or even active messages. Instead, requests are processed whenever certain memory group routines are called. This can cause large latencies and buffer overflows. If this is a problem, then the catchup member can be called to process all outstanding requests.

Reimplemented in sc::MemoryGrpRegion.

◆ clone()

virtual Ref<MemoryGrp> sc::MemoryGrp::clone ( void  )
virtual

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

This will throw for specializations that do not reimplement it.

Reimplemented in sc::MTMPIMemoryGrp, and sc::MemoryGrpRegion.

◆ get_default_memorygrp()

static MemoryGrp* sc::MemoryGrp::get_default_memorygrp ( )
static

Returns the default memory group.

If the default memory group has not yet been set, then one is created. The particular specialization used is determined by configuration options and which specializations are being used for MessageGrp and ThreadGrp.

◆ initial_memorygrp() [1/2]

static MemoryGrp* sc::MemoryGrp::initial_memorygrp ( )
static

Create a memory group.

See also
initial_memorygrp(int&,char**)

◆ initial_memorygrp() [2/2]

static MemoryGrp* sc::MemoryGrp::initial_memorygrp ( int &  argc,
char **  argv 
)
static

Create a memory group.

This routine looks for a -memorygrp argument, and then the environmental variable MEMORYGRP to decide which specialization of MemoryGrp would be appropriate. The argument to -memorygrp or the value of the environmental variable should be either string for a ParsedKeyVal constructor or a classname. The default ThreadGrp and MessageGrp objects should be initialized before this is called.

◆ malloc_local()

virtual void* sc::MemoryGrp::malloc_local ( size_t  nbyte)
virtual

Allocate data that will be accessed locally only.

Using this for data that will be used for global operations can improve efficiency. Data allocated in this way must be freed with free_local_double.

Reimplemented in sc::MemoryGrpRegion, and sc::ARMCIMemoryGrp.

◆ malloc_local_double()

double* sc::MemoryGrp::malloc_local_double ( size_t  ndouble)

Allocate double data that will be accessed locally only.

See also
malloc_local

◆ obtain_readwrite()

virtual void* sc::MemoryGrp::obtain_readwrite ( distsize_t  offset,
size_t  size 
)
pure virtual

Only one thread can have an unreleased obtain_readwrite at a time.

The actual memory region locked can be larger than that requested. If the memory region is already locked this will block. For this reason, data should be held as read/write for as short a time as possible.

Implemented in sc::ActiveMsgMemoryGrp, sc::ShmMemoryGrp, sc::RDMAMemoryGrp, sc::MemoryGrpRegion, and sc::ProcMemoryGrp.

◆ release_readwrite()

virtual void sc::MemoryGrp::release_readwrite ( void *  data,
distsize_t  offset,
size_t  size 
)
pure virtual

This is called when read/write access is no longer needed.

The memory will be unlocked.

Implemented in sc::ActiveMsgMemoryGrp, sc::ShmMemoryGrp, sc::RDMAMemoryGrp, sc::MemoryGrpRegion, and sc::ProcMemoryGrp.

◆ set_localsize()

virtual void sc::MemoryGrp::set_localsize ( size_t  )
pure virtual

Set the size of locally held memory.

When memory is accessed using a global offset counting starts at node 0 and proceeds up to node n() - 1.

Implemented in sc::ActiveMsgMemoryGrp, sc::ShmMemoryGrp, sc::MemoryGrpRegion, sc::ARMCIMemoryGrp, sc::ProcMemoryGrp, sc::RDMAMemoryGrp, and sc::MsgMemoryGrp.

◆ sum_reduction()

virtual void sc::MemoryGrp::sum_reduction ( double *  data,
distsize_t  doffset,
size_t  dsize 
)
virtual

Perform a sum reduction on double data.

Parameters
datathe contribution to sum into the global array.
doffsetthe global offset in terms of doubles.
dsizethe size in terms of doubles.

Reimplemented in sc::ActiveMsgMemoryGrp, and sc::RDMAMemoryGrp.

◆ sum_reduction_on_node()

virtual void sc::MemoryGrp::sum_reduction_on_node ( double *  data,
size_t  doffset,
size_t  dsize,
int  node = -1 
)
virtual

Perform a sum reduction on double data localized to a single node.

Parameters
datathe contribution to sum into the global array.
doffsetthe local offset on the node in terms of doubles.
dsizethe size in terms of doubles.
nodethe node holding the data. The default is the local node.

Reimplemented in sc::ActiveMsgMemoryGrp, sc::RDMAMemoryGrp, and sc::MemoryGrpRegion.

◆ sync()

virtual void sc::MemoryGrp::sync ( )
pure virtual

Synchronizes all the nodes.

This is useful after remote memory writes to be certain that all of the writes have completed and the data can be accessed locally, for example.

Implemented in sc::MTMPIMemoryGrp, sc::MemoryGrpRegion, sc::ARMCIMemoryGrp, sc::ProcMemoryGrp, and sc::MsgMemoryGrp.

◆ write()

virtual void sc::MemoryGrp::write ( const void *  data,
distsize_t  offset,
size_t  size 
)
virtual

This is used to write data directly.

The default implementation uses obtain_writeonly(). More efficient implementations will avoid copies

Reimplemented in sc::ActiveMsgMemoryGrp.


The documentation for this class was generated from the following file:

Generated at Sun Jan 26 2020 23:24:07 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.