diff --git a/include/spm.h b/include/spm.h index dc66ea3dafa8803d4db944bef328c38d9b65f2f8..f74efe7e60c812baa12c347802cfe0e0bbcc0a02 100644 --- a/include/spm.h +++ b/include/spm.h @@ -99,7 +99,7 @@ double spmNorm( spm_normtype_t ntype, const spmatrix_t *spm ); int spmMatVec( spm_trans_t trans, const void *alpha, const spmatrix_t *spm, const void *x, const void *beta, void *y ); int spmMatMat( spm_trans_t trans, spm_int_t n, const void *alpha, const spmatrix_t *A, - const void *B, spm_int_t ldb, + const void *B, spm_int_t ldb, const void *beta, void *C, spm_int_t ldc ); void spmScalMatrix( double alpha, spmatrix_t *spm ); void spmScalVector( spm_coeftype_t flt, double alpha, spm_int_t n, void *x, spm_int_t incx ); @@ -148,9 +148,17 @@ int spmSave( const spmatrix_t *spm, FILE *outfile ); * @{ */ int spmReadDriver( spm_driver_t driver, - const char *filename, - spmatrix_t *spm, - MPI_Comm spm_comm ); + const char *filename, + spmatrix_t *spm ); + +int spmParseLaplacianInfo( const char *filename, + spm_coeftype_t *flttype, + spm_int_t *dim1, + spm_int_t *dim2, + spm_int_t *dim3, + double *alpha, + double *beta ); + /** * @} * @name SPM debug subroutines diff --git a/include/spm_datatypes.h b/include/spm_datatypes.h index 9a7f90cb5033a10a7cf39d983108038f269d1122..be32812c4d08da41177bed2d25323581a1fbf65b 100644 --- a/include/spm_datatypes.h +++ b/include/spm_datatypes.h @@ -129,6 +129,4 @@ spm_size_of(spm_coeftype_t type) } } -typedef int MPI_Comm; - #endif /* _spm_datatypes_h_ */ diff --git a/src/drivers/laplacian.c b/src/drivers/laplacian.c index 602d55bae087af9cd3d3f0731d8a2b7893a402d4..e5edc26eea1e079867d4c971b5c9d4d808bff85f 100644 --- a/src/drivers/laplacian.c +++ b/src/drivers/laplacian.c @@ -51,7 +51,7 @@ laplacian_usage(void) /** ******************************************************************************* * - * @ingroup spm_spm_driver + * @ingroup spm * * @brief Parse information given through the filename string to configure the * laplacian matrix to generate. @@ -92,13 +92,13 @@ laplacian_usage(void) * *******************************************************************************/ int -laplacian_parse_info( const char *filename, - spm_coeftype_t *flttype, - spm_int_t *dim1, - spm_int_t *dim2, - spm_int_t *dim3, - double *alpha, - double *beta ) +spmParseLaplacianInfo( const char *filename, + spm_coeftype_t *flttype, + spm_int_t *dim1, + spm_int_t *dim2, + spm_int_t *dim3, + double *alpha, + double *beta ) { double val1, val2; long tmp1, tmp2, tmp3; @@ -282,7 +282,7 @@ genLaplacian( const char *filename, double beta = 1.; int rc; - rc = laplacian_parse_info(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta ); + rc = spmParseLaplacianInfo(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta ); if (rc != SPM_SUCCESS) return rc; @@ -336,7 +336,7 @@ genExtendedLaplacian( const char *filename, double beta = 1.; int rc; - rc = laplacian_parse_info(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta); + rc = spmParseLaplacianInfo(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta); if (rc != SPM_SUCCESS) return rc; diff --git a/src/drivers/laplacian.h b/src/drivers/laplacian.h index 423cb49640888bfc6c853ca842cbafb553c82729..2954365eaadb9468dc1ab9162eceb5c8d7f4886d 100644 --- a/src/drivers/laplacian.h +++ b/src/drivers/laplacian.h @@ -32,12 +32,4 @@ void d_spmExtendedLaplacian3D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, void s_spmExtendedLaplacian3D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3 ); void p_spmExtendedLaplacian3D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3 ); -int laplacian_parse_info( const char *filename, - spm_coeftype_t *flttype, - spm_int_t *dim1, - spm_int_t *dim2, - spm_int_t *dim3, - double *alpha, - double *beta ); - #endif /* _laplacian_h_ */ diff --git a/src/spm_drivers.h b/src/spm_drivers.h index 2343b6f55c62ddac0d1e6ca40f283e6cf37fd657..95259da19858a96e60393ada3aebbe22ec9f5d8d 100644 --- a/src/spm_drivers.h +++ b/src/spm_drivers.h @@ -29,7 +29,7 @@ int readIJV ( const char *filename, spmatrix_t *spm ); int readMM ( const char *filename, spmatrix_t *spm ); int readDMM ( const char *filename, spmatrix_t *spm ); int readPETSC( const char *filename, spmatrix_t *spm ); -int readCSCD ( const char *filename, spmatrix_t *spm, void **rhs, MPI_Comm spm_comm ); +//int readCSCD ( const char *filename, spmatrix_t *spm, void **rhs, MPI_Comm spm_comm ); int genLaplacian( const char *filename, spmatrix_t *spm ); int genExtendedLaplacian( const char *filename, spmatrix_t *spm ); diff --git a/src/spm_read_driver.c b/src/spm_read_driver.c index e9a3a2969cdd97adb2847f610805e12a953777d6..a24cab82b1eb9327980a592f128d8744c0328b30 100644 --- a/src/spm_read_driver.c +++ b/src/spm_read_driver.c @@ -52,10 +52,6 @@ * On exit, the filled sparse matrix structure with the matrix from the * file. * - * @param[in] comm - * The MPI communicator on which to distribute the sparse matrix. This - * is also used in case of distributed formats. - * ******************************************************************************** * * @retval SPM_SUCCESS if the file reading happened successfully, @@ -65,141 +61,100 @@ int spmReadDriver( spm_driver_t driver, const char *filename, - spmatrix_t *spm, - MPI_Comm comm ) + spmatrix_t *spm ) { - int mpirank = 0; - /* int mpiinit; */ - spmInit(spm); - /* MPI_Initialized( &mpiinit ); */ - /* if (mpiinit) { */ - /* MPI_Comm_rank( comm, &mpirank ); */ - /* } */ - mpirank = 0; - - if ( mpirank == 0 ) + switch(driver) { - switch(driver) - { #if defined(SPM_WITH_FORTRAN) - case SpmDriverRSA: - readRSA( filename, spm ); - break; + case SpmDriverRSA: + readRSA( filename, spm ); + break; #endif - case SpmDriverHB: - /* TODO: Possible to read the RHS, the solution or a guess of the solution */ - readHB( filename, spm ); - break; - - case SpmDriverIJV: - readIJV( filename, spm ); - break; - - case SpmDriverMM: - readMM( filename, spm ); - break; - - case SpmDriverLaplacian: - genLaplacian( filename, spm ); - break; - - case SpmDriverXLaplacian: - genExtendedLaplacian( filename, spm ); - break; - - case SpmDriverSPM: - { - FILE *file = fopen( filename, "r" ); - if ( file == NULL ) { - fprintf( stderr,"spmReadDriver: impossible to open the file %s\n", filename ); - return SPM_ERR_FILE; - } - - if ( spmLoad( spm, file ) != SPM_SUCCESS ) { - fprintf( stderr,"spmReadDriver: error while reading the file %s\n", filename ); - return SPM_ERR_FILE; - } - - fclose( file ); - } + case SpmDriverHB: + /* TODO: Possible to read the RHS, the solution or a guess of the solution */ + readHB( filename, spm ); break; - case SpmDriverGraph: -#if defined(HAVE_SCOTCH) - { - SCOTCH_Graph sgraph; - FILE *file; - - file = fopen( filename, "r" ); - if ( file == NULL ) { - fprintf( stderr,"spmReadDriver: impossible to open the file %s\n", filename ); - return SPM_ERR_FILE; - } - - /* Check integer compatibility */ - if (sizeof(spm_int_t) != sizeof(SCOTCH_Num)) { - fprintf( stderr,"Inconsistent integer type\n"); - fclose(file); - return SPM_ERR_INTEGER_TYPE; - } - - SCOTCH_graphLoad( &sgraph, file, 1, 0 ); - SCOTCH_graphData( &sgraph, NULL, &(spm->n), &(spm->colptr), NULL, NULL, NULL, - &(spm->nnz), &(spm->rowptr), NULL ); - fclose(file); + case SpmDriverIJV: + readIJV( filename, spm ); + break; - spm->mtxtype = SpmGeneral; - spm->flttype = SpmPattern; - spm->fmttype = SpmCSC; - spm->dof = 1; - spmUpdateComputedFields( spm ); + case SpmDriverMM: + readMM( filename, spm ); + break; + + case SpmDriverLaplacian: + genLaplacian( filename, spm ); + break; + + case SpmDriverXLaplacian: + genExtendedLaplacian( filename, spm ); + break; + + case SpmDriverSPM: + { + FILE *file = fopen( filename, "r" ); + if ( file == NULL ) { + fprintf( stderr,"spmReadDriver: impossible to open the file %s\n", filename ); + return SPM_ERR_FILE; } -#else - { - fprintf(stderr, "Scotch driver to read graph file unavailable.\n" - "Compile with Scotch support to provide it\n"); - return SPM_ERR_BADPARAMETER; + + if ( spmLoad( spm, file ) != SPM_SUCCESS ) { + fprintf( stderr,"spmReadDriver: error while reading the file %s\n", filename ); + return SPM_ERR_FILE; } -#endif - break; - default: - fprintf(stderr, "spmReadDriver: Driver not implemented\n"); - return SPM_ERR_UNKNOWN; + fclose( file ); + } + break; + + case SpmDriverGraph: +#if defined(HAVE_SCOTCH) + { + SCOTCH_Graph sgraph; + FILE *file; + + file = fopen( filename, "r" ); + if ( file == NULL ) { + fprintf( stderr,"spmReadDriver: impossible to open the file %s\n", filename ); + return SPM_ERR_FILE; } + + /* Check integer compatibility */ + if (sizeof(spm_int_t) != sizeof(SCOTCH_Num)) { + fprintf( stderr,"Inconsistent integer type\n"); + fclose(file); + return SPM_ERR_INTEGER_TYPE; + } + + SCOTCH_graphLoad( &sgraph, file, 1, 0 ); + SCOTCH_graphData( &sgraph, NULL, &(spm->n), &(spm->colptr), NULL, NULL, NULL, + &(spm->nnz), &(spm->rowptr), NULL ); + fclose(file); + + spm->mtxtype = SpmGeneral; + spm->flttype = SpmPattern; + spm->fmttype = SpmCSC; + spm->dof = 1; + spmUpdateComputedFields( spm ); + } +#else + { + fprintf(stderr, "Scotch driver to read graph file unavailable.\n" + "Compile with Scotch support to provide it\n"); + return SPM_ERR_BADPARAMETER; } +#endif + break; - /* if ( mpiinit ) */ - /* { */ - /* spm_int_t nnz = spm->nnz; */ - - /* MPI_Bcast( spm, sizeof(spmatrix_t), MPI_CHAR, 0, comm ); */ - /* MPI_Bcast( &nnz, 1, SPM_MPI_INT, 0, comm ); */ - - /* if ( mpirank != 0 ) */ - /* { */ - /* spm->colptr = (spm_int_t *) malloc((spm->gN+1) * sizeof(spm_int_t)); */ - /* spm->rowptr = (spm_int_t *) malloc(nnz * sizeof(spm_int_t)); */ - /* spm->loc2glob = NULL; */ - /* spm->loc2glob = NULL; */ - /* } */ - - /* MPI_Bcast( spm->colptr, spm->gN+1, SPM_MPI_INT, 0, comm ); */ - /* MPI_Bcast( spm->rowptr, nnz, SPM_MPI_INT, 0, comm ); */ - - /* if ( spm->flttype != SpmPattern ) { */ - /* size_t eltsize = spm_size_of( spm->flttype ); */ - /* if ( mpirank != 0 ) { */ - /* spm->values = (void *) malloc(nnz * eltsize); */ - /* } */ - /* MPI_Bcast( spm->values, nnz * eltsize, MPI_CHAR, 0, comm ); */ - /* } */ - /* } */ + default: + fprintf(stderr, "spmReadDriver: Driver not implemented\n"); + return SPM_ERR_UNKNOWN; + } spmUpdateComputedFields( spm ); - (void)comm; return SPM_SUCCESS; } diff --git a/tests/spm_convert_tests.c b/tests/spm_convert_tests.c index 4cf4fd2df931cb0bbd4429975a73db57be8e0dc0..1bc33bb8e7d9fd367432300cac4343c52a7ce890 100644 --- a/tests/spm_convert_tests.c +++ b/tests/spm_convert_tests.c @@ -117,7 +117,7 @@ int main (int argc, char **argv) spmGetOptions( argc, argv, &driver, &filename ); - rc = spmReadDriver( driver, filename, &spm, 0 ); + rc = spmReadDriver( driver, filename, &spm ); free(filename); if ( rc != SPM_SUCCESS ) { diff --git a/tests/spm_dof_expand_tests.c b/tests/spm_dof_expand_tests.c index 277095254bf43f459907dd5e56e2c8d205601ae9..0a343aa99c7f140b4f11edae9a4aea8db3abf9d7 100644 --- a/tests/spm_dof_expand_tests.c +++ b/tests/spm_dof_expand_tests.c @@ -63,7 +63,7 @@ int main (int argc, char **argv) spmGetOptions( argc, argv, &driver, &filename ); - rc = spmReadDriver( driver, filename, &original, 0 ); + rc = spmReadDriver( driver, filename, &original ); free(filename); if ( rc != SPM_SUCCESS ) { diff --git a/tests/spm_dof_matvec_tests.c b/tests/spm_dof_matvec_tests.c index 96db005302762421e5a1fa5c33fe4a8337b5b0bb..598804a9da9f4720f7bdbec9faacbd95d417f194 100644 --- a/tests/spm_dof_matvec_tests.c +++ b/tests/spm_dof_matvec_tests.c @@ -57,7 +57,7 @@ int main (int argc, char **argv) spmGetOptions( argc, argv, &driver, &filename ); - rc = spmReadDriver( driver, filename, &original, 0 ); + rc = spmReadDriver( driver, filename, &original ); free(filename); if ( rc != SPM_SUCCESS ) { diff --git a/tests/spm_dof_norm_tests.c b/tests/spm_dof_norm_tests.c index 71d24939f5adb37269433e4afb40a5b1c9f5551d..6d4e74f6a228fa6534f6235d63ec8347a2d96021 100644 --- a/tests/spm_dof_norm_tests.c +++ b/tests/spm_dof_norm_tests.c @@ -56,7 +56,7 @@ int main (int argc, char **argv) spmGetOptions( argc, argv, &driver, &filename ); - rc = spmReadDriver( driver, filename, &original, 0 ); + rc = spmReadDriver( driver, filename, &original ); free(filename); if ( rc != SPM_SUCCESS ) { diff --git a/tests/spm_matvec_tests.c b/tests/spm_matvec_tests.c index c605beef38c6a78b46e2a116b10422da5697b8ef..7ad94e560cd3c55358ee9be7cd5d6dae7dc215bc 100644 --- a/tests/spm_matvec_tests.c +++ b/tests/spm_matvec_tests.c @@ -52,7 +52,7 @@ int main (int argc, char **argv) spmGetOptions( argc, argv, &driver, &filename ); - rc = spmReadDriver( driver, filename, &spm, 0 ); + rc = spmReadDriver( driver, filename, &spm ); free(filename); if ( rc != SPM_SUCCESS ) { diff --git a/tests/spm_norm_tests.c b/tests/spm_norm_tests.c index f37d652914f5c85b5f1383442994edcdc08a5e4b..d6824b737159545edd007a8c386492753b5bfe97 100644 --- a/tests/spm_norm_tests.c +++ b/tests/spm_norm_tests.c @@ -55,7 +55,7 @@ int main (int argc, char **argv) spmGetOptions( argc, argv, &driver, &filename ); - rc = spmReadDriver( driver, filename, &spm, 0 ); + rc = spmReadDriver( driver, filename, &spm ); free(filename); if ( rc != SPM_SUCCESS ) {