1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "smpi_coll.hpp"
8 #include "smpi_comm.hpp"
9 #include "smpi_datatype_derived.hpp"
10 #include "smpi_op.hpp"
11 #include "smpi_process.hpp"
12 #include "smpi_win.hpp"
14 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
16 /* PMPI User level calls */
17 extern "C" { // Obviously, the C MPI interface should use the C linkage
19 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
22 if (comm == MPI_COMM_NULL) {
24 }else if ((base == nullptr && size != 0) || disp_unit <= 0 || size < 0 ){
25 retval= MPI_ERR_OTHER;
27 *win = new simgrid::smpi::Win( base, size, disp_unit, info, comm);
34 int PMPI_Win_allocate( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
37 if (comm == MPI_COMM_NULL) {
39 }else if (disp_unit <= 0 || size < 0 ){
40 retval= MPI_ERR_OTHER;
42 void* ptr = xbt_malloc(size);
44 return MPI_ERR_NO_MEM;
45 *static_cast<void**>(base) = ptr;
46 *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,1);
53 int PMPI_Win_create_dynamic( MPI_Info info, MPI_Comm comm, MPI_Win *win){
56 if (comm == MPI_COMM_NULL) {
59 *win = new simgrid::smpi::Win(info, comm);
66 int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){
69 if(win == MPI_WIN_NULL){
71 } else if ((base == nullptr && size != 0) || size < 0 ){
72 retval= MPI_ERR_OTHER;
74 retval = win->attach(base, size);
80 int PMPI_Win_detach(MPI_Win win, void* base)
84 if(win == MPI_WIN_NULL){
86 } else if (base == nullptr){
87 retval= MPI_ERR_OTHER;
89 retval = win->detach(base);
96 int PMPI_Win_free( MPI_Win* win){
99 if (win == nullptr || *win == MPI_WIN_NULL) {
100 retval = MPI_ERR_WIN;
109 int PMPI_Win_set_name(MPI_Win win, char * name)
111 if (win == MPI_WIN_NULL) {
113 } else if (name == nullptr) {
121 int PMPI_Win_get_name(MPI_Win win, char * name, int* len)
123 if (win == MPI_WIN_NULL) {
125 } else if (name == nullptr) {
128 win->get_name(name, len);
133 int PMPI_Win_get_info(MPI_Win win, MPI_Info* info)
135 if (win == MPI_WIN_NULL) {
143 int PMPI_Win_set_info(MPI_Win win, MPI_Info info)
145 if (win == MPI_WIN_NULL) {
153 int PMPI_Win_get_group(MPI_Win win, MPI_Group * group){
154 if (win == MPI_WIN_NULL) {
157 win->get_group(group);
163 int PMPI_Win_fence( int assert, MPI_Win win){
166 if (win == MPI_WIN_NULL) {
167 retval = MPI_ERR_WIN;
169 int rank = smpi_process()->index();
170 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_fence"));
171 retval = win->fence(assert);
172 TRACE_smpi_comm_out(rank);
178 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
179 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
182 if (win == MPI_WIN_NULL) {
183 retval = MPI_ERR_WIN;
184 } else if (target_rank == MPI_PROC_NULL) {
185 retval = MPI_SUCCESS;
186 } else if (target_rank <0){
187 retval = MPI_ERR_RANK;
188 } else if (win->dynamic()==0 && target_disp <0){
189 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
190 retval = MPI_ERR_ARG;
191 } else if ((origin_count < 0 || target_count < 0) ||
192 (origin_addr==nullptr && origin_count > 0)){
193 retval = MPI_ERR_COUNT;
194 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
195 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
196 retval = MPI_ERR_TYPE;
198 int rank = smpi_process()->index();
200 win->get_group(&group);
201 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Get", target_rank,
202 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
203 encode_datatype(origin_datatype)));
205 retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
208 TRACE_smpi_comm_out(rank);
214 int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
215 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
218 if (win == MPI_WIN_NULL) {
219 retval = MPI_ERR_WIN;
220 } else if (target_rank == MPI_PROC_NULL) {
221 *request = MPI_REQUEST_NULL;
222 retval = MPI_SUCCESS;
223 } else if (target_rank <0){
224 retval = MPI_ERR_RANK;
225 } else if (win->dynamic()==0 && target_disp <0){
226 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
227 retval = MPI_ERR_ARG;
228 } else if ((origin_count < 0 || target_count < 0) ||
229 (origin_addr==nullptr && origin_count > 0)){
230 retval = MPI_ERR_COUNT;
231 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
232 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
233 retval = MPI_ERR_TYPE;
234 } else if(request == nullptr){
235 retval = MPI_ERR_REQUEST;
237 int rank = smpi_process()->index();
239 win->get_group(&group);
240 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rget", target_rank,
241 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
242 encode_datatype(origin_datatype)));
244 retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
245 target_datatype, request);
247 TRACE_smpi_comm_out(rank);
253 int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
254 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
257 if (win == MPI_WIN_NULL) {
258 retval = MPI_ERR_WIN;
259 } else if (target_rank == MPI_PROC_NULL) {
260 retval = MPI_SUCCESS;
261 } else if (target_rank <0){
262 retval = MPI_ERR_RANK;
263 } else if (win->dynamic()==0 && target_disp <0){
264 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
265 retval = MPI_ERR_ARG;
266 } else if ((origin_count < 0 || target_count < 0) ||
267 (origin_addr==nullptr && origin_count > 0)){
268 retval = MPI_ERR_COUNT;
269 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
270 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
271 retval = MPI_ERR_TYPE;
273 int rank = smpi_process()->index();
275 win->get_group(&group);
276 int dst_traced = group->actor(target_rank)->getPid()-1;
277 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Put", dst_traced,
278 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
279 encode_datatype(origin_datatype)));
280 TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*origin_datatype->size());
282 retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
285 TRACE_smpi_comm_out(rank);
291 int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
292 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
295 if (win == MPI_WIN_NULL) {
296 retval = MPI_ERR_WIN;
297 } else if (target_rank == MPI_PROC_NULL) {
298 *request = MPI_REQUEST_NULL;
299 retval = MPI_SUCCESS;
300 } else if (target_rank <0){
301 retval = MPI_ERR_RANK;
302 } else if (win->dynamic()==0 && target_disp <0){
303 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
304 retval = MPI_ERR_ARG;
305 } else if ((origin_count < 0 || target_count < 0) ||
306 (origin_addr==nullptr && origin_count > 0)){
307 retval = MPI_ERR_COUNT;
308 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
309 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
310 retval = MPI_ERR_TYPE;
311 } else if(request == nullptr){
312 retval = MPI_ERR_REQUEST;
314 int rank = smpi_process()->index();
316 win->get_group(&group);
317 int dst_traced = group->actor(target_rank)->getPid()-1;
318 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rput", dst_traced,
319 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
320 encode_datatype(origin_datatype)));
321 TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*origin_datatype->size());
323 retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
324 target_datatype, request);
326 TRACE_smpi_comm_out(rank);
332 int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
333 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
336 if (win == MPI_WIN_NULL) {
337 retval = MPI_ERR_WIN;
338 } else if (target_rank == MPI_PROC_NULL) {
339 retval = MPI_SUCCESS;
340 } else if (target_rank <0){
341 retval = MPI_ERR_RANK;
342 } else if (win->dynamic()==0 && target_disp <0){
343 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
344 retval = MPI_ERR_ARG;
345 } else if ((origin_count < 0 || target_count < 0) ||
346 (origin_addr==nullptr && origin_count > 0)){
347 retval = MPI_ERR_COUNT;
348 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
349 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
350 retval = MPI_ERR_TYPE;
351 } else if (op == MPI_OP_NULL) {
354 int rank = smpi_process()->index();
356 win->get_group(&group);
357 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Accumulate", target_rank,
358 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
359 encode_datatype(origin_datatype)));
360 retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
361 target_datatype, op);
363 TRACE_smpi_comm_out(rank);
369 int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
370 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
373 if (win == MPI_WIN_NULL) {
374 retval = MPI_ERR_WIN;
375 } else if (target_rank == MPI_PROC_NULL) {
376 *request = MPI_REQUEST_NULL;
377 retval = MPI_SUCCESS;
378 } else if (target_rank <0){
379 retval = MPI_ERR_RANK;
380 } else if (win->dynamic()==0 && target_disp <0){
381 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
382 retval = MPI_ERR_ARG;
383 } else if ((origin_count < 0 || target_count < 0) ||
384 (origin_addr==nullptr && origin_count > 0)){
385 retval = MPI_ERR_COUNT;
386 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
387 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
388 retval = MPI_ERR_TYPE;
389 } else if (op == MPI_OP_NULL) {
391 } else if(request == nullptr){
392 retval = MPI_ERR_REQUEST;
394 int rank = smpi_process()->index();
396 win->get_group(&group);
397 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Raccumulate", target_rank,
398 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
399 encode_datatype(origin_datatype)));
401 retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
402 target_datatype, op, request);
404 TRACE_smpi_comm_out(rank);
410 int PMPI_Get_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
411 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
412 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
415 if (win == MPI_WIN_NULL) {
416 retval = MPI_ERR_WIN;
417 } else if (target_rank == MPI_PROC_NULL) {
418 retval = MPI_SUCCESS;
419 } else if (target_rank <0){
420 retval = MPI_ERR_RANK;
421 } else if (win->dynamic()==0 && target_disp <0){
422 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
423 retval = MPI_ERR_ARG;
424 } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
425 (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
426 (result_addr==nullptr && result_count > 0)){
427 retval = MPI_ERR_COUNT;
428 } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
429 (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
430 retval = MPI_ERR_TYPE;
431 } else if (op == MPI_OP_NULL) {
434 int rank = smpi_process()->index();
436 win->get_group(&group);
437 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Get_accumulate", target_rank,
438 target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
439 encode_datatype(target_datatype)));
441 retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
442 result_count, result_datatype, target_rank, target_disp,
443 target_count, target_datatype, op);
445 TRACE_smpi_comm_out(rank);
452 int PMPI_Rget_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
453 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
454 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
457 if (win == MPI_WIN_NULL) {
458 retval = MPI_ERR_WIN;
459 } else if (target_rank == MPI_PROC_NULL) {
460 *request = MPI_REQUEST_NULL;
461 retval = MPI_SUCCESS;
462 } else if (target_rank <0){
463 retval = MPI_ERR_RANK;
464 } else if (win->dynamic()==0 && target_disp <0){
465 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
466 retval = MPI_ERR_ARG;
467 } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
468 (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
469 (result_addr==nullptr && result_count > 0)){
470 retval = MPI_ERR_COUNT;
471 } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
472 (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
473 retval = MPI_ERR_TYPE;
474 } else if (op == MPI_OP_NULL) {
476 } else if(request == nullptr){
477 retval = MPI_ERR_REQUEST;
479 int rank = smpi_process()->index();
481 win->get_group(&group);
482 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rget_accumulate", target_rank,
483 target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
484 encode_datatype(target_datatype)));
486 retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
487 result_count, result_datatype, target_rank, target_disp,
488 target_count, target_datatype, op, request);
490 TRACE_smpi_comm_out(rank);
496 int PMPI_Fetch_and_op(void *origin_addr, void *result_addr, MPI_Datatype dtype, int target_rank, MPI_Aint target_disp, MPI_Op op, MPI_Win win){
497 return PMPI_Get_accumulate(origin_addr, origin_addr==nullptr?0:1, dtype, result_addr, 1, dtype, target_rank, target_disp, 1, dtype, op, win);
500 int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
501 int target_rank, MPI_Aint target_disp, MPI_Win win)
505 if (win == MPI_WIN_NULL) {
506 retval = MPI_ERR_WIN;
507 } else if (target_rank == MPI_PROC_NULL) {
508 retval = MPI_SUCCESS;
509 } else if (target_rank <0){
510 retval = MPI_ERR_RANK;
511 } else if (win->dynamic()==0 && target_disp <0){
512 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
513 retval = MPI_ERR_ARG;
514 } else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){
515 retval = MPI_ERR_COUNT;
516 } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) {
517 retval = MPI_ERR_TYPE;
519 int rank = smpi_process()->index();
521 win->get_group(&group);
522 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Compare_and_swap", target_rank,
523 datatype->is_replayable() ? 1 : datatype->size(),
524 encode_datatype(datatype)));
526 retval = win->compare_and_swap(origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp);
528 TRACE_smpi_comm_out(rank);
534 int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){
537 if (win == MPI_WIN_NULL) {
538 retval = MPI_ERR_WIN;
539 } else if (group==MPI_GROUP_NULL){
540 retval = MPI_ERR_GROUP;
542 int rank = smpi_process()->index();
543 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_post"));
544 retval = win->post(group,assert);
545 TRACE_smpi_comm_out(rank);
551 int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
554 if (win == MPI_WIN_NULL) {
555 retval = MPI_ERR_WIN;
556 } else if (group==MPI_GROUP_NULL){
557 retval = MPI_ERR_GROUP;
559 int rank = smpi_process()->index();
560 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_start"));
561 retval = win->start(group,assert);
562 TRACE_smpi_comm_out(rank);
568 int PMPI_Win_complete(MPI_Win win){
571 if (win == MPI_WIN_NULL) {
572 retval = MPI_ERR_WIN;
574 int rank = smpi_process()->index();
575 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_complete"));
577 retval = win->complete();
579 TRACE_smpi_comm_out(rank);
585 int PMPI_Win_wait(MPI_Win win){
588 if (win == MPI_WIN_NULL) {
589 retval = MPI_ERR_WIN;
591 int rank = smpi_process()->index();
592 TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_wait"));
594 retval = win->wait();
596 TRACE_smpi_comm_out(rank);
602 int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){
605 if (win == MPI_WIN_NULL) {
606 retval = MPI_ERR_WIN;
607 } else if (lock_type != MPI_LOCK_EXCLUSIVE &&
608 lock_type != MPI_LOCK_SHARED) {
609 retval = MPI_ERR_LOCKTYPE;
610 } else if (rank == MPI_PROC_NULL){
611 retval = MPI_SUCCESS;
613 int myrank = smpi_process()->index();
614 TRACE_smpi_comm_in(myrank, __func__, new simgrid::instr::NoOpTIData("Win_lock"));
615 retval = win->lock(lock_type,rank,assert);
616 TRACE_smpi_comm_out(myrank);
622 int PMPI_Win_unlock(int rank, MPI_Win win){
625 if (win == MPI_WIN_NULL) {
626 retval = MPI_ERR_WIN;
627 } else if (rank == MPI_PROC_NULL){
628 retval = MPI_SUCCESS;
630 int myrank = smpi_process()->index();
631 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock"));
632 retval = win->unlock(rank);
633 TRACE_smpi_comm_out(myrank);
639 int PMPI_Win_lock_all(int assert, MPI_Win win){
642 if (win == MPI_WIN_NULL) {
643 retval = MPI_ERR_WIN;
645 int myrank = smpi_process()->index();
646 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_lock_all"));
647 retval = win->lock_all(assert);
648 TRACE_smpi_comm_out(myrank);
654 int PMPI_Win_unlock_all(MPI_Win win){
657 if (win == MPI_WIN_NULL) {
658 retval = MPI_ERR_WIN;
660 int myrank = smpi_process()->index();
661 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
662 retval = win->unlock_all();
663 TRACE_smpi_comm_out(myrank);
669 int PMPI_Win_flush(int rank, MPI_Win win){
672 if (win == MPI_WIN_NULL) {
673 retval = MPI_ERR_WIN;
674 } else if (rank == MPI_PROC_NULL){
675 retval = MPI_SUCCESS;
677 int myrank = smpi_process()->index();
678 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush"));
679 retval = win->flush(rank);
680 TRACE_smpi_comm_out(myrank);
686 int PMPI_Win_flush_local(int rank, MPI_Win win){
689 if (win == MPI_WIN_NULL) {
690 retval = MPI_ERR_WIN;
691 } else if (rank == MPI_PROC_NULL){
692 retval = MPI_SUCCESS;
694 int myrank = smpi_process()->index();
695 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local"));
696 retval = win->flush_local(rank);
697 TRACE_smpi_comm_out(myrank);
703 int PMPI_Win_flush_all(MPI_Win win){
706 if (win == MPI_WIN_NULL) {
707 retval = MPI_ERR_WIN;
709 int myrank = smpi_process()->index();
710 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_all"));
711 retval = win->flush_all();
712 TRACE_smpi_comm_out(myrank);
718 int PMPI_Win_flush_local_all(MPI_Win win){
721 if (win == MPI_WIN_NULL) {
722 retval = MPI_ERR_WIN;
724 int myrank = smpi_process()->index();
725 TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
726 retval = win->flush_local_all();
727 TRACE_smpi_comm_out(myrank);
734 int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
736 static MPI_Aint size;
737 static int disp_unit;
738 if (win==MPI_WIN_NULL)
743 *static_cast<void**>(attribute_val) = win->base();
748 *static_cast<MPI_Aint**>(attribute_val) = &size;
751 case MPI_WIN_DISP_UNIT :
752 disp_unit=win->disp_unit();
753 *static_cast<int**>(attribute_val) = &disp_unit;
757 return win->attr_get<simgrid::smpi::Win>(keyval, attribute_val, flag);
763 int PMPI_Win_set_attr (MPI_Win win, int type_keyval, void *attribute_val)
765 if (win==MPI_WIN_NULL)
768 return win->attr_put<simgrid::smpi::Win>(type_keyval, attribute_val);
771 int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
773 if (win==MPI_WIN_NULL)
776 return win->attr_delete<simgrid::smpi::Win>(type_keyval);
779 int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
782 smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn};
783 smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn};
784 return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
787 int PMPI_Win_free_keyval(int* keyval) {
788 return simgrid::smpi::Keyval::keyval_free<simgrid::smpi::Win>(keyval);
791 MPI_Win PMPI_Win_f2c(MPI_Fint win){
792 return static_cast<MPI_Win>(simgrid::smpi::Win::f2c(win));
795 MPI_Fint PMPI_Win_c2f(MPI_Win win){