Skip to content
Snippets Groups Projects
Verified Commit 2f1c1e5f authored by baptiste.coudray's avatar baptiste.coudray
Browse files

Used context sync

parent b2501663
No related branches found
No related tags found
No related merge requests found
......@@ -187,7 +187,10 @@ static envelope_t get_inner_envelope_1d(struct dispatch_context *dc, struct futh
int thickness_x = min(thickness, dc->chunk_info->dimensions[1]);
int dimensions[2] = {1, thickness_x};
futhark_context_sync(fc);
futhark_entry_get_envelope_1d(fc, &fut_west, &fut_east, fut_chunk_data, dimensions[1] * dc->type);
futhark_context_sync(fc);
futhark_free_u8_1d(fc, fut_chunk_data);
envelope_t inner_envelope = (envelope_t) {0};
// West
......@@ -195,17 +198,17 @@ static envelope_t get_inner_envelope_1d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x;
chunk_info_init(&inner_envelope.west, dc->type, dimensions, 0, start_x, true);
futhark_values_u8_1d(fc, fut_west, inner_envelope.west.data);
futhark_free_u8_1d(fc, fut_west);
}
// East
{
int start_x = dc->chunk_info->x + dc->chunk_info->dimensions[1] - thickness_x;
chunk_info_init(&inner_envelope.east, dc->type, dimensions, 0, start_x, true);
futhark_values_u8_1d(fc, fut_east, inner_envelope.east.data);
futhark_free_u8_1d(fc, fut_east);
}
futhark_free_u8_1d(fc, fut_chunk_data);
futhark_context_sync(fc);
futhark_free_u8_1d(fc, fut_west);
futhark_free_u8_1d(fc, fut_east);
return inner_envelope;
}
......@@ -226,9 +229,12 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int thickness_y = min(thickness, dc->chunk_info->dimensions[0]);
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,
thickness_x * dc->type);
futhark_context_sync(fc);
futhark_free_u8_2d(fc, fut_chunk_data);
envelope_t inner_envelope = (envelope_t) {0};
......@@ -239,8 +245,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x;
chunk_info_init(&inner_envelope.north_west, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_north_west, inner_envelope.north_west.data);
futhark_free_u8_2d(fc, fut_north_west);
}
// North
{
int dimensions[2] = {thickness_y, dc->chunk_info->dimensions[1]};
......@@ -248,8 +254,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x;
chunk_info_init(&inner_envelope.north, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_north, inner_envelope.north.data);
futhark_free_u8_2d(fc, fut_north);
}
// North-East
{
int dimensions[2] = {thickness_y, thickness_x};
......@@ -257,8 +263,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x + dc->chunk_info->dimensions[1] - thickness_x;
chunk_info_init(&inner_envelope.north_east, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_north_east, inner_envelope.north_east.data);
futhark_free_u8_2d(fc, fut_north_east);
}
// West
{
int dimensions[2] = {dc->chunk_info->dimensions[0], thickness_x};
......@@ -266,8 +272,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x;
chunk_info_init(&inner_envelope.west, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_west, inner_envelope.west.data);
futhark_free_u8_2d(fc, fut_west);
}
// East
{
int dimensions[2] = {dc->chunk_info->dimensions[0], thickness_x};
......@@ -275,8 +281,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x + dc->chunk_info->dimensions[1] - thickness_x;
chunk_info_init(&inner_envelope.east, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_east, inner_envelope.east.data);
futhark_free_u8_2d(fc, fut_east);
}
// South-West
{
int dimensions[2] = {thickness_y, thickness_x};
......@@ -284,8 +290,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x;
chunk_info_init(&inner_envelope.south_west, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_south_west, inner_envelope.south_west.data);
futhark_free_u8_2d(fc, fut_south_west);
}
// South
{
int dimensions[2] = {thickness_y, dc->chunk_info->dimensions[1]};
......@@ -293,8 +299,8 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x;
chunk_info_init(&inner_envelope.south, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_south, inner_envelope.south.data);
futhark_free_u8_2d(fc, fut_south);
}
// South-East
{
int dimensions[2] = {thickness_y, thickness_x};
......@@ -302,8 +308,17 @@ static envelope_t get_inner_envelope_2d(struct dispatch_context *dc, struct futh
int start_x = dc->chunk_info->x + dc->chunk_info->dimensions[1] - thickness_x;
chunk_info_init(&inner_envelope.south_east, dc->type, dimensions, start_y, start_x, true);
futhark_values_u8_2d(fc, fut_south_east, inner_envelope.south_east.data);
futhark_free_u8_2d(fc, fut_south_east);
}
futhark_context_sync(fc);
futhark_free_u8_2d(fc, fut_north_west);
futhark_free_u8_2d(fc, fut_north);
futhark_free_u8_2d(fc, fut_north_east);
futhark_free_u8_2d(fc, fut_west);
futhark_free_u8_2d(fc, fut_east);
futhark_free_u8_2d(fc, fut_south_west);
futhark_free_u8_2d(fc, fut_south);
futhark_free_u8_2d(fc, fut_south_east);
return inner_envelope;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment