OpenMPI  0.1.1
win.h
1 // -*- c++ -*-
2 //
3 // Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 // University Research and Technology
5 // Corporation. All rights reserved.
6 // Copyright (c) 2004-2005 The University of Tennessee and The University
7 // of Tennessee Research Foundation. All rights
8 // reserved.
9 // Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 // University of Stuttgart. All rights reserved.
11 // Copyright (c) 2004-2005 The Regents of the University of California.
12 // All rights reserved.
13 // Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
14 // Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
15 // $COPYRIGHT$
16 //
17 // Additional copyrights may follow
18 //
19 // $HEADER$
20 //
21 
22 
23 class Win {
24 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
25  // friend class P;
26 #endif
27  friend class MPI::Comm; //so I can access pmpi_win data member in comm.cc
28  friend class MPI::Request; //and also from request.cc
29 
30 public:
31 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
32 
33  // construction / destruction
34  Win() { }
35  virtual ~Win() { }
36 
37 
38  // copy / assignment
39  Win(const Win& data) : pmpi_win(data.pmpi_win) { }
40 
41  Win(MPI_Win i) : pmpi_win(i) { }
42 
43  Win& operator=(const Win& data) {
44  pmpi_win = data.pmpi_win; return *this; }
45 
46  // comparison, don't need for win
47 
48  // inter-language operability
49  Win& operator= (const MPI_Win &i) {
50  pmpi_win = i; return *this; }
51  operator MPI_Win () const { return pmpi_win; }
52  // operator MPI_Win* () const { return pmpi_win; }
53  operator const PMPI::Win&() const { return pmpi_win; }
54 
55 #else
56 
57  Win() : mpi_win(MPI_WIN_NULL) { }
58  // copy
59  Win(const Win& data) : mpi_win(data.mpi_win) { }
60 
61  Win(MPI_Win i) : mpi_win(i) { }
62 
63  virtual ~Win() { }
64 
65  Win& operator=(const Win& data) {
66  mpi_win = data.mpi_win; return *this; }
67 
68  // comparison, don't need for win
69 
70  // inter-language operability
71  Win& operator= (const MPI_Win &i) {
72  mpi_win = i; return *this; }
73  operator MPI_Win () const { return mpi_win; }
74  // operator MPI_Win* () const { return (MPI_Win*)&mpi_win; }
75 
76 #endif
77 
78  //
79  // User defined functions
80  //
81  typedef int Copy_attr_function(const Win& oldwin, int win_keyval,
82  void* extra_state, void* attribute_val_in,
83  void* attribute_val_out, bool& flag);
84 
85  typedef int Delete_attr_function(Win& win, int win_keyval,
86  void* attribute_val, void* extra_state);
87 
88  typedef void Errhandler_function(Win &, int *, ... );
89  typedef Errhandler_function Errhandler_fn
90  __mpi_interface_deprecated__("MPI::Win::Errhandler_fn was deprecated in MPI-2.2; use MPI::Win::Errhandler_function instead");
91 
92  //
93  // Errhandler
94  //
95  static MPI::Errhandler Create_errhandler(Errhandler_function* function);
96 
97  virtual void Set_errhandler(const MPI::Errhandler& errhandler) const;
98 
99  virtual MPI::Errhandler Get_errhandler() const;
100 
101  //
102  // One sided communication
103  //
104  virtual void Accumulate(const void* origin_addr, int origin_count,
105  const MPI::Datatype& origin_datatype,
106  int target_rank, MPI::Aint target_disp,
107  int target_count,
108  const MPI::Datatype& target_datatype,
109  const MPI::Op& op) const;
110 
111  virtual void Complete() const;
112 
113  static Win Create(const void* base, MPI::Aint size, int disp_unit,
114  const MPI::Info& info, const MPI::Intracomm& comm);
115 
116  virtual void Fence(int assert) const;
117 
118  virtual void Free();
119 
120  virtual void Get(const void *origin_addr, int origin_count,
121  const MPI::Datatype& origin_datatype, int target_rank,
122  MPI::Aint target_disp, int target_count,
123  const MPI::Datatype& target_datatype) const;
124 
125  virtual MPI::Group Get_group() const;
126 
127  virtual void Lock(int lock_type, int rank, int assert) const;
128 
129  virtual void Post(const MPI::Group& group, int assert) const;
130 
131  virtual void Put(const void* origin_addr, int origin_count,
132  const MPI::Datatype& origin_datatype, int target_rank,
133  MPI::Aint target_disp, int target_count,
134  const MPI::Datatype& target_datatype) const;
135 
136  virtual void Start(const MPI::Group& group, int assert) const;
137 
138  virtual bool Test() const;
139 
140  virtual void Unlock(int rank) const;
141 
142  virtual void Wait() const;
143 
144 
145  //
146  // External Interfaces
147  //
148  virtual void Call_errhandler(int errorcode) const;
149 
150  // Need 4 overloaded versions of this function because per the
151  // MPI-2 spec, you can mix-n-match the C predefined functions with
152  // C++ functions.
153  static int Create_keyval(Copy_attr_function* win_copy_attr_fn,
154  Delete_attr_function* win_delete_attr_fn,
155  void* extra_state);
156  static int Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn,
157  MPI_Win_delete_attr_function* win_delete_attr_fn,
158  void* extra_state);
159  static int Create_keyval(Copy_attr_function* win_copy_attr_fn,
160  MPI_Win_delete_attr_function* win_delete_attr_fn,
161  void* extra_state);
162  static int Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn,
163  Delete_attr_function* win_delete_attr_fn,
164  void* extra_state);
165 
166 protected:
167  // Back-end function to do the heavy lifting for creating the
168  // keyval
169  static int do_create_keyval(MPI_Win_copy_attr_function* c_copy_fn,
170  MPI_Win_delete_attr_function* c_delete_fn,
171  Copy_attr_function* cxx_copy_fn,
172  Delete_attr_function* cxx_delete_fn,
173  void* extra_state, int &keyval);
174 
175 public:
176  virtual void Delete_attr(int win_keyval);
177 
178  static void Free_keyval(int& win_keyval);
179 
180  // version 1: pre-errata Get_attr (not correct, but probably nice to support
181  bool Get_attr(const Win& win, int win_keyval,
182  void* attribute_val) const;
183 
184  // version 2: post-errata Get_attr (correct, but no one seems to know about it)
185  bool Get_attr(int win_keyval, void* attribute_val) const;
186 
187  virtual void Get_name(char* win_name, int& resultlen) const;
188 
189  virtual void Set_attr(int win_keyval, const void* attribute_val);
190 
191  virtual void Set_name(const char* win_name);
192 
193  // Data that is passed through keyval create when C++ callback
194  // functions are used
196  MPI_Win_copy_attr_function *c_copy_fn;
197  MPI_Win_delete_attr_function *c_delete_fn;
198  Copy_attr_function* cxx_copy_fn;
199  Delete_attr_function* cxx_delete_fn;
200  void *extra_state;
201  };
202 
203  // Protect the global list from multiple thread access
204  static opal_mutex_t cxx_extra_states_lock;
205 
206 protected:
207 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
208  PMPI::Win pmpi_win;
209 #else
210  MPI_Win mpi_win;
211 #endif
212 };
Definition: win.h:53
Definition: win.h:23
Definition: mutex_unix.h:53
Definition: win.h:195