#define MPI_SEEK_END 604
#define MPI_MAX_DATAREP_STRING 128
+#define MPI_WIN_BASE -1
+#define MPI_WIN_SIZE -2
+#define MPI_WIN_DISP_UNIT -3
+
// FIXME : used nowhere...
typedef enum MPIR_Combiner_enum{
MPI_COMBINER_NAMED,
typedef int MPI_Type_copy_attr_function(MPI_Datatype type, int keyval, void* extra_state, void* attribute_val_in,
void* attribute_val_out, int* flag);
typedef int MPI_Type_delete_attr_function(MPI_Datatype type, int keyval, void* attribute_val, void* extra_state);
+typedef int MPI_Win_copy_attr_function(MPI_Win win, int keyval, void* extra_state, void* attribute_val_in,
+ void* attribute_val_out, int* flag);
+typedef int MPI_Win_delete_attr_function(MPI_Win win, int keyval, void* attribute_val, void* extra_state);
#define MPI_COMM_NULL_COPY_FN ((MPI_Comm_copy_attr_function*)0)
#define MPI_COMM_NULL_DELETE_FN ((MPI_Comm_delete_attr_function*)0)
#define MPI_TYPE_NULL_COPY_FN ((MPI_Type_copy_attr_function*)0)
#define MPI_TYPE_NULL_DELETE_FN ((MPI_Type_delete_attr_function*)0)
+#define MPI_WIN_NULL_COPY_FN ((MPI_Win_copy_attr_function*)0)
+#define MPI_WIN_NULL_DELETE_FN ((MPI_Win_delete_attr_function*)0)
MPI_CALL(XBT_PUBLIC(int), MPI_Init, (int *argc, char ***argv));
MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_name,(MPI_Win win, char * name, int* len));
MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_group,(MPI_Win win, MPI_Group * group));
MPI_CALL(XBT_PUBLIC(int), MPI_Win_fence,( int assert, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_attr, (MPI_Win type, int type_keyval, void *attribute_val, int* flag));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_set_attr, (MPI_Win type, int type_keyval, void *att));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_delete_attr, (MPI_Win type, int comm_keyval));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_create_keyval,(MPI_Win_copy_attr_function* copy_fn,
+ MPI_Win_delete_attr_function* delete_fn, int* keyval, void* extra_state));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_free_keyval,(int* keyval));
+
MPI_CALL(XBT_PUBLIC(int), MPI_Get,( 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));
typedef int MPI_Grequest_cancel_function(void *extra_state, int complete);
#define MPI_DUP_FN MPI_Comm_dup
+#define MPI_WIN_DUP_FN ((MPI_Win_copy_attr_function*)MPI_DUP_FN)
+#define MPI_TYPE_DUP_FN ((MPI_Type_copy_attr_function*)MPI_DUP_FN)
+#define MPI_COMM_DUP_FN ((MPI_Comm_copy_attr_function *)MPI_DUP_FN)
typedef MPI_Comm_errhandler_function MPI_Comm_errhandler_fn;
#define MPI_INFO_ENV 1
XBT_PUBLIC_DATA( const MPI_Datatype ) MPI_PACKED;
WRAPPED_PMPI_CALL(int,MPI_Win_set_name,(MPI_Win win, char * name),(win, name))
WRAPPED_PMPI_CALL(int,MPI_Win_start,(MPI_Group group, int assert, MPI_Win win),(group, assert, win))
WRAPPED_PMPI_CALL(int,MPI_Win_wait,(MPI_Win win),(win))
+WRAPPED_PMPI_CALL(int,MPI_Win_get_attr, (MPI_Win type, int type_keyval, void *attribute_val, int* flag), (type, type_keyval, attribute_val, flag))
+WRAPPED_PMPI_CALL(int,MPI_Win_set_attr, (MPI_Win type, int type_keyval, void *att), (type, type_keyval, att))
+WRAPPED_PMPI_CALL(int,MPI_Win_delete_attr, (MPI_Win type, int comm_keyval), (type, comm_keyval))
+WRAPPED_PMPI_CALL(int,MPI_Win_create_keyval,(MPI_Win_copy_attr_function* copy_fn,
+ MPI_Win_delete_attr_function* delete_fn, int* keyval, void* extra_state), (copy_fn, delete_fn, keyval, extra_state))
+WRAPPED_PMPI_CALL(int,MPI_Win_free_keyval,(int* keyval), (keyval))
WRAPPED_PMPI_CALL(MPI_Comm, MPI_Comm_f2c,(MPI_Fint comm),(comm))
WRAPPED_PMPI_CALL(MPI_Datatype, MPI_Type_f2c,(MPI_Fint datatype),(datatype))
WRAPPED_PMPI_CALL(MPI_Fint, MPI_Comm_c2f,(MPI_Comm comm),(comm))
return Keyval::keyval_free<Datatype>(keyval);
}
+int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
+{
+ static MPI_Aint size;
+ static int disp_unit;
+ if (win==MPI_WIN_NULL)
+ return MPI_ERR_TYPE;
+ else{
+ switch (keyval) {
+ case MPI_WIN_BASE :
+ *static_cast<void**>(attribute_val) = win->base();
+ *flag = 1;
+ return MPI_SUCCESS;
+ case MPI_WIN_SIZE :
+ size = win->size();
+ *static_cast<MPI_Aint**>(attribute_val) = &size;
+ *flag = 1;
+ return MPI_SUCCESS;
+ case MPI_WIN_DISP_UNIT :
+ disp_unit=win->disp_unit();
+ *static_cast<int**>(attribute_val) = &disp_unit;
+ *flag = 1;
+ return MPI_SUCCESS;
+ default:
+ return win->attr_get<Win>(keyval, attribute_val, flag);
+ }
+}
+
+}
+
+int PMPI_Win_set_attr (MPI_Win win, int type_keyval, void *attribute_val)
+{
+ if (win==MPI_WIN_NULL)
+ return MPI_ERR_TYPE;
+ else
+ return win->attr_put<Win>(type_keyval, attribute_val);
+}
+
+int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
+{
+ if (win==MPI_WIN_NULL)
+ return MPI_ERR_TYPE;
+ else
+ return win->attr_delete<Win>(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;
+ smpi_delete_fn _delete_fn;
+ _copy_fn.win_copy_fn = copy_fn;
+ _delete_fn.win_delete_fn = delete_fn;
+ return Keyval::keyval_create<Win>(_copy_fn, _delete_fn, keyval, extra_state);
+}
+
+int PMPI_Win_free_keyval(int* keyval) {
+ return Keyval::keyval_free<Win>(keyval);
+}
+
int PMPI_Info_create( MPI_Info *info){
if (info == nullptr)
return MPI_ERR_ARG;
namespace simgrid{
namespace smpi{
+std::unordered_map<int, smpi_key_elem> Win::keyvals_;
+int Win::keyval_id_=0;
Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm){
int comm_size = comm->size();
if(rank == 0)
MSG_barrier_destroy(bar_);
xbt_mutex_destroy(mut_);
+
+ if(!attributes_.empty()){
+ int flag;
+ for(auto it = attributes_.begin(); it != attributes_.end(); it++){
+ try{
+ smpi_key_elem elem = keyvals_.at((*it).first);
+ if (elem != nullptr && elem->delete_fn.win_delete_fn != nullptr)
+ elem->delete_fn.win_delete_fn(this, (*it).first, (*it).second, &flag);
+ }catch(const std::out_of_range& oor) {
+ //already deleted, not a problem;
+ }
+ }
+ }
+
}
void Win::get_name(char* name, int* length){
}
}
+MPI_Aint Win::size(){
+ return size_;
+}
+
+void* Win::base(){
+ return base_;
+}
+
+int Win::disp_unit(){
+ return disp_unit_;
+}
+
+
void Win::set_name(char* name){
name_ = xbt_strdup(name);
}
namespace simgrid{
namespace smpi{
-class Win : public F2C {
+class Win : public F2C, public Keyval {
private :
void* base_;
MPI_Aint size_;
int count_; //for ordering the accs
public:
+ static std::unordered_map<int, smpi_key_elem> keyvals_;
+ static int keyval_id_;
+
Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm);
~Win();
void get_name( char* name, int* length);
int post(MPI_Group group, int assert);
int complete();
int wait();
+ MPI_Aint size();
+ void* base();
+ int disp_unit();
int fence(int assert);
int put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype);