MPQC  3.0.0-alpha
memrdma.h
1 //
2 // memrdma.h
3 // Based on memamsg.h
4 //
5 // Copyright (C) 1996 Limit Point Systems, Inc.
6 //
7 // Author: Curtis Janssen <cljanss@limitpt.com>
8 // Maintainer: LPS
9 //
10 // This file is part of the SC Toolkit.
11 //
12 // The SC Toolkit is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Library General Public License as published by
14 // the Free Software Foundation; either version 2, or (at your option)
15 // any later version.
16 //
17 // The SC Toolkit is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Library General Public License for more details.
21 //
22 // You should have received a copy of the GNU Library General Public License
23 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
24 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 //
26 // The U.S. Government is granted a limited license as per AL 91-7.
27 //
28 
29 #ifndef _util_group_memrdma_h
30 #define _util_group_memrdma_h
31 
32 #include <iostream>
33 #include <vector>
34 
35 #include <util/group/pool.h>
36 #include <util/group/memmsg.h>
37 
38 namespace sc {
39 
42 class RDMAMemoryGrp : public MsgMemoryGrp {
43  protected:
44  char *data_;
45 
46  virtual void retrieve_data(void *, int node, long offset, long size,
47  int lock) = 0;
48  virtual void replace_data(void *, int node, long offset, long size,
49  int unlock) = 0;
50  virtual void sum_data(double *data, int node, long doffset, long dsize) = 0;
51 
52  std::vector<Pool*> pools_;
53  size_t default_pool_size_;
54  void* malloc_region(size_t nbyte);
55  void free_region(void*);
56  public:
57  RDMAMemoryGrp(const Ref<MessageGrp>& msg);
58  RDMAMemoryGrp(const Ref<KeyVal>&);
59  ~RDMAMemoryGrp();
60 
61  void *localdata();
62 
63  void set_localsize(size_t localsize);
64 
65  void *obtain_writeonly(distsize_t offset, size_t size);
66  void *obtain_readwrite(distsize_t offset, size_t size);
67  void *obtain_readonly(distsize_t offset, size_t size);
68  void release_readonly(void *data, distsize_t offset, size_t size);
69  void release_writeonly(void *data, distsize_t offset, size_t size);
70  void release_readwrite(void *data, distsize_t offset, size_t size);
71 
72  void sum_reduction(double *data, distsize_t doffset, size_t dsize);
73  void sum_reduction_on_node(double *data, size_t doffset, size_t dsize,
74  int node = -1);
75 
76  void print(std::ostream &o = ExEnv::out0()) const;
77 };
78 
79 }
80 
81 #endif
82 
83 // Local Variables:
84 // mode: c++
85 // c-file-style: "CLJ"
86 // End:
sc::RDMAMemoryGrp::set_localsize
void set_localsize(size_t localsize)
Set the size of locally held memory.
sc::MemoryGrp::offset
distsize_t offset(int node)
Returns the global offset to node's memory.
Definition: memory.h:164
sc::RDMAMemoryGrp::sum_reduction_on_node
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.
sc::RDMAMemoryGrp::obtain_writeonly
void * obtain_writeonly(distsize_t offset, size_t size)
This gives write access to the memory location. No locking is done.
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::RDMAMemoryGrp::obtain_readonly
void * obtain_readonly(distsize_t offset, size_t size)
This gives read access to the memory location. No locking is done.
sc::RDMAMemoryGrp
The RDMAMemoryGrp abstract class specializes the MsgMemoryGrp class.
Definition: memrdma.h:42
sc::MemoryGrp::size
int size(int node)
Returns the amount of memory residing on node.
Definition: memory.h:161
sc::RDMAMemoryGrp::localdata
void * localdata()
Returns a pointer to the local data.
sc::RDMAMemoryGrp::release_writeonly
void release_writeonly(void *data, distsize_t offset, size_t size)
This is called when write access is no longer needed.
sc::RDMAMemoryGrp::print
void print(std::ostream &o=ExEnv::out0()) const
Prints out information about the object.
sc::RDMAMemoryGrp::release_readwrite
void release_readwrite(void *data, distsize_t offset, size_t size)
This is called when read/write access is no longer needed.
sc::MemoryGrp::localsize
size_t localsize()
Returns the amount of memory residing locally on me().
Definition: memory.h:155
sc::RDMAMemoryGrp::sum_reduction
void sum_reduction(double *data, distsize_t doffset, size_t dsize)
Perform a sum reduction on double data.
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::MsgMemoryGrp
A MsgMemoryGrp that initializes its data using a messagegrp.
Definition: memmsg.h:37
sc::RDMAMemoryGrp::obtain_readwrite
void * obtain_readwrite(distsize_t offset, size_t size)
Only one thread can have an unreleased obtain_readwrite at a time.
sc::RDMAMemoryGrp::release_readonly
void release_readonly(void *data, distsize_t offset, size_t size)
This is called when read access is no longer needed.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

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