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

Add `fmpi_mpi_dims_create()`

parent bdf128dc
No related branches found
No related tags found
No related merge requests found
......@@ -237,6 +237,12 @@ int fmpi_mpi_world_reduce_in_place(
const struct fmpi_mpi_ctx * ctx, void * buf, size_t cnt, MPI_Datatype type,
MPI_Op op
);
/*------------------------------------------------------------------------------
fmpi_mpi_dims_create()
------------------------------------------------------------------------------*/
int fmpi_mpi_dims_create(
const struct fmpi_mpi_ctx * ctx, size_t * const dim_len, size_t dim_cnt
);
/*==============================================================================
GUARD
==============================================================================*/
......
......@@ -32,6 +32,7 @@
// External
#include <mpi.h>
// Internal
#include "internal/fmpi_common.h"
#include "internal/fmpi_error.h"
#include "internal/fmpi_type.h"
/*==============================================================================
......@@ -314,3 +315,24 @@ int fmpi_mpi_world_reduce_in_place(
}
return err;
}
/*------------------------------------------------------------------------------
fmpi_mpi_dims_create()
------------------------------------------------------------------------------*/
int fmpi_mpi_dims_create(
const struct fmpi_mpi_ctx * const ctx, size_t * const dim_len,
const size_t dim_cnt
){
assert(ctx != NULL);
assert(dim_len != NULL);
assert(dim_cnt <= FMPI_DIM_MAX);
int dims[FMPI_DIM_MAX];
for(size_t i = 0; i < dim_cnt; i++) {
dims[i] = (int)dim_len[i];
}
const int err = MPI_Dims_create(ctx->size, (int)dim_cnt, dims);
for(size_t i = 0; i < dim_cnt; i++) {
assert(dims[i] >= 0);
dim_len[i] = (size_t)dims[i];
}
return fmpi_mpi_check_error(ctx, err, "MPI_Dims_create");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment