1 /* Copyright (c) 2010-2019. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SMPI_WIN_HPP_INCLUDED
8 #define SMPI_WIN_HPP_INCLUDED
10 #include "simgrid/s4u/Barrier.hpp"
11 #include "smpi_f2c.hpp"
12 #include "smpi_keyvals.hpp"
13 #include "xbt/synchro.h"
21 class Win : public F2C, public Keyval {
28 std::vector<MPI_Request> *requests_;
31 MPI_Win* connected_wins_;
35 int count_; //for ordering the accs
36 s4u::MutexPtr lock_mut_;
37 s4u::MutexPtr atomic_mut_;
38 std::list<int> lockers_;
39 int rank_; // to identify owner for barriers in MPI_COMM_WORLD
40 int mode_; // exclusive or shared lock
45 static std::unordered_map<int, smpi_key_elem> keyvals_;
46 static int keyval_id_;
48 Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated = 0, int dynamic = 0);
49 Win(MPI_Info info, MPI_Comm comm) : Win(MPI_BOTTOM, 0, 1, info, comm, 0, 1) {};
50 Win(const Win&) = delete;
51 Win& operator=(const Win&) = delete;
53 int attach (void *base, MPI_Aint size);
54 int detach (void *base);
55 void get_name( char* name, int* length);
56 void get_group( MPI_Group* group);
57 void set_name( char* name);
60 int start(MPI_Group group, int assert);
61 int post(MPI_Group group, int assert);
64 void set_info( MPI_Info info);
69 int fence(int assert);
70 int put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
71 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
72 int get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
73 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
74 int accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
75 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request=nullptr);
76 int get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
77 int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
78 MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request=nullptr);
79 int compare_and_swap(void *origin_addr, void *compare_addr,
80 void *result_addr, MPI_Datatype datatype, int target_rank,
81 MPI_Aint target_disp);
82 static Win* f2c(int id);
84 int lock(int lock_type, int rank, int assert);
86 int lock_all(int assert);
89 int flush_local(int rank);
91 int flush_local_all();
93 int finish_comms(int rank);
94 int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr);