GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Typedefs | Enumerations | Functions | Variables
context.h File Reference

Types and functions related to GHOST contexts. More...

#include "config.h"
#include "types.h"
#include "error.h"
#include "map.h"
Include dependency graph for context.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ghost_kacz_setting
 
struct  ghost_context
 The GHOST context. More...
 

Typedefs

typedef struct ghost_context ghost_context
 

Enumerations

enum  ghost_permutation_direction { GHOST_PERMUTATION_ORIG2PERM, GHOST_PERMUTATION_PERM2ORIG }
 Possible permutation directions. More...
 
enum  ghost_context_flags_t { GHOST_CONTEXT_DEFAULT = 0, GHOST_CONTEXT_DIST_NZ = 4, GHOST_CONTEXT_DIST_ROWS = 8 }
 This struct holds all possible flags for a context. More...
 
enum  ghost_kacz_method {
  GHOST_KACZ_METHOD_MC, GHOST_KACZ_METHOD_BMC_RB, GHOST_KACZ_METHOD_BMC_one_sweep, GHOST_KACZ_METHOD_BMC_two_sweep,
  GHOST_KACZ_METHOD_BMC, GHOST_KACZ_METHOD_BMCshift, GHOST_KACZ_METHOD_BMCNORMAL
}
 internal to differentiate between different KACZ sweep methods More...
 

Functions

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. 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 *ctx)
 Free the context's resources. More...
 
char * ghost_context_workdist_string (ghost_context_flags_t flags)
 Get the name of the work distribution scheme. More...
 
ghost_error ghost_global_perm_inv (ghost_gidx *toPerm, ghost_gidx *fromPerm, ghost_context *context)
 Create a global inverse permutation from a present global permutation. 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...
 
ghost_error ghost_context_comm_string (char **str, ghost_context *ctx, int root)
 Create a string holding the context's communication information. More...
 

Variables

const ghost_context GHOST_CONTEXT_INITIALIZER
 

Detailed Description

Types and functions related to GHOST contexts.

Author
Moritz Kreutzer morit.nosp@m.z.kr.nosp@m.eutze.nosp@m.r@fa.nosp@m.u.de

Typedef Documentation

typedef struct ghost_context ghost_context

Enumeration Type Documentation

This struct holds all possible flags for a context.

Enumerator
GHOST_CONTEXT_DEFAULT 
GHOST_CONTEXT_DIST_NZ 

Distribute work among the ranks by number of nonzeros.

GHOST_CONTEXT_DIST_ROWS 

Distribute work among the ranks by number of rows.

internal to differentiate between different KACZ sweep methods

Enumerator
GHOST_KACZ_METHOD_MC 

Multicolored.

GHOST_KACZ_METHOD_BMC_RB 

Block Multicolored with RCM ( condition : nrows/(2*(total_bw+1)) > threads)

GHOST_KACZ_METHOD_BMC_one_sweep 

Block Multicolored with RCM ( condition : nrows/(total_bw+1) > threads, and transition does not overlap)

GHOST_KACZ_METHOD_BMC_two_sweep 

Block Multicolored with RCM ( condition : nrows/(total_bw+1) > threads, and transition can overlap)

GHOST_KACZ_METHOD_BMC 
GHOST_KACZ_METHOD_BMCshift 
GHOST_KACZ_METHOD_BMCNORMAL 

For system normalized at start.

Possible permutation directions.

Enumerator
GHOST_PERMUTATION_ORIG2PERM 

Permute from original to permuted space.

GHOST_PERMUTATION_PERM2ORIG 

Permute from permuted to original space.

Function Documentation

ghost_error ghost_context_comm_string ( char **  str,
ghost_context ctx,
int  root 
)

Create a string holding the context's communication information.

Parameters
strThe string, must be free'd by the caller.
ctxThe context.
rootOn which rank in the context's MPI communicator to gather the information and create the string.
Returns
GHOST_SUCCESS on success or an error indicator.

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.
ghost_error ghost_global_perm_inv ( ghost_gidx toPerm,
ghost_gidx fromPerm,
ghost_context context 
)

Create a global inverse permutation from a present global permutation.

Parameters
contextA context with a valid global permutation
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

Variable Documentation

const ghost_context GHOST_CONTEXT_INITIALIZER