RZ

01: // ConReservation.hh # the actual synthesize algorithm
02:
03: #ifndef _ConReservation_HH
04: #define _ConReservation_HH 1
05:
06: #include <cassert>
07: #include <sys/mman.h>
08:
09: #include <vector>
10: #include <algorithm>
11: //#include <utility>
12:
13: #include "RZError.hh"
14: #include "RZMagic.hh"
15: #include "RZIO.hh"
16: #include "ExtractIntermediate.hh"
17: #include "ExtractRemoteCon.hh"
18: #include "MMap.hh"
19:
20: namespace RZ {
21:     struct ConReservation;
22: }
23:
24: struct RZ::ConReservation {
25:     struct ConTable const rz_wrapper;
26:
27:     struct ReservationMaps {
28:         char const volatile * const ltab_mmap;
29:         char volatile * const rtab_mmap;
30:         ReservationMaps(char const volatile * const l, char volatile * const r)
31:         : ltab_mmap(l), rtab_mmap(r) {}
32:         ReservationMaps(int const ltabfd, int const rtabfd, unsigned int nblks)
33:         :   ltab_mmap(fd_memory_map(ltabfd, nblks, false, "local blocks")),
34:             rtab_mmap(fd_memory_map(rtabfd, nblks, true, "remote blocks")) {}
35:     } const reservation_tables;
36:
37:     ConReservation(struct RZWrapper const &rzwrapper,
38:         char const volatile * const l, char volatile * const r)
39:     :   rz_wrapper(rzwrapper),
40:         reservation_tables(l, r) {}
41:     ConReservation(struct IntermediateWrapper const &interwrap,
42:         int const ltabfd, int const rtabfd)
43:     :   rz_wrapper(interwrap),
44:         reservation_tables(ltabfd, rtabfd, interwrap.n_blks) {}
45:
46:     void writeremotetab(int at, int to);
47:
48: private:
49:     void fwdfindlocal(int &fwdi, int &fwdsize, int &sizelimit);
50:     void fwdfindremote(int &fwdi, int &fwdsize, int &sizelimit);
51:     void fwdlocalskip(std::vector< int > &f, int packetlimit,
52:         int &localsize, int &remotesize, int &nextsize, int &remaining);
53:     void fwdlocalinterval(std::vector< int > &f, int limit,
54:         int &localsize, int &remotesize, int &nextsize, int &remaining);
55:
56: public:
57:     void fwdcontiguousinterval(std::vector< int > &f, int packetlimit,
58:         int &fbegin, int &fend, int &fnext);
59:     void fwdmultipleintervals(std::vector< int > &f, int packetlimit);
60:     bool equalintervals(std::vector< int > &f, std::vector< int > &g);
61: };
62:
63: // ConReservation.hh # the actual synthesize algorithm
64:
65: #endif