GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
context.c File Reference
#include "ghost/config.h"
#include "ghost/core.h"
#include "ghost/types.h"
#include "ghost/util.h"
#include "ghost/context.h"
#include "ghost/locality.h"
#include "ghost/bincrs.h"
#include "ghost/matrixmarket.h"
#include "ghost/log.h"
#include "ghost/omp.h"
#include "ghost/machine.h"
#include "ghost/bench.h"
#include "ghost/map.h"
#include <float.h>
#include <math.h>
Include dependency graph for context.c:

Functions

ghost_error ghost_context_create (ghost_context **context, ghost_gidx gnrows, ghost_gidx gncols, ghost_context_flags_t context_flags, ghost_mpi_comm comm, double weight)
 Create a context. More...
 
ghost_error ghost_context_string (char **str, ghost_context *context)
 Create a string containing information on the context. More...
 
void ghost_context_destroy (ghost_context *context)
 Free the context's resources. More...
 
ghost_error ghost_context_comm_init (ghost_context *ctx, ghost_gidx *col_orig, ghost_sparsemat *mat, ghost_lidx *col, ghost_lidx *nhalo)
 Assemble communication information in the given context. More...
 
char * ghost_context_workdist_string (ghost_context_flags_t flags)
 Get the name of the work distribution scheme. More...
 
ghost_mapghost_context_map (const ghost_context *ctx, const ghost_maptype mt)
 Get the context's map with the given map type. More...
 
ghost_mapghost_context_other_map (const ghost_context *ctx, const ghost_maptype mt)
 Get the context's map which does not have the given map type. More...
 
ghost_mapghost_context_max_map (const ghost_context *ctx)
 Get the largest map of the context. More...
 
ghost_error ghost_context_set_map (ghost_context *ctx, ghost_maptype which, ghost_map *map)
 Set a context's map. More...
 

Function Documentation

ghost_error ghost_context_comm_init ( ghost_context ctx,
ghost_gidx col_orig,
ghost_sparsemat mat,
ghost_lidx col,
ghost_lidx nhalo 
)

Assemble communication information in the given context.

Parameters
[in,out]ctxThe context.
[in]col_origThe original column indices of the sparse matrix which is bound to the context.
[out]colThe compressed column indices of the sparse matrix which is bound to the context.
[out]nhaloThe number of halo elements.
Returns
GHOST_SUCCESS on success or an error indicator.

The following fields of ghost_context are being filled in this function: wishes, wishlist, dues, duelist, hput_pos, wishpartners, nwishpartners, duepartners, nduepartners. Additionally, the columns in col_orig are being compressed and stored in col.

Here is the call graph for this function:

ghost_error ghost_context_create ( ghost_context **  context,
ghost_gidx  gnrows,
ghost_gidx  gncols,
ghost_context_flags_t  flags,
ghost_mpi_comm  comm,
double  weight 
)

Create a context.

Parameters
[out]contextWhere to store the created context.
[in]gnrowsThe global number of rows for the context. If gnrows is 0 a valid matrix file path has to be provided in the argument matrixSource from which the number of rows will be read.
[in]gncolsThe global number of columns for the context. If gncols is 0 a valid matrix file path has to be provided in the argument matrixSource from which the number of columns will be read.
[in]flagsFlags to the context.
[in]matrixSourceThe sparse matrix source.
[in]srcTypeThe type of the sparse matrix source.
[in]commThe MPI communicator in which the context is present.
[in]weightThis influences the work distribution amon ranks. If set to 0., it is automatically determined.
Returns
GHOST_SUCCESS on success or an error indicator.

The matrix source can either be one of ghost_sparsemat_src. The concrete type has to be specified in the srcType parameter. It must not be GHOST_SPARSEMAT_SRC_NONE in the following cases:

  1. If gnrows or gncols are given as less than 1, the source has to be a a pointer to a ghost_sparsemat_src_rowfunc and srcType has to be set to GHOST_SPARSEMAT_SRC_FILE.
  2. If the flag GHOST_CONTEXT_WORKDIST_NZE is set in the flags, the source may be of any type (except GHOST_SPARSEMAT_SRC_NONE of course)

In all other cases, i.e., gnrows and gncols are correctly set and the distribution of matrix rows across ranks should be done by the number of rows, the matrixSource parameter will be ignored.

Each rank will get a portion of work which depends on the distribution scheme as set in the flags multiplied with the given weight divided by the sum of the weights of all ranks in the context's MPI communicator. Example: Rank A is of type GHOST_TYPE_CUDA using a GPU with a memory bandwidth of 150 GB/s and rank B is of type GHOST_TYPE_WORK using a CPU socket with a memory bandwidth of 50 GB/s. The work is to be distributed by rows and the matrix contains 8 million rows. A straight-forward distribution of work would assume a weight of 1.5 for A and 0.5 for B. Thus, A would be assigned 6 million matrix rows and B 2 million. Automatic weight determination is done using a main memory benchmark. If the bechmark results differ by less than 10% on each rank, the parallel run will be considered "homogeneous" and the weights will be fixed to 1.0

Here is the call graph for this function:

void ghost_context_destroy ( ghost_context ctx)

Free the context's resources.

Parameters
ctxThe context.

If the context is NULL it will be ignored.

Here is the call graph for this function:

ghost_map* ghost_context_map ( const ghost_context ctx,
const ghost_maptype  mt 
)

Get the context's map with the given map type.

Parameters
ctxThe context.
mtThe map type.
Returns
The map corresponding to the map type.
ghost_map* ghost_context_max_map ( const ghost_context ctx)

Get the largest map of the context.

Parameters
ctxThe context.
Returns
The map with the larger local dimension.
ghost_map* ghost_context_other_map ( const ghost_context ctx,
const ghost_maptype  mt 
)

Get the context's map which does not have the given map type.

Parameters
ctxThe context.
mtThe map type.
Returns
The map not corresponding to the map type.
ghost_error ghost_context_set_map ( ghost_context ctx,
ghost_maptype  which,
ghost_map map 
)

Set a context's map.

Parameters
ctxThe context.
whichThe map type to be set.
mapThe map.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

char* ghost_context_workdist_string ( ghost_context_flags_t  flags)

Get the name of the work distribution scheme.

Parameters
flagsThe context flags.
Returns
A string holding a sensible name of the work distribution scheme.