Skip to content
Snippets Groups Projects
Verified Commit 3a4ec19c authored by raphael.bach's avatar raphael.bach
Browse files

Add `fmpi_domain_set_inner()`

parent 0f013a72
No related branches found
No related tags found
No related merge requests found
...@@ -58,6 +58,13 @@ struct fmpi_domain fmpi_new_domain( ...@@ -58,6 +58,13 @@ struct fmpi_domain fmpi_new_domain(
const struct fmpi_ctx * ctx, const struct fmpi_data * data, const struct fmpi_ctx * ctx, const struct fmpi_data * data,
struct fmpi_stencil stencil struct fmpi_stencil stencil
); );
/*------------------------------------------------------------------------------
fmpi_domain_set_inner()
------------------------------------------------------------------------------*/
void fmpi_domain_set_inner(
const struct fmpi_ctx * ctx, const struct fmpi_domain * domain,
const void * data
);
/*============================================================================== /*==============================================================================
GUARD GUARD
==============================================================================*/ ==============================================================================*/
......
...@@ -73,9 +73,22 @@ struct fmpi_domain fmpi_new_domain( ...@@ -73,9 +73,22 @@ struct fmpi_domain fmpi_new_domain(
domain.inner = fmpi_partition_block_1d(ctx, data); domain.inner = fmpi_partition_block_1d(ctx, data);
if(stencil.type != FMPI_STENCIL_NONE) { if(stencil.type != FMPI_STENCIL_NONE) {
domain.halo = fmpi_halo_1d(ctx, domain.inner, stencil); domain.halo = fmpi_halo_1d(ctx, domain.inner, stencil);
domain.inner.raw = (char *)domain.halo.raw + (data->type.size * stencil.length);
} }
return domain; return domain;
} }
/*------------------------------------------------------------------------------
fmpi_domain_set_inner()
------------------------------------------------------------------------------*/
void fmpi_domain_set_inner(
const struct fmpi_ctx * const ctx, const struct fmpi_domain * const domain,
const void * const data
){
assert(ctx != NULL);
assert(domain != NULL);
assert(data != NULL);
memcpy(domain->inner.raw, data, domain->inner.size);
}
/*============================================================================== /*==============================================================================
PRIVATE FUNCTION DEFINITION PRIVATE FUNCTION DEFINITION
==============================================================================*/ ==============================================================================*/
......
...@@ -116,7 +116,7 @@ int fmpi_task_run_sync( ...@@ -116,7 +116,7 @@ int fmpi_task_run_sync(
"fmpi_futhark_get_data_sync() failed!" "fmpi_futhark_get_data_sync() failed!"
); );
} }
const int err = fmpi_futhark_free_data_sync( int err = fmpi_futhark_free_data_sync(
ctx->fut, task->args.out.gpu, task->args.out.type.base, ctx->fut, task->args.out.gpu, task->args.out.type.base,
task->args.out.dim_cnt task->args.out.dim_cnt
); );
...@@ -127,16 +127,11 @@ int fmpi_task_run_sync( ...@@ -127,16 +127,11 @@ int fmpi_task_run_sync(
} }
} }
if(task->stencil.type != FMPI_STENCIL_NONE) { if(task->stencil.type != FMPI_STENCIL_NONE) {
const int rank = ctx->mpi->rank; fmpi_domain_set_inner(ctx, &task->domains[0], task->args.out.raw);
size_t type_size = task->domains[0].halo.type.size;
void * const halo = task->domains[0].halo.raw;
const void * const inner = task->args.out.raw;
void * const dest = (rank == 0) ? ((char *)halo + type_size) : halo;
const void * const src = (rank != 0) ? ((const char *)inner - type_size) : inner;
const size_t inner_size = task->domains[0].inner.size;
const size_t size = (rank != (ctx->mpi->size - 1)) ? (inner_size + type_size) : inner_size;
memcpy(dest, src, size);
const int rank = ctx->mpi->rank;
size_t type_size = task->domains[0].inner.type.size;
const size_t idx_1 = type_size; const size_t idx_1 = type_size;
const size_t idx_nm2 = (task->domains[0].halo.cnt-2) * type_size; const size_t idx_nm2 = (task->domains[0].halo.cnt-2) * type_size;
const size_t idx_nm1 = idx_nm2 + idx_1; const size_t idx_nm1 = idx_nm2 + idx_1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment