-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathno_mpi.impala
164 lines (148 loc) · 5.37 KB
/
no_mpi.impala
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
type size_t = u64;
type MPI_Comm = i32;
type MPI_Datatype = i32;
type MPI_Op = i32;
type MPI_Request = i32;
type MPI_Status = &mut [i8];
type MPI_Buf = &[i8];
type MPI_MutBuf = &mut [i8];
fn @MPI_init() -> i32 { 0 }
fn @MPI_Comm_size(MPI_Comm, size: &mut i32) -> i32 { *size = 0; 0 }
fn @MPI_Comm_rank(MPI_Comm, rank: &mut i32) -> i32 { *rank = 0; 0 }
fn @MPI_Send(MPI_Buf, i32, MPI_Datatype, i32, i32, MPI_Comm) -> i32 { 0 }
fn @MPI_Isend(MPI_Buf, i32, MPI_Datatype, i32, i32, MPI_Comm, i32) -> i32 { 0 }
fn @MPI_Recv(MPI_MutBuf, i32, MPI_Datatype, i32, i32, MPI_Comm, MPI_Status) -> i32 { 0 }
fn @MPI_Irecv(MPI_MutBuf, i32, MPI_Datatype, i32, i32, MPI_Comm, i32) -> i32 { 0 }
fn @MPI_Wait(&MPI_Request, MPI_Status) -> i32 { 0 }
fn @MPI_Probe(i32, i32, MPI_Comm, MPI_Status) -> i32 { 0 }
fn @MPI_Get_count(MPI_Status, MPI_Datatype, count: &mut i32) -> i32 { *count = 0; 0 }
fn @MPI_Gather(MPI_Buf, i32, MPI_Datatype, MPI_MutBuf, i32, MPI_Datatype, i32, MPI_Comm) -> i32 { 0 }
fn @MPI_Barrier(MPI_Comm, &MPI_Request) -> i32 { 0 }
fn @MPI_Wtime() -> f64 { 0.0 }
fn @MPI_Finalize() -> i32 { 0 }
// wrappers in mpi.cpp for getting MPI constants
fn @get_mpi_comm_world() -> MPI_Comm { 0 }
fn @get_mpi_int() -> MPI_Datatype { 0 }
fn @get_mpi_int64() -> MPI_Datatype { 1 }
fn @get_mpi_double() -> MPI_Datatype { 2 }
fn @get_mpi_float() -> MPI_Datatype { 3 }
fn @get_mpi_max() -> MPI_Op { 0 }
fn @get_mpi_sum() -> MPI_Op { 0 }
fn @get_mpi_status_ignore() -> MPI_Status { 0 as MPI_Status }
fn @get_mpi_cart_neighborhood(
i32, i32, i32,
locx: &mut i32, locy: &mut i32, locz: &mut i32,
xprev: &mut i32, xnext: &mut i32, yprev: &mut i32, ynext: &mut i32, zprev: &mut i32, znext: &mut i32) -> () {
*locx = 0;
*locy = 0;
*locz = 0;
*xprev = 0;
*xnext = 0;
*yprev = 0;
*ynext = 0;
*zprev = 0;
*znext = 0;
}
fn @sync_ghost_layer_loop(i32, MPI_Buf, MPI_MutBuf, &[i32], &[i32], &[i32], &[i32], &[i32], &[i32]) -> () {}
fn @get_world_size() -> i32 { 1 }
fn @get_process_rank() -> i32 { 0 }
fn @barrier() -> () {}
fn @MPI_Allreduce(local: MPI_Buf, global: MPI_MutBuf, i32, data_type: MPI_Datatype, MPI_Op, MPI_Comm) -> i32 {
if data_type == get_mpi_int() {
bitcast[&mut[i32]](global)(0) = bitcast[&[i32]](local)(0)
} else if data_type == get_mpi_double() {
bitcast[&mut[f64]](global)(0) = bitcast[&[f64]](local)(0)
} else if data_type == get_mpi_int64() {
bitcast[&mut[i64]](global)(0) = bitcast[&[i64]](local)(0)
}
0
}
struct MPIComms {
world : MPI_Comm,
}
struct MPIOps {
max : MPI_Op,
sum : MPI_Op,
}
// TODO should be autogenerated, differs for other MPI implementations (e.g. MPICH)
struct MPIStatus {
source : i32,
tag : i32,
error : i32,
// internal to openmpi, do not access
_cancelled : i32,
_ucount : u64
}
struct MPIStatuses {
ignore : &mut MPIStatus,
}
struct MPI {
comms : MPIComms,
ops : MPIOps,
status : MPIStatuses,
int_t : MPI_Datatype,
double_t : MPI_Datatype,
float_t : MPI_Datatype,
int64_t: MPI_Datatype,
init : fn() -> i32,
comm_size : fn(MPI_Comm, &mut i32) -> i32,
comm_rank : fn(MPI_Comm, &mut i32) -> i32,
cart: fn(i32, i32, i32, &mut i32, &mut i32, &mut i32, &mut i32, &mut i32, &mut i32, &mut i32, &mut i32, &mut i32) -> (),
allreduce : fn(MPI_Buf, MPI_MutBuf, i32, MPI_Datatype, MPI_Op, MPI_Comm) -> i32,
send : fn(MPI_Buf, i32, MPI_Datatype, i32, i32, MPI_Comm) -> i32,
recv : fn(MPI_MutBuf, i32, MPI_Datatype, i32, i32, MPI_Comm, &mut MPIStatus) -> i32,
isend : fn(MPI_Buf, i32, MPI_Datatype, i32, i32, MPI_Comm, i32) -> i32,
irecv : fn(MPI_MutBuf, i32, MPI_Datatype, i32, i32, MPI_Comm, i32) -> i32,
wait : fn(&MPI_Request, &mut MPIStatus) -> i32,
wait_all : fn(i32) -> i32,
probe: fn(i32, i32, MPI_Comm, &mut MPIStatus) -> i32,
get_count: fn(&mut MPIStatus, MPI_Datatype, &mut i32) -> i32,
gather: fn(MPI_Buf, i32, MPI_Datatype, MPI_MutBuf, i32, MPI_Datatype, i32, MPI_Comm) -> i32,
barrier : fn(MPI_Comm, &MPI_Request) -> i32,
wtime : fn() -> f64,
finalize : fn() -> i32,
}
fn @mpi() -> MPI {
MPI {
comms : MPIComms {
world : get_mpi_comm_world(),
},
ops : MPIOps {
max : get_mpi_max(),
sum : get_mpi_sum(),
},
status : MPIStatuses {
ignore : get_mpi_status_ignore() as &mut MPIStatus,
},
double_t : get_mpi_double(),
int_t : get_mpi_int(),
int64_t : get_mpi_int64(),
float_t : get_mpi_float(),
init : MPI_init,
comm_size : MPI_Comm_size,
comm_rank : MPI_Comm_rank,
cart: get_mpi_cart_neighborhood,
allreduce : MPI_Allreduce,
send : MPI_Send,
isend: MPI_Isend,
recv : @|buf, count, datatype, source, tag, comm, status| {
MPI_Recv(buf, count, datatype, source, tag, comm, status as MPI_Status)
},
irecv : MPI_Irecv,
wait : @|request, status| {
MPI_Wait(request, status as MPI_Status)
},
wait_all : |i| { 0 },
probe: @|source, tag, comm, status| {
MPI_Probe(source, tag, comm, status as MPI_Status)
},
get_count: @|status, datatype, count| {
MPI_Get_count(status as MPI_Status, datatype, count)
},
gather: MPI_Gather,
barrier : MPI_Barrier,
wtime : MPI_Wtime,
finalize : MPI_Finalize,
}
}
;