SpM Handbook 1.2.4
Loading...
Searching...
No Matches
spm_scatter.c File Reference
#include "common.h"

Go to the source code of this file.

Functions

static void spm_scatter_getn (const spmatrix_t *spm, spm_int_t *allcounts, int root)
 Gather the n values from all nodes.
 
static void spm_scatter_csx_get_locals (const spmatrix_t *oldspm, spmatrix_t *newspm, spm_int_t *allcounts, int root)
 Compute the allcounts array with CSC/CSR formats.
 
static void spm_scatter_ijv_get_locals (const spmatrix_t *oldspm, spmatrix_t *newspm, int distByColumn, spm_int_t *allcounts, int root)
 Compute the allcounts array with IJV format.
 
static void spm_scatter_init (spmatrix_t *newspm, const spmatrix_t *oldspm, int n, const spm_int_t *loc2glob, int distByColumn, spm_int_t **allcounts, int root, int clustnum, SPM_Comm comm)
 Generic function to initialize a scattered spm on each node.
 
static void spm_scatter_csx_local_generic (const spmatrix_t *oldspm, spmatrix_t *newspm)
 Local copy of a scattered SPM in CSC or CSR format when everyone holds the original (Generic loc2glob).
 
static void spm_scatter_csx_local_continuous (const spmatrix_t *oldspm, spmatrix_t *newspm, const spm_int_t *allcounts)
 Local copy of a scattered SPM in CSC or CSR format when everyone holds the original (Contiuous loc2glob).
 
static void spm_scatter_csx_send_generic (const spmatrix_t *oldspm, const spmatrix_t *newspm, const spm_int_t *allcounts, int root)
 Send function to scatter an SPM in CSC or CSR format from a single node when the loc2glob array is generic.
 
static MPI_Request * spm_scatter_csx_send_continuous (const spmatrix_t *oldspm, const spmatrix_t *newspm, const spm_int_t *allcounts, int root)
 Send function to scatter an SPM in CSC or CSR format from a single node when the loc2glob array is split in continuous sets.
 
static void spm_scatter_csx_send (const spmatrix_t *oldspm, spmatrix_t *newspm, const spm_int_t *allcounts, int continuous, int root)
 Send wrapper function to scatter an SPM in CSC or CSR format from a single node.
 
static void spm_scatter_csx_recv (const spmatrix_t *newspm, int continuous, int root)
 Reception of a scattered SPM in the CSC/CSR formats.
 
static void spm_scatter_csx (const spmatrix_t *oldspm, spmatrix_t *newspm, const spm_int_t *allcounts, int continuous, int root)
 Scatter the SPM in the CSC/CSR formats.
 
static void spm_scatter_ijv_local (const spmatrix_t *oldspm, spmatrix_t *newspm, int distByColumn)
 Initialize a local spm in IJV format.
 
static void spm_scatter_ijv_remote (const spmatrix_t *oldspm, spmatrix_t *newspm, int distByColumn)
 Initialize a temporary remote spm in IJV format to send it.
 
static void spm_scatter_ijv_send (const spmatrix_t *oldspm, spmatrix_t *newspm, const spm_int_t *allcounts, int distByColumn, int root)
 Send function to scatter an IJV SPM from a single node.
 
static void spm_scatter_ijv_recv (const spmatrix_t *newspm, int root)
 Reception of a scattered SPM in the IJV format.
 
static void spm_scatter_ijv (const spmatrix_t *oldspm, spmatrix_t *newspm, const spm_int_t *allcounts, int distByColumn, int root)
 Scatter the SPM in the IJV format.
 
SPM distribution subroutines
int spmScatter (spmatrix_t *newspm, int root, const spmatrix_t *oldspm, spm_int_t n, const spm_int_t *loc2glob, int distByColumn, SPM_Comm comm)
 Scatter the SPM thanks to loc2glob.
 

Detailed Description

SParse Matrix scatter routine.

Version
1.2.4
Author
Tony Delarue
Mathieu Faverge
Alycia Lisito
Date
2024-07-02

Definition in file spm_scatter.c.

Function Documentation

◆ spm_scatter_getn()

static void spm_scatter_getn ( const spmatrix_t spm,
spm_int_t allcounts,
int  root 
)
static

Gather the n values from all nodes.

Parameters
[in]spmThe newspm that will be generated with the n field correctly set.
[in,out]allcountsOn entry, the array must be allocated. On exit, stores the {n, nnz, nnzexp} information for all nodes.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 72 of file spm_scatter.c.

References spmatrix_s::clustnbr, spmatrix_s::comm, spmatrix_s::n, and SPM_MPI_INT.

Referenced by spm_scatter_init().

◆ spm_scatter_csx_get_locals()

static void spm_scatter_csx_get_locals ( const spmatrix_t oldspm,
spmatrix_t newspm,
spm_int_t allcounts,
int  root 
)
static

Compute the allcounts array with CSC/CSR formats.

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in,out]newspmThe allocated and spmInit() spm in which to store the local information. On entry, n and loc2glob must be specified. On exit, nnz and nnzexp fields are updated.
[in,out]allcountsOn entry, the array must be allocated. On exit, stores the {n, nnz, nnzexp} information for all nodes.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 121 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::fmttype, spmatrix_s::gN, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_getandset_glob2loc(), SPM_MPI_INT, and SpmCSC.

Referenced by spm_scatter_init().

◆ spm_scatter_ijv_get_locals()

static void spm_scatter_ijv_get_locals ( const spmatrix_t oldspm,
spmatrix_t newspm,
int  distByColumn,
spm_int_t allcounts,
int  root 
)
static

Compute the allcounts array with IJV format.

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in,out]newspmThe allocated and spmInit() spm in which to store the local information. On entry, n and loc2glob must be specified. On exit, nnz and nnzexp fields are updated.
[in]distByColumnBoolean to decide if the matrix is distributed by rows or columns. If false, distribution by rows. If true, distribution by columns.
[in,out]allcountsOn entry, the array must be allocated. On exit, stores the {n, nnz, nnzexp} information for all nodes.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 251 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_getandset_glob2loc(), and SPM_MPI_INT.

Referenced by spm_scatter_init().

◆ spm_scatter_init()

static void spm_scatter_init ( spmatrix_t newspm,
const spmatrix_t oldspm,
int  n,
const spm_int_t loc2glob,
int  distByColumn,
spm_int_t **  allcounts,
int  root,
int  clustnum,
SPM_Comm  comm 
)
static

Generic function to initialize a scattered spm on each node.

Parameters
[in,out]newspmOn entry, an allocated spm structure. Must be provided by all participants. On exit, contains the local part of the scattered spm.
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in]nThe local loc2glob size if provided. Unused if spm->replicated
[in]loc2globThe indices of the local unknowns in the scattered spm. Must be of size n if provided. If NULL, the spm is scattered with equal chunks of unknowns.
[in]distByColumnBoolean to decide if the matrix is distributed by rows or columns. If false, distribution by rows. If true, distribution by columns.
[out]allcountsPointer to an array of triplet {n, nnz, nnzexp} per node allocated by this call.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.
[in]clustnumLocal MPI procnum index in the communicator comm.
[in]commThe MPI communicator on which to distribute the SPM.

Definition at line 375 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::clustnbr, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::fmttype, spmatrix_s::gN, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::replicated, spmatrix_s::rowptr, spm_create_loc2glob_continuous(), SPM_MPI_INT, spm_scatter_csx_get_locals(), spm_scatter_getn(), spm_scatter_ijv_get_locals(), spmAlloc(), SpmIJV, spmInit(), and spmatrix_s::values.

Referenced by spmScatter().

◆ spm_scatter_csx_local_generic()

static void spm_scatter_csx_local_generic ( const spmatrix_t oldspm,
spmatrix_t newspm 
)
static

Local copy of a scattered SPM in CSC or CSR format when everyone holds the original (Generic loc2glob).

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in]newspmThe new scattered sparse matrix structure to access the clustnbr and communicator.

Definition at line 490 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::colptr, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_get_value_idx_by_elt(), spm_size_of(), SpmCSC, SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_csx(), spm_scatter_csx_send(), and spm_scatter_csx_send_generic().

◆ spm_scatter_csx_local_continuous()

static void spm_scatter_csx_local_continuous ( const spmatrix_t oldspm,
spmatrix_t newspm,
const spm_int_t allcounts 
)
static

Local copy of a scattered SPM in CSC or CSR format when everyone holds the original (Contiuous loc2glob).

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in]newspmThe new scattered sparse matrix structure to access the clustnbr and communicator.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.

Definition at line 577 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_size_of(), SpmCSC, SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_csx(), and spm_scatter_csx_send().

◆ spm_scatter_csx_send_generic()

static void spm_scatter_csx_send_generic ( const spmatrix_t oldspm,
const spmatrix_t newspm,
const spm_int_t allcounts,
int  root 
)
static

Send function to scatter an SPM in CSC or CSR format from a single node when the loc2glob array is generic.

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in]newspmThe new scattered sparse matrix structure to access the clustnbr and communicator.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 644 of file spm_scatter.c.

References spmatrix_s::clustnbr, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nexp, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_imax(), SPM_MPI_INT, spm_scatter_csx_local_generic(), spm_size_of(), SpmCSC, SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_csx_send().

◆ spm_scatter_csx_send_continuous()

static MPI_Request * spm_scatter_csx_send_continuous ( const spmatrix_t oldspm,
const spmatrix_t newspm,
const spm_int_t allcounts,
int  root 
)
static

Send function to scatter an SPM in CSC or CSR format from a single node when the loc2glob array is split in continuous sets.

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in]newspmThe new scattered sparse matrix structure to access the clustnbr and communicator.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.
Returns
The pointer to the communication request.

Definition at line 777 of file spm_scatter.c.

References spmatrix_s::clustnbr, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::rowptr, SPM_MPI_INT, spm_size_of(), SpmCSC, SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_csx_send().

◆ spm_scatter_csx_send()

static void spm_scatter_csx_send ( const spmatrix_t oldspm,
spmatrix_t newspm,
const spm_int_t allcounts,
int  continuous,
int  root 
)
static

Send wrapper function to scatter an SPM in CSC or CSR format from a single node.

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in,out]newspmThe structure to hold the local new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.
[in]continuousBoolean to specify if the distribution is made by regular continuous sets or not.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 869 of file spm_scatter.c.

References spmatrix_s::clustnbr, spmatrix_s::n, spm_scatter_csx_local_continuous(), spm_scatter_csx_local_generic(), spm_scatter_csx_send_continuous(), and spm_scatter_csx_send_generic().

Referenced by spm_scatter_csx().

◆ spm_scatter_csx_recv()

static void spm_scatter_csx_recv ( const spmatrix_t newspm,
int  continuous,
int  root 
)
static

Reception of a scattered SPM in the CSC/CSR formats.

Parameters
[in,out]newspmThe structure to hold the new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]continuousBoolean to specify if the distribution is made by regular continuous sets or not.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 922 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, SPM_MPI_INT, SpmCSC, SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_csx().

◆ spm_scatter_csx()

static void spm_scatter_csx ( const spmatrix_t oldspm,
spmatrix_t newspm,
const spm_int_t allcounts,
int  continuous,
int  root 
)
static

Scatter the SPM in the CSC/CSR formats.

Parameters
[in]oldspmThe input sparse matrix to scatter in the CSC or CSR format.
[in,out]newspmThe structure to hold the new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.
[in]continuousBoolean to specify if the distribution is made by regular continuous sets or not.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 994 of file spm_scatter.c.

References spmatrix_s::clustnum, spmatrix_s::n, spm_scatter_csx_local_continuous(), spm_scatter_csx_local_generic(), spm_scatter_csx_recv(), and spm_scatter_csx_send().

Referenced by spmScatter().

◆ spm_scatter_ijv_local()

static void spm_scatter_ijv_local ( const spmatrix_t oldspm,
spmatrix_t newspm,
int  distByColumn 
)
static

Initialize a local spm in IJV format.

Parameters
[in]oldspmThe input sparse matrix to scatter in the IJV format.
[in,out]newspmThe structure to hold the local new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]distByColumnBoolean to decide if the matrix is distributed by rows or columns. If false, distribution by rows. If true, distribution by columns.

Definition at line 1043 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::colptr, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, spmatrix_s::glob2loc, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_size_of(), SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_ijv(), and spm_scatter_ijv_send().

◆ spm_scatter_ijv_remote()

static void spm_scatter_ijv_remote ( const spmatrix_t oldspm,
spmatrix_t newspm,
int  distByColumn 
)
static

Initialize a temporary remote spm in IJV format to send it.

Parameters
[in]oldspmThe input sparse matrix to scatter in the IJV format.
[in,out]newspmThe structure to hold the local new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]distByColumnBoolean to decide if the matrix is distributed by rows or columns. If false, distribution by rows. If true, distribution by columns.

Definition at line 1133 of file spm_scatter.c.

References spmatrix_s::baseval, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, spmatrix_s::glob2loc, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_size_of(), SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_ijv_send().

◆ spm_scatter_ijv_send()

static void spm_scatter_ijv_send ( const spmatrix_t oldspm,
spmatrix_t newspm,
const spm_int_t allcounts,
int  distByColumn,
int  root 
)
static

Send function to scatter an IJV SPM from a single node.

Parameters
[in]oldspmThe input sparse matrix to scatter in the IJV format.
[in,out]newspmThe structure to hold the local new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.
[in]distByColumnBoolean to decide if the matrix is distributed by rows or columns. If false, distribution by rows. If true, distribution by columns.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 1230 of file spm_scatter.c.

References spmatrix_s::clustnbr, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::flttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nexp, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, spm_imax(), SPM_MPI_INT, spm_scatter_ijv_local(), spm_scatter_ijv_remote(), spm_size_of(), SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_ijv().

◆ spm_scatter_ijv_recv()

static void spm_scatter_ijv_recv ( const spmatrix_t newspm,
int  root 
)
static

Reception of a scattered SPM in the IJV format.

Parameters
[in,out]newspmThe structure to hold the new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]rootThe root process sending the information.

Definition at line 1336 of file spm_scatter.c.

References spmatrix_s::colptr, spmatrix_s::comm, spmatrix_s::flttype, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::rowptr, SPM_MPI_INT, SpmPattern, and spmatrix_s::values.

Referenced by spm_scatter_ijv().

◆ spm_scatter_ijv()

static void spm_scatter_ijv ( const spmatrix_t oldspm,
spmatrix_t newspm,
const spm_int_t allcounts,
int  distByColumn,
int  root 
)
static

Scatter the SPM in the IJV format.

Parameters
[in]oldspmThe input sparse matrix to scatter in the IJV format.
[in,out]newspmThe structure to hold the new scattered sparse matrix. It must have been allocated first, and non array fields must have been initialized, as well as dof and loc2glob.
[in]allcountsInternal array that stores the triplets {n, nnz, nnzexp} for each node.
[in]distByColumnBoolean to decide if the matrix is distributed by rows or columns. If false, distribution by rows. If true, distribution by columns.
[in]rootThe root process of the scatter operation. -1 if everyone hold a copy of the oldspm.

Definition at line 1389 of file spm_scatter.c.

References spmatrix_s::clustnum, spm_scatter_ijv_local(), spm_scatter_ijv_recv(), and spm_scatter_ijv_send().

Referenced by spmScatter().