Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / smpi / bindings / smpi_pmpi_win.cpp
index 903371e..6bbeef2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,8 +8,8 @@
 #include "smpi_comm.hpp"
 #include "smpi_datatype_derived.hpp"
 #include "smpi_op.hpp"
-#include "smpi_process.hpp"
 #include "smpi_win.hpp"
+#include "src/smpi/include/smpi_actor.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
 
@@ -49,6 +49,33 @@ int PMPI_Win_allocate( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm com
   return retval;
 }
 
+int PMPI_Win_allocate_shared( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
+  int retval = 0;
+  smpi_bench_end();
+  if (comm == MPI_COMM_NULL) {
+    retval= MPI_ERR_COMM;
+  }else if (disp_unit <= 0 || size < 0 ){
+    retval= MPI_ERR_OTHER;
+  }else{
+    void* ptr = nullptr;
+    int rank = comm->rank();
+    if(rank==0){
+       ptr = xbt_malloc(size*comm->size());
+       if(ptr==nullptr)
+         return MPI_ERR_NO_MEM;
+    }
+    
+    simgrid::smpi::Colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm);
+    simgrid::smpi::Colls::barrier(comm);
+    
+    *static_cast<void**>(base) = (char*)ptr+rank*size;
+    *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
 int PMPI_Win_create_dynamic( MPI_Info info, MPI_Comm comm, MPI_Win *win){
   int retval = 0;
   smpi_bench_end();
@@ -76,7 +103,7 @@ int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){
   return retval;
 }
 
-int PMPI_Win_detach(MPI_Win win, void* base)
+int PMPI_Win_detach(MPI_Win win, const void* base)
 {
   int retval = 0;
   smpi_bench_end();
@@ -105,7 +132,7 @@ int PMPI_Win_free( MPI_Win* win){
   return retval;
 }
 
-int PMPI_Win_set_name(MPI_Win  win, char * name)
+int PMPI_Win_set_name(MPI_Win  win, const char * name)
 {
   if (win == MPI_WIN_NULL)  {
     return MPI_ERR_TYPE;
@@ -165,8 +192,8 @@ int PMPI_Win_fence( int assert,  MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_fence"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_fence"));
     retval = win->fence(assert);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -194,10 +221,10 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
             ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
     retval = MPI_ERR_TYPE;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData("Get", target_rank, origin_datatype->is_replayable()
                                                                                ? origin_count
                                                                                : origin_count * origin_datatype->size(),
@@ -235,10 +262,10 @@ int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
   } else if(request == nullptr){
     retval = MPI_ERR_REQUEST;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData(
                            "Rget", target_rank,
                            origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
@@ -253,7 +280,7 @@ int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
   return retval;
 }
 
-int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+int PMPI_Put(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
   int retval = 0;
   smpi_bench_end();
@@ -273,11 +300,11 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
             ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
     retval = MPI_ERR_TYPE;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    int dst_traced = group->actor(target_rank)->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    int dst_traced = group->actor(target_rank)->get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData("Put", target_rank, origin_datatype->is_replayable()
                                                                                ? origin_count
                                                                                : origin_count * origin_datatype->size(),
@@ -293,7 +320,7 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
   return retval;
 }
 
-int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+int PMPI_Rput(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
   int retval = 0;
   smpi_bench_end();
@@ -316,11 +343,11 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
   } else if(request == nullptr){
     retval = MPI_ERR_REQUEST;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    int dst_traced = group->actor(target_rank)->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    int dst_traced = group->actor(target_rank)->get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData(
                            "Rput", target_rank,
                            origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
@@ -336,7 +363,7 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
   return retval;
 }
 
-int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+int PMPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
   int retval = 0;
   smpi_bench_end();
@@ -358,10 +385,10 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
   } else if (op == MPI_OP_NULL) {
     retval = MPI_ERR_OP;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData(
                            "Accumulate", target_rank,
                            origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
@@ -375,7 +402,7 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
   return retval;
 }
 
-int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+int PMPI_Raccumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
   int retval = 0;
   smpi_bench_end();
@@ -400,10 +427,10 @@ int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_d
   } else if(request == nullptr){
     retval = MPI_ERR_REQUEST;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData(
                            "Raccumulate", target_rank,
                            origin_datatype->is_replayable() ? origin_count : origin_count * origin_datatype->size(),
@@ -418,7 +445,7 @@ int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_d
   return retval;
 }
 
-int PMPI_Get_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
+int PMPI_Get_accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
   int retval = 0;
@@ -442,10 +469,10 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
   } else if (op == MPI_OP_NULL) {
     retval = MPI_ERR_OP;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData(
                            "Get_accumulate", target_rank,
                            target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
@@ -462,7 +489,7 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
 }
 
 
-int PMPI_Rget_accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
+int PMPI_Rget_accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
 MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
   int retval = 0;
@@ -489,10 +516,10 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
   } else if(request == nullptr){
     retval = MPI_ERR_REQUEST;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData(
                            "Rget_accumulate", target_rank,
                            target_datatype->is_replayable() ? target_count : target_count * target_datatype->size(),
@@ -508,11 +535,11 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
   return retval;
 }
 
-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){
+int PMPI_Fetch_and_op(const void *origin_addr, void *result_addr, MPI_Datatype dtype, int target_rank, MPI_Aint target_disp, MPI_Op op, MPI_Win win){
   return PMPI_Get_accumulate(origin_addr, origin_addr==nullptr?0:1, dtype, result_addr, 1, dtype, target_rank, target_disp, 1, dtype, op, win);
 }
 
-int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
+int PMPI_Compare_and_swap(const void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
                           int target_rank, MPI_Aint target_disp, MPI_Win win)
 {
   int retval = 0;
@@ -531,10 +558,10 @@ int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_ad
   } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) {
     retval = MPI_ERR_TYPE;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
+    TRACE_smpi_comm_in(my_proc_id, __func__,
                        new simgrid::instr::Pt2PtTIData("Compare_and_swap", target_rank,
                                                        datatype->is_replayable() ? 1 : datatype->size(),
                                                        simgrid::smpi::Datatype::encode(datatype)));
@@ -555,8 +582,8 @@ int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){
   } else if (group==MPI_GROUP_NULL){
     retval = MPI_ERR_GROUP;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_post"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_post"));
     retval = win->post(group,assert);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -572,8 +599,8 @@ int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
   } else if (group==MPI_GROUP_NULL){
     retval = MPI_ERR_GROUP;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_start"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_start"));
     retval = win->start(group,assert);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -587,8 +614,8 @@ int PMPI_Win_complete(MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_complete"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_complete"));
 
     retval = win->complete();
 
@@ -604,8 +631,8 @@ int PMPI_Win_wait(MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_wait"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_wait"));
 
     retval = win->wait();
 
