Skip to content

Commit

Permalink
Provide workaround for version without MPI
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Ravedutti <[email protected]>
  • Loading branch information
rafaelravedutti committed Oct 22, 2020
1 parent 89b5239 commit fe7b150
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions comm/no_mpi.impala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ 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_Allreduce(MPI_Buf, MPI_MutBuf, i32, MPI_Datatype, MPI_Op, MPI_Comm) -> i32 { 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, &MPI_Request) -> 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 }
Expand All @@ -26,9 +26,9 @@ 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 { 0 }
fn @get_mpi_double() -> MPI_Datatype { 0 }
fn @get_mpi_float() -> 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 }
Expand All @@ -51,6 +51,22 @@ fn @get_mpi_cart_neighborhood(

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,
}
Expand Down Expand Up @@ -89,8 +105,10 @@ struct MPI {
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,
irecv : fn(MPI_MutBuf, i32, MPI_Datatype, i32, i32, MPI_Comm, &MPI_Request) -> 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,
Expand Down Expand Up @@ -121,13 +139,15 @@ fn @mpi() -> MPI {
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)
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)
},
Expand Down

0 comments on commit fe7b150

Please sign in to comment.