28#ifndef _util_group_memregion_h
29#define _util_group_memregion_h
36#include <util/group/memory.h>
83 static const int only_allow_double_aligned_regions_ = 1;
90 static const int classdebug_ = 0;
91 static int classdebug() {
return classdebug_; }
99 LocalRegion(
size_t start,
size_t size) : start_(start), size_(size) {}
100 size_t start()
const {
return start_; }
101 size_t size()
const {
return size_; }
102 bool operator==(
const LocalRegion&
other)
const {
103 return start() ==
other.start() && size() ==
other.size();
105 bool operator>(
const LocalRegion&
other)
const {
106 return start() >
other.start();
112 typedef std::list<LocalRegion> LocalRegions;
114 Ref<MemoryGrp> host_;
115 LocalRegion reserve_;
116 std::vector<distsize_t> host_offsets_;
118 distsize_t offset_to_host_offset(
const distsize_t&
offset)
const;
121 class HostToRegionsMap {
125 void insert(
const MemoryGrp* host,
const LocalRegion& region);
126 void erase(
const MemoryGrp* host,
const LocalRegion& region);
128 size_t find_free(
const MemoryGrp* host,
size_t sz)
const;
130 const LocalRegions* regions(
const MemoryGrp* host)
const;
131 typedef std::map<const MemoryGrp*,LocalRegions*> ImplType;
133 Ref<ThreadLock> lock_;
135 static HostToRegionsMap map_;
static std::ostream & out0()
Return an ostream that writes from node 0.
The MemoryGrpRegion is a MemoryGrp proxy to a region of a MemoryGrp.
Definition memregion.h:46
void sync()
Synchronizes all the nodes.
void release_readwrite(void *data, distsize_t offset, size_t size)
This is called when read/write access is no longer needed.
void * obtain_readwrite(distsize_t offset, size_t size)
Only one thread can have an unreleased obtain_readwrite at a time.
void release_readonly(void *data, distsize_t offset, size_t size)
This is called when read access is no longer needed.
Ref< MemoryGrp > clone()
Returns a copy of this MemoryGrp specialization that provides an independent communication context.
MemoryGrpRegion(const Ref< MemoryGrp > &mem, size_t max_size)
same as above, except mem_start is determined automatically
void * obtain_readonly(distsize_t offset, size_t size)
This gives read access to the memory location. No locking is done.
void print(std::ostream &o=ExEnv::out0()) const
Prints out information about the object.
void * malloc_local(size_t nbytes)
Allocate data that will be accessed locally only.
void deactivate()
Deactivate is called after the memory has been used.
void catchup()
Processes outstanding requests.
MemoryGrpRegion(const Ref< MemoryGrp > &mem, size_t mem_start, size_t max_size)
MemoryGrpRegion is defined by the host MemoryGrp and position and size of the local segment within th...
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.
void free_local(void *&data)
Free data that was allocated with malloc_local, and set the pointer to 0.
void * obtain_writeonly(distsize_t offset, size_t size)
This gives write access to the memory location. No locking is done.
void set_localsize(size_t)
Set the size of locally held memory.
void release_writeonly(void *data, distsize_t offset, size_t size)
This is called when write access is no longer needed.
void * localdata()
Returns a pointer to the local data.
void activate()
Activate is called before the memory is to be used.
The MemoryGrp abstract class provides a way of accessing distributed memory in a parallel machine.
Definition memory.h:120
int size(int node)
Returns the amount of memory residing on node.
Definition memory.h:161
distsize_t offset(int node)
Returns the global offset to node's memory.
Definition memory.h:164
A template class that maintains references counts.
Definition ref.h:361
SpinCase1 other(SpinCase1 S)
given 1-spin return the other 1-spin
Contains all MPQC code up to version 3.
Definition mpqcin.h:14