[97] | 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-2008 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_fn(Win &, int *, ... ); |
---|
| 89 | |
---|
| 90 | // |
---|
| 91 | // Errhandler |
---|
| 92 | // |
---|
| 93 | static MPI::Errhandler Create_errhandler(Errhandler_fn* function); |
---|
| 94 | |
---|
| 95 | virtual void Set_errhandler(const MPI::Errhandler& errhandler) const; |
---|
| 96 | |
---|
| 97 | virtual MPI::Errhandler Get_errhandler() const; |
---|
| 98 | |
---|
| 99 | // |
---|
| 100 | // One sided communication |
---|
| 101 | // |
---|
| 102 | virtual void Accumulate(const void* origin_addr, int origin_count, |
---|
| 103 | const MPI::Datatype& origin_datatype, |
---|
| 104 | int target_rank, MPI::Aint target_disp, |
---|
| 105 | int target_count, |
---|
| 106 | const MPI::Datatype& target_datatype, |
---|
| 107 | const MPI::Op& op) const; |
---|
| 108 | |
---|
| 109 | virtual void Complete() const; |
---|
| 110 | |
---|
| 111 | static Win Create(const void* base, MPI::Aint size, int disp_unit, |
---|
| 112 | const MPI::Info& info, const MPI::Intracomm& comm); |
---|
| 113 | |
---|
| 114 | virtual void Fence(int assert) const; |
---|
| 115 | |
---|
| 116 | virtual void Free(); |
---|
| 117 | |
---|
| 118 | virtual void Get(const void *origin_addr, int origin_count, |
---|
| 119 | const MPI::Datatype& origin_datatype, int target_rank, |
---|
| 120 | MPI::Aint target_disp, int target_count, |
---|
| 121 | const MPI::Datatype& target_datatype) const; |
---|
| 122 | |
---|
| 123 | virtual MPI::Group Get_group() const; |
---|
| 124 | |
---|
| 125 | virtual void Lock(int lock_type, int rank, int assert) const; |
---|
| 126 | |
---|
| 127 | virtual void Post(const MPI::Group& group, int assert) const; |
---|
| 128 | |
---|
| 129 | virtual void Put(const void* origin_addr, int origin_count, |
---|
| 130 | const MPI::Datatype& origin_datatype, int target_rank, |
---|
| 131 | MPI::Aint target_disp, int target_count, |
---|
| 132 | const MPI::Datatype& target_datatype) const; |
---|
| 133 | |
---|
| 134 | virtual void Start(const MPI::Group& group, int assert) const; |
---|
| 135 | |
---|
| 136 | virtual bool Test() const; |
---|
| 137 | |
---|
| 138 | virtual void Unlock(int rank) const; |
---|
| 139 | |
---|
| 140 | virtual void Wait() const; |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | // |
---|
| 144 | // External Interfaces |
---|
| 145 | // |
---|
| 146 | virtual void Call_errhandler(int errorcode) const; |
---|
| 147 | |
---|
| 148 | // Need 4 overloaded versions of this function because per the |
---|
| 149 | // MPI-2 spec, you can mix-n-match the C predefined functions with |
---|
| 150 | // C++ functions. |
---|
| 151 | static int Create_keyval(Copy_attr_function* win_copy_attr_fn, |
---|
| 152 | Delete_attr_function* win_delete_attr_fn, |
---|
| 153 | void* extra_state); |
---|
| 154 | static int Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn, |
---|
| 155 | MPI_Win_delete_attr_function* win_delete_attr_fn, |
---|
| 156 | void* extra_state); |
---|
| 157 | static int Create_keyval(Copy_attr_function* win_copy_attr_fn, |
---|
| 158 | MPI_Win_delete_attr_function* win_delete_attr_fn, |
---|
| 159 | void* extra_state); |
---|
| 160 | static int Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn, |
---|
| 161 | Delete_attr_function* win_delete_attr_fn, |
---|
| 162 | void* extra_state); |
---|
| 163 | |
---|
| 164 | protected: |
---|
| 165 | // Back-end function to do the heavy lifting for creating the |
---|
| 166 | // keyval |
---|
| 167 | static int do_create_keyval(MPI_Win_copy_attr_function* c_copy_fn, |
---|
| 168 | MPI_Win_delete_attr_function* c_delete_fn, |
---|
| 169 | Copy_attr_function* cxx_copy_fn, |
---|
| 170 | Delete_attr_function* cxx_delete_fn, |
---|
| 171 | void* extra_state, int &keyval); |
---|
| 172 | |
---|
| 173 | public: |
---|
| 174 | virtual void Delete_attr(int win_keyval); |
---|
| 175 | |
---|
| 176 | static void Free_keyval(int& win_keyval); |
---|
| 177 | |
---|
| 178 | // version 1: pre-errata Get_attr (not correct, but probably nice to support |
---|
| 179 | bool Get_attr(const Win& win, int win_keyval, |
---|
| 180 | void* attribute_val) const; |
---|
| 181 | |
---|
| 182 | // version 2: post-errata Get_attr (correct, but no one seems to know about it) |
---|
| 183 | bool Get_attr(int win_keyval, void* attribute_val) const; |
---|
| 184 | |
---|
| 185 | virtual void Get_name(char* win_name, int& resultlen) const; |
---|
| 186 | |
---|
| 187 | virtual void Set_attr(int win_keyval, const void* attribute_val); |
---|
| 188 | |
---|
| 189 | virtual void Set_name(const char* win_name); |
---|
| 190 | |
---|
| 191 | // Data that is passed through keyval create when C++ callback |
---|
| 192 | // functions are used |
---|
| 193 | struct keyval_intercept_data_t { |
---|
| 194 | MPI_Win_copy_attr_function *c_copy_fn; |
---|
| 195 | MPI_Win_delete_attr_function *c_delete_fn; |
---|
| 196 | Copy_attr_function* cxx_copy_fn; |
---|
| 197 | Delete_attr_function* cxx_delete_fn; |
---|
| 198 | void *extra_state; |
---|
| 199 | }; |
---|
| 200 | |
---|
| 201 | // Protect the global list from multiple thread access |
---|
| 202 | static opal_mutex_t cxx_extra_states_lock; |
---|
| 203 | |
---|
| 204 | protected: |
---|
| 205 | #if 0 /* OMPI_ENABLE_MPI_PROFILING */ |
---|
| 206 | PMPI::Win pmpi_win; |
---|
| 207 | #else |
---|
| 208 | MPI_Win mpi_win; |
---|
| 209 | #endif |
---|
| 210 | }; |
---|