Mentions légales du service

Skip to content
Snippets Groups Projects

3 - SPM/Dist_basic_routines

Merged Tony Delarue requested to merge tdelarue/spm:dist/basic_routines into master
All threads resolved!
6 files
+ 127
10
Compare changes
  • Side-by-side
  • Inline
Files
6
src/spm_utils.c 0 → 100644
+ 67
0
/**
*
* @file spm_utils.h
*
* Source file for developper routines only.
* Allow us to hide precision independant routines from the user
*
* @copyright 2004-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Tony Delarue
* @date 2020-03-18
*
**/
#include "spm_utils.h"
/**
*******************************************************************************
*
* @brief Create a glob2loc array.
*
* If the spm contains the column/row, it local is stored.
* Otherwise it contains the (clustnum - clustnbr) of the owner.
* <=> if (glob2loc[col] < 0) owner[col] = glob2loc[col] + clustnbr
*
*******************************************************************************
*
* @param[inout] spm
* The sparse matrix distributed
*
*******************************************************************************
*
* @retval The global2local array. If loc2glob == NULL, glob2loc = NULL
*
********************************************************************************/
spm_int_t *
spmCreateGlob2Loc( const spmatrix_t *spm )
{
int negproc;
spm_int_t i;
spm_int_t *glob2loc;
spm_int_t *loc2glob = spm->loc2glob;
if( loc2glob == NULL ) {
return NULL;
}
glob2loc = calloc( spm->gN, sizeof(spm_int_t) );
/* Get the clustnum of every columns */
negproc = spm->clustnum - spm->clustnbr;
for (i=0; i<spm->n; i++, loc2glob++)
{
glob2loc[ *loc2glob ] = negproc;
}
#if defined(SPM_WITH_MPI)
MPI_Allreduce( MPI_IN_PLACE, glob2loc, spm->gN, SPM_MPI_INT, MPI_SUM, spm->comm );
#endif
/* Get the local index for every global colnum */
loc2glob = spm->loc2glob;
for (i=0; i<spm->n; i++, loc2glob++)
{
glob2loc[ *loc2glob ] = i;
}
return glob2loc;
}
Loading