Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplifications
[simgrid.git] / src / smpi / include / smpi_win.hpp
1 /* Copyright (c) 2010-2019. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #ifndef SMPI_WIN_HPP_INCLUDED
8 #define SMPI_WIN_HPP_INCLUDED
9
10 #include "simgrid/s4u/Barrier.hpp"
11 #include "smpi_f2c.hpp"
12 #include "smpi_keyvals.hpp"
13 #include "xbt/synchro.h"
14
15 #include <vector>
16 #include <list>
17
18 namespace simgrid{
19 namespace smpi{
20
21 class Win : public F2C, public Keyval {
22   private :
23   void* base_;
24   MPI_Aint size_;
25   int disp_unit_;
26   int assert_;
27   MPI_Info info_;
28   MPI_Comm comm_;
29   std::vector<MPI_Request> *requests_;
30   s4u::MutexPtr mut_;
31   s4u::Barrier* bar_;
32   MPI_Win* connected_wins_;
33   char* name_;
34   int opened_;
35   MPI_Group group_;
36   int count_; //for ordering the accs
37   s4u::MutexPtr lock_mut_;
38   s4u::MutexPtr atomic_mut_;
39   std::list<int> lockers_;
40   int rank_; // to identify owner for barriers in MPI_COMM_WORLD
41   int mode_; // exclusive or shared lock
42   int allocated_;
43   int dynamic_;
44
45 public:
46   static std::unordered_map<int, smpi_key_elem> keyvals_;
47   static int keyval_id_;
48
49   Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated = 0, int dynamic = 0);
50   Win(MPI_Info info, MPI_Comm comm) : Win(MPI_BOTTOM, 0, 1, info, comm, 0, 1) {};
51   Win(const Win&) = delete;
52   Win& operator=(const Win&) = delete;
53   ~Win();
54   int attach (void *base, MPI_Aint size);
55   int detach (void *base);
56   void get_name( char* name, int* length);
57   void get_group( MPI_Group* group);
58   void set_name( char* name);
59   int rank();
60   int dynamic();
61   int start(MPI_Group group, int assert);
62   int post(MPI_Group group, int assert);
63   int complete();
64   MPI_Info info();
65   void set_info( MPI_Info info);
66   int wait();
67   MPI_Aint size();
68   void* base();
69   int disp_unit();
70   int fence(int assert);
71   int put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
72               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
73   int get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
74               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
75   int accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
76               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request=nullptr);
77   int get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
78               int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
79               MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request=nullptr);
80   int compare_and_swap(void *origin_addr, void *compare_addr,
81         void *result_addr, MPI_Datatype datatype, int target_rank,
82         MPI_Aint target_disp);
83   static Win* f2c(int id);
84
85   int lock(int lock_type, int rank, int assert);
86   int unlock(int rank);
87   int lock_all(int assert);
88   int unlock_all();
89   int flush(int rank);
90   int flush_local(int rank);
91   int flush_all();
92   int flush_local_all();
93   int finish_comms();
94   int finish_comms(int rank);
95   int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr);
96 };
97
98
99 }
100 }
101
102 #endif