1 /* Copyright (c) 2007-2018. 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 */
18 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
21 if (comm == MPI_COMM_NULL) {
23 }else if ((base == nullptr && size != 0) || disp_unit <= 0 || size < 0 ){
24 retval= MPI_ERR_OTHER;
26 *win = new simgrid::smpi::Win( base, size, disp_unit, info, comm);
33 int PMPI_Win_allocate( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
36 if (comm == MPI_COMM_NULL) {
38 }else if (disp_unit <= 0 || size < 0 ){
39 retval= MPI_ERR_OTHER;
41 void* ptr = xbt_malloc(size);
43 return MPI_ERR_NO_MEM;
44 *static_cast<void**>(base) = ptr;
45 *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,1);
52 int PMPI_Win_create_dynamic( MPI_Info info, MPI_Comm comm, MPI_Win *win){
55 if (comm == MPI_COMM_NULL) {
58 *win = new simgrid::smpi::Win(info, comm);
65 int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){
68 if(win == MPI_WIN_NULL){
70 } else if ((base == nullptr && size != 0) || size < 0 ){
71 retval= MPI_ERR_OTHER;
73 retval = win->attach(base, size);
79 int PMPI_Win_detach(MPI_Win win, void* base)
83 if(win == MPI_WIN_NULL){
85 } else if (base == nullptr){
86 retval= MPI_ERR_OTHER;
88 retval = win->detach(base);
95 int PMPI_Win_free( MPI_Win* win){
98 if (win == nullptr || *win == MPI_WIN_NULL) {
108 int PMPI_Win_set_name(MPI_Win win, char * name)
110 if (win == MPI_WIN_NULL) {
112 } else if (name == nullptr) {
120 int PMPI_Win_get_name(MPI_Win win, char * name, int* len)
122 if (win == MPI_WIN_NULL) {
124 } else if (name == nullptr) {
127 win->get_name(name, len);
132 int PMPI_Win_get_info(MPI_Win win, MPI_Info* info)
134 if (win == MPI_WIN_NULL) {
142 int PMPI_Win_set_info(MPI_Win win, MPI_Info info)
144 if (win == MPI_WIN_NULL) {
152 int PMPI_Win_get_group(MPI_Win win, MPI_Group * group){
153 if (win == MPI_WIN_NULL) {
156 win->get_group(group);
162 int PMPI_Win_fence( int assert, MPI_Win win){
165 if (win == MPI_WIN_NULL) {
166 retval = MPI_ERR_WIN;
168 int my_proc_id = simgrid::s4u::this_actor::getPid();
169 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_fence"));
170 retval = win->fence(assert);
171 TRACE_smpi_comm_out(my_proc_id);
177 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
178 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
181 if (win == MPI_WIN_NULL) {
182 retval = MPI_ERR_WIN;
183 } else if (target_rank == MPI_PROC_NULL) {
184 retval = MPI_SUCCESS;
185 } else if (target_rank <0){
186 retval = MPI_ERR_RANK;
187 } else if (win->dynamic()==0 && target_disp <0){
188 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
189 retval = MPI_ERR_ARG;
190 } else if ((origin_count < 0 || target_count < 0) ||
191 (origin_addr==nullptr && origin_count > 0)){
192 retval = MPI_ERR_COUNT;
193 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
194 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
195 retval = MPI_ERR_TYPE;
197 int my_proc_id = simgrid::s4u::this_actor::getPid();
199 win->get_group(&group);
200 TRACE_smpi_comm_in(my_proc_id, __func__,
201 new simgrid::instr::Pt2PtTIData("Get", target_rank, origin_datatype->is_replayable()
203 : origin_count * origin_datatype->size(),
204 simgrid::smpi::Datatype::encode(origin_datatype)));
206 retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
209 TRACE_smpi_comm_out(my_proc_id);
215 int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
216 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
219 if (win == MPI_WIN_NULL) {
220 retval = MPI_ERR_WIN;
221 } else if (target_rank == MPI_PROC_NULL) {
222 *request = MPI_REQUEST_NULL;
223 retval = MPI_SUCCESS;
224 } else if (target_rank <0){
225 retval = MPI_ERR_RANK;
226 } else if (win->dynamic()==0 && target_disp <0){
227 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
228 retval = MPI_ERR_ARG;
229 } else if ((origin_count < 0 || target_count < 0) ||
230 (origin_addr==nullptr && origin_count > 0)){
231 retval = MPI_ERR_COUNT;
232 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
233 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
234 retval = MPI_ERR_TYPE;
235 } else if(request == nullptr){
236 retval = MPI_ERR_REQUEST;
238 int my_proc_id = simgrid::s4u::this_actor::getPid();
240 win->get_group(&group);
241 TRACE_smpi_comm_in(my_proc_id, __func__,
242 new simgrid::instr::Pt2PtTIData(
244 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
245 simgrid::smpi::Datatype::encode(origin_datatype)));
247 retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
248 target_datatype, request);
250 TRACE_smpi_comm_out(my_proc_id);
256 int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
257 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
260 if (win == MPI_WIN_NULL) {
261 retval = MPI_ERR_WIN;
262 } else if (target_rank == MPI_PROC_NULL) {
263 retval = MPI_SUCCESS;
264 } else if (target_rank <0){
265 retval = MPI_ERR_RANK;
266 } else if (win->dynamic()==0 && target_disp <0){
267 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
268 retval = MPI_ERR_ARG;
269 } else if ((origin_count < 0 || target_count < 0) ||
270 (origin_addr==nullptr && origin_count > 0)){
271 retval = MPI_ERR_COUNT;
272 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
273 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
274 retval = MPI_ERR_TYPE;
276 int my_proc_id = simgrid::s4u::this_actor::getPid();
278 win->get_group(&group);
279 int dst_traced = group->actor(target_rank)->get_pid();
280 TRACE_smpi_comm_in(my_proc_id, __func__,
281 new simgrid::instr::Pt2PtTIData("Put", target_rank, origin_datatype->is_replayable()
283 : origin_count * origin_datatype->size(),
284 simgrid::smpi::Datatype::encode(origin_datatype)));
285 TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, SMPI_RMA_TAG, origin_count * origin_datatype->size());
287 retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
290 TRACE_smpi_comm_out(my_proc_id);
296 int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
297 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
300 if (win == MPI_WIN_NULL) {
301 retval = MPI_ERR_WIN;
302 } else if (target_rank == MPI_PROC_NULL) {
303 *request = MPI_REQUEST_NULL;
304 retval = MPI_SUCCESS;
305 } else if (target_rank <0){
306 retval = MPI_ERR_RANK;
307 } else if (win->dynamic()==0 && target_disp <0){
308 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
309 retval = MPI_ERR_ARG;
310 } else if ((origin_count < 0 || target_count < 0) ||
311 (origin_addr==nullptr && origin_count > 0)){
312 retval = MPI_ERR_COUNT;
313 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
314 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
315 retval = MPI_ERR_TYPE;
316 } else if(request == nullptr){
317 retval = MPI_ERR_REQUEST;
319 int my_proc_id = simgrid::s4u::this_actor::getPid();
321 win->get_group(&group);
322 int dst_traced = group->actor(target_rank)->get_pid();
323 TRACE_smpi_comm_in(my_proc_id, __func__,
324 new simgrid::instr::Pt2PtTIData(
326 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
327 simgrid::smpi::Datatype::encode(origin_datatype)));
328 TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, SMPI_RMA_TAG, origin_count * origin_datatype->size());
330 retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
331 target_datatype, request);
333 TRACE_smpi_comm_out(my_proc_id);
339 int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
340 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
343 if (win == MPI_WIN_NULL) {
344 retval = MPI_ERR_WIN;
345 } else if (target_rank == MPI_PROC_NULL) {
346 retval = MPI_SUCCESS;
347 } else if (target_rank <0){
348 retval = MPI_ERR_RANK;
349 } else if (win->dynamic()==0 && target_disp <0){
350 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
351 retval = MPI_ERR_ARG;
352 } else if ((origin_count < 0 || target_count < 0) ||
353 (origin_addr==nullptr && origin_count > 0)){
354 retval = MPI_ERR_COUNT;
355 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
356 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
357 retval = MPI_ERR_TYPE;
358 } else if (op == MPI_OP_NULL) {
361 int my_proc_id = simgrid::s4u::this_actor::getPid();
363 win->get_group(&group);
364 TRACE_smpi_comm_in(my_proc_id, __func__,
365 new simgrid::instr::Pt2PtTIData(
366 "Accumulate", target_rank,
367 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
368 simgrid::smpi::Datatype::encode(origin_datatype)));
369 retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
370 target_datatype, op);
372 TRACE_smpi_comm_out(my_proc_id);
378 int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
379 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
382 if (win == MPI_WIN_NULL) {
383 retval = MPI_ERR_WIN;
384 } else if (target_rank == MPI_PROC_NULL) {
385 *request = MPI_REQUEST_NULL;
386 retval = MPI_SUCCESS;
387 } else if (target_rank <0){
388 retval = MPI_ERR_RANK;
389 } else if (win->dynamic()==0 && target_disp <0){
390 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
391 retval = MPI_ERR_ARG;
392 } else if ((origin_count < 0 || target_count < 0) ||
393 (origin_addr==nullptr && origin_count > 0)){
394 retval = MPI_ERR_COUNT;
395 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
396 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
397 retval = MPI_ERR_TYPE;
398 } else if (op == MPI_OP_NULL) {
400 } else if(request == nullptr){
401 retval = MPI_ERR_REQUEST;
403 int my_proc_id = simgrid::s4u::this_actor::getPid();
405 win->get_group(&group);
406 TRACE_smpi_comm_in(my_proc_id, __func__,
407 new simgrid::instr::Pt2PtTIData(
408 "Raccumulate", target_rank,
409 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
410 simgrid::smpi::Datatype::encode(origin_datatype)));
412 retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
413 target_datatype, op, request);
415 TRACE_smpi_comm_out(my_proc_id);
421 int PMPI_Get_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
422 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
423 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
426 if (win == MPI_WIN_NULL) {
427 retval = MPI_ERR_WIN;
428 } else if (target_rank == MPI_PROC_NULL) {
429 retval = MPI_SUCCESS;
430 } else if (target_rank <0){
431 retval = MPI_ERR_RANK;
432 } else if (win->dynamic()==0 && target_disp <0){
433 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
434 retval = MPI_ERR_ARG;
435 } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
436 (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
437 (result_addr==nullptr && result_count > 0)){
438 retval = MPI_ERR_COUNT;
439 } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
440 (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
441 retval = MPI_ERR_TYPE;
442 } else if (op == MPI_OP_NULL) {
445 int my_proc_id = simgrid::s4u::this_actor::getPid();
447 win->get_group(&group);
448 TRACE_smpi_comm_in(my_proc_id, __func__,
449 new simgrid::instr::Pt2PtTIData(
450 "Get_accumulate", target_rank,
451 target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
452 simgrid::smpi::Datatype::encode(target_datatype)));
454 retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
455 result_count, result_datatype, target_rank, target_disp,
456 target_count, target_datatype, op);
458 TRACE_smpi_comm_out(my_proc_id);
465 int PMPI_Rget_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
466 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
467 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
470 if (win == MPI_WIN_NULL) {
471 retval = MPI_ERR_WIN;
472 } else if (target_rank == MPI_PROC_NULL) {
473 *request = MPI_REQUEST_NULL;
474 retval = MPI_SUCCESS;
475 } else if (target_rank <0){
476 retval = MPI_ERR_RANK;
477 } else if (win->dynamic()==0 && target_disp <0){
478 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
479 retval = MPI_ERR_ARG;
480 } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
481 (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
482 (result_addr==nullptr && result_count > 0)){
483 retval = MPI_ERR_COUNT;
484 } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
485 (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
486 retval = MPI_ERR_TYPE;
487 } else if (op == MPI_OP_NULL) {
489 } else if(request == nullptr){
490 retval = MPI_ERR_REQUEST;
492 int my_proc_id = simgrid::s4u::this_actor::getPid();
494 win->get_group(&group);
495 TRACE_smpi_comm_in(my_proc_id, __func__,
496 new simgrid::instr::Pt2PtTIData(
497 "Rget_accumulate", target_rank,
498 target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
499 simgrid::smpi::Datatype::encode(target_datatype)));
501 retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
502 result_count, result_datatype, target_rank, target_disp,
503 target_count, target_datatype, op, request);
505 TRACE_smpi_comm_out(my_proc_id);
511 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){
512 return PMPI_Get_accumulate(origin_addr, origin_addr==nullptr?0:1, dtype, result_addr, 1, dtype, target_rank, target_disp, 1, dtype, op, win);
515 int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
516 int target_rank, MPI_Aint target_disp, MPI_Win win)
520 if (win == MPI_WIN_NULL) {
521 retval = MPI_ERR_WIN;
522 } else if (target_rank == MPI_PROC_NULL) {
523 retval = MPI_SUCCESS;
524 } else if (target_rank <0){
525 retval = MPI_ERR_RANK;
526 } else if (win->dynamic()==0 && target_disp <0){
527 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
528 retval = MPI_ERR_ARG;
529 } else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){
530 retval = MPI_ERR_COUNT;
531 } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) {
532 retval = MPI_ERR_TYPE;
534 int my_proc_id = simgrid::s4u::this_actor::getPid();
536 win->get_group(&group);
537 TRACE_smpi_comm_in(my_proc_id, __func__,
538 new simgrid::instr::Pt2PtTIData("Compare_and_swap", target_rank,
539 datatype->is_replayable() ? 1 : datatype->size(),
540 simgrid::smpi::Datatype::encode(datatype)));
542 retval = win->compare_and_swap(origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp);
544 TRACE_smpi_comm_out(my_proc_id);
550 int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){
553 if (win == MPI_WIN_NULL) {
554 retval = MPI_ERR_WIN;
555 } else if (group==MPI_GROUP_NULL){
556 retval = MPI_ERR_GROUP;
558 int my_proc_id = simgrid::s4u::this_actor::getPid();
559 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_post"));
560 retval = win->post(group,assert);
561 TRACE_smpi_comm_out(my_proc_id);
567 int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
570 if (win == MPI_WIN_NULL) {
571 retval = MPI_ERR_WIN;
572 } else if (group==MPI_GROUP_NULL){
573 retval = MPI_ERR_GROUP;
575 int my_proc_id = simgrid::s4u::this_actor::getPid();
576 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_start"));
577 retval = win->start(group,assert);
578 TRACE_smpi_comm_out(my_proc_id);
584 int PMPI_Win_complete(MPI_Win win){
587 if (win == MPI_WIN_NULL) {
588 retval = MPI_ERR_WIN;
590 int my_proc_id = simgrid::s4u::this_actor::getPid();
591 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_complete"));
593 retval = win->complete();
595 TRACE_smpi_comm_out(my_proc_id);
601 int PMPI_Win_wait(MPI_Win win){
604 if (win == MPI_WIN_NULL) {
605 retval = MPI_ERR_WIN;
607 int my_proc_id = simgrid::s4u::this_actor::getPid();
608 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_wait"));
610 retval = win->wait();
612 TRACE_smpi_comm_out(my_proc_id);
618 int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){
621 if (win == MPI_WIN_NULL) {
622 retval = MPI_ERR_WIN;
623 } else if (lock_type != MPI_LOCK_EXCLUSIVE &&
624 lock_type != MPI_LOCK_SHARED) {
625 retval = MPI_ERR_LOCKTYPE;
626 } else if (rank == MPI_PROC_NULL){
627 retval = MPI_SUCCESS;
629 int my_proc_id = simgrid::s4u::this_actor::getPid();
630 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock"));
631 retval = win->lock(lock_type,rank,assert);
632 TRACE_smpi_comm_out(my_proc_id);
638 int PMPI_Win_unlock(int rank, MPI_Win win){
641 if (win == MPI_WIN_NULL) {
642 retval = MPI_ERR_WIN;
643 } else if (rank == MPI_PROC_NULL){
644 retval = MPI_SUCCESS;
646 int my_proc_id = simgrid::s4u::this_actor::getPid();
647 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock"));
648 retval = win->unlock(rank);
649 TRACE_smpi_comm_out(my_proc_id);
655 int PMPI_Win_lock_all(int assert, MPI_Win win){
658 if (win == MPI_WIN_NULL) {
659 retval = MPI_ERR_WIN;
661 int my_proc_id = simgrid::s4u::this_actor::getPid();
662 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock_all"));
663 retval = win->lock_all(assert);
664 TRACE_smpi_comm_out(my_proc_id);
670 int PMPI_Win_unlock_all(MPI_Win win){
673 if (win == MPI_WIN_NULL) {
674 retval = MPI_ERR_WIN;
676 int my_proc_id = simgrid::s4u::this_actor::getPid();
677 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
678 retval = win->unlock_all();
679 TRACE_smpi_comm_out(my_proc_id);
685 int PMPI_Win_flush(int rank, MPI_Win win){
688 if (win == MPI_WIN_NULL) {
689 retval = MPI_ERR_WIN;
690 } else if (rank == MPI_PROC_NULL){
691 retval = MPI_SUCCESS;
693 int my_proc_id = simgrid::s4u::this_actor::getPid();
694 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush"));
695 retval = win->flush(rank);
696 TRACE_smpi_comm_out(my_proc_id);
702 int PMPI_Win_flush_local(int rank, MPI_Win win){
705 if (win == MPI_WIN_NULL) {
706 retval = MPI_ERR_WIN;
707 } else if (rank == MPI_PROC_NULL){
708 retval = MPI_SUCCESS;
710 int my_proc_id = simgrid::s4u::this_actor::getPid();
711 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local"));
712 retval = win->flush_local(rank);
713 TRACE_smpi_comm_out(my_proc_id);
719 int PMPI_Win_flush_all(MPI_Win win){
722 if (win == MPI_WIN_NULL) {
723 retval = MPI_ERR_WIN;
725 int my_proc_id = simgrid::s4u::this_actor::getPid();
726 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_all"));
727 retval = win->flush_all();
728 TRACE_smpi_comm_out(my_proc_id);
734 int PMPI_Win_flush_local_all(MPI_Win win){
737 if (win == MPI_WIN_NULL) {
738 retval = MPI_ERR_WIN;
740 int my_proc_id = simgrid::s4u::this_actor::getPid();
741 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
742 retval = win->flush_local_all();
743 TRACE_smpi_comm_out(my_proc_id);
750 int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
752 static MPI_Aint size;
753 static int disp_unit;
754 if (win==MPI_WIN_NULL)
759 *static_cast<void**>(attribute_val) = win->base();
764 *static_cast<MPI_Aint**>(attribute_val) = &size;
767 case MPI_WIN_DISP_UNIT :
768 disp_unit=win->disp_unit();
769 *static_cast<int**>(attribute_val) = &disp_unit;
773 return win->attr_get<simgrid::smpi::Win>(keyval, attribute_val, flag);
779 int PMPI_Win_set_attr (MPI_Win win, int type_keyval, void *attribute_val)
781 if (win==MPI_WIN_NULL)
784 return win->attr_put<simgrid::smpi::Win>(type_keyval, attribute_val);
787 int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
789 if (win==MPI_WIN_NULL)
792 return win->attr_delete<simgrid::smpi::Win>(type_keyval);
795 int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
798 smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn};
799 smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn};
800 return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
803 int PMPI_Win_free_keyval(int* keyval) {
804 return simgrid::smpi::Keyval::keyval_free<simgrid::smpi::Win>(keyval);
807 MPI_Win PMPI_Win_f2c(MPI_Fint win){
808 return static_cast<MPI_Win>(simgrid::smpi::Win::f2c(win));
811 MPI_Fint PMPI_Win_c2f(MPI_Win win){