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 my_proc_id = simgrid::s4u::Actor::self()->getPid();
170 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_fence"));
171 retval = win->fence(assert);
172 TRACE_smpi_comm_out(my_proc_id);
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 my_proc_id = simgrid::s4u::Actor::self()->getPid();
200 win->get_group(&group);
201 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
202 new simgrid::instr::Pt2PtTIData("Get", target_rank, origin_datatype->is_replayable()
204 : origin_count * origin_datatype->size(),
205 encode_datatype(origin_datatype)));
207 retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
210 TRACE_smpi_comm_out(my_proc_id);
216 int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
217 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
220 if (win == MPI_WIN_NULL) {
221 retval = MPI_ERR_WIN;
222 } else if (target_rank == MPI_PROC_NULL) {
223 *request = MPI_REQUEST_NULL;
224 retval = MPI_SUCCESS;
225 } else if (target_rank <0){
226 retval = MPI_ERR_RANK;
227 } else if (win->dynamic()==0 && target_disp <0){
228 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
229 retval = MPI_ERR_ARG;
230 } else if ((origin_count < 0 || target_count < 0) ||
231 (origin_addr==nullptr && origin_count > 0)){
232 retval = MPI_ERR_COUNT;
233 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
234 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
235 retval = MPI_ERR_TYPE;
236 } else if(request == nullptr){
237 retval = MPI_ERR_REQUEST;
239 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
241 win->get_group(&group);
242 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
243 new simgrid::instr::Pt2PtTIData(
245 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
246 encode_datatype(origin_datatype)));
248 retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
249 target_datatype, request);
251 TRACE_smpi_comm_out(my_proc_id);
257 int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
258 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
261 if (win == MPI_WIN_NULL) {
262 retval = MPI_ERR_WIN;
263 } else if (target_rank == MPI_PROC_NULL) {
264 retval = MPI_SUCCESS;
265 } else if (target_rank <0){
266 retval = MPI_ERR_RANK;
267 } else if (win->dynamic()==0 && target_disp <0){
268 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
269 retval = MPI_ERR_ARG;
270 } else if ((origin_count < 0 || target_count < 0) ||
271 (origin_addr==nullptr && origin_count > 0)){
272 retval = MPI_ERR_COUNT;
273 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
274 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
275 retval = MPI_ERR_TYPE;
277 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
279 win->get_group(&group);
280 int dst_traced = group->actor(target_rank)->getPid();
281 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
282 new simgrid::instr::Pt2PtTIData("Put", target_rank, origin_datatype->is_replayable()
284 : origin_count * origin_datatype->size(),
285 encode_datatype(origin_datatype)));
286 TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, SMPI_RMA_TAG, origin_count * origin_datatype->size());
288 retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
291 TRACE_smpi_comm_out(my_proc_id);
297 int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
298 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
301 if (win == MPI_WIN_NULL) {
302 retval = MPI_ERR_WIN;
303 } else if (target_rank == MPI_PROC_NULL) {
304 *request = MPI_REQUEST_NULL;
305 retval = MPI_SUCCESS;
306 } else if (target_rank <0){
307 retval = MPI_ERR_RANK;
308 } else if (win->dynamic()==0 && target_disp <0){
309 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
310 retval = MPI_ERR_ARG;
311 } else if ((origin_count < 0 || target_count < 0) ||
312 (origin_addr==nullptr && origin_count > 0)){
313 retval = MPI_ERR_COUNT;
314 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
315 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
316 retval = MPI_ERR_TYPE;
317 } else if(request == nullptr){
318 retval = MPI_ERR_REQUEST;
320 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
322 win->get_group(&group);
323 int dst_traced = group->actor(target_rank)->getPid();
324 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
325 new simgrid::instr::Pt2PtTIData(
327 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
328 encode_datatype(origin_datatype)));
329 TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, SMPI_RMA_TAG, origin_count * origin_datatype->size());
331 retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
332 target_datatype, request);
334 TRACE_smpi_comm_out(my_proc_id);
340 int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
341 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
344 if (win == MPI_WIN_NULL) {
345 retval = MPI_ERR_WIN;
346 } else if (target_rank == MPI_PROC_NULL) {
347 retval = MPI_SUCCESS;
348 } else if (target_rank <0){
349 retval = MPI_ERR_RANK;
350 } else if (win->dynamic()==0 && target_disp <0){
351 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
352 retval = MPI_ERR_ARG;
353 } else if ((origin_count < 0 || target_count < 0) ||
354 (origin_addr==nullptr && origin_count > 0)){
355 retval = MPI_ERR_COUNT;
356 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
357 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
358 retval = MPI_ERR_TYPE;
359 } else if (op == MPI_OP_NULL) {
362 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
364 win->get_group(&group);
365 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
366 new simgrid::instr::Pt2PtTIData(
367 "Accumulate", target_rank,
368 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
369 encode_datatype(origin_datatype)));
370 retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
371 target_datatype, op);
373 TRACE_smpi_comm_out(my_proc_id);
379 int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
380 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
383 if (win == MPI_WIN_NULL) {
384 retval = MPI_ERR_WIN;
385 } else if (target_rank == MPI_PROC_NULL) {
386 *request = MPI_REQUEST_NULL;
387 retval = MPI_SUCCESS;
388 } else if (target_rank <0){
389 retval = MPI_ERR_RANK;
390 } else if (win->dynamic()==0 && target_disp <0){
391 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
392 retval = MPI_ERR_ARG;
393 } else if ((origin_count < 0 || target_count < 0) ||
394 (origin_addr==nullptr && origin_count > 0)){
395 retval = MPI_ERR_COUNT;
396 } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
397 ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
398 retval = MPI_ERR_TYPE;
399 } else if (op == MPI_OP_NULL) {
401 } else if(request == nullptr){
402 retval = MPI_ERR_REQUEST;
404 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
406 win->get_group(&group);
407 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
408 new simgrid::instr::Pt2PtTIData(
409 "Raccumulate", target_rank,
410 origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
411 encode_datatype(origin_datatype)));
413 retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
414 target_datatype, op, request);
416 TRACE_smpi_comm_out(my_proc_id);
422 int PMPI_Get_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
423 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
424 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
427 if (win == MPI_WIN_NULL) {
428 retval = MPI_ERR_WIN;
429 } else if (target_rank == MPI_PROC_NULL) {
430 retval = MPI_SUCCESS;
431 } else if (target_rank <0){
432 retval = MPI_ERR_RANK;
433 } else if (win->dynamic()==0 && target_disp <0){
434 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
435 retval = MPI_ERR_ARG;
436 } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
437 (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
438 (result_addr==nullptr && result_count > 0)){
439 retval = MPI_ERR_COUNT;
440 } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
441 (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
442 retval = MPI_ERR_TYPE;
443 } else if (op == MPI_OP_NULL) {
446 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
448 win->get_group(&group);
449 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
450 new simgrid::instr::Pt2PtTIData(
451 "Get_accumulate", target_rank,
452 target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
453 encode_datatype(target_datatype)));
455 retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
456 result_count, result_datatype, target_rank, target_disp,
457 target_count, target_datatype, op);
459 TRACE_smpi_comm_out(my_proc_id);
466 int PMPI_Rget_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
467 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
468 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
471 if (win == MPI_WIN_NULL) {
472 retval = MPI_ERR_WIN;
473 } else if (target_rank == MPI_PROC_NULL) {
474 *request = MPI_REQUEST_NULL;
475 retval = MPI_SUCCESS;
476 } else if (target_rank <0){
477 retval = MPI_ERR_RANK;
478 } else if (win->dynamic()==0 && target_disp <0){
479 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
480 retval = MPI_ERR_ARG;
481 } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
482 (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
483 (result_addr==nullptr && result_count > 0)){
484 retval = MPI_ERR_COUNT;
485 } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
486 (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
487 retval = MPI_ERR_TYPE;
488 } else if (op == MPI_OP_NULL) {
490 } else if(request == nullptr){
491 retval = MPI_ERR_REQUEST;
493 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
495 win->get_group(&group);
496 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
497 new simgrid::instr::Pt2PtTIData(
498 "Rget_accumulate", target_rank,
499 target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
500 encode_datatype(target_datatype)));
502 retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
503 result_count, result_datatype, target_rank, target_disp,
504 target_count, target_datatype, op, request);
506 TRACE_smpi_comm_out(my_proc_id);
512 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){
513 return PMPI_Get_accumulate(origin_addr, origin_addr==nullptr?0:1, dtype, result_addr, 1, dtype, target_rank, target_disp, 1, dtype, op, win);
516 int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
517 int target_rank, MPI_Aint target_disp, MPI_Win win)
521 if (win == MPI_WIN_NULL) {
522 retval = MPI_ERR_WIN;
523 } else if (target_rank == MPI_PROC_NULL) {
524 retval = MPI_SUCCESS;
525 } else if (target_rank <0){
526 retval = MPI_ERR_RANK;
527 } else if (win->dynamic()==0 && target_disp <0){
528 //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
529 retval = MPI_ERR_ARG;
530 } else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){
531 retval = MPI_ERR_COUNT;
532 } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) {
533 retval = MPI_ERR_TYPE;
535 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
537 win->get_group(&group);
538 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
539 new simgrid::instr::Pt2PtTIData("Compare_and_swap", target_rank,
540 datatype->is_replayable() ? 1 : datatype->size(),
541 encode_datatype(datatype)));
543 retval = win->compare_and_swap(origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp);
545 TRACE_smpi_comm_out(my_proc_id);
551 int PMPI_Win_post(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 my_proc_id = simgrid::s4u::Actor::self()->getPid();
560 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_post"));
561 retval = win->post(group,assert);
562 TRACE_smpi_comm_out(my_proc_id);
568 int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
571 if (win == MPI_WIN_NULL) {
572 retval = MPI_ERR_WIN;
573 } else if (group==MPI_GROUP_NULL){
574 retval = MPI_ERR_GROUP;
576 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
577 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_start"));
578 retval = win->start(group,assert);
579 TRACE_smpi_comm_out(my_proc_id);
585 int PMPI_Win_complete(MPI_Win win){
588 if (win == MPI_WIN_NULL) {
589 retval = MPI_ERR_WIN;
591 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
592 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_complete"));
594 retval = win->complete();
596 TRACE_smpi_comm_out(my_proc_id);
602 int PMPI_Win_wait(MPI_Win win){
605 if (win == MPI_WIN_NULL) {
606 retval = MPI_ERR_WIN;
608 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
609 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_wait"));
611 retval = win->wait();
613 TRACE_smpi_comm_out(my_proc_id);
619 int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){
622 if (win == MPI_WIN_NULL) {
623 retval = MPI_ERR_WIN;
624 } else if (lock_type != MPI_LOCK_EXCLUSIVE &&
625 lock_type != MPI_LOCK_SHARED) {
626 retval = MPI_ERR_LOCKTYPE;
627 } else if (rank == MPI_PROC_NULL){
628 retval = MPI_SUCCESS;
630 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
631 TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock"));
632 retval = win->lock(lock_type,rank,assert);
633 TRACE_smpi_comm_out(my_proc_id);
639 int PMPI_Win_unlock(int rank, MPI_Win win){
642 if (win == MPI_WIN_NULL) {
643 retval = MPI_ERR_WIN;
644 } else if (rank == MPI_PROC_NULL){
645 retval = MPI_SUCCESS;
647 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
648 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock"));
649 retval = win->unlock(rank);
650 TRACE_smpi_comm_out(my_proc_id);
656 int PMPI_Win_lock_all(int assert, MPI_Win win){
659 if (win == MPI_WIN_NULL) {
660 retval = MPI_ERR_WIN;
662 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
663 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_lock_all"));
664 retval = win->lock_all(assert);
665 TRACE_smpi_comm_out(my_proc_id);
671 int PMPI_Win_unlock_all(MPI_Win win){
674 if (win == MPI_WIN_NULL) {
675 retval = MPI_ERR_WIN;
677 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
678 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
679 retval = win->unlock_all();
680 TRACE_smpi_comm_out(my_proc_id);
686 int PMPI_Win_flush(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 my_proc_id = simgrid::s4u::Actor::self()->getPid();
695 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush"));
696 retval = win->flush(rank);
697 TRACE_smpi_comm_out(my_proc_id);
703 int PMPI_Win_flush_local(int rank, MPI_Win win){
706 if (win == MPI_WIN_NULL) {
707 retval = MPI_ERR_WIN;
708 } else if (rank == MPI_PROC_NULL){
709 retval = MPI_SUCCESS;
711 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
712 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local"));
713 retval = win->flush_local(rank);
714 TRACE_smpi_comm_out(my_proc_id);
720 int PMPI_Win_flush_all(MPI_Win win){
723 if (win == MPI_WIN_NULL) {
724 retval = MPI_ERR_WIN;
726 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
727 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_all"));
728 retval = win->flush_all();
729 TRACE_smpi_comm_out(my_proc_id);
735 int PMPI_Win_flush_local_all(MPI_Win win){
738 if (win == MPI_WIN_NULL) {
739 retval = MPI_ERR_WIN;
741 int my_proc_id = simgrid::s4u::Actor::self()->getPid();
742 TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
743 retval = win->flush_local_all();
744 TRACE_smpi_comm_out(my_proc_id);
751 int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
753 static MPI_Aint size;
754 static int disp_unit;
755 if (win==MPI_WIN_NULL)
760 *static_cast<void**>(attribute_val) = win->base();
765 *static_cast<MPI_Aint**>(attribute_val) = &size;
768 case MPI_WIN_DISP_UNIT :
769 disp_unit=win->disp_unit();
770 *static_cast<int**>(attribute_val) = &disp_unit;
774 return win->attr_get<simgrid::smpi::Win>(keyval, attribute_val, flag);
780 int PMPI_Win_set_attr (MPI_Win win, int type_keyval, void *attribute_val)
782 if (win==MPI_WIN_NULL)
785 return win->attr_put<simgrid::smpi::Win>(type_keyval, attribute_val);
788 int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
790 if (win==MPI_WIN_NULL)
793 return win->attr_delete<simgrid::smpi::Win>(type_keyval);
796 int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
799 smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn};
800 smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn};
801 return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
804 int PMPI_Win_free_keyval(int* keyval) {
805 return simgrid::smpi::Keyval::keyval_free<simgrid::smpi::Win>(keyval);
808 MPI_Win PMPI_Win_f2c(MPI_Fint win){
809 return static_cast<MPI_Win>(simgrid::smpi::Win::f2c(win));
812 MPI_Fint PMPI_Win_c2f(MPI_Win win){