MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
memmtmpi.h
1//
2// memmtmpi.h
3// based on memmpi.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_memmtmpi_h
30#define _util_group_memmtmpi_h
31
32#include <fstream>
33#include <vector>
34
35#define OMPI_SKIP_MPICXX
36#define MPICH_SKIP_MPICXX
37#include <mpi.h>
38
39#include <util/group/message.h>
40#include <util/group/memamsg.h>
41#include <util/group/thread.h>
42#include <util/misc/regtime.h>
43
44namespace sc {
45
46class MTMPIThread;
47
53 private:
55
56 Ref<ThreadLock> serial_lock_;
57 int serial_;
58 int serial(int node);
59
60 MPI_Comm comp_comm_;
61 MPI_Comm comm_comm_;
62 int req_tag_;
63
64 int active_;
65
66 unsigned int *nreq_sent_;
67 unsigned int *nreq_sent_buf_;
68
69 MTMPIThread **thread_;
70 Ref<ThreadLock> print_lock_; // needed for debugging only
71 std::ofstream hout; // handler out
72 std::ofstream mout; // main thread out
73
74 void init_mtmpimg(MPI_Comm comm, int nthreads);
75
76 Ref<RegionTimer> timer_;
77
78 // Buffer data and manipulation members.
79 int nbuffer_;
80
81 int current_datareq_index_;
82 std::vector<MemoryDataRequest> datareqs_;
83 std::vector<MPI_Request> datareqs_mpireq_;
84
85 int current_data_index_;
86 std::vector<double*> databufs_;
87 std::vector<MPI_Request> databufs_mpireq_;
88
89 Ref<ThreadLock> buffer_lock_;
90
91 int next_buffer(int &counter);
92 void init_buffer();
93 int next_buffer(int &counter,
94 std::vector<MPI_Request> &reqs);
95 int get_buffer();
96 int get_request();
97 void done_buffers();
98
99 // parent class pure virtuals
100 void retrieve_data(void *, int node, long offset, long size, int lock);
101 void replace_data(void *, int node, long offset, long size, int unlock);
102 void sum_data(double *data, int node, long doffset, long dsize);
103
104 friend class MTMPIThread;
105 public:
111 MPI_Comm comm = MPI_COMM_WORLD);
125
126 void activate();
128
129 void sync();
130
132};
133
134}
135
136#endif
137
138// Local Variables:
139// mode: c++
140// c-file-style: "CLJ"
141// End:
The ActiveMsgMemoryGrp abstract class specializes the MsgMemoryGrp class.
Definition memamsg.h:97
This MemoryGrp class requires a MT-safe MPI implementation.
Definition memmtmpi.h:52
void sync()
Synchronizes all the nodes.
void deactivate()
Deactivate is called after the memory has been used.
MTMPIMemoryGrp(const Ref< MessageGrp > &msg, const Ref< ThreadGrp > &th, MPI_Comm comm=MPI_COMM_WORLD)
Construct a MTMPIMemoryGrp given a MessageGrp, ThreadGrp, and an MPI communicator.
void activate()
Activate is called before the memory is to be used.
MTMPIMemoryGrp(const Ref< KeyVal > &)
Construct a MTMPIMemoryGrp given a KeyVal input object.
Ref< MemoryGrp > clone()
Returns a copy of this MemoryGrp specialization that provides an independent communication context.
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
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.