Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

memamsg.h

00001 //
00002 // memamsg.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031 
00032 #ifndef _util_group_memamsg_h
00033 #define _util_group_memamsg_h
00034 
00035 #include <iostream>
00036 
00037 #include <util/group/memmsg.h>
00038 
00039 class MemoryDataRequest {
00040   public:
00041     enum { NData = 6 };
00042     enum Request { Deactivate, Sync, Retrieve, Replace, DoubleSum };
00043   private:
00044     int data_[NData];
00045   public:
00046     MemoryDataRequest() {}
00047     MemoryDataRequest(Request r, int node = 0, int offset = 0, int size = 0,
00048                       int lock = 0, int serial = 0);
00049     void assign(Request r, int node, int offset, int size,
00050                 int lock, int serial);
00051     void *data() const { return (void *) data_; }
00052     int nbytes() const { return sizeof(int)*NData; }
00053 
00054     const char *request_string() const;
00055 
00056     MemoryDataRequest::Request request() const { return (Request) data_[0]; }
00057     int node() const { return data_[1]; }
00058     int offset() const { return data_[2]; }
00059     int size() const { return data_[3]; }
00060     int serial_number() const { return data_[4]; }
00061     int lock() const { return data_[5]; }
00062 
00063     int touches_data() const {return request()!=Deactivate&&request()!=Sync;}
00064 
00065     // Sync messages only define one datum besides type and node
00066     int reactivate() const { return data_[2]; }
00067 
00068     void operator =(const MemoryDataRequest &r);
00069 
00070     void print(const char* msg = 0, std::ostream & o = ExEnv::out()) const;
00071 };
00072 
00073 class MemoryDataRequestQueue {
00074   public:
00075     enum { MaxDepth = 1024 };
00076   private:
00077     MemoryDataRequest q_[MaxDepth];
00078     int n_;
00079   public:
00080     MemoryDataRequestQueue(): n_(0) {}
00081     int n() const { return n_; }
00082     void push(MemoryDataRequest&);
00083     void pop(MemoryDataRequest&);
00084 
00085     MemoryDataRequest& operator[](int i) { return q_[i]; }
00086     void clear() { n_ = 0; }
00087 };
00088 
00091 class ActiveMsgMemoryGrp : public MsgMemoryGrp {
00092   protected:
00093     char *data_;
00094 
00095     virtual void retrieve_data(void *, int node, int offset, int size,
00096                                int lock) = 0;
00097     virtual void replace_data(void *, int node, int offset, int size,
00098                               int unlock) = 0;
00099     virtual void sum_data(double *data, int node, int doffset, int dsize) = 0;
00100   public:
00101     ActiveMsgMemoryGrp(const Ref<MessageGrp>& msg);
00102     ActiveMsgMemoryGrp(const Ref<KeyVal>&);
00103     ~ActiveMsgMemoryGrp();
00104 
00105     void set_localsize(int);
00106     void *localdata();
00107 
00108     void *obtain_writeonly(distsize_t offset, int size);
00109     void *obtain_readwrite(distsize_t offset, int size);
00110     void *obtain_readonly(distsize_t offset, int size);
00111     void release_readonly(void *data, distsize_t offset, int size);
00112     void release_writeonly(void *data, distsize_t offset, int size);
00113     void release_readwrite(void *data, distsize_t offset, int size);
00114 
00115     void sum_reduction(double *data, distsize_t doffset, int dsize);
00116     void sum_reduction_on_node(double *data, int doffset, int dsize,
00117                                int node = -1);
00118 
00119     void print(std::ostream &o = ExEnv::out()) const;
00120 };
00121 
00122 #endif
00123 
00124 // Local Variables:
00125 // mode: c++
00126 // c-file-style: "CLJ"
00127 // End:

Generated at Thu Oct 4 18:08:45 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.