@@ -626,7 +653,7 @@ int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){
   } else if (rank == MPI_PROC_NULL){
     retval = MPI_SUCCESS;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
     TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock"));
     retval = win->lock(lock_type,rank,assert);
     TRACE_smpi_comm_out(my_proc_id);
@@ -643,8 +670,8 @@ int PMPI_Win_unlock(int rank, MPI_Win win){
   } else if (rank == MPI_PROC_NULL){
     retval = MPI_SUCCESS;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock"));
     retval = win->unlock(rank);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -658,8 +685,8 @@ int PMPI_Win_lock_all(int assert, MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_lock_all"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock_all"));
     retval = win->lock_all(assert);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -673,8 +700,8 @@ int PMPI_Win_unlock_all(MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
     retval = win->unlock_all();
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -690,8 +717,8 @@ int PMPI_Win_flush(int rank, MPI_Win win){
   } else if (rank == MPI_PROC_NULL){
     retval = MPI_SUCCESS;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush"));
     retval = win->flush(rank);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -707,8 +734,8 @@ int PMPI_Win_flush_local(int rank, MPI_Win win){
   } else if (rank == MPI_PROC_NULL){
     retval = MPI_SUCCESS;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local"));
     retval = win->flush_local(rank);
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -722,8 +749,8 @@ int PMPI_Win_flush_all(MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_all"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_all"));
     retval = win->flush_all();
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -737,8 +764,8 @@ int PMPI_Win_flush_local_all(MPI_Win win){
   if (win == MPI_WIN_NULL) {
     retval = MPI_ERR_WIN;
   } else {
-    int my_proc_id = simgrid::s4u::Actor::self()->getPid();
-    TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
+    int my_proc_id = simgrid::s4u::this_actor::get_pid();
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
     retval = win->flush_local_all();
     TRACE_smpi_comm_out(my_proc_id);
   }
@@ -746,11 +773,18 @@ int PMPI_Win_flush_local_all(MPI_Win win){
   return retval;
 }
 
+int PMPI_Win_shared_query (MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
+{
+  if (win==MPI_WIN_NULL)
+    return MPI_ERR_TYPE;
+  else
+    return win->shared_query(rank, size, disp_unit, baseptr);
+}
 
 int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
 {
   static MPI_Aint size;
-  static int disp_unit;
+  static MPI_Aint disp_unit;
   if (win==MPI_WIN_NULL)
     return MPI_ERR_TYPE;
   else{
@@ -766,7 +800,7 @@ int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
       return MPI_SUCCESS;
     case MPI_WIN_DISP_UNIT :
       disp_unit=win->disp_unit();
-      *static_cast<int**>(attribute_val)  = &disp_unit;
+      *static_cast<MPI_Aint**>(attribute_val)  = &disp_unit;
       *flag = 1;
       return MPI_SUCCESS;
     default:
@@ -795,8 +829,8 @@ int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
 int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state)
 {
-  smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn};
-  smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn};
+  smpi_copy_fn _copy_fn={nullptr, nullptr,copy_fn,nullptr, nullptr,nullptr};
+  smpi_delete_fn _delete_fn={nullptr, nullptr,delete_fn,nullptr, nullptr,nullptr};
   return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
 }