diff --git a/futhark_mpi/dispatch.c b/futhark_mpi/dispatch.c index e5300bd19fb655a4f0f85036cd7a1dc6b8784af3..0cc2396650f4fee630db64e11d78f2abd8bf9110 100644 --- a/futhark_mpi/dispatch.c +++ b/futhark_mpi/dispatch.c @@ -231,8 +231,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh int thickness_x = min(thickness, dc->chunk_info->dimensions[1]); futhark_context_sync(fc); - futhark_entry_get_envelope_2d(fc, &fut_north, &fut_north_east, &fut_east, &fut_south_east, &fut_south, - &fut_south_west, &fut_west, &fut_north_west, fut_chunk_data, thickness_y, + futhark_entry_get_envelope_2d(fc, &fut_north_west, &fut_north, &fut_north_east, &fut_west, &fut_east, + &fut_south_west, &fut_south, &fut_south_east, fut_chunk_data, thickness_y, thickness_x * dc->type); futhark_context_sync(fc); futhark_free_u8_2d(fc, fut_chunk_data); diff --git a/futhark_mpi/envelope.fut b/futhark_mpi/envelope.fut index d02aa95ce28f9c858729dc68d8fdf4c892bc23e8..be9c77464bcf4c17f32c9ee76ad7758bad07f159 100644 --- a/futhark_mpi/envelope.fut +++ b/futhark_mpi/envelope.fut @@ -1,9 +1,25 @@ -let get_envelope_1d [n] (xs: [n]u8) (thickness: i64) : ([]u8, []u8) = +-- type envelope_1d_t [n] = { +-- west: [n]u8, +-- east: [n]u8 +-- } +-- +-- type envelope_2d_t [n][m][ty][tx] = { +-- north_west: [ty][tx]u8, +-- north: [ty][m]u8, +-- north_east: [ty][tx]u8, +-- west: [n][tx]u8, +-- east: [n][tx]u8, +-- south_west: [ty][tx]u8, +-- south: [ty][m]u8, +-- south_east: [ty][tx]u8 +-- } + +entry get_envelope_1d [n] (xs: [n]u8) (thickness: i64) : ([]u8, []u8) = let west = xs[0:thickness] :> [thickness]u8 let east = xs[n - thickness:] :> [thickness]u8 in (west, east) -let get_envelope_2d [n][m] (matrix: [n][m]u8) (thickness_y: i64) (thickness_x: i64): ([][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8) = +entry get_envelope_2d [n][m] (matrix: [n][m]u8) (thickness_y: i64) (thickness_x: i64): ([][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8) = let north = matrix[0:thickness_y] :> [thickness_y][m]u8 let north_west = matrix[0:thickness_y,0:thickness_x] :> [thickness_y][thickness_x]u8 @@ -17,4 +33,4 @@ let get_envelope_2d [n][m] (matrix: [n][m]u8) (thickness_y: i64) (thickness_x: i let east = matrix[:,m - (thickness_x):] :> [n][thickness_x]u8 let west = matrix[:,0:thickness_x] :> [n][thickness_x]u8 - in (north, north_east, east, south_east, south, south_west, west, north_west) + in (north_west, north, north_east, west, east, south_west, south, south_east)