-
Notifications
You must be signed in to change notification settings - Fork 6
/
address_space.h
72 lines (56 loc) · 1.63 KB
/
address_space.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef GASSYFS_ADDRESS_SPACE_H_
#define GASSYFS_ADDRESS_SPACE_H_
#include <cstddef>
#include <vector>
struct gassyfs_opts;
/*
* A node is a single linearly addressable region that supports random read /
* write operations (e.g. a GASNet node). The address space exposed by a node
* is physically located on a single host.
*/
class Node {
public:
typedef void* group_io_handle_t;
// valid address space: [0, size)
virtual size_t size() = 0;
// synchronous
virtual void read(void *dst, void *src, size_t len) = 0;
virtual void write(void *dst, void *src, size_t len) = 0;
virtual void aio_read(group_io_handle_t handle, void *dst,
void *src, size_t len) = 0;
virtual void aio_write(group_io_handle_t handle, void *dst,
void *src, size_t len) = 0;
};
/*
* An address space is a set of nodes.
*/
class AddressSpace {
public:
virtual std::vector<Node*>& nodes() = 0;
// aio
virtual Node::group_io_handle_t group_io_start() = 0;
virtual void group_io_wait(Node::group_io_handle_t handle) = 0;
};
class LocalAddressSpace : public AddressSpace {
public:
int init(struct gassyfs_opts *opts);
std::vector<Node*>& nodes() {
return nodes_;
}
Node::group_io_handle_t group_io_start();
void group_io_wait(Node::group_io_handle_t handle);
private:
std::vector<Node*> nodes_;
};
class GASNetAddressSpace : public AddressSpace {
public:
int init(int *argc, char ***argv, struct gassyfs_opts *opts);
std::vector<Node*>& nodes() {
return nodes_;
}
Node::group_io_handle_t group_io_start();
void group_io_wait(Node::group_io_handle_t handle);
private:
std::vector<Node*> nodes_;
};
#endif