[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) 2008 Cisco Systems, Inc. All rights reserved. |
---|
| 14 | // $COPYRIGHT$ |
---|
| 15 | // |
---|
| 16 | // Additional copyrights may follow |
---|
| 17 | // |
---|
| 18 | // $HEADER$ |
---|
| 19 | // |
---|
| 20 | |
---|
| 21 | #include <string.h> |
---|
| 22 | |
---|
| 23 | // |
---|
| 24 | // Point-to-Point Communication |
---|
| 25 | // |
---|
| 26 | |
---|
| 27 | inline void |
---|
| 28 | MPI::Attach_buffer(void* buffer, int size) |
---|
| 29 | { |
---|
| 30 | (void)MPI_Buffer_attach(buffer, size); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | inline int |
---|
| 34 | MPI::Detach_buffer(void*& buffer) |
---|
| 35 | { |
---|
| 36 | int size; |
---|
| 37 | (void)MPI_Buffer_detach(&buffer, &size); |
---|
| 38 | return size; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | // |
---|
| 42 | // Process Topologies |
---|
| 43 | // |
---|
| 44 | |
---|
| 45 | inline void |
---|
| 46 | MPI::Compute_dims(int nnodes, int ndims, int dims[]) |
---|
| 47 | { |
---|
| 48 | (void)MPI_Dims_create(nnodes, ndims, dims); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | // |
---|
| 53 | // Environmental Inquiry |
---|
| 54 | // |
---|
| 55 | |
---|
| 56 | inline void |
---|
| 57 | MPI::Get_processor_name(char* name, int& resultlen) |
---|
| 58 | { |
---|
| 59 | (void)MPI_Get_processor_name(name, &resultlen); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | inline void |
---|
| 63 | MPI::Get_error_string(int errorcode, char* string, int& resultlen) |
---|
| 64 | { |
---|
| 65 | (void)MPI_Error_string(errorcode, string, &resultlen); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | inline int |
---|
| 69 | MPI::Get_error_class(int errorcode) |
---|
| 70 | { |
---|
| 71 | int errorclass; |
---|
| 72 | (void)MPI_Error_class(errorcode, &errorclass); |
---|
| 73 | return errorclass; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | inline double |
---|
| 77 | MPI::Wtime() |
---|
| 78 | { |
---|
| 79 | return (MPI_Wtime()); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | inline double |
---|
| 83 | MPI::Wtick() |
---|
| 84 | { |
---|
| 85 | return (MPI_Wtick()); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | inline void |
---|
| 89 | MPI::Real_init() |
---|
| 90 | { |
---|
| 91 | MPI::InitializeIntercepts(); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | inline void |
---|
| 96 | MPI::Init(int& argc, char**& argv) |
---|
| 97 | { |
---|
| 98 | (void)MPI_Init(&argc, &argv); |
---|
| 99 | Real_init(); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | inline void |
---|
| 103 | MPI::Init() |
---|
| 104 | { |
---|
| 105 | (void)MPI_Init(0, 0); |
---|
| 106 | Real_init(); |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | inline void |
---|
| 110 | MPI::Finalize() |
---|
| 111 | { |
---|
| 112 | (void)MPI_Finalize(); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | inline bool |
---|
| 116 | MPI::Is_initialized() |
---|
| 117 | { |
---|
| 118 | int t; |
---|
| 119 | (void)MPI_Initialized(&t); |
---|
| 120 | return OPAL_INT_TO_BOOL(t); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | inline bool |
---|
| 124 | MPI::Is_finalized() |
---|
| 125 | { |
---|
| 126 | int t; |
---|
| 127 | (void)MPI_Finalized(&t); |
---|
| 128 | return OPAL_INT_TO_BOOL(t); |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | // |
---|
| 133 | // External Interfaces |
---|
| 134 | // |
---|
| 135 | |
---|
| 136 | inline int |
---|
| 137 | MPI::Init_thread(int required) |
---|
| 138 | { |
---|
| 139 | int provided; |
---|
| 140 | (void) MPI_Init_thread(0, NULL, required, &provided); |
---|
| 141 | Real_init(); |
---|
| 142 | return provided; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | inline int |
---|
| 147 | MPI::Init_thread(int& argc, char**& argv, int required) |
---|
| 148 | { |
---|
| 149 | int provided; |
---|
| 150 | (void) MPI_Init_thread(&argc, &argv, required, &provided); |
---|
| 151 | Real_init(); |
---|
| 152 | return provided; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | inline bool |
---|
| 157 | MPI::Is_thread_main() |
---|
| 158 | { |
---|
| 159 | int flag; |
---|
| 160 | (void) MPI_Is_thread_main(&flag); |
---|
| 161 | return OPAL_INT_TO_BOOL(flag == 1); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | inline int |
---|
| 166 | MPI::Query_thread() |
---|
| 167 | { |
---|
| 168 | int provided; |
---|
| 169 | (void) MPI_Query_thread(&provided); |
---|
| 170 | return provided; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | // |
---|
| 175 | // Miscellany |
---|
| 176 | // |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | inline void* |
---|
| 180 | MPI::Alloc_mem(MPI::Aint size, const MPI::Info& info) |
---|
| 181 | { |
---|
| 182 | void* baseptr; |
---|
| 183 | (void) MPI_Alloc_mem(size, info, &baseptr); |
---|
| 184 | return baseptr; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | inline void |
---|
| 189 | MPI::Free_mem(void* base) |
---|
| 190 | { |
---|
| 191 | (void) MPI_Free_mem(base); |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | // |
---|
| 196 | // Process Creation |
---|
| 197 | // |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | inline void |
---|
| 201 | MPI::Close_port(const char* port_name) |
---|
| 202 | { |
---|
| 203 | (void) MPI_Close_port(const_cast<char *>(port_name)); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | inline void |
---|
| 208 | MPI::Lookup_name(const char * service_name, |
---|
| 209 | const MPI::Info& info, |
---|
| 210 | char* port_name) |
---|
| 211 | { |
---|
| 212 | (void) MPI_Lookup_name(const_cast<char *>(service_name), info, port_name); |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | inline void |
---|
| 217 | MPI::Open_port(const MPI::Info& info, char* port_name) |
---|
| 218 | { |
---|
| 219 | (void) MPI_Open_port(info, port_name); |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | inline void |
---|
| 224 | MPI::Publish_name(const char* service_name, |
---|
| 225 | const MPI::Info& info, |
---|
| 226 | const char* port_name) |
---|
| 227 | { |
---|
| 228 | (void) MPI_Publish_name(const_cast<char *>(service_name), info, |
---|
| 229 | const_cast<char *>(port_name)); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | inline void |
---|
| 234 | MPI::Unpublish_name(const char* service_name, |
---|
| 235 | const MPI::Info& info, |
---|
| 236 | const char* port_name) |
---|
| 237 | { |
---|
| 238 | (void)MPI_Unpublish_name(const_cast<char *>(service_name), info, |
---|
| 239 | const_cast<char *>(port_name)); |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | // |
---|
| 245 | // Profiling |
---|
| 246 | // |
---|
| 247 | |
---|
| 248 | inline void |
---|
| 249 | MPI::Pcontrol(const int level, ...) |
---|
| 250 | { |
---|
| 251 | va_list ap; |
---|
| 252 | va_start(ap, level); |
---|
| 253 | |
---|
| 254 | (void)MPI_Pcontrol(level, ap); |
---|
| 255 | va_end(ap); |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | |
---|
| 259 | inline void |
---|
| 260 | MPI::Get_version(int& version, int& subversion) |
---|
| 261 | { |
---|
| 262 | (void)MPI_Get_version(&version, &subversion); |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | inline MPI::Aint |
---|
| 267 | MPI::Get_address(void* location) |
---|
| 268 | { |
---|
| 269 | MPI::Aint ret; |
---|
| 270 | MPI_Get_address(location, &ret); |
---|
| 271 | return ret; |
---|
| 272 | } |
---|