diff --git a/CMakeLists.txt b/CMakeLists.txt index e2f9ff2df1095e1b74becaac5ea41ec5c3e6443a..63061c76aaaee2f2868d3bb5a0049b4dce7e6392 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,17 @@ else() set( BUILD_SUBPROJECT ON ) endif() +if ( PASTIX_INT64 ) + set( SPM_INT64 ${PASTIX_INT64} ) +else() + option(SPM_INT64 + "Choose between int32 and int64 for integer representation" ON) +endif() + + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") include(GenSPMPkgConfig) +include(AddSourceFiles) # The current version number set (SPM_VERSION_MAJOR 0) @@ -49,8 +58,8 @@ set( RP_SPM_DICTIONNARY ${MORSE_CMAKE_MODULE_PATH}/precision_generator/subs.py ) set( RP_SPM_PRECISIONS "s;d;c;z" ) include(RulesPrecisions) -include(RulesPrecisions) -include(AddSourceFiles) +### System parameter detection +include(CheckSystem) # PaStiX depends on CBLAS #---------------------------- @@ -66,7 +75,15 @@ if(LAPACKE_FOUND) include_directories(${LAPACKE_INCLUDE_DIRS}) endif() +#Configuration header +#-------------------- +configure_file ( + "${CMAKE_CURRENT_SOURCE_DIR}/include/spm_config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/src/spm_config.h") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/src/spm_config.h" DESTINATION include) + include_directories(include) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src") include_directories("${CMAKE_CURRENT_BINARY_DIR}/src") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/drivers") @@ -81,12 +98,13 @@ set(HEADERS precisions_rules_py(generated_headers "${HEADERS}" + TARGETDIR src PRECISIONS "p;s;d;c;z") set(spm_headers ${generated_headers} include/spm.h - include/spm_drivers.h + src/spm_drivers.h ) add_custom_target(spm_headers_tgt @@ -113,6 +131,7 @@ set(SOURCES precisions_rules_py(generated_sources "${SOURCES}" + TARGETDIR src PRECISIONS "p;s;d;c;z") set(spm_sources diff --git a/cmake_modules/CheckSystem.cmake b/cmake_modules/CheckSystem.cmake new file mode 100644 index 0000000000000000000000000000000000000000..50e8a6f41473e4c915eb90339f42c46164857ae8 --- /dev/null +++ b/cmake_modules/CheckSystem.cmake @@ -0,0 +1,257 @@ +# cmake modules setup +cmake_minimum_required (VERSION 2.8.7) +include (CMakeDetermineSystem) +include (CheckCCompilerFlag) +include (CheckFunctionExists) +include (CheckSymbolExists) +include (CheckIncludeFiles) +include (CMakePushCheckState) + +# +# Fix the building system for 32 or 64 bits. +# +# On MAC OS X there is an easy solution, by setting the +# CMAKE_OSX_ARCHITECTURES to a subset of the following values: +# ppc;ppc64;i386;x86_64. +# On Linux this is a little bit tricky. We have to check that the +# compiler supports the -m32/-m64 flags as well as the linker. +# Once this issue is resolved the CMAKE_C_FLAGS and CMAKE_C_LDFLAGS +# have to be updated accordingly. +# +# TODO: Same trick for the Fortran compiler... +# no idea how to correctly detect if the required/optional +# libraries are in the correct format. +# +if (BUILD_64bits) + if( _match_xlc) + set( ARCH_BUILD "-q64" ) + else (_match_xlc) + if( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "sparc64fx" ) + set ( ARCH_BUILD " " ) + else() + set( ARCH_BUILD "-m64" ) + endif() + endif(_match_xlc) +else (BUILD_64bits) + if( _match_xlc) + set( ARCH_BUILD "-q32" ) + else (_match_xlc) + set( ARCH_BUILD "-m32" ) + endif(_match_xlc) +endif (BUILD_64bits) + +check_c_compiler_flag( ${ARCH_BUILD} C_M32or64 ) +if( C_M32or64 ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_BUILD}" ) + set( CMAKE_C_LDFLAGS "${CMAKE_C_LDFLAGS} ${ARCH_BUILD}" ) + set( LOCAL_FORTRAN_LINK_FLAGS "${LOCAL_FORTRAN_LINK_FLAGS} ${ARCH_BUILD}" ) +endif( C_M32or64 ) + +# Set warnings for debug builds +check_c_compiler_flag( "-Wall" HAVE_WALL ) +if( HAVE_WALL ) + set( C_WFLAGS "${C_WFLAGS} -Wall" ) +endif( HAVE_WALL ) +check_c_compiler_flag( "-Wextra" HAVE_WEXTRA ) +if( HAVE_WEXTRA ) + set( C_WFLAGS "${C_WFLAGS} -Wextra" ) +endif( HAVE_WEXTRA ) + +# +# flags for Intel icc +# +string(REGEX MATCH ".*icc$" _match_icc ${CMAKE_C_COMPILER}) +if(_match_icc) + # Silence annoying warnings + check_c_compiler_flag( "-wd424" HAVE_WD ) + if( HAVE_WD ) + # 424: checks for duplicate ";" + # 981: every volatile triggers a "unspecified evaluation order", obnoxious + # but might be useful for some debugging sessions. + # 1419: warning about extern functions being declared in .c + # files + # 1572: cuda compares floats with 0.0f. + set( C_WFLAGS "${C_WFLAGS} -wd424 -wd981 -wd1419 -wd1572" ) + endif( HAVE_WD ) +endif(_match_icc) + +set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_WFLAGS}" ) + +# add gdb symbols in debug and relwithdebinfo +check_c_compiler_flag( "-g3" HAVE_G3 ) +if( HAVE_G3 ) + set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3" ) + set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g3" ) +else() + set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0" ) +endif( HAVE_G3 ) + +# +# Remove all duplicates from the CFLAGS. +# +set(TMP_LIST ${CMAKE_C_FLAGS}) +separate_arguments(TMP_LIST) +list(REMOVE_DUPLICATES TMP_LIST) +set(CMAKE_C_FLAGS "") +foreach( ITEM ${TMP_LIST}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ITEM}") +endforeach() + +# Check for attribute fallthrough +# ------------------------------- +check_c_source_compiles(" +#include <stdarg.h> +int main(void) { + int a = 2; + switch( a ){ + case 0: + __attribute__((fallthrough)); + default: + ; + } + return 0; +} +" + HAVE_FALLTHROUGH + ) + +# Check for Thread library +# ------------------------ +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_package(Threads) +if(Threads_FOUND) + CMAKE_PUSH_CHECK_STATE() + list( APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}" ) + check_function_exists(pthread_create HAVE_PTHREAD) + CMAKE_POP_CHECK_STATE() + if(HAVE_PTHREAD) + list(APPEND EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT}) + endif(HAVE_PTHREAD) +endif(Threads_FOUND) + +check_function_exists(sched_setaffinity HAVE_SCHED_SETAFFINITY) +if( NOT HAVE_SCHED_SETAFFINITY ) + check_library_exists(rt sched_setaffinity "" HAVE_SCHED_SETAFFINITY) +endif( NOT HAVE_SCHED_SETAFFINITY ) + +# timeval, timespec, realtime clocks, etc +include(CheckStructHasMember) +check_struct_has_member("struct timespec" tv_nsec time.h HAVE_TIMESPEC_TV_NSEC) +if( NOT HAVE_TIMESPEC_TV_NSEC ) + add_definitions(-D_GNU_SOURCE) + check_struct_has_member("struct timespec" tv_nsec time.h HAVE_TIMESPEC_TV_NSEC) +endif( NOT HAVE_TIMESPEC_TV_NSEC ) +check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME) +if( HAVE_CLOCK_GETTIME ) + list(APPEND EXTRA_LIBS rt) +endif( HAVE_CLOCK_GETTIME ) + +# stdlib, stdio, string, getopt, etc +check_include_files(stdarg.h HAVE_STDARG_H) +# va_copy is special as it is not required to be a function. +if (HAVE_STDARG_H) + check_c_source_compiles(" + #include <stdarg.h> + int main(void) { + va_list a, b; + va_copy(a, b); + return 0; + }" + HAVE_VA_COPY + ) + + if (NOT HAVE_VA_COPY) + check_c_source_compiles(" + #include <stdarg.h> + int main(void) { + va_list a, b; + __va_copy(a, b); + return 0; + }" + HAVE_UNDERSCORE_VA_COPY + ) + endif (NOT HAVE_VA_COPY) +endif (HAVE_STDARG_H) + +check_function_exists(asprintf HAVE_ASPRINTF) +check_function_exists(vasprintf HAVE_VASPRINTF) +check_include_files(getopt.h HAVE_GETOPT_H) +check_include_files(unistd.h HAVE_UNISTD_H) +check_function_exists(getopt_long HAVE_GETOPT_LONG) +check_include_files(errno.h HAVE_ERRNO_H) +check_include_files(stddef.h HAVE_STDDEF_H) +check_include_files(stdbool.h HAVE_STDBOOL_H) +check_function_exists(getrusage HAVE_GETRUSAGE) +check_symbol_exists(RUSAGE_THREAD sys/resource.h HAVE_RUSAGE_THREAD) +check_include_files(limits.h HAVE_LIMITS_H) +check_include_files(string.h HAVE_STRING_H) +check_include_files(libgen.h HAVE_GEN_H) +check_include_files(complex.h HAVE_COMPLEX_H) +check_include_files(sys/param.h HAVE_SYS_PARAM_H) +check_include_files(sys/types.h HAVE_SYS_TYPES_H) +check_include_files(syslog.h HAVE_SYSLOG_H) + +# +# Fortran tricks +# +IF (CMAKE_Fortran_COMPILER_WORKS) + STRING(REGEX MATCH "Intel" _match_intel ${CMAKE_Fortran_COMPILER_ID}) + IF (_match_intel) + MESSAGE(STATUS "Add -nofor_main to the Fortran linker.") + SET(LOCAL_FORTRAN_LINK_FLAGS "${LOCAL_FORTRAN_LINK_FLAGS} -nofor_main") + ENDIF (_match_intel) + + STRING(REGEX MATCH "PGI$" _match_pgi ${CMAKE_Fortran_COMPILER_ID}) + IF (_match_pgi) + MESSAGE(STATUS "Add -Mnomain to the Fortran linker.") + SET(LOCAL_FORTRAN_LINK_FLAGS "${LOCAL_FORTRAN_LINK_FLAGS} -Mnomain -Bstatic") + ENDIF (_match_pgi) + + STRING(REGEX MATCH ".*xlc$" _match_xlc ${CMAKE_C_COMPILER}) + IF (_match_xlc) + MESSAGE(ERROR "Please use the thread-safe version of the xlc compiler (xlc_r)") + ENDIF (_match_xlc) + STRING(REGEX MATCH "XL" _match_xlc ${CMAKE_C_COMPILER_ID}) + IF (_match_xlc AND BUILD_64bits) + MESSAGE(STATUS "Add -q64 to the C compiler/linker.") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -q64") + ENDIF (_match_xlc AND BUILD_64bits) + + STRING(REGEX MATCH ".*xlf$" _match_xlf ${CMAKE_Fortran_COMPILER}) + IF (_match_xlf) + MESSAGE(ERROR "Please use the thread-safe version of the xlf compiler (xlf_r)") + ENDIF (_match_xlf) + STRING(REGEX MATCH "XL$" _match_xlf ${CMAKE_Fortran_COMPILER_ID}) + IF (_match_xlf) + SET(arch_flags "-q32") + IF(BUILD_64bits) + SET(arch_flags "-q64") + ENDIF(BUILD_64bits) + MESSAGE(STATUS "Add ${arch_flags} and -nofor_main to the Fortran linker.") + SET(LOCAL_FORTRAN_LINK_FLAGS "${LOCAL_FORTRAN_LINK_FLAGS} ${arch_flags} -nofor_main") + ENDIF (_match_xlf) + +# +# Even more Fortran tricks. +# +# FFLAGS depend on the compiler + + if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") + # gfortran + set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3") + set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g") + list(APPEND EXTRA_LIBS gfortran) + elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") + # ifort + set (CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3") + set (CMAKE_Fortran_FLAGS_DEBUG "-f77rtl -O0 -g") + string (REPLACE "-i_dynamic" "" CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS}") + else (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") + get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME) + message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER}) + message ("Fortran compiler: " ${Fortran_COMPILER_NAME}) + message ("No optimized Fortran compiler flags are known, we just try -O2...") + set (CMAKE_Fortran_FLAGS_RELEASE "-O2") + set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g") + endif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") +ENDIF (CMAKE_Fortran_COMPILER_WORKS) diff --git a/include/spm.h b/include/spm.h index 9ec6ccf14943b8647242b5de1de847226f66df23..dfd5ad14ae66f5dae87d3d6a3edbf3d9dd1b03f7 100644 --- a/include/spm.h +++ b/include/spm.h @@ -13,7 +13,7 @@ * @author Mathieu Faverge * @date 2013-06-24 * - * @addtogroup pastix_spm + * @addtogroup spm * @{ * @brief Describe all the internals routines of the SParse Matrix package. * @@ -27,133 +27,138 @@ #ifndef _spm_h_ #define _spm_h_ -#include "pastix/api.h" +#include <stdlib.h> +#include <assert.h> +#include <stdio.h> +#include "spm_config.h" +#include "spm_const.h" +#include "spm_datatypes.h" /** * * @brief The sparse matrix data structure * * This structure describes matrices with different characteristics that can be useful to any solver: - * - the storage format (PastixCSC, PastixCSR or PastixIJV) - * - the properties (PastixGeneral, PastixHermitian, PastixSymmetric) + * - the storage format (SpmCSC, SpmCSR or SpmIJV) + * - the properties (SpmGeneral, SpmHermitian, SpmSymmetric) * - the base value (0 in C or 1 in Fortran) * * It is also possible to describe a matrix with constant or variable degrees of freedom. * */ -typedef struct pastix_spm_s { - pastix_mtxtype_t mtxtype; /**< Matrix structure: PastixGeneral, PastixSymmetric - or PastixHermitian. */ - pastix_coeftype_t flttype; /**< values datatype: PastixPattern, PastixFloat, PastixDouble, - PastixComplex32 or PastixComplex64 */ - pastix_fmttype_t fmttype; /**< Matrix storage format: PastixCSC, PastixCSR, PastixIJV */ - - pastix_int_t gN; /**< Global number of vertices in the compressed graph (Computed) */ - pastix_int_t n; /**< Local number of vertices in the compressed graph */ - pastix_int_t gnnz; /**< Global number of non zeroes in the compressed graph (Computed) */ - pastix_int_t nnz; /**< Local number of non zeroes in the compressed graph */ - - pastix_int_t gNexp; /**< Global number of vertices in the compressed graph (Computed) */ - pastix_int_t nexp; /**< Local number of vertices in the compressed graph (Computed) */ - pastix_int_t gnnzexp; /**< Global number of non zeroes in the compressed graph (Computed) */ - pastix_int_t nnzexp; /**< Local number of non zeroes in the compressed graph (Computed) */ - - pastix_int_t dof; /**< Number of degrees of freedom per unknown, - if > 0, constant degree of freedom - otherwise, irregular degree of freedom (refer to dofs) */ - pastix_int_t *dofs; /**< Array of the first column of each element in the - expanded matrix [+baseval] */ - pastix_layout_t layout; /**< PastixColMajor, or PastixRowMajor */ - - pastix_int_t *colptr; /**< List of indirections to rows for each vertex [+baseval] */ - pastix_int_t *rowptr; /**< List of edges for each vertex [+baseval] */ - pastix_int_t *loc2glob;/**< Corresponding numbering from local to global [+baseval] */ +typedef struct spmatrix_s { + spm_mtxtype_t mtxtype; /**< Matrix structure: SpmGeneral, SpmSymmetric + or SpmHermitian. */ + spm_coeftype_t flttype; /**< values datatype: SpmPattern, SpmFloat, SpmDouble, + SpmComplex32 or SpmComplex64 */ + spm_fmttype_t fmttype; /**< Matrix storage format: SpmCSC, SpmCSR, SpmIJV */ + + spm_int_t gN; /**< Global number of vertices in the compressed graph (Computed) */ + spm_int_t n; /**< Local number of vertices in the compressed graph */ + spm_int_t gnnz; /**< Global number of non zeroes in the compressed graph (Computed) */ + spm_int_t nnz; /**< Local number of non zeroes in the compressed graph */ + + spm_int_t gNexp; /**< Global number of vertices in the compressed graph (Computed) */ + spm_int_t nexp; /**< Local number of vertices in the compressed graph (Computed) */ + spm_int_t gnnzexp; /**< Global number of non zeroes in the compressed graph (Computed) */ + spm_int_t nnzexp; /**< Local number of non zeroes in the compressed graph (Computed) */ + + spm_int_t dof; /**< Number of degrees of freedom per unknown, + if > 0, constant degree of freedom + otherwise, irregular degree of freedom (refer to dofs) */ + spm_int_t *dofs; /**< Array of the first column of each element in the + expanded matrix [+baseval] */ + spm_layout_t layout; /**< SpmColMajor, or SpmRowMajor */ + + spm_int_t *colptr; /**< List of indirections to rows for each vertex [+baseval] */ + spm_int_t *rowptr; /**< List of edges for each vertex [+baseval] */ + spm_int_t *loc2glob;/**< Corresponding numbering from local to global [+baseval] */ void *values; /**< Values stored in the matrix */ -} pastix_spm_t; +} spmatrix_t; /** * @name SPM basic subroutines * @{ */ -void spmInit( pastix_spm_t *spm ); -void spmExit( pastix_spm_t *spm ); +void spmInit( spmatrix_t *spm ); +void spmExit( spmatrix_t *spm ); -pastix_spm_t *spmCopy( const pastix_spm_t *spm ); -void spmBase( pastix_spm_t *spm, int baseval ); -pastix_int_t spmFindBase( const pastix_spm_t *spm ); -int spmConvert( int ofmttype, pastix_spm_t *ospm ); -void spmUpdateComputedFields( pastix_spm_t *spm ); -void spmGenFakeValues( pastix_spm_t *spm ); +spmatrix_t *spmCopy( const spmatrix_t *spm ); +void spmBase( spmatrix_t *spm, int baseval ); +spm_int_t spmFindBase( const spmatrix_t *spm ); +int spmConvert( int ofmttype, spmatrix_t *ospm ); +void spmUpdateComputedFields( spmatrix_t *spm ); +void spmGenFakeValues( spmatrix_t *spm ); /** * @} * @name SPM BLAS subroutines * @{ */ -double spmNorm( pastix_normtype_t ntype, const pastix_spm_t *spm ); -int spmMatVec( pastix_trans_t trans, const void *alpha, const pastix_spm_t *spm, const void *x, const void *beta, void *y ); -int spmMatMat( pastix_trans_t trans, pastix_int_t n, - const void *alpha, const pastix_spm_t *A, - const void *B, pastix_int_t ldb, - const void *beta, void *C, pastix_int_t ldc ); -void spmScalMatrix( double alpha, pastix_spm_t *spm ); -void spmScalVector( pastix_coeftype_t flt, double alpha, pastix_int_t n, void *x, pastix_int_t incx ); +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 *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 ); /** * @} * @name SPM subroutines to check format * @{ */ -int spmSort( pastix_spm_t *spm ); -pastix_int_t spmMergeDuplicate( pastix_spm_t *spm ); -pastix_int_t spmSymmetrize( pastix_spm_t *spm ); -pastix_spm_t *spmCheckAndCorrect( pastix_spm_t *spm ); +int spmSort( spmatrix_t *spm ); +spm_int_t spmMergeDuplicate( spmatrix_t *spm ); +spm_int_t spmSymmetrize( spmatrix_t *spm ); +spmatrix_t *spmCheckAndCorrect( spmatrix_t *spm ); /** * @} * @name SPM subroutines to check factorization/solve * @{ */ -int spmGenRHS( pastix_rhstype_t type, pastix_int_t nrhs, const pastix_spm_t *spm, void *x, pastix_int_t ldx, void *b, pastix_int_t ldb ); -int spmCheckAxb( double eps, pastix_int_t nrhs, const pastix_spm_t *spm, void *x0, pastix_int_t ldx0, void *b, pastix_int_t ldb, const void *x, pastix_int_t ldx ); +int spmGenRHS( spm_rhstype_t type, spm_int_t nrhs, const spmatrix_t *spm, void *x, spm_int_t ldx, void *b, spm_int_t ldb ); +int spmCheckAxb( double eps, spm_int_t nrhs, const spmatrix_t *spm, void *x0, spm_int_t ldx0, void *b, spm_int_t ldb, const void *x, spm_int_t ldx ); /** * @} * @name SPM subroutines to manipulate integers arrays * @{ */ -pastix_int_t *spmIntConvert( pastix_int_t n, int *input ); -void spmIntSort1Asc1( void * const pbase, const pastix_int_t n ); -void spmIntSort2Asc1( void * const pbase, const pastix_int_t n ); -void spmIntSort2Asc2( void * const pbase, const pastix_int_t n ); +spm_int_t * spmIntConvert( spm_int_t n, int *input ); +void spmIntSort1Asc1( void * const pbase, const spm_int_t n ); +void spmIntSort2Asc1( void * const pbase, const spm_int_t n ); +void spmIntSort2Asc2( void * const pbase, const spm_int_t n ); /** * @} * @name SPM IO subroutines * @{ */ -int spmLoad( pastix_spm_t *spm, FILE *infile ); -int spmSave( const pastix_spm_t *spm, FILE *outfile ); +int spmLoad( spmatrix_t *spm, FILE *infile ); +int spmSave( const spmatrix_t *spm, FILE *outfile ); /** * @} * @name SPM driver * @{ */ -int spmReadDriver( pastix_driver_t driver, - const char *filename, - pastix_spm_t *spm, - MPI_Comm pastix_comm ); +int spmReadDriver( spm_driver_t driver, + const char *filename, + spmatrix_t *spm, + MPI_Comm spm_comm ); /** * @} * @name SPM debug subroutines * @{ */ -void * spm2Dense ( const pastix_spm_t *spm ); -void spmPrint ( const pastix_spm_t *spm, FILE *f ); -void spmPrintInfo( const pastix_spm_t *spm, FILE *f ); -pastix_spm_t *spmExpand ( const pastix_spm_t *spm ); -pastix_spm_t *spmDofExtend( const pastix_spm_t *spm, const int type, const int dof ); +void * spm2Dense ( const spmatrix_t *spm ); +void spmPrint ( const spmatrix_t *spm, FILE *f ); +void spmPrintInfo( const spmatrix_t *spm, FILE *f ); +spmatrix_t * spmExpand ( const spmatrix_t *spm ); +spmatrix_t * spmDofExtend( const spmatrix_t *spm, const int type, const int dof ); /** * @} @@ -181,7 +186,7 @@ pastix_spm_t *spmDofExtend( const pastix_spm_t *spm, const int type, const int d * Double complex case * */ -static inline void z_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, pastix_complex64_t A ){ +static inline void z_spmPrintElt( FILE *f, spm_int_t i, spm_int_t j, spm_complex64_t A ){ fprintf( f, "%ld %ld %e %e\n", (long)i, (long)j, creal(A), cimag(A) ); } @@ -189,21 +194,21 @@ static inline void z_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, pasti * @copydoc z_spmPrintElt * @details Single complex case */ -static inline void c_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, pastix_complex32_t A ){ +static inline void c_spmPrintElt( FILE *f, spm_int_t i, spm_int_t j, spm_complex32_t A ){ fprintf( f, "%ld %ld %e %e\n", (long)i, (long)j, crealf(A), cimagf(A) ); } /** * @copydoc z_spmPrintElt * @details Double real case */ -static inline void d_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, double A ){ +static inline void d_spmPrintElt( FILE *f, spm_int_t i, spm_int_t j, double A ){ fprintf( f, "%ld %ld %e\n", (long)i, (long)j, A ); } /** * @copydoc z_spmPrintElt * @details Single real case */ -static inline void s_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, float A ){ +static inline void s_spmPrintElt( FILE *f, spm_int_t i, spm_int_t j, float A ){ fprintf( f, "%ld %ld %e\n", (long)i, (long)j, A ); } /** diff --git a/include/spm_config.h.in b/include/spm_config.h.in new file mode 100644 index 0000000000000000000000000000000000000000..25c7c00fae086395217a07d23a1640265cd04526 --- /dev/null +++ b/include/spm_config.h.in @@ -0,0 +1,74 @@ +/** + * + * @file spm_config.h.in + * + * Spm configuration parameters + * + * @copyright 2016-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 6.0.0 + * @author Pierre Ramet + * @author Mathieu Faverge + * @date 2017-09-28 + * + **/ +#ifndef _spm_config_h_ +#define _spm_config_h_ + +#define SPM_VERSION_MAJOR @SPM_VERSION_MAJOR@ +#define SPM_VERSION_MINOR @SPM_VERSION_MINOR@ +#define SPM_VERSION_MICRO @SPM_VERSION_MICRO@ + +#cmakedefine SPM_WITH_FORTRAN +#cmakedefine SPM_WITH_MPI + +/* system */ +#cmakedefine HAVE_CLOCK_GETTIME +#cmakedefine HAVE_ASPRINTF +#cmakedefine HAVE_VASPRINTF +#cmakedefine HAVE_STDARG_H +#cmakedefine HAVE_UNISTD_H +#cmakedefine HAVE_VA_COPY +#cmakedefine HAVE_UNDERSCORE_VA_COPY +#cmakedefine HAVE_GETOPT_LONG +#cmakedefine HAVE_GETRUSAGE +#cmakedefine HAVE_GETOPT_H +#cmakedefine HAVE_ERRNO_H +#cmakedefine HAVE_STDDEF_H +#cmakedefine HAVE_LIMITS_H +#cmakedefine HAVE_STRING_H +#cmakedefine HAVE_COMPLEX_H +#cmakedefine HAVE_FALLTHROUGH + +/* Datatypes used */ +#cmakedefine SPM_INT64 + +#if defined(SPM_WITH_MPI) +#define HAVE_MPI +#else +#undef HAVE_MPI +#endif + +#if defined(HAVE_FALLTHROUGH) +#define spm_attr_fallthrough __attribute__((fallthrough)) +#else +#define spm_attr_fallthrough do {} while(0) +#endif + +/* + * BEGIN_C_DECLS should be used at the beginning of your declarations, + * so that C++ compilers don't mangle their names. Use END_C_DECLS at + * the end of C declarations. + */ +#undef BEGIN_C_DECLS +#undef END_C_DECLS +#if defined(c_plusplus) || defined(__cplusplus) +# define BEGIN_C_DECLS extern "C" { +# define END_C_DECLS } +#else +#define BEGIN_C_DECLS /* empty */ +#define END_C_DECLS /* empty */ +#endif + +#endif /* _spm_config_h_ */ diff --git a/include/spm_const.h b/include/spm_const.h new file mode 100644 index 0000000000000000000000000000000000000000..e9732c81eb439a26c192faf9073708b4c4d97953 --- /dev/null +++ b/include/spm_const.h @@ -0,0 +1,351 @@ +/** + * + * @file spm/api.h + * + * Spm API enums parameters. + * + * @copyright 2004-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 6.0.0 + * @author Xavier Lacoste + * @author Pierre Ramet + * @author Mathieu Faverge + * @date 2013-06-24 + * + * @addtogroup spm_api + * @{ + * + **/ +#ifndef _spm_api_h_ +#define _spm_api_h_ + +/******************************************************************** + * CBLAS value address + */ +#ifndef CBLAS_SADDR +#define CBLAS_SADDR( a_ ) (&(a_)) +#endif + +/** + * @brief Verbose modes + */ +typedef enum spm_verbose_e { + SpmVerboseNot = 0, /**< Nothing */ + SpmVerboseNo = 1, /**< Default */ + SpmVerboseYes = 2 /**< Extended */ +} spm_verbose_t; + +/** + * @brief IO strategy for graph and ordering + */ +typedef enum spm_io_e { + SpmIONo = 0, /**< No output or input */ + SpmIOLoad = 1, /**< Load ordering and symbol matrix instead of applying symbolic factorisation step */ + SpmIOSave = 2, /**< Save ordering and symbol matrix after symbolic factorisation step */ + SpmIOLoadGraph = 4, /**< Load graph during ordering step */ + SpmIOSaveGraph = 8, /**< Save graph during ordering step */ + SpmIOLoadCSC = 16,/**< Load CSC(d) during ordering step */ + SpmIOSaveCSC = 32 /**< Save CSC(d) during ordering step */ +} spm_io_t; + +/** + * @brief Factorization Schur modes + * + * Describe which part of the matrix is factorized or not + * + */ +typedef enum spm_fact_mode_e { + SpmFactModeLocal = 0, + SpmFactModeSchur = 1, + SpmFactModeBoth = 2 +} spm_fact_mode_t; + +/** + * @brief Solve Schur modes + * + * Describe which part of the solve is applied with the matrix + * + * \f[ A = \left( \begin{array}{cc} + * L_{11}U_{11} & U_{12} \\ + * L_{21} & S_{22} \end{array} \right) \f] + * + * For the lower part (and symmetrically for upper part): + * -# Solve \f[ L_{11} * x_{11} = b_{11} \f] + * -# Apply the update \f[ b_{22} = b_{22} - L_{21} * b_{11} \f] + * -# Solve the lower part of \f[ S_{22} * x_{22} = b_{22} \f] if S22 has been previously factorized. + * + * SpmSolvModeLocal applies only the step 1. + * SpmSolvModeInterface applies steps 1 and 2. + * SpmSolvModeSchur applies all steps. + * + */ +typedef enum spm_solv_mode_e { + SpmSolvModeLocal = 0, + SpmSolvModeInterface = 1, + SpmSolvModeSchur = 2 +} spm_solv_mode_t; + +/** + * @brief Iterative refinement algorithms + */ +typedef enum spm_refine_e { + SpmRefineGMRES, /**< GMRES */ + SpmRefineCG, /**< Conjugate Gradiant */ + SpmRefineSR, /**< Simple refinement */ + SpmRefineBiCGSTAB /**< BiCGStab */ +} spm_refine_t; + +/** + * @brief Arithmetic types. + * + * This describes the different arithmetics that can be stored in a sparse matrix. + * @remark The values start at 2 for compatibility purpose with PLASMA and + * DPLASMA libraries. + */ +typedef enum spm_coeftype_e { + SpmPattern = 0, /**< Pattern only, no values are stored */ + SpmFloat = 2, /**< Single precision real */ + SpmDouble = 3, /**< Double precision real */ + SpmComplex32 = 4, /**< Single precision complex */ + SpmComplex64 = 5 /**< Double precision complex */ +} spm_coeftype_t; + +/** + * @brief Sparse matrix format + */ +typedef enum spm_fmttype_e { + SpmCSC, /**< Compressed sparse column */ + SpmCSR, /**< Compressed sparse row */ + SpmIJV /**< Coordinates */ +} spm_fmttype_t; + +/** + * @brief Factorization algorithms available for IPARM_FACTORIZATION parameter + */ +typedef enum spm_factotype_e { + SpmFactPOTRF = 0, /**< Cholesky factorization */ + SpmFactSYTRF = 1, /**< LDL^t factorization */ + SpmFactGETRF = 2, /**< LU factorization */ + SpmFactPXTRF = 3, /**< LL^t factorization for complex matrices */ + SpmFactHETRF = 4, /**< LDL^h factorization for complex matrices */ + + SpmFactLLH = 0, /**< LL^h factorization for complex matrices */ + SpmFactLDLT = 1, /**< LDL^t factorization */ + SpmFactLU = 2, /**< LU factorization */ + SpmFactLLT = 3, /**< LL^t factorization */ + SpmFactLDLH = 4, /**< LDL^h factorization for complex matrices */ +} spm_factotype_t; + +/** + * @brief Scheduler + */ +typedef enum spm_scheduler_e { + SpmSchedSequential = 0, /**< Sequential */ + SpmSchedStatic = 1, /**< Shared memory with static scheduler */ + SpmSchedParsec = 2, /**< PaRSEC scheduler */ + SpmSchedStarPU = 3, /**< StarPU scheduler */ + SpmSchedDynamic = 4, /**< Shared memory with dynamic scheduler */ +} spm_scheduler_t; + +/** + * @brief Ordering strategy + */ +enum spm_order_e { + SpmOrderScotch, /**< Use Scotch ordering */ + SpmOrderMetis, /**< Use Metis ordering */ + SpmOrderPersonal, /**< Apply user's permutation, or load from file */ + SpmOrderPtScotch, /**< Use Pt-Scotch ordering */ + SpmOrderParMetis /**< Use ParMetis ordering */ +}; + +#if defined(SPM_WITH_MPI) +/** + * @brief MPI thread mode + */ +typedef enum spm_threadmode_e { + SpmThreadMultiple = 1, /**< All threads communicate */ + SpmThreadFunneled = 2 /**< One thread perform all the MPI Calls */ +} spm_threadmode_t; +#endif /* defined(SPM_WITH_MPI) */ + +/** + * @brief Error codes + */ +typedef enum spm_error_e { + SPM_SUCCESS = 0, /**< No error */ + SPM_ERR_UNKNOWN = 1, /**< Unknown error */ + SPM_ERR_ALLOC = 2, /**< Allocation error */ + SPM_ERR_NOTIMPLEMENTED = 3, /**< Not implemented feature */ + SPM_ERR_OUTOFMEMORY = 4, /**< Not enough memory */ + SPM_ERR_THREAD = 5, /**< Error with threads */ + SPM_ERR_INTERNAL = 6, /**< Internal error */ + SPM_ERR_BADPARAMETER = 7, /**< Bad parameters given */ + SPM_ERR_FILE = 8, /**< Error in In/Out operations */ + SPM_ERR_INTEGER_TYPE = 9, /**< Error with integer types */ + SPM_ERR_IO = 10, /**< Error with input/output */ + SPM_ERR_MPI = 11 /**< Error with MPI calls */ +} spm_error_t; + +/** + * @brief Compression strategy available for IPARM_COMPRESS_WHEN parameter + */ +typedef enum spm_compress_when_e { + SpmCompressNever, + SpmCompressWhenBegin, + SpmCompressWhenEnd, + SpmCompressWhenDuring +} spm_compress_when_t; + +/** + * @brief Compression method available for IPARM_COMPRESS_METHOD parameter + */ +typedef enum spm_compress_method_e { + SpmCompressMethodSVD, + SpmCompressMethodRRQR +} spm_compress_method_t; + +/** + * @brief Orthogonalization method available for IPARM_COMPRESS_ORTHO parameter + */ +typedef enum spm_compress_ortho_e { + SpmCompressOrthoCGS, + SpmCompressOrthoQR, + SpmCompressOrthoPartialQR, +} spm_compress_ortho_t; + +/** + * @brief The list of matrix driver readers and generators + */ +typedef enum spm_driver_e { + SpmDriverRSA, /**< RSA Fortran driver */ + SpmDriverHB, /**< Harwell Boeing driver */ + SpmDriverIJV, /**< IJV Coordinate driver */ + SpmDriverMM, /**< Matrix Market C driver */ + SpmDriverLaplacian, /**< 3, 5, or 7 points Laplacian stencil generator */ + SpmDriverXLaplacian, /**< 15-points Laplacian stencil generator */ + SpmDriverGraph, /**< Scotch Graph driver */ + SpmDriverSPM, /**< SPM matrix driver */ + /* SpmDriverDMM, /\**< Distributed Matrix Market driver *\/ */ + /* SpmDriverCSCD, /\**< CSC distributed driver *\/ */ + /* SpmDriverPetscS, /\**< Petsc Symmetric driver *\/ */ + /* SpmDriverPetscU, /\**< Pestc Unssymmetric driver *\/ */ + /* SpmDriverPetscH, /\**< Pestc Hermitian driver *\/ */ + /* SpmDriverCCC, /\**< Not supported yet *\/ */ + /* SpmDriverRCC, /\**< Not supported yet *\/ */ + /* SpmDriverOlaf, /\**< Not supported yet *\/ */ + /* SpmDriverPeer, /\**< Not supported yet *\/ */ + /* SpmDriverBRGM, /\**< Not supported yet *\/ */ + /* SpmDriverBRGMD, /\**< Not supported yet *\/ */ +} spm_driver_t; + +/** + * @brief How to generate RHS + */ +typedef enum spm_rhstype_e { + SpmRhsOne, + SpmRhsI, + SpmRhsRndX, + SpmRhsRndB +} spm_rhstype_t; + +/** + * + * @name Constants compatible with CBLAS & LAPACK & PLASMA + * @{ + * The naming and numbering of the following constants is consistent with: + * + * - CBLAS from Netlib (http://www.netlib.org/blas/blast-forum/cblas.tgz) + * - C Interface to LAPACK from Netlib (http://www.netlib.org/lapack/lapwrapc/) + * - Plasma (http://icl.cs.utk.edu/plasma/index.html) + * + */ + +/** + * @brief Direction of the matrix storage + */ +typedef enum spm_layout_e { + SpmRowMajor = 101, /**< Storage in row major order */ + SpmColMajor = 102 /**< Storage in column major order */ +} spm_layout_t; + +/** + * @brief Transpostion + */ +typedef enum spm_trans_e { + SpmNoTrans = 111, /**< Use A */ + SpmTrans = 112, /**< Use A^t */ + SpmConjTrans = 113 /**< Use conj(A^t) */ +} spm_trans_t; + +/** + * @brief Matrix symmetry type property. + * @remark Must match transposition. + */ +typedef enum spm_mtxtype_e { + SpmGeneral = SpmNoTrans, /**< The matrix is general */ + SpmSymmetric = SpmTrans, /**< The matrix is symmetric */ + SpmHermitian = SpmConjTrans /**< The matrix is hermitian */ +} spm_mtxtype_t; + +/** + * @brief Upper/Lower part + */ +typedef enum spm_uplo_e { + SpmUpper = 121, /**< Use lower triangle of A */ + SpmLower = 122, /**< Use upper triangle of A */ + SpmUpperLower = 123 /**< Use the full A */ +} spm_uplo_t; + +/** + * @brief Data blocks used in the kernel + */ +typedef enum spm_coefside_e { + SpmLCoef = 0, /**< Coefficients of the lower triangular L are used */ + SpmUCoef = 1, /**< Coefficients of the upper triangular U are used */ + SpmLUCoef = 2 /**< Coefficients of the upper/lower triangular U/L are used */ +} spm_coefside_t; + +/** + * @brief Diagonal + */ +typedef enum spm_diag_e { + SpmNonUnit = 131, /**< Diagonal is non unitary */ + SpmUnit = 132 /**< Diagonal is unitary */ +} spm_diag_t; + +/** + * @brief Side of the operation + */ +typedef enum spm_side_e { + SpmLeft = 141, /**< Apply operator on the left */ + SpmRight = 142 /**< Apply operator on the right */ +} spm_side_t; + +/** + * @brief Norms + */ +typedef enum spm_normtype_e { + SpmOneNorm = 171, /**< One norm: max_j( sum_i( |a_{ij}| ) ) */ + SpmFrobeniusNorm = 174, /**< Frobenius norm: sqrt( sum_{i,j} (a_{ij}^2) ) */ + SpmInfNorm = 175, /**< Inifinite norm: max_i( sum_j( |a_{ij}| ) ) */ + SpmMaxNorm = 177 /**< Inifinite norm: max_{i,j}( | a_{ij} | ) */ +} spm_normtype_t; + +/** + * @brief Direction + */ +typedef enum spm_dir_e { + SpmDirForward = 391, /**< Forward direction */ + SpmDirBackward = 392, /**< Backward direction */ +} spm_dir_t; + +/** + * @} + */ + +#endif /* _spm_api_h_ */ + +/** + * @} + */ diff --git a/include/spm_datatypes.h b/include/spm_datatypes.h new file mode 100644 index 0000000000000000000000000000000000000000..4bd988eb2ea0faa1c558b1338eea486d439529fd --- /dev/null +++ b/include/spm_datatypes.h @@ -0,0 +1,134 @@ +/** + * + * @file spm_datatypes.h + * + * @copyright 2013-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * Definitions of the datatypes used in SPM + * + * @version 6.0.0 + * @author Mathieu Faverge + * @author Xavier Lacoste + * @author Pierre Ramet + * @date 2017-01-17 + * + */ +#ifndef _spm_datatypes_h_ +#define _spm_datatypes_h_ + +#include <inttypes.h> + +/** **************************************************************************** + * Integers + */ +#if defined(SPM_INT64) + +typedef int64_t spm_int_t; +typedef uint64_t spm_uint_t; +#define SPM_MPI_INT MPI_INTEGER8 +#define SPM_INT_MAX INT64_MAX + +#elif defined(SPM_INT32) + +typedef int32_t spm_int_t; +typedef uint32_t spm_uint_t; +#define SPM_MPI_INT MPI_INTEGER4 +#define SPM_INT_MAX INT32_MAX + +#elif defined(SPM_LONG) + +typedef long spm_int_t; +typedef unsigned long spm_uint_t; +#define SPM_MPI_INT MPI_LONG +#define SPM_INT_MAX LONG_MAX + +#else + +typedef int spm_int_t; +typedef unsigned int spm_uint_t; +#define SPM_MPI_INT MPI_INT +#define SPM_INT_MAX INT_MAX + +#endif + +static inline spm_int_t spm_imin( spm_int_t a, spm_int_t b) { + return ( a < b ) ? a : b; +} + +static inline spm_int_t spm_imax( spm_int_t a, spm_int_t b) { + return ( a > b ) ? a : b; +} + +static inline spm_int_t spm_iceil( spm_int_t a, spm_int_t b) { + return ( a + b - 1 ) / b; +} + +/** **************************************************************************** + * Double that are not converted through precision generator functions + **/ +typedef double spm_fixdbl_t; + +/** **************************************************************************** + * Complex numbers (Extracted from PaRSEC project) + **/ +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +/* Windows and non-Intel compiler */ +#include <complex> +typedef std::complex<float> spm_complex32_t; +typedef std::complex<double> spm_complex64_t; +#else +typedef float _Complex spm_complex32_t; +typedef double _Complex spm_complex64_t; +#endif + +#if !defined(__cplusplus) && defined(HAVE_COMPLEX_H) +#include <complex.h> +#else + +#ifdef __cplusplus +extern "C" { +#endif + +/* These declarations will not clash with what C++ provides because + * the names in C++ are name-mangled. */ + +extern double cabs (spm_complex64_t z); +extern double creal (spm_complex64_t z); +extern double cimag (spm_complex64_t z); + +extern float cabsf (spm_complex32_t z); +extern float crealf (spm_complex32_t z); +extern float cimagf (spm_complex32_t z); + +extern spm_complex64_t conj (spm_complex64_t z); +extern spm_complex64_t csqrt (spm_complex64_t z); + +extern spm_complex32_t conjf (spm_complex32_t z); +extern spm_complex32_t csqrtf(spm_complex32_t z); + +#ifdef __cplusplus +} +#endif + +#endif /* HAVE_COMPLEX_H */ + + +static inline size_t +spm_size_of(spm_coeftype_t type) +{ + switch(type) { + case SpmFloat: return sizeof(float); + case SpmDouble: return sizeof(double); + case SpmComplex32: return 2*sizeof(float); + case SpmComplex64: return 2*sizeof(double); + default: + fprintf(stderr, "spm_size_of: invalid type parameter\n"); + assert(0); + return sizeof(double); + } +} + +typedef int MPI_Comm; + +#endif /* _spm_datatypes_h_ */ diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000000000000000000000000000000000000..76c22ea74ed8f519e894d4ecbb860b753506b3cb --- /dev/null +++ b/src/common.h @@ -0,0 +1,116 @@ +/** + * + * @file common.h + * + * @copyright 2004-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 6.0.0 + * @author David Goudin + * @author François Pellegrini + * @author Gregoire Pichon + * @author Mathieu Faverge + * @author Pascal Henon + * @author Pierre Ramet + * @author Xavier Lacoste + * @date 2011-11-11 + * + **/ +#ifndef _spm_common_h_ +#define _spm_common_h_ + +#include "spm.h" +#include <unistd.h> +#include <assert.h> +#include <errno.h> +#include <inttypes.h> +#include <limits.h> +#include <string.h> +#include <stdarg.h> +#include <math.h> + +/******************************************************************** + * Errors functions + */ +#if defined(__GNUC__) +static inline void spm_print_error ( const char *fmt, ...) __attribute__((format(printf,1,2))); +static inline void spm_print_warning( const char *fmt, ...) __attribute__((format(printf,1,2))); +#endif + +static inline void +spm_print_error( const char *fmt, ... ) +{ + va_list arglist; + va_start(arglist, fmt); + vfprintf(stderr, fmt, arglist); + va_end(arglist); +} + +static inline void +spm_print_warning( const char *fmt, ... ) +{ + va_list arglist; + va_start(arglist, fmt); + fprintf(stderr, "WARNING: "); + vfprintf(stderr, fmt, arglist); + va_end(arglist); +} + +/******************************************************************** + * CBLAS value address + */ +#ifndef CBLAS_SADDR +#define CBLAS_SADDR( a_ ) (&(a_)) +#endif + +/* + * Get environment variable + */ +#if defined SPM_OS_WINDOWS + +static inline int +spm_setenv( const char *var, const char *value, int overwrite ) { + return !(SetEnvironmentVariable( var, value )); +} + +static inline char * +spm_getenv( const char *var ) { + char *str; + int len = 512; + int rc; + str = (char*)malloc(len * sizeof(char)); + rc = GetEnvironmentVariable(var, str, len); + if (rc == 0) { + free(str); + str = NULL; + } + return str; +} + +static inline void +spm_cleanenv( char *str ) { + if (str != NULL) free(str); +} + +#else /* Other OS systems */ + +static inline int +spm_setenv( const char *var, const char *value, int overwrite ) { + return setenv( var, value, overwrite ); +} + +static inline char * +spm_getenv( const char *var ) { + return getenv( var ); +} + +static inline void +spm_cleanenv( char *str ) { + (void)str; +} + +#endif + + +#endif /* _spm_common_h_ */ + diff --git a/src/drivers/iohb.c b/src/drivers/iohb.c index ebc849511960d4f8cdbd3ea7d41361aba3bac824..d6bfd90d773831d84ac4b83e8c3fa5914b54c9e9 100644 --- a/src/drivers/iohb.c +++ b/src/drivers/iohb.c @@ -213,10 +213,6 @@ #define _SP_base 1 #endif /*---------------------------------------------------------------------*/ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> #include "common.h" #include "spm_drivers.h" #include "drivers/iohb.h" diff --git a/src/drivers/laplacian.c b/src/drivers/laplacian.c index b49b85581d5303001815861e55ee1bb78753b405..602d55bae087af9cd3d3f0731d8a2b7893a402d4 100644 --- a/src/drivers/laplacian.c +++ b/src/drivers/laplacian.c @@ -13,9 +13,6 @@ * @date 2011-11-11 * **/ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> #include "common.h" #include "spm_drivers.h" #include "drivers/laplacian.h" @@ -23,7 +20,7 @@ /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * laplacian_usage - Print the usage information to generate correct Laplacian * matrices. @@ -54,7 +51,7 @@ laplacian_usage(void) /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Parse information given through the filename string to configure the * laplacian matrix to generate. @@ -90,16 +87,16 @@ laplacian_usage(void) * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been generated successfully - * @retval PASTIX_ERR_BADPARAMETER if the configuration string is incorrect + * @retval SPM_SUCCESS if the matrix has been generated successfully + * @retval SPM_ERR_BADPARAMETER if the configuration string is incorrect * *******************************************************************************/ int laplacian_parse_info( const char *filename, - pastix_coeftype_t *flttype, - pastix_int_t *dim1, - pastix_int_t *dim2, - pastix_int_t *dim3, + spm_coeftype_t *flttype, + spm_int_t *dim1, + spm_int_t *dim2, + spm_int_t *dim3, double *alpha, double *beta ) { @@ -119,27 +116,27 @@ laplacian_parse_info( const char *filename, switch( flt ){ case 'Z': case 'z': - *flttype = PastixComplex64; + *flttype = SpmComplex64; break; case 'C': case 'c': - *flttype = PastixComplex32; + *flttype = SpmComplex32; break; case 'D': case 'd': - *flttype = PastixDouble; + *flttype = SpmDouble; break; case 'S': case 's': - *flttype = PastixFloat; + *flttype = SpmFloat; break; case 'P': case 'p': - *flttype = PastixPattern; + *flttype = SpmPattern; break; case '1': @@ -151,7 +148,7 @@ laplacian_parse_info( const char *filename, case '7': case '8': case '9': - *flttype = PastixDouble; + *flttype = SpmDouble; /* * The first dimension is only one character long so we come * back to the beginning of the string @@ -161,11 +158,11 @@ laplacian_parse_info( const char *filename, default: laplacian_usage(); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } } else { - *flttype = PastixDouble; + *flttype = SpmDouble; } free(tmpf); @@ -175,45 +172,45 @@ laplacian_parse_info( const char *filename, *dim1 = *dim2 = *dim3 = 1; if ( sscanf( filename, "%ld:%ld:%ld:%lf:%lf", &tmp1, &tmp2, &tmp3, &val1, &val2 ) == 5 ) { - *dim1 = (pastix_int_t)tmp1; - *dim2 = (pastix_int_t)tmp2; - *dim3 = (pastix_int_t)tmp3; + *dim1 = (spm_int_t)tmp1; + *dim2 = (spm_int_t)tmp2; + *dim3 = (spm_int_t)tmp3; *alpha = val1; *beta = val2; } else if ( sscanf( filename, "%ld:%ld:%ld:%lf", &tmp1, &tmp2, &tmp3, &val1 ) == 4 ) { - *dim1 = (pastix_int_t)tmp1; - *dim2 = (pastix_int_t)tmp2; - *dim3 = (pastix_int_t)tmp3; + *dim1 = (spm_int_t)tmp1; + *dim2 = (spm_int_t)tmp2; + *dim3 = (spm_int_t)tmp3; *alpha = val1; } else if ( sscanf( filename, "%ld:%ld:%ld", &tmp1, &tmp2, &tmp3 ) == 3 ) { - *dim1 = (pastix_int_t)tmp1; - *dim2 = (pastix_int_t)tmp2; - *dim3 = (pastix_int_t)tmp3; + *dim1 = (spm_int_t)tmp1; + *dim2 = (spm_int_t)tmp2; + *dim3 = (spm_int_t)tmp3; } else if ( sscanf( filename, "%ld:%ld", &tmp1, &tmp2 ) == 2 ) { - *dim1 = (pastix_int_t)tmp1; - *dim2 = (pastix_int_t)tmp2; + *dim1 = (spm_int_t)tmp1; + *dim2 = (spm_int_t)tmp2; } else if ( sscanf( filename, "%ld", &tmp1 ) == 1 ) { - *dim1 = (pastix_int_t)tmp1; + *dim1 = (spm_int_t)tmp1; } else { laplacian_usage(); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } /* One of the dimension was set to 0 */ if ( (*dim1 == 0) || (*dim2 == 0) || (*dim3 == 0) ) { laplacian_usage(); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } -static void (*laplacian_7points[6])(pastix_spm_t *, pastix_int_t, pastix_int_t, pastix_int_t, pastix_fixdbl_t, pastix_fixdbl_t) = +static void (*laplacian_7points[6])(spmatrix_t *, spm_int_t, spm_int_t, spm_int_t, spm_fixdbl_t, spm_fixdbl_t) = { p_spmLaplacian_7points, NULL, @@ -223,7 +220,7 @@ static void (*laplacian_7points[6])(pastix_spm_t *, pastix_int_t, pastix_int_t, z_spmLaplacian_7points }; -static void (*extended_laplacian_table2D[6])(pastix_spm_t *, pastix_int_t, pastix_int_t) = +static void (*extended_laplacian_table2D[6])(spmatrix_t *, spm_int_t, spm_int_t) = { p_spmExtendedLaplacian2D, NULL, @@ -233,7 +230,7 @@ static void (*extended_laplacian_table2D[6])(pastix_spm_t *, pastix_int_t, pasti z_spmExtendedLaplacian2D }; -static void (*extended_laplacian_table3D[6])(pastix_spm_t *, pastix_int_t, pastix_int_t, pastix_int_t) = +static void (*extended_laplacian_table3D[6])(spmatrix_t *, spm_int_t, spm_int_t, spm_int_t) = { p_spmExtendedLaplacian3D, NULL, @@ -246,7 +243,7 @@ static void (*extended_laplacian_table3D[6])(pastix_spm_t *, pastix_int_t, pasti /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * genLaplacian - Generate a Laplacian of size spm->n * @@ -271,22 +268,22 @@ static void (*extended_laplacian_table3D[6])(pastix_spm_t *, pastix_int_t, pasti ******************************************************************************* * * @return - * \retval PASTIX_SUCCESS if the matrix has been generated successfully - * \retval PASTIX_ERR_BADPARAMETER if the configuration string is incorrect + * \retval SPM_SUCCESS if the matrix has been generated successfully + * \retval SPM_ERR_BADPARAMETER if the configuration string is incorrect * *******************************************************************************/ int genLaplacian( const char *filename, - pastix_spm_t *spm ) + spmatrix_t *spm ) { - pastix_coeftype_t flttype; - pastix_int_t dim1, dim2, dim3; + spm_coeftype_t flttype; + spm_int_t dim1, dim2, dim3; double alpha = 1.; double beta = 1.; int rc; rc = laplacian_parse_info(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta ); - if (rc != PASTIX_SUCCESS) + if (rc != SPM_SUCCESS) return rc; spm->flttype = flttype; @@ -294,13 +291,13 @@ genLaplacian( const char *filename, laplacian_7points[spm->flttype](spm, dim1, dim2, dim3, alpha, beta); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * genExtendedLaplacian - Generate a extended Laplacian of size spm->n * @@ -325,22 +322,22 @@ genLaplacian( const char *filename, ******************************************************************************* * * @return - * \retval PASTIX_SUCCESS if the matrix has been generated successfully - * \retval PASTIX_ERR_BADPARAMETER if the configuration string is incorrect + * \retval SPM_SUCCESS if the matrix has been generated successfully + * \retval SPM_ERR_BADPARAMETER if the configuration string is incorrect * *******************************************************************************/ int genExtendedLaplacian( const char *filename, - pastix_spm_t *spm ) + spmatrix_t *spm ) { - pastix_coeftype_t flttype; - pastix_int_t dim1, dim2, dim3; + spm_coeftype_t flttype; + spm_int_t dim1, dim2, dim3; double alpha = 1.; double beta = 1.; int rc; rc = laplacian_parse_info(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta); - if (rc != PASTIX_SUCCESS) + if (rc != SPM_SUCCESS) return rc; spm->flttype = flttype; @@ -353,5 +350,5 @@ genExtendedLaplacian( const char *filename, extended_laplacian_table2D[spm->flttype](spm, dim1, dim2); } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/drivers/laplacian.h b/src/drivers/laplacian.h index 29d8395eb0aa8114b096a3e0ad61c5c93c6d5f1e..423cb49640888bfc6c853ca842cbafb553c82729 100644 --- a/src/drivers/laplacian.h +++ b/src/drivers/laplacian.h @@ -14,29 +14,29 @@ #ifndef _laplacian_h_ #define _laplacian_h_ -void z_spmLaplacian_7points( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3, pastix_fixdbl_t alpha, pastix_fixdbl_t beta ); -void c_spmLaplacian_7points( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3, pastix_fixdbl_t alpha, pastix_fixdbl_t beta ); -void d_spmLaplacian_7points( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3, pastix_fixdbl_t alpha, pastix_fixdbl_t beta ); -void s_spmLaplacian_7points( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3, pastix_fixdbl_t alpha, pastix_fixdbl_t beta ); -void p_spmLaplacian_7points( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3, pastix_fixdbl_t alpha, pastix_fixdbl_t beta ); +void z_spmLaplacian_7points( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta ); +void c_spmLaplacian_7points( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta ); +void d_spmLaplacian_7points( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta ); +void s_spmLaplacian_7points( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta ); +void p_spmLaplacian_7points( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta ); -void z_spmExtendedLaplacian2D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2 ); -void c_spmExtendedLaplacian2D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2 ); -void d_spmExtendedLaplacian2D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2 ); -void s_spmExtendedLaplacian2D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2 ); -void p_spmExtendedLaplacian2D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2 ); +void z_spmExtendedLaplacian2D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2 ); +void c_spmExtendedLaplacian2D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2 ); +void d_spmExtendedLaplacian2D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2 ); +void s_spmExtendedLaplacian2D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2 ); +void p_spmExtendedLaplacian2D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2 ); -void z_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); -void c_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); -void d_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); -void s_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); -void p_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); +void z_spmExtendedLaplacian3D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3 ); +void c_spmExtendedLaplacian3D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3 ); +void d_spmExtendedLaplacian3D( spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3 ); +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, - pastix_coeftype_t *flttype, - pastix_int_t *dim1, - pastix_int_t *dim2, - pastix_int_t *dim3, + spm_coeftype_t *flttype, + spm_int_t *dim1, + spm_int_t *dim2, + spm_int_t *dim3, double *alpha, double *beta ); diff --git a/src/drivers/mmio.c b/src/drivers/mmio.c index a966218f73f11fee6fe465491ac76c1ea4e92c2b..4c61a2eba44f7d8639a3e6217cc3732bca615f36 100644 --- a/src/drivers/mmio.c +++ b/src/drivers/mmio.c @@ -5,14 +5,10 @@ * * */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <ctype.h> - #include "common.h" #include "spm_drivers.h" #include "drivers/mmio.h" +#include <ctype.h> int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, double **val_, int **row_, int **col_) diff --git a/src/drivers/readhb.c b/src/drivers/readhb.c index baae93da287e5754d923bf3f3275a94f701fb5fe..7baaf355bd1d3320a68c247eecd3cb0e88241bd2 100644 --- a/src/drivers/readhb.c +++ b/src/drivers/readhb.c @@ -12,7 +12,6 @@ * @date 2011-11-11 * **/ -#include <stdio.h> #include "common.h" #include "spm_drivers.h" #include "drivers/iohb.h" @@ -20,7 +19,7 @@ /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Interface to the Harwell-Boeing C driver (iohb.c) * @@ -34,19 +33,19 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occured in the Harwell Boeing driver - * @retval PASTIX_ERR_BADPARAMETER if the matrix is no in a supported format + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occured in the Harwell Boeing driver + * @retval SPM_ERR_BADPARAMETER if the matrix is no in a supported format * *******************************************************************************/ int readHB( const char *filename, - pastix_spm_t *spm ) + spmatrix_t *spm ) { int M, N, nz, nrhs; /* Harwell Boeing is a variant of RSA */ - spm->fmttype = PastixCSC; + spm->fmttype = SpmCSC; spm->dof = 1; spm->loc2glob= NULL; @@ -60,7 +59,7 @@ readHB( const char *filename, if ( M != N ) { fprintf(stderr, "readHB: PaStiX does not support non square matrices (m=%d, N=%d\n", M, N); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } spm->gN = M; @@ -72,36 +71,36 @@ readHB( const char *filename, switch( Type[0] ) { case 'C': case 'c': - spm->flttype = PastixComplex64; + spm->flttype = SpmComplex64; break; case 'R': case 'r': - spm->flttype = PastixDouble; + spm->flttype = SpmDouble; break; case 'P': case 'p': - spm->flttype = PastixPattern; + spm->flttype = SpmPattern; break; default: fprintf(stderr, "readhb: Floating type unknown (%c)\n", Type[0]); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } /* Check Symmetry */ switch( Type[1] ) { case 'S': case 's': - spm->mtxtype = PastixSymmetric; + spm->mtxtype = SpmSymmetric; break; case 'H': case 'h': - spm->mtxtype = PastixHermitian; - assert( spm->flttype == PastixDouble ); + spm->mtxtype = SpmHermitian; + assert( spm->flttype == SpmDouble ); break; case 'U': case 'u': default: - spm->mtxtype = PastixGeneral; + spm->mtxtype = SpmGeneral; } free(Type); } @@ -116,12 +115,12 @@ readHB( const char *filename, if (rc == 0) { fprintf(stderr, "readhb: Error in reading the HB matrix values\n"); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } - /* Move the colptr/rowind from int to pastix_int_t if different sizes */ + /* Move the colptr/rowind from int to spm_int_t if different sizes */ spm->colptr = spmIntConvert(spm->n+1, colptr); spm->rowptr = spmIntConvert(spm->nnz, rowind); } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/drivers/readijv.c b/src/drivers/readijv.c index 807ceecb8d8029995de28205bb6b2373cc8e5755..d8566f81f51a7efd4da023b725d316ce817d5367 100644 --- a/src/drivers/readijv.c +++ b/src/drivers/readijv.c @@ -12,15 +12,13 @@ * @date 2011-11-11 * **/ -#include <stdio.h> -#include <stdlib.h> #include "common.h" #include "spm_drivers.h" /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read header from three file IJV format. * @@ -40,15 +38,15 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the information has been read successfully - * @retval PASTIX_ERR_BADPARAMETER if the header has a wrong format + * @retval SPM_SUCCESS if the information has been read successfully + * @retval SPM_ERR_BADPARAMETER if the header has a wrong format * *******************************************************************************/ int threeFilesReadHeader(FILE *infile, - pastix_int_t *Nrow, - pastix_int_t *Ncol, - pastix_int_t *Nnzero) + spm_int_t *Nrow, + spm_int_t *Ncol, + spm_int_t *Nnzero) { long temp1,temp2,temp3; @@ -56,19 +54,19 @@ threeFilesReadHeader(FILE *infile, if (fscanf(infile, "%ld %ld %ld\n", &temp1, &temp2, &temp3) != 3) { Nrow = Ncol = Nnzero = 0; fprintf(stderr, "readijv: Wrong format in header file\n"); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - *Nrow = (pastix_int_t)temp1; - *Ncol = (pastix_int_t)temp2; - *Nnzero = (pastix_int_t)temp3; + *Nrow = (spm_int_t)temp1; + *Ncol = (spm_int_t)temp2; + *Nnzero = (spm_int_t)temp3; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** * ****************************************************************************** * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read matrix from three files IJV * @@ -87,29 +85,29 @@ threeFilesReadHeader(FILE *infile, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occurs while reading the files - * @retval PASTIX_ERR_BADPARAMETER if a problem occurs while opening the files + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occurs while reading the files + * @retval SPM_ERR_BADPARAMETER if a problem occurs while opening the files * *******************************************************************************/ int readIJV( const char *dirname, - pastix_spm_t *spm ) + spmatrix_t *spm ) { FILE *iafile, *jafile, *rafile; FILE *hdrfile; char *filename; - pastix_int_t *tempcol; - pastix_int_t *temprow; + spm_int_t *tempcol; + spm_int_t *temprow; double *tempval; - pastix_int_t i, Nrow, Ncol, Nnzero; + spm_int_t i, Nrow, Ncol, Nnzero; filename = malloc(strlen(dirname)+10); - spm->flttype = PastixDouble; - spm->mtxtype = PastixGeneral; - spm->fmttype = PastixIJV; + spm->flttype = SpmDouble; + spm->mtxtype = SpmGeneral; + spm->fmttype = SpmIJV; spm->dof = 1; spm->loc2glob= NULL; @@ -121,7 +119,7 @@ readIJV( const char *dirname, { fprintf(stderr,"readijv: Cannot open the header file (%s)\n", filename); free(filename); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } threeFilesReadHeader(hdrfile, &Nrow, &Ncol, &Nnzero); fclose(hdrfile); @@ -131,8 +129,8 @@ readIJV( const char *dirname, spm->n = Ncol; spm->gnnz = Nnzero; spm->nnz = Nnzero; - spm->colptr = (pastix_int_t *) malloc(Nnzero*sizeof(pastix_int_t)); - spm->rowptr = (pastix_int_t *) malloc(Nnzero*sizeof(pastix_int_t)); + spm->colptr = (spm_int_t *) malloc(Nnzero*sizeof(spm_int_t)); + spm->rowptr = (spm_int_t *) malloc(Nnzero*sizeof(spm_int_t)); spm->values = (double *) malloc(Nnzero*sizeof(double)); /* Open the 3 files */ @@ -142,7 +140,7 @@ readIJV( const char *dirname, { fprintf(stderr,"readijv: Cannot open the ia file (%s)\n", filename); free(filename); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } sprintf(filename,"%s/ja_threeFiles",dirname); @@ -152,7 +150,7 @@ readIJV( const char *dirname, fprintf(stderr,"readijv: Cannot open the ja file (%s)\n", filename); fclose(iafile); free(filename); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } sprintf(filename,"%s/ra_threeFiles",dirname); @@ -163,7 +161,7 @@ readIJV( const char *dirname, fclose(iafile); fclose(jafile); free(filename); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } /* Read the files */ @@ -185,15 +183,15 @@ readIJV( const char *dirname, fclose(jafile); fclose(rafile); free(filename); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } - *temprow = (pastix_int_t)temp1; - *tempcol = (pastix_int_t)temp2; + *temprow = (spm_int_t)temp1; + *tempcol = (spm_int_t)temp2; *tempval = temp3; } fclose(iafile); fclose(jafile); fclose(rafile); free(filename); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/drivers/readmm.c b/src/drivers/readmm.c index b811cd9fffd5ef8f48c8b066fa8f90a3c23e6360..642cd90e7085f7c100ef6240944d0315234b91de 100644 --- a/src/drivers/readmm.c +++ b/src/drivers/readmm.c @@ -20,7 +20,7 @@ /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read the data part of a complex matrix in Matrix Market file. * @@ -37,47 +37,47 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occured in the RSA driver + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occured in the RSA driver * *******************************************************************************/ int z_readMM( FILE *file, - pastix_spm_t *spm ) + spmatrix_t *spm ) { - pastix_complex64_t *valptr; - pastix_int_t *colptr; - pastix_int_t *rowptr; - pastix_int_t i; + spm_complex64_t *valptr; + spm_int_t *colptr; + spm_int_t *rowptr; + spm_int_t i; long row, col; double re, im; - spm->values = malloc( spm->nnz * sizeof(pastix_complex64_t) ); + spm->values = malloc( spm->nnz * sizeof(spm_complex64_t) ); colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); for (i=0; i<spm->nnz; i++, colptr++, rowptr++, valptr++) { if (4 != fscanf(file,"%ld %ld %lg %lg\n", &row, &col, &re, &im)) { fprintf(stderr, "readmm: erro while reading matrix file (line %ld)\n", (long)i); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } - *rowptr = (pastix_int_t)row; - *colptr = (pastix_int_t)col; - *valptr = (pastix_complex64_t)(re + im * I); + *rowptr = (spm_int_t)row; + *colptr = (spm_int_t)col; + *valptr = (spm_complex64_t)(re + im * I); } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read the data part of a real matrix in Matrix Market file. * For more information about matrix market format see mmio.c/mmio.h @@ -93,18 +93,18 @@ z_readMM( FILE *file, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occured in the RSA driver + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occured in the RSA driver * *******************************************************************************/ int d_readMM( FILE *file, - pastix_spm_t *spm ) + spmatrix_t *spm ) { double *valptr; - pastix_int_t *colptr; - pastix_int_t *rowptr; - pastix_int_t i; + spm_int_t *colptr; + spm_int_t *rowptr; + spm_int_t i; long row, col; double re; @@ -119,21 +119,21 @@ d_readMM( FILE *file, if (3 != fscanf(file,"%ld %ld %lg\n", &row, &col, &re)) { fprintf(stderr, "readmm: erro while reading matrix file (line %ld)\n", (long)i); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } - *rowptr = (pastix_int_t)row; - *colptr = (pastix_int_t)col; + *rowptr = (spm_int_t)row; + *colptr = (spm_int_t)col; *valptr = re; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read the data part of a pattern matrix in Matrix Market file. * For more information about matrix market format see mmio.c/mmio.h @@ -149,17 +149,17 @@ d_readMM( FILE *file, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occured in the RSA driver + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occured in the RSA driver * *******************************************************************************/ int p_readMM( FILE *file, - pastix_spm_t *spm ) + spmatrix_t *spm ) { - pastix_int_t *colptr; - pastix_int_t *rowptr; - pastix_int_t i; + spm_int_t *colptr; + spm_int_t *rowptr; + spm_int_t i; long row, col; spm->values = NULL; @@ -172,20 +172,20 @@ p_readMM( FILE *file, if (2 != fscanf(file,"%ld %ld\n", &row, &col)) { fprintf(stderr, "readmm: erro while reading matrix file (line %ld)\n", (long)i); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } - *rowptr = (pastix_int_t)row; - *colptr = (pastix_int_t)col; + *rowptr = (spm_int_t)row; + *colptr = (spm_int_t)col; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read a matrix in Matrix Market fill. This corresponds to * IJV format with (%d %d[ %lf[ %lf]]) format per line. @@ -201,14 +201,14 @@ p_readMM( FILE *file, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occured in the RSA driver - * @retval PASTIX_ERR_BADPARAMETER if the matrix is no in a supported format + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occured in the RSA driver + * @retval SPM_ERR_BADPARAMETER if the matrix is no in a supported format * *******************************************************************************/ int readMM( const char *filename, - pastix_spm_t *spm ) + spmatrix_t *spm ) { MM_typecode matcode; FILE *file; @@ -218,47 +218,47 @@ readMM( const char *filename, if (file == NULL) { fprintf(stderr,"readmm: Cannot open the file (%s)\n", filename); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } if (mm_read_banner(file, &matcode) != 0) { fprintf(stderr,"readmm: Could not process Matrix Market banner.\n"); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } /* Float values type */ if (mm_is_complex(matcode)) { - spm->flttype = PastixComplex64; + spm->flttype = SpmComplex64; } else if (mm_is_real(matcode)) { - spm->flttype = PastixDouble; + spm->flttype = SpmDouble; } else if (mm_is_pattern(matcode)) { - spm->flttype = PastixPattern; + spm->flttype = SpmPattern; } else { fprintf(stderr,"readmm: Unsupported type of matrix.\n"); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } /* Matrix structure */ if (mm_is_general(matcode)) { - spm->mtxtype = PastixGeneral; + spm->mtxtype = SpmGeneral; } else if (mm_is_symmetric(matcode)) { - spm->mtxtype = PastixSymmetric; + spm->mtxtype = SpmSymmetric; } else if (mm_is_hermitian(matcode)) { - spm->mtxtype = PastixHermitian; + spm->mtxtype = SpmHermitian; } else { fprintf(stderr,"readmm: Unsupported type of matrix.\n"); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - spm->fmttype = PastixIJV; + spm->fmttype = SpmIJV; spm->dof = 1; spm->loc2glob= NULL; @@ -267,7 +267,7 @@ readMM( const char *filename, int m, n, nnz; if (mm_read_mtx_crd_size(file, &m, &n, &nnz) != 0) { fprintf(stderr, "readmm: error while reading matrix sizes\n"); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } spm->gN = n; @@ -276,19 +276,19 @@ readMM( const char *filename, spm->nnz = nnz; } - spm->colptr = (pastix_int_t*)malloc(spm->nnz * sizeof(pastix_int_t)); - spm->rowptr = (pastix_int_t*)malloc(spm->nnz * sizeof(pastix_int_t)); + spm->colptr = (spm_int_t*)malloc(spm->nnz * sizeof(spm_int_t)); + spm->rowptr = (spm_int_t*)malloc(spm->nnz * sizeof(spm_int_t)); switch( spm->flttype ) { - case PastixComplex64: + case SpmComplex64: rc = z_readMM(file, spm); break; - case PastixDouble: + case SpmDouble: rc = d_readMM(file, spm); break; - case PastixPattern: + case SpmPattern: default: rc = p_readMM(file, spm); } diff --git a/src/drivers/readrsa.c b/src/drivers/readrsa.c index 188f88eb6cf220bf719e7c3eef59466f68154dba..ae92280f38fdaae631079083ac830456b7ae4dc8 100644 --- a/src/drivers/readrsa.c +++ b/src/drivers/readrsa.c @@ -66,7 +66,7 @@ FC_GLOBAL(wreadmtc,WREADMTC)(int *tmp1, /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read the header structure of a RSA file * @@ -132,7 +132,7 @@ readRSAHeader( const char *filename, /** ******************************************************************************* * - * @ingroup pastix_spm_driver + * @ingroup spm_spm_driver * * @brief Read a RSA matrix file. This driver reads only real matrices, and * does not support complex matrices. @@ -150,14 +150,14 @@ readRSAHeader( const char *filename, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the matrix has been read successfully - * @retval PASTIX_ERR_IO if a problem occured in the RSA driver - * @retval PASTIX_ERR_BADPARAMETER if the matrix is no in a supported format + * @retval SPM_SUCCESS if the matrix has been read successfully + * @retval SPM_ERR_IO if a problem occured in the RSA driver + * @retval SPM_ERR_BADPARAMETER if the matrix is no in a supported format * *******************************************************************************/ int readRSA( const char *filename, - pastix_spm_t *spm ) + spmatrix_t *spm ) { char Type[4]; char RhsType[4]; @@ -177,28 +177,28 @@ readRSA( const char *filename, switch( Type[1] ){ case 'S': case 's': - spm->mtxtype = PastixSymmetric; + spm->mtxtype = SpmSymmetric; break; case 'H': case 'h': - spm->mtxtype = PastixHermitian; + spm->mtxtype = SpmHermitian; /** * We should not arrive here, since the fortran driver is not able to * read complex matrices */ fprintf(stderr,"readrsa: Unsupported Complex.\n"); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; case 'U': case 'u': - spm->mtxtype = PastixGeneral; + spm->mtxtype = SpmGeneral; break; default: fprintf(stderr,"readrsa: Unsupported type of matrix.\n"); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - spm->flttype = PastixDouble; - spm->fmttype = PastixCSC; + spm->flttype = SpmDouble; + spm->fmttype = SpmCSC; spm->gN = N; spm->n = N; spm->gnnz = Nnz; @@ -232,8 +232,8 @@ readRSA( const char *filename, RhsType[0] = '\0'; if(ierr != 0) { fprintf(stderr, "cannot read matrix (job=2)\n"); - return PASTIX_ERR_IO; + return SPM_ERR_IO; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/frobeniusupdate.h b/src/frobeniusupdate.h new file mode 100644 index 0000000000000000000000000000000000000000..90cbdad1bfc0f65fccceb0bb3f2ca28308665099 --- /dev/null +++ b/src/frobeniusupdate.h @@ -0,0 +1,80 @@ +/** + * + * @file frobeniusupdate.h + * + * Formula to update frobenius norm computation in a safe manner. + * + * @copyright 2004-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @version 6.0.0 + * @author Mathieu Faverge + * @date 2017-04-26 + * + */ +#ifndef _frobeniusupdate_h_ +#define _frobeniusupdate_h_ + +#include <math.h> + +/** + ******************************************************************************* + * + * @ingroup pastix_internal + * + * frobenius_update - Update the couple (scale, sumsq) with one element when + * computing the Froebnius norm. + * + * The frobenius norm is equal to scale * sqrt( sumsq ), this method allows to + * avoid overflow in the sum square computation. + * + ******************************************************************************* + * + * @param[inout] scale + * On entry, the former scale + * On exit, the update scale to take into account the value + * + * @param[inout] sumsq + * On entry, the former sumsq + * On exit, the update sumsq to take into account the value + * + * @param[in] value + * The value to integrate into the couple (scale, sumsq) + * + *******************************************************************************/ +static inline void +#if defined(PRECISION_d) || defined(PRECISION_z) +frobenius_update( int nb, double *scale, double *sumsq, double *value ) +{ + double absval = fabs(*value); + double ratio; + if ( absval != 0. ){ + if ( (*scale) < absval ) { + ratio = (*scale) / absval; + *sumsq = (double)nb + (*sumsq) * ratio * ratio; + *scale = absval; + } else { + ratio = absval / (*scale); + *sumsq = (*sumsq) + (double)nb * ratio * ratio; + } + } +} +#elif defined(PRECISION_s) || defined(PRECISION_c) +frobenius_update( int nb, float *scale, float *sumsq, float *value ) +{ + float absval = fabs(*value); + float ratio; + if ( absval != 0. ){ + if ( (*scale) < absval ) { + ratio = (*scale) / absval; + *sumsq = (float)nb + (*sumsq) * ratio * ratio; + *scale = absval; + } else { + ratio = absval / (*scale); + *sumsq = (*sumsq) + (float)nb * ratio * ratio; + } + } +} +#endif + +#endif /* _frobeniusupdate_h_ */ diff --git a/src/integer_sort.c b/src/integer_sort.c index cd79798a7a4b8d2fb8e9ccce261ce887b74badb7..838b606585890210924567e4d727027a5bb83631 100644 --- a/src/integer_sort.c +++ b/src/integer_sort.c @@ -76,7 +76,7 @@ typedef struct log(MAX_THRESH)). Since total_elements has type size_t, we get as upper bound for log (total_elements): bits per byte (CHAR_BIT) * sizeof(size_t). */ -#define STACK_SIZE (CHAR_BIT * sizeof (pastix_int_t)) +#define STACK_SIZE (CHAR_BIT * sizeof (spm_int_t)) #define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) #define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) #define STACK_NOT_EMPTY (stack < top) @@ -117,7 +117,7 @@ typedef struct void INTSORTNAME ( void * const pbase, /*+ Array to sort +*/ -const pastix_int_t total_elems) /*+ Number of entries to sort +*/ +const spm_int_t total_elems) /*+ Number of entries to sort +*/ { register char *base_ptr = (char *) pbase; diff --git a/src/integer_sort_mtypes.c b/src/integer_sort_mtypes.c index ed46b9d9d2d7612419389967e85b682805001491..b1662a00881c1b5aefc1d0c674f1d15d1736ffd4 100644 --- a/src/integer_sort_mtypes.c +++ b/src/integer_sort_mtypes.c @@ -78,7 +78,7 @@ typedef struct log(MAX_THRESH_2)). Since total_elements has type size_t, we get as upper bound for log (total_elements): bits per unsigned char (CHAR_BIT) * sizeof(size_t). */ -#define STACK_SIZE_2 (CHAR_BIT * sizeof (pastix_int_t)) +#define STACK_SIZE_2 (CHAR_BIT * sizeof (spm_int_t)) #define PUSH_2(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) #define POP_2(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) #define STACK_NOT_EMPTY_2 (stack < top) @@ -119,7 +119,7 @@ typedef struct void INTSORTNAME ( void ** const pbase, /*+ Array of arrays to sort +*/ -const pastix_int_t total_elems) /*+ Number of entries to sort +*/ +const spm_int_t total_elems) /*+ Number of entries to sort +*/ { register char *base_ptr = (char *) (*pbase); diff --git a/src/spm.c b/src/spm.c index 571b37801dd7f2027d6bbc0c1c1c8860aa063807..c6a1c4f19e2fe698df358d51cc9a2d44af40b91e 100644 --- a/src/spm.c +++ b/src/spm.c @@ -13,11 +13,10 @@ * @author Mathieu Faverge * @date 2013-06-24 * - * @addtogroup pastix_spm + * @addtogroup spm_spm * @{ **/ #include "common.h" -#include "spm.h" #include "z_spm.h" #include "c_spm.h" @@ -30,7 +29,7 @@ #if !defined(DOXYGEN_SHOULD_SKIP_THIS) -static int (*conversionTable[3][3][6])(pastix_spm_t*) = { +static int (*conversionTable[3][3][6])(spmatrix_t*) = { /* From CSC */ {{ NULL, NULL, NULL, NULL, NULL, NULL }, { p_spmConvertCSC2CSR, @@ -89,11 +88,11 @@ static int (*conversionTable[3][3][6])(pastix_spm_t*) = { * *******************************************************************************/ void -spmInit( pastix_spm_t *spm ) +spmInit( spmatrix_t *spm ) { - spm->mtxtype = PastixGeneral; - spm->flttype = PastixDouble; - spm->fmttype = PastixCSC; + spm->mtxtype = SpmGeneral; + spm->flttype = SpmDouble; + spm->fmttype = SpmCSC; spm->gN = 0; spm->n = 0; @@ -107,7 +106,7 @@ spmInit( pastix_spm_t *spm ) spm->dof = 1; spm->dofs = NULL; - spm->layout = PastixColMajor; + spm->layout = SpmColMajor; spm->colptr = NULL; spm->rowptr = NULL; @@ -127,7 +126,7 @@ spmInit( pastix_spm_t *spm ) * *******************************************************************************/ void -spmUpdateComputedFields( pastix_spm_t *spm ) +spmUpdateComputedFields( spmatrix_t *spm ) { /* @@ -138,8 +137,8 @@ spmUpdateComputedFields( pastix_spm_t *spm ) spm->nnzexp = spm->nnz * spm->dof * spm->dof; } else { - pastix_int_t i, j, k, dofi, dofj, baseval; - pastix_int_t *dofptr, *colptr, *rowptr; + spm_int_t i, j, k, dofi, dofj, baseval; + spm_int_t *dofptr, *colptr, *rowptr; baseval = spmFindBase( spm ); @@ -152,14 +151,14 @@ spmUpdateComputedFields( pastix_spm_t *spm ) spm->nnzexp = 0; switch(spm->fmttype) { - case PastixCSR: + case SpmCSR: /* Swap pointers to call CSC */ colptr = spm->rowptr; rowptr = spm->colptr; - pastix_attr_fallthrough; + spm_attr_fallthrough; - case PastixCSC: + case SpmCSC: for(j=0; j<spm->n; j++, colptr++) { dofj = dofptr[j+1] - dofptr[j]; @@ -171,7 +170,7 @@ spmUpdateComputedFields( pastix_spm_t *spm ) } } break; - case PastixIJV: + case SpmIJV: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { i = *rowptr - baseval; @@ -203,18 +202,28 @@ spmUpdateComputedFields( pastix_spm_t *spm ) * *******************************************************************************/ void -spmExit( pastix_spm_t *spm ) +spmExit( spmatrix_t *spm ) { - if(spm->colptr != NULL) - memFree_null(spm->colptr); - if(spm->rowptr != NULL) - memFree_null(spm->rowptr); - if(spm->loc2glob != NULL) - memFree_null(spm->loc2glob); - if(spm->values != NULL) - memFree_null(spm->values); - if(spm->dofs != NULL) - memFree_null(spm->dofs); + if(spm->colptr != NULL) { + free(spm->colptr); + spm->colptr = NULL; + } + if(spm->rowptr != NULL) { + free(spm->rowptr); + spm->rowptr = NULL; + } + if(spm->loc2glob != NULL) { + free(spm->loc2glob); + spm->loc2glob = NULL; + } + if(spm->values != NULL) { + free(spm->values); + spm->values = NULL; + } + if(spm->dofs != NULL) { + free(spm->dofs); + spm->dofs = NULL; + } } /** @@ -234,27 +243,27 @@ spmExit( pastix_spm_t *spm ) * *******************************************************************************/ void -spmBase( pastix_spm_t *spm, +spmBase( spmatrix_t *spm, int baseval ) { - pastix_int_t baseadj; - pastix_int_t i, n, nnz; + spm_int_t baseadj; + spm_int_t i, n, nnz; /* Parameter checks */ if ( spm == NULL ) { - pastix_print_error("spmBase: spm pointer is NULL"); + fprintf( stderr,"spmBase: spm pointer is NULL"); return; } if ( (spm->colptr == NULL) || (spm->rowptr == NULL) ) { - pastix_print_error("spmBase: spm pointer is not correctly initialized"); + fprintf( stderr,"spmBase: spm pointer is not correctly initialized"); return; } if ( (baseval != 0) && (baseval != 1) ) { - pastix_print_error("spmBase: baseval is incorrect, must be 0 or 1"); + fprintf( stderr,"spmBase: baseval is incorrect, must be 0 or 1"); return; } @@ -267,7 +276,7 @@ spmBase( pastix_spm_t *spm, switch(spm->fmttype) { - case PastixCSC: + case SpmCSC: assert( nnz == (spm->colptr[n] - spm->colptr[0]) ); for (i = 0; i <= n; i++) { @@ -278,7 +287,7 @@ spmBase( pastix_spm_t *spm, } break; - case PastixCSR: + case SpmCSR: assert( nnz == (spm->rowptr[n] - spm->rowptr[0]) ); for (i = 0; i <= n; i++) { spm->rowptr[i] += baseadj; @@ -287,7 +296,7 @@ spmBase( pastix_spm_t *spm, spm->colptr[i] += baseadj; } break; - case PastixIJV: + case SpmIJV: for (i = 0; i < nnz; i++) { spm->rowptr[i] += baseadj; spm->colptr[i] += baseadj; @@ -322,16 +331,16 @@ spmBase( pastix_spm_t *spm, * @return The baseval used in the given sparse matrix structure. * *******************************************************************************/ -pastix_int_t -spmFindBase( const pastix_spm_t *spm ) +spm_int_t +spmFindBase( const spmatrix_t *spm ) { - pastix_int_t i, *tmp, baseval; + spm_int_t i, *tmp, baseval; /* * Check the baseval, we consider that arrays are sorted by columns or rows */ - baseval = pastix_imin( *(spm->colptr), *(spm->rowptr) ); + baseval = spm_imin( *(spm->colptr), *(spm->rowptr) ); /* * if not: */ @@ -341,7 +350,7 @@ spmFindBase( const pastix_spm_t *spm ) baseval = spm->n; tmp = spm->colptr; for(i=0; i<spm->nnz; i++, tmp++){ - baseval = pastix_imin( *tmp, baseval ); + baseval = spm_imin( *tmp, baseval ); } } @@ -357,32 +366,32 @@ spmFindBase( const pastix_spm_t *spm ) * * @param[in] ofmttype * The output format of the sparse matrix. It must be: - * - PastixCSC - * - PastixCSR - * - PastixIJV + * - SpmCSC + * - SpmCSR + * - SpmIJV * * @param[inout] spm * The sparse matrix structure to convert. * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the conversion happened successfully. - * @retval PASTIX_ERR_BADPARAMETER if one the parameter is incorrect. - * @retval PASTIX_ERR_NOTIMPLEMENTED if the case is not yet implemented. + * @retval SPM_SUCCESS if the conversion happened successfully. + * @retval SPM_ERR_BADPARAMETER if one the parameter is incorrect. + * @retval SPM_ERR_NOTIMPLEMENTED if the case is not yet implemented. * *******************************************************************************/ int -spmConvert( int ofmttype, pastix_spm_t *spm ) +spmConvert( int ofmttype, spmatrix_t *spm ) { if ( conversionTable[spm->fmttype][ofmttype][spm->flttype] ) { if ( spm->dof != 1 ) { - //pastix_print_error( "spmConvert: Conversion of non unique dof not yet implemented\n"); - return PASTIX_ERR_NOTIMPLEMENTED; + //fprintf( stderr, "spmConvert: Conversion of non unique dof not yet implemented\n"); + return SPM_ERR_NOTIMPLEMENTED; } return conversionTable[spm->fmttype][ofmttype][spm->flttype]( spm ); } else { - return PASTIX_SUCCESS; + return SPM_SUCCESS; } } @@ -406,16 +415,16 @@ spmConvert( int ofmttype, pastix_spm_t *spm ) * *******************************************************************************/ void * -spm2Dense( const pastix_spm_t *spm ) +spm2Dense( const spmatrix_t *spm ) { switch (spm->flttype) { - case PastixFloat: + case SpmFloat: return s_spm2dense( spm ); - case PastixComplex32: + case SpmComplex32: return c_spm2dense( spm ); - case PastixComplex64: + case SpmComplex64: return z_spm2dense( spm ); - case PastixDouble: + case SpmDouble: return d_spm2dense( spm ); default: return NULL; @@ -429,13 +438,13 @@ spm2Dense( const pastix_spm_t *spm ) * * Return the ntype norm of the sparse matrix spm. * - * spmNorm = ( max(abs(spm(i,j))), NORM = PastixMaxNorm + * spmNorm = ( max(abs(spm(i,j))), NORM = SpmMaxNorm * ( - * ( norm1(spm), NORM = PastixOneNorm + * ( norm1(spm), NORM = SpmOneNorm * ( - * ( normI(spm), NORM = PastixInfNorm + * ( normI(spm), NORM = SpmInfNorm * ( - * ( normF(spm), NORM = PastixFrobeniusNorm + * ( normF(spm), NORM = SpmFrobeniusNorm * * where norm1 denotes the one norm of a matrix (maximum column sum), * normI denotes the infinity norm of a matrix (maximum row sum) and @@ -446,10 +455,10 @@ spm2Dense( const pastix_spm_t *spm ) ******************************************************************************* * * @param[in] ntype - * - PastixMaxNorm - * - PastixOneNorm - * - PastixInfNorm - * - PastixFrobeniusNorm + * - SpmMaxNorm + * - SpmOneNorm + * - SpmInfNorm + * - SpmFrobeniusNorm * * @param[in] spm * The sparse matrix structure. @@ -464,10 +473,10 @@ spm2Dense( const pastix_spm_t *spm ) * *******************************************************************************/ double -spmNorm( pastix_normtype_t ntype, - const pastix_spm_t *spm ) +spmNorm( spm_normtype_t ntype, + const spmatrix_t *spm ) { - pastix_spm_t *spmtmp = (pastix_spm_t*)spm; + spmatrix_t *spmtmp = (spmatrix_t*)spm; double norm = -1.; if ( spm->dof != 1 ) { @@ -475,23 +484,23 @@ spmNorm( pastix_normtype_t ntype, spmtmp = spmExpand( spm ); } switch (spm->flttype) { - case PastixFloat: + case SpmFloat: norm = (double)s_spmNorm( ntype, spmtmp ); break; - case PastixDouble: + case SpmDouble: norm = d_spmNorm( ntype, spmtmp ); break; - case PastixComplex32: + case SpmComplex32: norm = (double)c_spmNorm( ntype, spmtmp ); break; - case PastixComplex64: + case SpmComplex64: norm = z_spmNorm( ntype, spmtmp ); break; - case PastixPattern: + case SpmPattern: default: ; } @@ -521,37 +530,37 @@ spmNorm( pastix_normtype_t ntype, * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the sort was called - * @retval PASTIX_ERR_BADPARAMETER if the given spm was incorrect. + * @retval SPM_SUCCESS if the sort was called + * @retval SPM_ERR_BADPARAMETER if the given spm was incorrect. * *******************************************************************************/ int -spmSort( pastix_spm_t *spm ) +spmSort( spmatrix_t *spm ) { if ( spm->dof != 1 ) { fprintf(stderr, "WARNING: spm expanded due to non implemented sort for non-expanded spm\n"); spm = spmExpand( spm ); } switch (spm->flttype) { - case PastixPattern: + case SpmPattern: p_spmSort( spm ); break; - case PastixFloat: + case SpmFloat: s_spmSort( spm ); break; - case PastixDouble: + case SpmDouble: d_spmSort( spm ); break; - case PastixComplex32: + case SpmComplex32: c_spmSort( spm ); break; - case PastixComplex64: + case SpmComplex64: z_spmSort( spm ); break; default: - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -573,34 +582,34 @@ spmSort( pastix_spm_t *spm ) ******************************************************************************** * * @retval >=0 the number of vertices that were merged, - * @retval PASTIX_ERR_BADPARAMETER if the given spm was incorrect. + * @retval SPM_ERR_BADPARAMETER if the given spm was incorrect. * *******************************************************************************/ -pastix_int_t -spmMergeDuplicate( pastix_spm_t *spm ) +spm_int_t +spmMergeDuplicate( spmatrix_t *spm ) { if ( spm->dof != 1 ) { fprintf(stderr, "WARNING: spm expanded due to non implemented merge for non-expanded spm\n"); spm = spmExpand( spm ); } switch (spm->flttype) { - case PastixPattern: + case SpmPattern: return p_spmMergeDuplicate( spm ); - case PastixFloat: + case SpmFloat: return s_spmMergeDuplicate( spm ); - case PastixDouble: + case SpmDouble: return d_spmMergeDuplicate( spm ); - case PastixComplex32: + case SpmComplex32: return c_spmMergeDuplicate( spm ); - case PastixComplex64: + case SpmComplex64: return z_spmMergeDuplicate( spm ); default: - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } } @@ -623,34 +632,34 @@ spmMergeDuplicate( pastix_spm_t *spm ) ******************************************************************************** * * @retval >=0 the number of entries added to the matrix, - * @retval PASTIX_ERR_BADPARAMETER if the given spm was incorrect. + * @retval SPM_ERR_BADPARAMETER if the given spm was incorrect. * *******************************************************************************/ -pastix_int_t -spmSymmetrize( pastix_spm_t *spm ) +spm_int_t +spmSymmetrize( spmatrix_t *spm ) { if ( spm->dof != 1 ) { fprintf(stderr, "WARNING: spm expanded due to non implemented symmetrize for non-expanded spm\n"); spm = spmExpand( spm ); } switch (spm->flttype) { - case PastixPattern: + case SpmPattern: return p_spmSymmetrize( spm ); - case PastixFloat: + case SpmFloat: return s_spmSymmetrize( spm ); - case PastixDouble: + case SpmDouble: return d_spmSymmetrize( spm ); - case PastixComplex32: + case SpmComplex32: return c_spmSymmetrize( spm ); - case PastixComplex64: + case SpmComplex64: return z_spmSymmetrize( spm ); default: - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } } @@ -677,17 +686,17 @@ spmSymmetrize( pastix_spm_t *spm ) * is returned. * *******************************************************************************/ -pastix_spm_t * -spmCheckAndCorrect( pastix_spm_t *spm ) +spmatrix_t * +spmCheckAndCorrect( spmatrix_t *spm ) { - pastix_spm_t *newspm = NULL; - pastix_int_t count; + spmatrix_t *newspm = NULL; + spm_int_t count; /* Let's work on a copy */ newspm = spmCopy( spm ); /* PaStiX works on CSC matrices */ - spmConvert( PastixCSC, newspm ); + spmConvert( SpmCSC, newspm ); if ( newspm->dof != 1 ) { fprintf(stderr, "WARNING: newspm expanded due to missing check functions implementations\n"); @@ -708,7 +717,7 @@ spmCheckAndCorrect( pastix_spm_t *spm ) * part, otherwise, we symmetrize the graph to get A+A^t, new values are set * to 0. */ - if ( newspm->mtxtype == PastixGeneral ) { + if ( newspm->mtxtype == SpmGeneral ) { count = spmSymmetrize( newspm ); if ( count > 0 ) { fprintf(stderr, "spmCheckAndCorrect: %ld entries have been added for symmetry\n", (long)count ); @@ -732,7 +741,7 @@ spmCheckAndCorrect( pastix_spm_t *spm ) else { spmExit( newspm ); free(newspm); - return (pastix_spm_t*)spm; + return (spmatrix_t*)spm; } } @@ -756,28 +765,28 @@ spmCheckAndCorrect( pastix_spm_t *spm ) * The copy of the sparse matrix. * *******************************************************************************/ -pastix_spm_t * -spmCopy( const pastix_spm_t *spm ) +spmatrix_t * +spmCopy( const spmatrix_t *spm ) { - pastix_spm_t *newspm = (pastix_spm_t*)malloc(sizeof(pastix_spm_t)); - pastix_int_t colsize, rowsize, valsize, dofsize; + spmatrix_t *newspm = (spmatrix_t*)malloc(sizeof(spmatrix_t)); + spm_int_t colsize, rowsize, valsize, dofsize; - memcpy( newspm, spm, sizeof(pastix_spm_t)); + memcpy( newspm, spm, sizeof(spmatrix_t)); switch(spm->fmttype){ - case PastixCSC: + case SpmCSC: colsize = spm->n + 1; rowsize = spm->nnz; valsize = spm->nnzexp; dofsize = spm->n + 1; break; - case PastixCSR: + case SpmCSR: colsize = spm->nnz; rowsize = spm->n + 1; valsize = spm->nnzexp; dofsize = spm->n + 1; break; - case PastixIJV: + case SpmIJV: default: colsize = spm->nnz; rowsize = spm->nnz; @@ -786,23 +795,23 @@ spmCopy( const pastix_spm_t *spm ) } if(spm->colptr != NULL) { - newspm->colptr = (pastix_int_t*)malloc( colsize * sizeof(pastix_int_t)); - memcpy( newspm->colptr, spm->colptr, colsize * sizeof(pastix_int_t)); + newspm->colptr = (spm_int_t*)malloc( colsize * sizeof(spm_int_t)); + memcpy( newspm->colptr, spm->colptr, colsize * sizeof(spm_int_t)); } if(spm->rowptr != NULL) { - newspm->rowptr = (pastix_int_t*)malloc(rowsize * sizeof(pastix_int_t)); - memcpy( newspm->rowptr, spm->rowptr, rowsize * sizeof(pastix_int_t)); + newspm->rowptr = (spm_int_t*)malloc(rowsize * sizeof(spm_int_t)); + memcpy( newspm->rowptr, spm->rowptr, rowsize * sizeof(spm_int_t)); } if(spm->loc2glob != NULL) { - newspm->loc2glob = (pastix_int_t*)malloc(dofsize * sizeof(pastix_int_t)); - memcpy( newspm->loc2glob, spm->loc2glob, dofsize * sizeof(pastix_int_t)); + newspm->loc2glob = (spm_int_t*)malloc(dofsize * sizeof(spm_int_t)); + memcpy( newspm->loc2glob, spm->loc2glob, dofsize * sizeof(spm_int_t)); } if(spm->dofs != NULL) { - newspm->dofs = (pastix_int_t*)malloc(dofsize * sizeof(pastix_int_t)); - memcpy( newspm->dofs, spm->dofs, dofsize * sizeof(pastix_int_t) ); + newspm->dofs = (spm_int_t*)malloc(dofsize * sizeof(spm_int_t)); + memcpy( newspm->dofs, spm->dofs, dofsize * sizeof(spm_int_t) ); } if(spm->values != NULL) { - valsize = valsize * pastix_size_of( spm->flttype ); + valsize = valsize * spm_size_of( spm->flttype ); newspm->values = malloc(valsize); memcpy( newspm->values, spm->values, valsize ); } @@ -824,14 +833,14 @@ spmCopy( const pastix_spm_t *spm ) * *******************************************************************************/ void -spmPrintInfo( const pastix_spm_t* spm, FILE *stream ) +spmPrintInfo( const spmatrix_t* spm, FILE *stream ) { char *mtxtypestr[4] = { "General", "Symmetric", "Hermitian", "Incorrect" }; char *flttypestr[7] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64", "Incorrect" }; char *fmttypestr[4] = { "CSC", "CSR", "IJV", "Incorrect" }; - int mtxtype = spm->mtxtype - PastixGeneral; - int flttype = spm->flttype - PastixPattern; - int fmttype = spm->fmttype - PastixCSC; + int mtxtype = spm->mtxtype - SpmGeneral; + int flttype = spm->flttype - SpmPattern; + int fmttype = spm->fmttype - SpmCSC; if (stream == NULL) { stream = stdout; @@ -885,7 +894,7 @@ spmPrintInfo( const pastix_spm_t* spm, FILE *stream ) * *******************************************************************************/ void -spmPrint( const pastix_spm_t *spm, +spmPrint( const spmatrix_t *spm, FILE *stream ) { if (stream == NULL) { @@ -894,19 +903,19 @@ spmPrint( const pastix_spm_t *spm, switch(spm->flttype) { - case PastixPattern: + case SpmPattern: //return p_f, spmPrint(f, spm); break; - case PastixFloat: + case SpmFloat: s_spmPrint(stream, spm); break; - case PastixComplex32: + case SpmComplex32: c_spmPrint(stream, spm); break; - case PastixComplex64: + case SpmComplex64: z_spmPrint(stream, spm); break; - case PastixDouble: + case SpmDouble: default: d_spmPrint(stream, spm); } @@ -932,24 +941,24 @@ spmPrint( const pastix_spm_t *spm, * The copy of the sparse matrix. * *******************************************************************************/ -pastix_spm_t * -spmExpand( const pastix_spm_t* spm ) +spmatrix_t * +spmExpand( const spmatrix_t* spm ) { switch(spm->flttype) { - case PastixPattern: + case SpmPattern: return p_spmExpand(spm); break; - case PastixFloat: + case SpmFloat: return s_spmExpand(spm); break; - case PastixComplex32: + case SpmComplex32: return c_spmExpand(spm); break; - case PastixComplex64: + case SpmComplex64: return z_spmExpand(spm); break; - case PastixDouble: + case SpmDouble: default: return d_spmExpand(spm); } @@ -970,15 +979,15 @@ spmExpand( const pastix_spm_t* spm ) * * @param[in] trans * Specifies whether the matrix spm is transposed, not transposed or conjugate transposed: - * - PastixTrans - * - PastixNoTrans - * - PastixConjTrans + * - SpmTrans + * - SpmNoTrans + * - SpmConjTrans * * @param[in] alpha * alpha specifies the scalar alpha. * * @param[in] spm - * The PastixGeneral spm. + * The SpmGeneral spm. * * @param[in] x * The vector x. @@ -991,39 +1000,39 @@ spmExpand( const pastix_spm_t* spm ) * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed successfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed successfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -spmMatVec( pastix_trans_t trans, +spmMatVec( spm_trans_t trans, const void *alpha, - const pastix_spm_t *spm, + const spmatrix_t *spm, const void *x, const void *beta, void *y ) { - pastix_spm_t *espm = (pastix_spm_t*)spm; - int rc = PASTIX_SUCCESS; + spmatrix_t *espm = (spmatrix_t*)spm; + int rc = SPM_SUCCESS; - if ( spm->fmttype != PastixCSC ) { - return PASTIX_ERR_BADPARAMETER; + if ( spm->fmttype != SpmCSC ) { + return SPM_ERR_BADPARAMETER; } if ( spm->dof != 1 ) { espm = spmExpand( spm ); } switch (spm->flttype) { - case PastixFloat: + case SpmFloat: rc = s_spmCSCMatVec( trans, alpha, espm, x, beta, y ); break; - case PastixComplex32: + case SpmComplex32: rc = c_spmCSCMatVec( trans, alpha, espm, x, beta, y ); break; - case PastixComplex64: + case SpmComplex64: rc = z_spmCSCMatVec( trans, alpha, espm, x, beta, y ); break; - case PastixDouble: + case SpmDouble: default: rc = d_spmCSCMatVec( trans, alpha, espm, x, beta, y ); } @@ -1052,9 +1061,9 @@ spmMatVec( pastix_trans_t trans, * * @param[in] trans * Specifies whether the matrix spm is transposed, not transposed or conjugate transposed: - * - PastixTrans - * - PastixNoTrans - * - PastixConjTrans + * - SpmTrans + * - SpmNoTrans + * - SpmConjTrans * * @param[in] n * The number of columns of the matrices B and C. @@ -1082,42 +1091,42 @@ spmMatVec( pastix_trans_t trans, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed successfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed successfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -spmMatMat( pastix_trans_t trans, - pastix_int_t n, +spmMatMat( spm_trans_t trans, + spm_int_t n, const void *alpha, - const pastix_spm_t *A, + const spmatrix_t *A, const void *B, - pastix_int_t ldb, + spm_int_t ldb, const void *beta, void *C, - pastix_int_t ldc ) + spm_int_t ldc ) { - pastix_spm_t *espm = (pastix_spm_t*)A; - int rc = PASTIX_SUCCESS; + spmatrix_t *espm = (spmatrix_t*)A; + int rc = SPM_SUCCESS; - if ( A->fmttype != PastixCSC ) { - return PASTIX_ERR_BADPARAMETER; + if ( A->fmttype != SpmCSC ) { + return SPM_ERR_BADPARAMETER; } if ( A->dof != 1 ) { espm = spmExpand( A ); } switch (A->flttype) { - case PastixFloat: + case SpmFloat: rc = s_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc ); break; - case PastixComplex32: + case SpmComplex32: rc = c_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc ); break; - case PastixComplex64: + case SpmComplex64: rc = z_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc ); break; - case PastixDouble: + case SpmDouble: default: rc = d_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc ); break; @@ -1141,11 +1150,11 @@ spmMatMat( pastix_trans_t trans, * * @param[in] type * Defines how to compute the vector b. - * - PastixRhsOne: b is computed such that x = 1 [ + I ] - * - PastixRhsI: b is computed such that x = i [ + i * I ] - * - PastixRhsRndX: b is computed by matrix-vector product, such that + * - SpmRhsOne: b is computed such that x = 1 [ + I ] + * - SpmRhsI: b is computed such that x = i [ + i * I ] + * - SpmRhsRndX: b is computed by matrix-vector product, such that * is a random vector in the range [-0.5, 0.5] - * - PastixRhsRndB: b is computed randomly and x is not computed. + * - SpmRhsRndB: b is computed randomly and x is not computed. * * @param[in] nrhs * Defines the number of right hand side that must be generated. @@ -1172,26 +1181,26 @@ spmMatMat( pastix_trans_t trans, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the b vector has been computed successfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the b vector has been computed successfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -spmGenRHS( pastix_rhstype_t type, pastix_int_t nrhs, - const pastix_spm_t *spm, - void *x, pastix_int_t ldx, - void *b, pastix_int_t ldb ) +spmGenRHS( spm_rhstype_t type, spm_int_t nrhs, + const spmatrix_t *spm, + void *x, spm_int_t ldx, + void *b, spm_int_t ldb ) { - static int (*ptrfunc[4])(pastix_rhstype_t, int, - const pastix_spm_t *, + static int (*ptrfunc[4])(spm_rhstype_t, int, + const spmatrix_t *, void *, int, void *, int) = { s_spmGenRHS, d_spmGenRHS, c_spmGenRHS, z_spmGenRHS }; - int id = spm->flttype - PastixFloat; + int id = spm->flttype - SpmFloat; if ( (id < 0) || (id > 3) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } else { return ptrfunc[id](type, nrhs, spm, x, ldx, b, ldb ); @@ -1241,27 +1250,27 @@ spmGenRHS( pastix_rhstype_t type, pastix_int_t nrhs, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the tests are succesfull - * @retval PASTIX_ERR_BADPARAMETER if the input matrix is incorrect + * @retval SPM_SUCCESS if the tests are succesfull + * @retval SPM_ERR_BADPARAMETER if the input matrix is incorrect * @retval 1, if one of the test failed * *******************************************************************************/ int -spmCheckAxb( double eps, pastix_int_t nrhs, - const pastix_spm_t *spm, - void *x0, pastix_int_t ldx0, - void *b, pastix_int_t ldb, - const void *x, pastix_int_t ldx ) +spmCheckAxb( double eps, spm_int_t nrhs, + const spmatrix_t *spm, + void *x0, spm_int_t ldx0, + void *b, spm_int_t ldb, + const void *x, spm_int_t ldx ) { - static int (*ptrfunc[4])( double, int, const pastix_spm_t *, + static int (*ptrfunc[4])( double, int, const spmatrix_t *, void *, int, void *, int, const void *, int ) = { s_spmCheckAxb, d_spmCheckAxb, c_spmCheckAxb, z_spmCheckAxb }; - int id = spm->flttype - PastixFloat; + int id = spm->flttype - SpmFloat; if ( (id < 0) || (id > 3) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } else { return ptrfunc[id]( eps, nrhs, spm, x0, ldx0, b, ldb, x, ldx ); @@ -1285,22 +1294,22 @@ spmCheckAxb( double eps, pastix_int_t nrhs, * *******************************************************************************/ void -spmScalMatrix(double alpha, pastix_spm_t* spm) +spmScalMatrix(double alpha, spmatrix_t* spm) { switch(spm->flttype) { - case PastixPattern: + case SpmPattern: break; - case PastixFloat: + case SpmFloat: s_spmScal((float)alpha, spm); break; - case PastixComplex32: + case SpmComplex32: c_spmScal((float)alpha, spm); break; - case PastixComplex64: + case SpmComplex64: z_spmScal(alpha, spm); break; - case PastixDouble: + case SpmDouble: default: d_spmScal(alpha, spm); } @@ -1317,10 +1326,10 @@ spmScalMatrix(double alpha, pastix_spm_t* spm) * * @param[in] flt * Datatype of the elements in the vector that must be: - * @arg PastixFloat - * @arg PastixDouble - * @arg PastixComplex32 - * @arg PastixComplex64 + * @arg SpmFloat + * @arg SpmDouble + * @arg SpmComplex32 + * @arg SpmComplex64 * * @param[in] n * Number of elements in the input vectors @@ -1337,26 +1346,26 @@ spmScalMatrix(double alpha, pastix_spm_t* spm) * *******************************************************************************/ void -spmScalVector( pastix_coeftype_t flt, +spmScalVector( spm_coeftype_t flt, double alpha, - pastix_int_t n, + spm_int_t n, void *x, - pastix_int_t incx ) + spm_int_t incx ) { switch( flt ) { - case PastixPattern: + case SpmPattern: break; - case PastixFloat: + case SpmFloat: cblas_sscal( n, (float)alpha, x, incx ); break; - case PastixComplex32: + case SpmComplex32: cblas_csscal( n, (float)alpha, x, incx ); break; - case PastixComplex64: + case SpmComplex64: cblas_zdscal( n, alpha, x, incx ); break; - case PastixDouble: + case SpmDouble: default: cblas_dscal( n, alpha, x, incx ); } diff --git a/src/spm_dof_extend.c b/src/spm_dof_extend.c index 51510ec3279248d7f0a3fc1d97bc01f9cd36a95a..88fd41522a4fb713703ec08747706ec9a17845cf 100644 --- a/src/spm_dof_extend.c +++ b/src/spm_dof_extend.c @@ -15,7 +15,6 @@ * **/ #include "common.h" -#include "spm.h" #include "z_spm.h" #include "c_spm.h" @@ -26,7 +25,7 @@ /** ******************************************************************************* * - * @ingroup pastix_spm + * @ingroup spm_spm * * @brief Generate a random multidof spm from a given spm (with dof=1). * @@ -48,20 +47,20 @@ * @return the new multidof spm. * *******************************************************************************/ -pastix_spm_t * -spmDofExtend( const pastix_spm_t *spm, +spmatrix_t * +spmDofExtend( const spmatrix_t *spm, const int type, const int dof ) { - pastix_spm_t *newspm; + spmatrix_t *newspm; /* Quick return */ if ( dof == 1 ) - return (pastix_spm_t *)spm; + return (spmatrix_t *)spm; if ( spm->dof != 1 ) { - pastix_print_error( "Cannot extend spm including dofs already\n" ); - return (pastix_spm_t *)spm; + spm_print_error( "Cannot extend spm including dofs already\n" ); + return (spmatrix_t *)spm; } newspm = spmCopy( spm ); @@ -73,13 +72,13 @@ spmDofExtend( const pastix_spm_t *spm, newspm->dof = dof; } else { - pastix_int_t i, dofi, baseval; - pastix_int_t *dofptr; + spm_int_t i, dofi, baseval; + spm_int_t *dofptr; baseval = spmFindBase( spm ); newspm->dof = -1; - newspm->dofs = malloc( (spm->n+1) * sizeof(pastix_int_t) ); + newspm->dofs = malloc( (spm->n+1) * sizeof(spm_int_t) ); dofptr = newspm->dofs; /* @@ -96,23 +95,23 @@ spmDofExtend( const pastix_spm_t *spm, spmUpdateComputedFields( newspm ); switch (spm->flttype) { - case PastixFloat: + case SpmFloat: s_spmDofExtend( newspm ); break; - case PastixDouble: + case SpmDouble: d_spmDofExtend( newspm ); break; - case PastixComplex32: + case SpmComplex32: c_spmDofExtend( newspm ); break; - case PastixComplex64: + case SpmComplex64: z_spmDofExtend( newspm ); break; - case PastixPattern: + case SpmPattern: ; } diff --git a/src/spm_drivers.h b/src/spm_drivers.h index 2a3cef11ba96a3a1e400cc2acd09a59805614330..2343b6f55c62ddac0d1e6ca40f283e6cf37fd657 100644 --- a/src/spm_drivers.h +++ b/src/spm_drivers.h @@ -18,19 +18,19 @@ #include "spm.h" -void convertArrayToComplex64( pastix_int_t n, const double *A, void **B ); -void convertArrayToComplex32( pastix_int_t n, const double *A, void **B ); -void convertArrayToDouble( pastix_int_t n, const double *A, void **B ); -void convertArrayToFloat( pastix_int_t n, const double *A, void **B ); +void convertArrayToComplex64( spm_int_t n, const double *A, void **B ); +void convertArrayToComplex32( spm_int_t n, const double *A, void **B ); +void convertArrayToDouble( spm_int_t n, const double *A, void **B ); +void convertArrayToFloat( spm_int_t n, const double *A, void **B ); -int readHB ( const char *filename, pastix_spm_t *spm ); -int readRSA ( const char *filename, pastix_spm_t *spm ); -int readIJV ( const char *filename, pastix_spm_t *spm ); -int readMM ( const char *filename, pastix_spm_t *spm ); -int readDMM ( const char *filename, pastix_spm_t *spm ); -int readPETSC( const char *filename, pastix_spm_t *spm ); -int readCSCD ( const char *filename, pastix_spm_t *spm, void **rhs, MPI_Comm pastix_comm ); -int genLaplacian( const char *filename, pastix_spm_t *spm ); -int genExtendedLaplacian( const char *filename, pastix_spm_t *spm ); +int readHB ( const char *filename, spmatrix_t *spm ); +int readRSA ( const char *filename, spmatrix_t *spm ); +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 genLaplacian( const char *filename, spmatrix_t *spm ); +int genExtendedLaplacian( const char *filename, spmatrix_t *spm ); #endif /* _spm_drivers_h_ */ diff --git a/src/spm_gen_fake_values.c b/src/spm_gen_fake_values.c index fa01704c7f636b08d8086f4cc8d2ccec0782e8d4..e1560e1281e0d033f68a6f17f362ea01535de92c 100644 --- a/src/spm_gen_fake_values.c +++ b/src/spm_gen_fake_values.c @@ -14,7 +14,6 @@ * **/ #include "common.h" -#include "spm.h" /** ******************************************************************************* @@ -39,36 +38,36 @@ * @return the number of diagonal elements found during the computation. * *******************************************************************************/ -static inline pastix_int_t -spm_compute_degrees( const pastix_spm_t *spm, - pastix_int_t *degrees ) +static inline spm_int_t +spm_compute_degrees( const spmatrix_t *spm, + spm_int_t *degrees ) { - pastix_int_t i, j, k; - pastix_int_t *colptr = spm->colptr; - pastix_int_t *rowptr = spm->rowptr; - pastix_int_t baseval; - pastix_int_t diagval = 0; + spm_int_t i, j, k; + spm_int_t *colptr = spm->colptr; + spm_int_t *rowptr = spm->rowptr; + spm_int_t baseval; + spm_int_t diagval = 0; baseval = spmFindBase( spm ); - memset( degrees, 0, spm->n * sizeof(pastix_int_t) ); + memset( degrees, 0, spm->n * sizeof(spm_int_t) ); switch(spm->fmttype) { - case PastixCSR: + case SpmCSR: /* Swap pointers to call CSC */ colptr = spm->rowptr; rowptr = spm->colptr; - pastix_attr_fallthrough; + spm_attr_fallthrough; - case PastixCSC: + case SpmCSC: for(j=0; j<spm->n; j++, colptr++) { for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = *rowptr - baseval; if ( i != j ) { degrees[j] += 1; - if ( spm->mtxtype != PastixGeneral ) { + if ( spm->mtxtype != SpmGeneral ) { degrees[i] += 1; } } @@ -78,7 +77,7 @@ spm_compute_degrees( const pastix_spm_t *spm, } } break; - case PastixIJV: + case SpmIJV: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { i = *rowptr - baseval; @@ -87,7 +86,7 @@ spm_compute_degrees( const pastix_spm_t *spm, if ( i != j ) { degrees[j] += 1; - if ( spm->mtxtype != PastixGeneral ) { + if ( spm->mtxtype != SpmGeneral ) { degrees[i] += 1; } } @@ -119,44 +118,44 @@ spm_compute_degrees( const pastix_spm_t *spm, * *******************************************************************************/ static inline void -spm_add_diag( pastix_spm_t *spm, - pastix_int_t diagval ) +spm_add_diag( spmatrix_t *spm, + spm_int_t diagval ) { - pastix_spm_t oldspm; - pastix_int_t i, j, k; - pastix_int_t *oldcol = spm->colptr; - pastix_int_t *oldrow = spm->rowptr; - pastix_int_t *newrow, *newcol; - pastix_int_t baseval; + spmatrix_t oldspm; + spm_int_t i, j, k; + spm_int_t *oldcol = spm->colptr; + spm_int_t *oldrow = spm->rowptr; + spm_int_t *newrow, *newcol; + spm_int_t baseval; baseval = spmFindBase( spm ); - memcpy( &oldspm, spm, sizeof(pastix_spm_t)); + memcpy( &oldspm, spm, sizeof(spmatrix_t)); spm->nnz = oldspm.nnz + (spm->n - diagval); - newrow = malloc( spm->nnz * sizeof(pastix_int_t) ); + newrow = malloc( spm->nnz * sizeof(spm_int_t) ); switch(spm->fmttype) { - case PastixCSR: + case SpmCSR: /* Swap pointers to call CSC */ oldcol = spm->rowptr; oldrow = spm->colptr; spm->colptr = newrow; - pastix_attr_fallthrough; + spm_attr_fallthrough; - case PastixCSC: + case SpmCSC: newcol = oldcol; - if ( spm->fmttype == PastixCSC ) { + if ( spm->fmttype == SpmCSC ) { spm->rowptr = newrow; } diagval = 0; for(j=0; j<spm->n; j++, newcol++) { - pastix_int_t nbelt = newcol[1] - newcol[0]; + spm_int_t nbelt = newcol[1] - newcol[0]; int diag = 0; - memcpy( newrow, oldrow, nbelt * sizeof(pastix_int_t) ); + memcpy( newrow, oldrow, nbelt * sizeof(spm_int_t) ); newrow += nbelt; for(k=0; k<nbelt; k++, oldrow++) { @@ -175,7 +174,7 @@ spm_add_diag( pastix_spm_t *spm, } newcol[0] += diagval; - if ( spm->fmttype == PastixCSC ) { + if ( spm->fmttype == SpmCSC ) { free( oldspm.rowptr ); } else { @@ -184,8 +183,8 @@ spm_add_diag( pastix_spm_t *spm, assert( diagval == spm->n ); break; - case PastixIJV: - newcol = malloc( spm->nnz * sizeof(pastix_int_t) ); + case SpmIJV: + newcol = malloc( spm->nnz * sizeof(spm_int_t) ); spm->colptr = newcol; spm->rowptr = newrow; @@ -234,15 +233,15 @@ spm_add_diag( pastix_spm_t *spm, * *******************************************************************************/ static inline void -spm_generate_fake_values( pastix_spm_t *spm, - const pastix_int_t *degrees, +spm_generate_fake_values( spmatrix_t *spm, + const spm_int_t *degrees, double alpha, double beta ) { double *values; - pastix_int_t i, j, k; - pastix_int_t *colptr = spm->colptr; - pastix_int_t *rowptr = spm->rowptr; - pastix_int_t baseval; + spm_int_t i, j, k; + spm_int_t *colptr = spm->colptr; + spm_int_t *rowptr = spm->rowptr; + spm_int_t baseval; baseval = spmFindBase( spm ); @@ -251,14 +250,14 @@ spm_generate_fake_values( pastix_spm_t *spm, switch(spm->fmttype) { - case PastixCSR: + case SpmCSR: /* Swap pointers to call CSC */ colptr = spm->rowptr; rowptr = spm->colptr; - pastix_attr_fallthrough; + spm_attr_fallthrough; - case PastixCSC: + case SpmCSC: for(j=0; j<spm->n; j++, colptr++) { for(k=colptr[0]; k<colptr[1]; k++, rowptr++, values++) { i = *rowptr - baseval; @@ -272,7 +271,7 @@ spm_generate_fake_values( pastix_spm_t *spm, } } break; - case PastixIJV: + case SpmIJV: for(k=0; k<spm->nnz; k++, rowptr++, colptr++, values++) { i = *rowptr - baseval; @@ -287,13 +286,13 @@ spm_generate_fake_values( pastix_spm_t *spm, } } - spm->flttype = PastixDouble; + spm->flttype = SpmDouble; } /** ******************************************************************************* * - * @ingroup pastix_spm + * @ingroup spm_spm * * @brief Generate the fake values array such that \[ M = \alpha * D - \beta * A \] * @@ -307,13 +306,13 @@ spm_generate_fake_values( pastix_spm_t *spm, * *******************************************************************************/ void -spmGenFakeValues( pastix_spm_t *spm ) +spmGenFakeValues( spmatrix_t *spm ) { - pastix_int_t *degrees, diagval; + spm_int_t *degrees, diagval; double alpha = 10.; double beta = 1.; - assert( spm->flttype == PastixPattern ); + assert( spm->flttype == SpmPattern ); assert( spm->values == NULL ); assert( spm->dof == 1 ); @@ -321,7 +320,7 @@ spmGenFakeValues( pastix_spm_t *spm ) * Read environment values for alpha/beta */ { - char *str = pastix_getenv( "PASTIX_FAKE_ALPHA" ); + char *str = spm_getenv( "SPM_FAKE_ALPHA" ); double value; if ( str != NULL ) { @@ -331,10 +330,10 @@ spmGenFakeValues( pastix_spm_t *spm ) { alpha = value; } - pastix_cleanenv( str ); + spm_cleanenv( str ); } - str = pastix_getenv( "PASTIX_FAKE_BETA" ); + str = spm_getenv( "SPM_FAKE_BETA" ); if ( str != NULL ) { value = strtod( str, NULL ); if ( (value != HUGE_VAL) && (value != 0.) && @@ -342,11 +341,11 @@ spmGenFakeValues( pastix_spm_t *spm ) { beta = value; } - pastix_cleanenv( str ); + spm_cleanenv( str ); } } - degrees = malloc( spm->n * sizeof(pastix_int_t)); + degrees = malloc( spm->n * sizeof(spm_int_t)); diagval = spm_compute_degrees( spm, degrees ); if ( diagval != spm->n ) { /* Diagonal elements must be added to the sparse matrix */ diff --git a/src/spm_integers.c b/src/spm_integers.c index 2f5343dcb5ec41421e77d280fb1ad353728b72b6..ef5b1e6a5227402ae1892bc412d72aaacad0b455 100644 --- a/src/spm_integers.c +++ b/src/spm_integers.c @@ -15,18 +15,14 @@ * @date 2013-06-24 * **/ -#include <ctype.h> -#include <limits.h> -#include <time.h> -#include <stdlib.h> #include "common.h" /** ******************************************************************************* * - * @ingroup pastix_spm + * @ingroup spm_spm * - * @brief Convert integer array to pastix_int_t format. + * @brief Convert integer array to spm_int_t format. * ******************************************************************************* * @@ -43,35 +39,35 @@ * or the original array if the types are identical. * *******************************************************************************/ -pastix_int_t * -spmIntConvert( pastix_int_t n, int *input ) +spm_int_t * +spmIntConvert( spm_int_t n, int *input ) { - if (sizeof(pastix_int_t) != sizeof(int)) { - pastix_int_t *output, *tmpo; + if (sizeof(spm_int_t) != sizeof(int)) { + spm_int_t *output, *tmpo; int *tmpi, i; - output = malloc( n * sizeof(pastix_int_t) ); + output = malloc( n * sizeof(spm_int_t) ); tmpi = input; tmpo = output; for(i=0; i<n; i++, tmpi++, tmpo++) { - *tmpo = (pastix_int_t)(*tmpi); + *tmpo = (spm_int_t)(*tmpi); } free(input); return output; } else { - return (pastix_int_t*)input; + return (spm_int_t*)input; } } /** ******************************************************************************* * - * @fn void spmIntSort1Asc1(void * const pbase, const pastix_int_t n); + * @fn void spmIntSort1Asc1(void * const pbase, const spm_int_t n); * @ingroup spm_dev_integer * * Sorts in ascending order array of element composed of one single - * pastix_int_t with a single key value. + * spm_int_t with a single key value. * ******************************************************************************* * @@ -85,14 +81,14 @@ spmIntConvert( pastix_int_t n, int *input ) */ #ifndef DOXYGEN_SHOULD_SKIP_THIS #define INTSORTNAME spmIntSort1Asc1 -#define INTSORTSIZE (sizeof (pastix_int_t)) +#define INTSORTSIZE (sizeof (spm_int_t)) #define INTSORTSWAP(p,q) do { \ - pastix_int_t t; \ - t = *((pastix_int_t *) (p)); \ - *((pastix_int_t *) (p)) = *((pastix_int_t *) (q)); \ - *((pastix_int_t *) (q)) = t; \ + spm_int_t t; \ + t = *((spm_int_t *) (p)); \ + *((spm_int_t *) (p)) = *((spm_int_t *) (q)); \ + *((spm_int_t *) (q)) = t; \ } while (0) -#define INTSORTCMP(p,q) (*((pastix_int_t *) (p)) < *((pastix_int_t *) (q))) +#define INTSORTCMP(p,q) (*((spm_int_t *) (p)) < *((spm_int_t *) (q))) #include "integer_sort.c" #undef INTSORTNAME #undef INTSORTSIZE @@ -103,11 +99,11 @@ spmIntConvert( pastix_int_t n, int *input ) /** ******************************************************************************* * - * @fn void spmIntSort2Asc1(void * const pbase, const pastix_int_t n); + * @fn void spmIntSort2Asc1(void * const pbase, const spm_int_t n); * @ingroup spm_dev_integer * * Sorts in ascending order array of element composed of two - * pastix_int_t by ascending order. The first value is used as key. + * spm_int_t by ascending order. The first value is used as key. * ******************************************************************************* * @@ -121,17 +117,17 @@ spmIntConvert( pastix_int_t n, int *input ) */ #ifndef DOXYGEN_SHOULD_SKIP_THIS #define INTSORTNAME spmIntSort2Asc1 -#define INTSORTSIZE (2 * sizeof (pastix_int_t)) +#define INTSORTSIZE (2 * sizeof (spm_int_t)) #define INTSORTSWAP(p,q) do { \ - pastix_int_t t, u; \ - t = *((pastix_int_t *) (p)); \ - u = *((pastix_int_t *) (p) + 1); \ - *((pastix_int_t *) (p)) = *((pastix_int_t *) (q)); \ - *((pastix_int_t *) (p) + 1) = *((pastix_int_t *) (q) + 1); \ - *((pastix_int_t *) (q)) = t; \ - *((pastix_int_t *) (q) + 1) = u; \ + spm_int_t t, u; \ + t = *((spm_int_t *) (p)); \ + u = *((spm_int_t *) (p) + 1); \ + *((spm_int_t *) (p)) = *((spm_int_t *) (q)); \ + *((spm_int_t *) (p) + 1) = *((spm_int_t *) (q) + 1); \ + *((spm_int_t *) (q)) = t; \ + *((spm_int_t *) (q) + 1) = u; \ } while (0) -#define INTSORTCMP(p,q) (*((pastix_int_t *) (p)) < *((pastix_int_t *) (q))) +#define INTSORTCMP(p,q) (*((spm_int_t *) (p)) < *((spm_int_t *) (q))) #include "integer_sort.c" #undef INTSORTNAME #undef INTSORTSIZE @@ -142,11 +138,11 @@ spmIntConvert( pastix_int_t n, int *input ) /** ******************************************************************************* * - * @fn void spmIntSort3Asc1(void * const pbase, const pastix_int_t n); + * @fn void spmIntSort3Asc1(void * const pbase, const spm_int_t n); * @ingroup spm_dev_integer * * @brief Sorts in ascending order array of element composed of three - * pastix_int_t by ascending order. The first value is used as key. + * spm_int_t by ascending order. The first value is used as key. * ******************************************************************************* * @@ -159,24 +155,24 @@ spmIntConvert( pastix_int_t n, int *input ) ******************************************************************************* */ /* Declare here for now, because unused */ -void spmIntSort3Asc1(void *const pbase, const pastix_int_t n); +void spmIntSort3Asc1(void *const pbase, const spm_int_t n); #ifndef DOXYGEN_SHOULD_SKIP_THIS #define INTSORTNAME spmIntSort3Asc1 -#define INTSORTSIZE (3 * sizeof (pastix_int_t)) +#define INTSORTSIZE (3 * sizeof (spm_int_t)) #define INTSORTSWAP(p,q) do { \ - pastix_int_t t, u, v; \ - t = *((pastix_int_t *) (p)); \ - u = *((pastix_int_t *) (p) + 1); \ - v = *((pastix_int_t *) (p) + 2); \ - *((pastix_int_t *) (p)) = *((pastix_int_t *) (q)); \ - *((pastix_int_t *) (p) + 1) = *((pastix_int_t *) (q) + 1); \ - *((pastix_int_t *) (p) + 2) = *((pastix_int_t *) (q) + 2); \ - *((pastix_int_t *) (q)) = t; \ - *((pastix_int_t *) (q) + 1) = u; \ - *((pastix_int_t *) (q) + 2) = v; \ + spm_int_t t, u, v; \ + t = *((spm_int_t *) (p)); \ + u = *((spm_int_t *) (p) + 1); \ + v = *((spm_int_t *) (p) + 2); \ + *((spm_int_t *) (p)) = *((spm_int_t *) (q)); \ + *((spm_int_t *) (p) + 1) = *((spm_int_t *) (q) + 1); \ + *((spm_int_t *) (p) + 2) = *((spm_int_t *) (q) + 2); \ + *((spm_int_t *) (q)) = t; \ + *((spm_int_t *) (q) + 1) = u; \ + *((spm_int_t *) (q) + 2) = v; \ } while (0) -#define INTSORTCMP(p,q) (*((pastix_int_t *) (p)) < *((pastix_int_t *) (q))) +#define INTSORTCMP(p,q) (*((spm_int_t *) (p)) < *((spm_int_t *) (q))) #include "integer_sort.c" #undef INTSORTNAME #undef INTSORTSIZE @@ -187,10 +183,10 @@ void spmIntSort3Asc1(void *const pbase, const pastix_int_t n); /** ******************************************************************************* * - * @fn void spmIntSort2Asc2(void * const pbase, const pastix_int_t n); + * @fn void spmIntSort2Asc2(void * const pbase, const spm_int_t n); * @ingroup spm_dev_integer * @brief Sorts in ascending order array of element composed of two - * pastix_int_t by ascending order. Both values are used as key. + * spm_int_t by ascending order. Both values are used as key. * ******************************************************************************* * @@ -204,17 +200,17 @@ void spmIntSort3Asc1(void *const pbase, const pastix_int_t n); */ #ifndef DOXYGEN_SHOULD_SKIP_THIS #define INTSORTNAME spmIntSort2Asc2 -#define INTSORTSIZE (2 * sizeof (pastix_int_t)) +#define INTSORTSIZE (2 * sizeof (spm_int_t)) #define INTSORTSWAP(p,q) do { \ - pastix_int_t t, u; \ - t = *((pastix_int_t *) (p)); \ - u = *((pastix_int_t *) (p) + 1); \ - *((pastix_int_t *) (p)) = *((pastix_int_t *) (q)); \ - *((pastix_int_t *) (p) + 1) = *((pastix_int_t *) (q) + 1); \ - *((pastix_int_t *) (q)) = t; \ - *((pastix_int_t *) (q) + 1) = u; \ + spm_int_t t, u; \ + t = *((spm_int_t *) (p)); \ + u = *((spm_int_t *) (p) + 1); \ + *((spm_int_t *) (p)) = *((spm_int_t *) (q)); \ + *((spm_int_t *) (p) + 1) = *((spm_int_t *) (q) + 1); \ + *((spm_int_t *) (q)) = t; \ + *((spm_int_t *) (q) + 1) = u; \ } while (0) -#define INTSORTCMP(p,q) ((*((pastix_int_t *) (p)) < *((pastix_int_t *) (q))) || ((*((pastix_int_t *) (p)) == *((pastix_int_t *) (q))) && (*((pastix_int_t *) (p) + 1) < *((pastix_int_t *) (q) + 1)))) +#define INTSORTCMP(p,q) ((*((spm_int_t *) (p)) < *((spm_int_t *) (q))) || ((*((spm_int_t *) (p)) == *((spm_int_t *) (q))) && (*((spm_int_t *) (p) + 1) < *((spm_int_t *) (q) + 1)))) #include "integer_sort.c" #undef INTSORTNAME #undef INTSORTSIZE @@ -225,12 +221,12 @@ void spmIntSort3Asc1(void *const pbase, const pastix_int_t n); /** ******************************************************************************* * - * @fn void spmIntMSortIntAsc(void ** const pbase, const pastix_int_t n); + * @fn void spmIntMSortIntAsc(void ** const pbase, const spm_int_t n); * @ingroup spm_dev_integer * * @brief Sort 2 arrays simultaneously, the first array is an array of - * pastix_int_t and used as primary key for sorting. The second array is an - * other array of pastix_int_t used as secondary key. + * spm_int_t and used as primary key for sorting. The second array is an + * other array of spm_int_t used as secondary key. * ******************************************************************************* * @@ -243,30 +239,30 @@ void spmIntSort3Asc1(void *const pbase, const pastix_int_t n); ******************************************************************************* */ /* Declare here for now, because unused */ -void spmIntMSortIntAsc(void ** const pbase, const pastix_int_t n); +void spmIntMSortIntAsc(void ** const pbase, const spm_int_t n); #ifndef DOXYGEN_SHOULD_SKIP_THIS #define INTSORTNAME spmIntMSortIntAsc -#define INTSORTSIZE(x) (sizeof (pastix_int_t)) +#define INTSORTSIZE(x) (sizeof (spm_int_t)) #define INTSORTNTAB 2 #define INTSORTSWAP(p,q) do { \ - pastix_int_t t; \ - long disp_p = (((pastix_int_t*)p)-((pastix_int_t*)base_ptr)); \ - long disp_q = (((pastix_int_t*)q)-((pastix_int_t*)base_ptr)); \ - pastix_int_t * int2ptr = *(pbase+1); \ + spm_int_t t; \ + long disp_p = (((spm_int_t*)p)-((spm_int_t*)base_ptr)); \ + long disp_q = (((spm_int_t*)q)-((spm_int_t*)base_ptr)); \ + spm_int_t * int2ptr = *(pbase+1); \ /* swap integers */ \ - t = *((pastix_int_t *) (p)); \ - *((pastix_int_t *) (p)) = *((pastix_int_t *) (q)); \ - *((pastix_int_t *) (q)) = t; \ + t = *((spm_int_t *) (p)); \ + *((spm_int_t *) (p)) = *((spm_int_t *) (q)); \ + *((spm_int_t *) (q)) = t; \ /* swap on second integer array */ \ t = int2ptr[disp_p]; \ int2ptr[disp_p] = int2ptr[disp_q]; \ int2ptr[disp_q] = t; \ } while (0) -#define INTSORTCMP(p,q) ((*((pastix_int_t *) (p)) < *((pastix_int_t *) (q))) || \ - ((*((pastix_int_t *) (p)) == *((pastix_int_t *) (q))) && \ - ((( pastix_int_t *)(*(pbase+1)))[(((pastix_int_t*)p)-((pastix_int_t*)base_ptr))] < \ - (( pastix_int_t *)(*(pbase+1)))[(((pastix_int_t*)q)-((pastix_int_t*)base_ptr))]))) +#define INTSORTCMP(p,q) ((*((spm_int_t *) (p)) < *((spm_int_t *) (q))) || \ + ((*((spm_int_t *) (p)) == *((spm_int_t *) (q))) && \ + ((( spm_int_t *)(*(pbase+1)))[(((spm_int_t*)p)-((spm_int_t*)base_ptr))] < \ + (( spm_int_t *)(*(pbase+1)))[(((spm_int_t*)q)-((spm_int_t*)base_ptr))]))) #include "integer_sort_mtypes.c" #undef INTSORTNAME #undef INTSORTSIZE @@ -278,11 +274,11 @@ void spmIntMSortIntAsc(void ** const pbase, const pastix_int_t n); /** ******************************************************************************* * - * @fn void spmIntMSortSmallIntAsc(void **const pbase, const pastix_int_t n); + * @fn void spmIntMSortSmallIntAsc(void **const pbase, const spm_int_t n); * @ingroup spm_dev_integer * @brief Sort 2 arrays simultaneously, the first array is an array of - * pastix_int_t and used as primary key for sorting. The second array is an - * other array of pastix_int_t used as secondary key. + * spm_int_t and used as primary key for sorting. The second array is an + * other array of spm_int_t used as secondary key. * ******************************************************************************* * @@ -295,7 +291,7 @@ void spmIntMSortIntAsc(void ** const pbase, const pastix_int_t n); ******************************************************************************* */ /* Declare here for now, because unused */ -void spmIntMSortSmallIntAsc(void ** const pbase, const pastix_int_t n); +void spmIntMSortSmallIntAsc(void ** const pbase, const spm_int_t n); #ifndef DOXYGEN_SHOULD_SKIP_THIS #define INTSORTNAME spmIntMSortSmallIntAsc diff --git a/src/spm_io.c b/src/spm_io.c index bdd7c774963594fa557a6b197233c6ca7fb5bfd3..053e50eb9639d0cf533e2dddb8051048bdc05afb 100644 --- a/src/spm_io.c +++ b/src/spm_io.c @@ -15,7 +15,6 @@ * **/ #include "common.h" -#include "spm.h" /** ******************************************************************************* @@ -37,30 +36,30 @@ * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the read happened successfully, - * @retval PASTIX_ERR_FILE if the input format is incorrect. + * @retval SPM_SUCCESS if the read happened successfully, + * @retval SPM_ERR_FILE if the input format is incorrect. * *******************************************************************************/ static inline int readArrayOfInteger( FILE *stream, - pastix_int_t n, - pastix_int_t *array ) + spm_int_t n, + spm_int_t *array ) { long tmp1, tmp2, tmp3, tmp4; - pastix_int_t i; + spm_int_t i; /* Read 4 by 4 */ for (i=0; i<(n-3); i+=4) { if (4 != fscanf(stream, "%ld %ld %ld %ld", &tmp1, &tmp2, &tmp3, &tmp4)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_int_t)tmp1; - array[i+1] = (pastix_int_t)tmp2; - array[i+2] = (pastix_int_t)tmp3; - array[i+3] = (pastix_int_t)tmp4; + array[i ] = (spm_int_t)tmp1; + array[i+1] = (spm_int_t)tmp2; + array[i+2] = (spm_int_t)tmp3; + array[i+3] = (spm_int_t)tmp4; } assert( n-i < 4 ); @@ -68,34 +67,34 @@ readArrayOfInteger( FILE *stream, { case 3: if (3 != fscanf(stream, "%ld %ld %ld", &tmp1, &tmp2, &tmp3)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_int_t)tmp1; - array[i+1] = (pastix_int_t)tmp2; - array[i+2] = (pastix_int_t)tmp3; + array[i ] = (spm_int_t)tmp1; + array[i+1] = (spm_int_t)tmp2; + array[i+2] = (spm_int_t)tmp3; break; case 2: if (2 != fscanf(stream, "%ld %ld", &tmp1, &tmp2)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_int_t)tmp1; - array[i+1] = (pastix_int_t)tmp2; + array[i ] = (spm_int_t)tmp1; + array[i+1] = (spm_int_t)tmp2; break; case 1: if (1 != fscanf(stream, "%ld", &tmp1)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_int_t)tmp1; + array[i ] = (spm_int_t)tmp1; break; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -118,18 +117,18 @@ readArrayOfInteger( FILE *stream, * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the read happened successfully, - * @retval PASTIX_ERR_FILE if the input format is incorrect. + * @retval SPM_SUCCESS if the read happened successfully, + * @retval SPM_ERR_FILE if the input format is incorrect. * *******************************************************************************/ static inline int readArrayOfComplex64( FILE *stream, - pastix_int_t n, - pastix_complex64_t *array ) + spm_int_t n, + spm_complex64_t *array ) { double tmp1, tmp2, tmp3, tmp4; double tmp5, tmp6, tmp7, tmp8; - pastix_int_t i; + spm_int_t i; /* Read 4 by 4 */ for (i=0; i<(n-3); i+=4) @@ -137,13 +136,13 @@ readArrayOfComplex64( FILE *stream, if (8 != fscanf(stream, "%lg %lg %lg %lg %lg %lg %lg %lg", &tmp1, &tmp2, &tmp3, &tmp4, &tmp5, &tmp6, &tmp7, &tmp8)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex64_t)(tmp1 + I * tmp2); - array[i+1] = (pastix_complex64_t)(tmp3 + I * tmp4); - array[i+2] = (pastix_complex64_t)(tmp5 + I * tmp6); - array[i+3] = (pastix_complex64_t)(tmp7 + I * tmp8); + array[i ] = (spm_complex64_t)(tmp1 + I * tmp2); + array[i+1] = (spm_complex64_t)(tmp3 + I * tmp4); + array[i+2] = (spm_complex64_t)(tmp5 + I * tmp6); + array[i+3] = (spm_complex64_t)(tmp7 + I * tmp8); } assert( n-i < 4 ); @@ -153,35 +152,35 @@ readArrayOfComplex64( FILE *stream, if (6 != fscanf(stream, "%lg %lg %lg %lg %lg %lg", &tmp1, &tmp2, &tmp3, &tmp4, &tmp5, &tmp6)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex64_t)(tmp1 + I * tmp2); - array[i+1] = (pastix_complex64_t)(tmp3 + I * tmp4); - array[i+2] = (pastix_complex64_t)(tmp5 + I * tmp6); + array[i ] = (spm_complex64_t)(tmp1 + I * tmp2); + array[i+1] = (spm_complex64_t)(tmp3 + I * tmp4); + array[i+2] = (spm_complex64_t)(tmp5 + I * tmp6); break; case 2: if (4 != fscanf(stream, "%lg %lg %lg %lg", &tmp1, &tmp2, &tmp3, &tmp4)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex64_t)(tmp1 + I * tmp2); - array[i+1] = (pastix_complex64_t)(tmp3 + I * tmp4); + array[i ] = (spm_complex64_t)(tmp1 + I * tmp2); + array[i+1] = (spm_complex64_t)(tmp3 + I * tmp4); break; case 1: if (2 != fscanf(stream, "%lg %lg", &tmp1, &tmp2)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex64_t)(tmp1 + I * tmp2); + array[i ] = (spm_complex64_t)(tmp1 + I * tmp2); break; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -204,18 +203,18 @@ readArrayOfComplex64( FILE *stream, * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the read happened successfully, - * @retval PASTIX_ERR_FILE if the input format is incorrect. + * @retval SPM_SUCCESS if the read happened successfully, + * @retval SPM_ERR_FILE if the input format is incorrect. * *******************************************************************************/ static inline int readArrayOfComplex32( FILE *stream, - pastix_int_t n, - pastix_complex32_t *array ) + spm_int_t n, + spm_complex32_t *array ) { float tmp1, tmp2, tmp3, tmp4; float tmp5, tmp6, tmp7, tmp8; - pastix_int_t i; + spm_int_t i; /* Read 4 by 4 */ for (i=0; i<(n-3); i+=4) @@ -223,13 +222,13 @@ readArrayOfComplex32( FILE *stream, if (8 != fscanf(stream, "%g %g %g %g %g %g %g %g", &tmp1, &tmp2, &tmp3, &tmp4, &tmp5, &tmp6, &tmp7, &tmp8)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex32_t)(tmp1 + I * tmp2); - array[i+1] = (pastix_complex32_t)(tmp3 + I * tmp4); - array[i+2] = (pastix_complex32_t)(tmp5 + I * tmp6); - array[i+3] = (pastix_complex32_t)(tmp7 + I * tmp8); + array[i ] = (spm_complex32_t)(tmp1 + I * tmp2); + array[i+1] = (spm_complex32_t)(tmp3 + I * tmp4); + array[i+2] = (spm_complex32_t)(tmp5 + I * tmp6); + array[i+3] = (spm_complex32_t)(tmp7 + I * tmp8); } assert( n-i < 4 ); @@ -239,35 +238,35 @@ readArrayOfComplex32( FILE *stream, if (6 != fscanf(stream, "%g %g %g %g %g %g", &tmp1, &tmp2, &tmp3, &tmp4, &tmp5, &tmp6)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex32_t)(tmp1 + I * tmp2); - array[i+1] = (pastix_complex32_t)(tmp3 + I * tmp4); - array[i+2] = (pastix_complex32_t)(tmp5 + I * tmp6); + array[i ] = (spm_complex32_t)(tmp1 + I * tmp2); + array[i+1] = (spm_complex32_t)(tmp3 + I * tmp4); + array[i+2] = (spm_complex32_t)(tmp5 + I * tmp6); break; case 2: if (4 != fscanf(stream, "%g %g %g %g", &tmp1, &tmp2, &tmp3, &tmp4)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex32_t)(tmp1 + I * tmp2); - array[i+1] = (pastix_complex32_t)(tmp3 + I * tmp4); + array[i ] = (spm_complex32_t)(tmp1 + I * tmp2); + array[i+1] = (spm_complex32_t)(tmp3 + I * tmp4); break; case 1: if (2 != fscanf(stream, "%g %g", &tmp1, &tmp2)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } - array[i ] = (pastix_complex32_t)(tmp1 + I * tmp2); + array[i ] = (spm_complex32_t)(tmp1 + I * tmp2); break; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -290,25 +289,25 @@ readArrayOfComplex32( FILE *stream, * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the read happened successfully, - * @retval PASTIX_ERR_FILE if the input format is incorrect. + * @retval SPM_SUCCESS if the read happened successfully, + * @retval SPM_ERR_FILE if the input format is incorrect. * *******************************************************************************/ static inline int readArrayOfDouble( FILE *stream, - pastix_int_t n, + spm_int_t n, double *array ) { double tmp1, tmp2, tmp3, tmp4; - pastix_int_t i; + spm_int_t i; /* Read 4 by 4 */ for (i=0; i<(n-3); i+=4) { if (4 != fscanf(stream, "%lg %lg %lg %lg", &tmp1, &tmp2, &tmp3, &tmp4)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (double)(tmp1); array[i+1] = (double)(tmp2); @@ -322,8 +321,8 @@ readArrayOfDouble( FILE *stream, case 3: if (1 != fscanf(stream, "%lg %lg %lg", &tmp1, &tmp2, &tmp3)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (double)(tmp1); array[i+1] = (double)(tmp2); @@ -333,8 +332,8 @@ readArrayOfDouble( FILE *stream, case 2: if (2 != fscanf(stream, "%lg %lg", &tmp1, &tmp2)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (double)(tmp1); array[i+1] = (double)(tmp2); @@ -343,14 +342,14 @@ readArrayOfDouble( FILE *stream, case 1: if (1 != fscanf(stream, "%lg", &tmp1)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (double)(tmp1); break; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } @@ -374,25 +373,25 @@ readArrayOfDouble( FILE *stream, * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the read happened successfully, - * @retval PASTIX_ERR_FILE if the input format is incorrect. + * @retval SPM_SUCCESS if the read happened successfully, + * @retval SPM_ERR_FILE if the input format is incorrect. * *******************************************************************************/ static inline int readArrayOfFloat( FILE *stream, - pastix_int_t n, + spm_int_t n, float *array ) { float tmp1, tmp2, tmp3, tmp4; - pastix_int_t i; + spm_int_t i; /* Read 4 by 4 */ for (i=0; i<(n-3); i+=4) { if (4 != fscanf(stream, "%g %g %g %g", &tmp1, &tmp2, &tmp3, &tmp4)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (float)(tmp1); array[i+1] = (float)(tmp2); @@ -406,8 +405,8 @@ readArrayOfFloat( FILE *stream, case 3: if (3 != fscanf(stream, "%g %g %g", &tmp1, &tmp2, &tmp3)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (float)(tmp1); array[i+1] = (float)(tmp2); @@ -417,8 +416,8 @@ readArrayOfFloat( FILE *stream, case 2: if (2 != fscanf(stream, "%g %g", &tmp1, &tmp2)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (float)(tmp1); array[i+1] = (float)(tmp2); @@ -426,20 +425,20 @@ readArrayOfFloat( FILE *stream, case 1: if (1 != fscanf(stream, "%g", &tmp1)){ - errorPrint("spmLoad: Wrong input format"); - return PASTIX_ERR_FILE; + spm_print_error("spmLoad: Wrong input format"); + return SPM_ERR_FILE; } array[i ] = (float)(tmp1); break; } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** ******************************************************************************* * - * @ingroup pastix_spm + * @ingroup spm_spm * * @brief Load the spm structure from a file (internal format). * @@ -456,25 +455,25 @@ readArrayOfFloat( FILE *stream, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the load happened successfully, - * @retval PASTIX_ERR_FILE if the input format is incorrect. + * @retval SPM_SUCCESS if the load happened successfully, + * @retval SPM_ERR_FILE if the input format is incorrect. * *******************************************************************************/ int -spmLoad( pastix_spm_t *spm, +spmLoad( spmatrix_t *spm, FILE *infile ) { - pastix_int_t colsize=0, rowsize=0; + spm_int_t colsize=0, rowsize=0; char line[256], *test; - int rc = PASTIX_SUCCESS; + int rc = SPM_SUCCESS; int local_stream = 0; if ( infile == NULL ) { infile = fopen( "matrix.spm", "r" ); if ( infile == NULL ) { - pastix_print_error( "spmLoad: Impossible to open the file matrix.spm\n"); - return PASTIX_ERR_FILE; + spm_print_error( "spmLoad: Impossible to open the file matrix.spm\n"); + return SPM_ERR_FILE; } local_stream = 1; @@ -486,7 +485,7 @@ spmLoad( pastix_spm_t *spm, do { test = fgets( line, 256, infile ); if ( test != line ) { - return PASTIX_ERR_FILE; + return SPM_ERR_FILE; } } while( line[0] == '#' ); @@ -501,12 +500,12 @@ spmLoad( pastix_spm_t *spm, if ( 10 != sscanf( line, "%d %d %d %d %ld %ld %ld %d %ld %d\n", &version, &mtxtype, &flttype, &fmttype, &gN, &n, &nnz, &dof, &nnzexp, &layout ) ) { - return PASTIX_ERR_FILE; + return SPM_ERR_FILE; } /* Handle only version 1 for now */ if (version != 1) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } spm->mtxtype = mtxtype; @@ -525,15 +524,15 @@ spmLoad( pastix_spm_t *spm, } switch(spm->fmttype){ - case PastixCSC: + case SpmCSC: colsize = spm->n + 1; rowsize = spm->nnz; break; - case PastixCSR: + case SpmCSR: colsize = spm->nnz; rowsize = spm->n + 1; break; - case PastixIJV: + case SpmIJV: colsize = spm->nnz; rowsize = spm->nnz; break; @@ -542,18 +541,18 @@ spmLoad( pastix_spm_t *spm, /* * Read colptr */ - spm->colptr = malloc( colsize * sizeof(pastix_int_t) ); + spm->colptr = malloc( colsize * sizeof(spm_int_t) ); rc = readArrayOfInteger( infile, colsize, spm->colptr ); - if (rc != PASTIX_SUCCESS ) { + if (rc != SPM_SUCCESS ) { return rc; } /* * Read rowptr */ - spm->rowptr = malloc( rowsize * sizeof(pastix_int_t) ); + spm->rowptr = malloc( rowsize * sizeof(spm_int_t) ); rc = readArrayOfInteger( infile, rowsize, spm->rowptr ); - if (rc != PASTIX_SUCCESS ) { + if (rc != SPM_SUCCESS ) { return rc; } @@ -564,9 +563,9 @@ spmLoad( pastix_spm_t *spm, spm->dofs = NULL; } else { - spm->dofs = malloc( (spm->n+1) * sizeof(pastix_int_t) ); + spm->dofs = malloc( (spm->n+1) * sizeof(spm_int_t) ); rc = readArrayOfInteger( infile, spm->n+1, spm->dofs ); - if (rc != PASTIX_SUCCESS ) { + if (rc != SPM_SUCCESS ) { return rc; } } @@ -578,9 +577,9 @@ spmLoad( pastix_spm_t *spm, spm->loc2glob = NULL; } else { - spm->loc2glob = malloc( spm->n * sizeof(pastix_int_t) ); + spm->loc2glob = malloc( spm->n * sizeof(spm_int_t) ); rc = readArrayOfInteger( infile, spm->n, spm->dofs ); - if (rc != PASTIX_SUCCESS ) { + if (rc != SPM_SUCCESS ) { return rc; } } @@ -588,26 +587,26 @@ spmLoad( pastix_spm_t *spm, /* * Read values */ - if (spm->flttype == PastixPattern ) { + if (spm->flttype == SpmPattern ) { spm->values = NULL; } else { - spm->values = malloc( spm->nnzexp * pastix_size_of( spm->flttype ) ); + spm->values = malloc( spm->nnzexp * spm_size_of( spm->flttype ) ); } switch( spm->flttype ) { - case PastixPattern: + case SpmPattern: break; - case PastixFloat: + case SpmFloat: rc = readArrayOfFloat( infile, spm->nnzexp, spm->values ); break; - case PastixDouble: + case SpmDouble: rc = readArrayOfDouble( infile, spm->nnzexp, spm->values ); break; - case PastixComplex32: + case SpmComplex32: rc = readArrayOfComplex32( infile, spm->nnzexp, spm->values ); break; - case PastixComplex64: + case SpmComplex64: rc = readArrayOfComplex64( infile, spm->nnzexp, spm->values ); break; } @@ -639,15 +638,15 @@ spmLoad( pastix_spm_t *spm, * ******************************************************************************* * - * @return PASTIX_SUCCESS if the write happened successfully. + * @return SPM_SUCCESS if the write happened successfully. * *******************************************************************************/ static inline int writeArrayOfComplex64( FILE *outfile, - pastix_int_t n, - const pastix_complex64_t *array ) + spm_int_t n, + const spm_complex64_t *array ) { - pastix_int_t i; + spm_int_t i; /* Write 4 by 4 */ for (i=0; i<n; i++) @@ -657,7 +656,7 @@ writeArrayOfComplex64( FILE *outfile, } if ((i-1)%4 !=3) fprintf(outfile, "\n"); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -680,15 +679,15 @@ writeArrayOfComplex64( FILE *outfile, * ******************************************************************************* * - * @return PASTIX_SUCCESS if the write happened successfully. + * @return SPM_SUCCESS if the write happened successfully. * *******************************************************************************/ static inline int writeArrayOfComplex32( FILE *outfile, - pastix_int_t n, - const pastix_complex32_t *array ) + spm_int_t n, + const spm_complex32_t *array ) { - pastix_int_t i; + spm_int_t i; /* Write 4 by 4 */ for (i=0; i<n; i++) @@ -698,7 +697,7 @@ writeArrayOfComplex32( FILE *outfile, } if ((i-1)%4 !=3) fprintf(outfile, "\n"); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -721,15 +720,15 @@ writeArrayOfComplex32( FILE *outfile, * ******************************************************************************* * - * @return PASTIX_SUCCESS if the write happened successfully. + * @return SPM_SUCCESS if the write happened successfully. * *******************************************************************************/ static inline int writeArrayOfDouble( FILE *outfile, - pastix_int_t n, + spm_int_t n, const double *array ) { - pastix_int_t i; + spm_int_t i; /* Write 4 by 4 */ for (i=0; i<n; i++) @@ -739,7 +738,7 @@ writeArrayOfDouble( FILE *outfile, } if ((i-1)%4 !=3) fprintf(outfile, "\n"); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -762,16 +761,16 @@ writeArrayOfDouble( FILE *outfile, * ******************************************************************************* * - * @return PASTIX_SUCCESS if the write happened successfully. + * @return SPM_SUCCESS if the write happened successfully. * * *******************************************************************************/ static inline int writeArrayOfFloat( FILE *outfile, - pastix_int_t n, + spm_int_t n, const float *array ) { - pastix_int_t i; + spm_int_t i; /* Write 4 by 4 */ for (i=0; i<n; i++) @@ -781,13 +780,13 @@ writeArrayOfFloat( FILE *outfile, } if ((i-1)%4 !=3) fprintf(outfile, "\n"); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** ******************************************************************************* * - * @ingroup pastix_spm + * @ingroup spm_spm * * @brief Save the spm structure into a file (internal format). * @@ -803,21 +802,21 @@ writeArrayOfFloat( FILE *outfile, * ******************************************************************************** * - * @return PASTIX_SUCCESS if the save happened successfully. + * @return SPM_SUCCESS if the save happened successfully. * *******************************************************************************/ int -spmSave( const pastix_spm_t *spm, +spmSave( const spmatrix_t *spm, FILE *outfile ) { - pastix_int_t i, colsize, rowsize; + spm_int_t i, colsize, rowsize; int local_stream = 0; if ( outfile == NULL ) { outfile = fopen( "matrix.spm", "w" ); if ( outfile == NULL ) { - pastix_print_error( "spmSave: Impossible to open the file matrix.spm\n"); - return PASTIX_ERR_FILE; + spm_print_error( "spmSave: Impossible to open the file matrix.spm\n"); + return SPM_ERR_FILE; } local_stream = 1; @@ -834,15 +833,15 @@ spmSave( const pastix_spm_t *spm, (int)spm->dof, (long)spm->nnzexp, spm->layout ); switch(spm->fmttype){ - case PastixCSC: + case SpmCSC: colsize = spm->n + 1; rowsize = spm->nnz; break; - case PastixCSR: + case SpmCSR: colsize = spm->nnz; rowsize = spm->n + 1; break; - case PastixIJV: + case SpmIJV: colsize = spm->nnz; rowsize = spm->nnz; break; @@ -899,18 +898,18 @@ spmSave( const pastix_spm_t *spm, * Write values */ switch( spm->flttype ) { - case PastixPattern: + case SpmPattern: break; - case PastixFloat: + case SpmFloat: writeArrayOfFloat( outfile, spm->nnzexp, spm->values ); break; - case PastixDouble: + case SpmDouble: writeArrayOfDouble( outfile, spm->nnzexp, spm->values ); break; - case PastixComplex32: + case SpmComplex32: writeArrayOfComplex32( outfile, spm->nnzexp, spm->values ); break; - case PastixComplex64: + case SpmComplex64: writeArrayOfComplex64( outfile, spm->nnzexp, spm->values ); break; } @@ -918,5 +917,5 @@ spmSave( const pastix_spm_t *spm, if (local_stream) { fclose(outfile); } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/spm_read_driver.c b/src/spm_read_driver.c index f2f1f9d80b1e9b4856ecc5c666e6ef0a1767dfa6..1077595cf96f921932413a1d188525810d776af5 100644 --- a/src/spm_read_driver.c +++ b/src/spm_read_driver.c @@ -15,7 +15,6 @@ * **/ #include "common.h" -#include "spm.h" #include "spm_drivers.h" #if defined(HAVE_SCOTCH) #include <scotch.h> @@ -24,7 +23,7 @@ /** ******************************************************************************* * - * @ingroup pastix_spm + * @ingroup spm_spm * * @brief Import a matrix file into a spm structure. * @@ -36,14 +35,14 @@ * * @param[in] driver * This defines the driver to use to create the spm structure: - * - PastixDriverRSA - * - PastixDriverHB - * - PastixDriverIJV - * - PastixDriverMM - * - PastixDriverLaplacian - * - PastixDriverXLaplacian - * - PastixDriverGraph - * - PastixDriverSPM + * - SpmDriverRSA + * - SpmDriverHB + * - SpmDriverIJV + * - SpmDriverMM + * - SpmDriverLaplacian + * - SpmDriverXLaplacian + * - SpmDriverGraph + * - SpmDriverSPM * * @param[in] filename * The name of the file that stores the matrix (see driver). @@ -59,74 +58,75 @@ * ******************************************************************************** * - * @retval PASTIX_SUCCESS if the file reading happened successfully, - * @retval PASTIX_ERR_BADPARAMETER if one the parameter is incorrect. + * @retval SPM_SUCCESS if the file reading happened successfully, + * @retval SPM_ERR_BADPARAMETER if one the parameter is incorrect. * *******************************************************************************/ int -spmReadDriver( pastix_driver_t driver, +spmReadDriver( spm_driver_t driver, const char *filename, - pastix_spm_t *spm, + spmatrix_t *spm, MPI_Comm comm ) { int mpirank = 0; - int mpiinit; + /* int mpiinit; */ spmInit(spm); - MPI_Initialized( &mpiinit ); - if (mpiinit) { - MPI_Comm_rank( comm, &mpirank ); - } + /* MPI_Initialized( &mpiinit ); */ + /* if (mpiinit) { */ + /* MPI_Comm_rank( comm, &mpirank ); */ + /* } */ + mpirank = 0; if ( mpirank == 0 ) { switch(driver) { -#if defined(PASTIX_WITH_FORTRAN) - case PastixDriverRSA: +#if defined(SPM_WITH_FORTRAN) + case SpmDriverRSA: readRSA( filename, spm ); break; #endif - case PastixDriverHB: + case SpmDriverHB: /* TODO: Possible to read the RHS, the solution or a guess of the solution */ readHB( filename, spm ); break; - case PastixDriverIJV: + case SpmDriverIJV: readIJV( filename, spm ); break; - case PastixDriverMM: + case SpmDriverMM: readMM( filename, spm ); break; - case PastixDriverLaplacian: + case SpmDriverLaplacian: genLaplacian( filename, spm ); break; - case PastixDriverXLaplacian: + case SpmDriverXLaplacian: genExtendedLaplacian( filename, spm ); break; - case PastixDriverSPM: + case SpmDriverSPM: { FILE *file = fopen( filename, "r" ); if ( file == NULL ) { - pastix_print_error("spmReadDriver: impossible to open the file %s\n", filename ); - return PASTIX_ERR_FILE; + fprintf( stderr,"spmReadDriver: impossible to open the file %s\n", filename ); + return SPM_ERR_FILE; } - if ( spmLoad( spm, file ) != PASTIX_SUCCESS ) { - pastix_print_error("spmReadDriver: error while reading the file %s\n", filename ); - return PASTIX_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 ); } break; - case PastixDriverGraph: + case SpmDriverGraph: #if defined(HAVE_SCOTCH) { SCOTCH_Graph sgraph; @@ -134,15 +134,15 @@ spmReadDriver( pastix_driver_t driver, file = fopen( filename, "r" ); if ( file == NULL ) { - pastix_print_error("spmReadDriver: impossible to open the file %s\n", filename ); - return PASTIX_ERR_FILE; + fprintf( stderr,"spmReadDriver: impossible to open the file %s\n", filename ); + return SPM_ERR_FILE; } /* Check integer compatibility */ - if (sizeof(pastix_int_t) != sizeof(SCOTCH_Num)) { - pastix_print_error("Inconsistent integer type\n"); + if (sizeof(spm_int_t) != sizeof(SCOTCH_Num)) { + fprintf( stderr,"Inconsistent integer type\n"); fclose(file); - return PASTIX_ERR_INTEGER_TYPE; + return SPM_ERR_INTEGER_TYPE; } SCOTCH_graphLoad( &sgraph, file, 1, 0 ); @@ -150,9 +150,9 @@ spmReadDriver( pastix_driver_t driver, &(spm->nnz), &(spm->rowptr), NULL ); fclose(file); - spm->mtxtype = PastixGeneral; - spm->flttype = PastixPattern; - spm->fmttype = PastixCSC; + spm->mtxtype = SpmGeneral; + spm->flttype = SpmPattern; + spm->fmttype = SpmCSC; spm->dof = 1; spmUpdateComputedFields( spm ); } @@ -160,7 +160,7 @@ spmReadDriver( pastix_driver_t driver, { fprintf(stderr, "Scotch driver to read graph file unavailable.\n" "Compile with Scotch support to provide it\n"); - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } #endif break; @@ -170,35 +170,35 @@ spmReadDriver( pastix_driver_t driver, } } - if ( mpiinit ) - { - pastix_int_t nnz = spm->nnz; - - MPI_Bcast( spm, sizeof(pastix_spm_t), MPI_CHAR, 0, comm ); - MPI_Bcast( &nnz, 1, PASTIX_MPI_INT, 0, comm ); - - if ( mpirank != 0 ) - { - spm->colptr = (pastix_int_t *) malloc((spm->gN+1) * sizeof(pastix_int_t)); - spm->rowptr = (pastix_int_t *) malloc(nnz * sizeof(pastix_int_t)); - spm->loc2glob = NULL; - spm->loc2glob = NULL; - } - - MPI_Bcast( spm->colptr, spm->gN+1, PASTIX_MPI_INT, 0, comm ); - MPI_Bcast( spm->rowptr, nnz, PASTIX_MPI_INT, 0, comm ); - - if ( spm->flttype != PastixPattern ) { - size_t eltsize = pastix_size_of( spm->flttype ); - if ( mpirank != 0 ) { - spm->values = (void *) malloc(nnz * eltsize); - } - MPI_Bcast( spm->values, nnz * eltsize, MPI_CHAR, 0, comm ); - } - } + /* 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 ); */ + /* } */ + /* } */ spmUpdateComputedFields( spm ); (void)comm; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/z_spm.c b/src/z_spm.c index cf1806a4ce04ac4376ba5097a3345b97a9955a62..34e59f5a9116e2ae6feabe883d5fd46a14ad7388 100644 --- a/src/z_spm.c +++ b/src/z_spm.c @@ -15,8 +15,8 @@ * **/ #include "common.h" -#include "spm.h" #include "z_spm.h" +#include <string.h> /** ******************************************************************************* @@ -39,14 +39,14 @@ * *******************************************************************************/ void -z_spmSort( pastix_spm_t *spm ) +z_spmSort( spmatrix_t *spm ) { - pastix_int_t *colptr = spm->colptr; - pastix_int_t *rowptr = spm->rowptr; - pastix_complex64_t *values = spm->values; + spm_int_t *colptr = spm->colptr; + spm_int_t *rowptr = spm->rowptr; + spm_complex64_t *values = spm->values; void *sortptr[2]; - pastix_int_t n = spm->n; - pastix_int_t i, size; + spm_int_t n = spm->n; + spm_int_t i, size; (void)sortptr; if (spm->dof > 1){ @@ -55,7 +55,7 @@ z_spmSort( pastix_spm_t *spm ) } /* Sort in place each subset */ - if ( spm->fmttype == PastixCSC ) { + if ( spm->fmttype == SpmCSC ) { for (i=0; i<n; i++, colptr++) { size = colptr[1] - colptr[0]; @@ -71,7 +71,7 @@ z_spmSort( pastix_spm_t *spm ) values += size; } } - else if ( spm->fmttype == PastixCSR ) { + else if ( spm->fmttype == SpmCSR ) { for (i=0; i<n; i++, rowptr++) { size = rowptr[1] - rowptr[0]; @@ -113,21 +113,21 @@ z_spmSort( pastix_spm_t *spm ) * @return The number of vertices that were merged * *******************************************************************************/ -pastix_int_t -z_spmMergeDuplicate( pastix_spm_t *spm ) +spm_int_t +z_spmMergeDuplicate( spmatrix_t *spm ) { - pastix_int_t *colptr = spm->colptr; - pastix_int_t *oldrow = spm->rowptr; - pastix_int_t *newrow = spm->rowptr; - pastix_complex64_t *newval = spm->values; - pastix_complex64_t *oldval = spm->values; - pastix_int_t n = spm->n; - pastix_int_t baseval = spm->colptr[0]; - pastix_int_t dof2 = spm->dof * spm->dof; - pastix_int_t idx, i, j, d, size; - pastix_int_t merge = 0; - - if ( spm->fmttype == PastixCSC ) { + spm_int_t *colptr = spm->colptr; + spm_int_t *oldrow = spm->rowptr; + spm_int_t *newrow = spm->rowptr; + spm_complex64_t *newval = spm->values; + spm_complex64_t *oldval = spm->values; + spm_int_t n = spm->n; + spm_int_t baseval = spm->colptr[0]; + spm_int_t dof2 = spm->dof * spm->dof; + spm_int_t idx, i, j, d, size; + spm_int_t merge = 0; + + if ( spm->fmttype == SpmCSC ) { idx = 0; for (i=0; i<n; i++, colptr++) { @@ -138,7 +138,7 @@ z_spmMergeDuplicate( pastix_spm_t *spm ) if ( newrow != oldrow ) { newrow[0] = oldrow[0]; #if !defined(PRECISION_p) - memcpy( newval, oldval, dof2 * sizeof(pastix_complex64_t) ); + memcpy( newval, oldval, dof2 * sizeof(spm_complex64_t) ); #endif } @@ -165,14 +165,14 @@ z_spmMergeDuplicate( pastix_spm_t *spm ) spm->nnz = spm->nnz - merge; spm->gnnz = spm->nnz; - newrow = malloc( spm->nnz * sizeof(pastix_int_t) ); - memcpy( newrow, spm->rowptr, spm->nnz * sizeof(pastix_int_t) ); + newrow = malloc( spm->nnz * sizeof(spm_int_t) ); + memcpy( newrow, spm->rowptr, spm->nnz * sizeof(spm_int_t) ); free(spm->rowptr); spm->rowptr = newrow; #if !defined(PRECISION_p) - newval = malloc( spm->nnz * dof2 * sizeof(pastix_int_t) ); - memcpy( newval, spm->values, spm->nnz * dof2 * sizeof(pastix_complex64_t) ); + newval = malloc( spm->nnz * dof2 * sizeof(spm_int_t) ); + memcpy( newval, spm->values, spm->nnz * dof2 * sizeof(spm_complex64_t) ); free(spm->values); spm->values = newval; #endif @@ -206,24 +206,24 @@ z_spmMergeDuplicate( pastix_spm_t *spm ) * @retval Return the number of entries added to the matrix. * *******************************************************************************/ -pastix_int_t -z_spmSymmetrize( pastix_spm_t *spm ) +spm_int_t +z_spmSymmetrize( spmatrix_t *spm ) { - pastix_complex64_t *oldval, *valtmp, *newval = NULL; - pastix_int_t *oldcol, *coltmp, *newcol = NULL; - pastix_int_t *oldrow, *rowtmp, *newrow = NULL; - pastix_int_t *toaddtab = NULL; - pastix_int_t *toaddtmp, toaddcnt, toaddsze; - pastix_int_t n = spm->n; - pastix_int_t dof2 = spm->dof * spm->dof; - pastix_int_t i, j, k, r, size; - pastix_int_t baseval; + spm_complex64_t *oldval, *valtmp, *newval = NULL; + spm_int_t *oldcol, *coltmp, *newcol = NULL; + spm_int_t *oldrow, *rowtmp, *newrow = NULL; + spm_int_t *toaddtab = NULL; + spm_int_t *toaddtmp, toaddcnt, toaddsze; + spm_int_t n = spm->n; + spm_int_t dof2 = spm->dof * spm->dof; + spm_int_t i, j, k, r, size; + spm_int_t baseval; toaddcnt = 0; toaddsze = 0; - if ( (spm->fmttype == PastixCSC) || (spm->fmttype == PastixCSR) ) { - if (spm->fmttype == PastixCSC) { + if ( (spm->fmttype == SpmCSC) || (spm->fmttype == SpmCSR) ) { + if (spm->fmttype == SpmCSC) { oldcol = spm->colptr; coltmp = spm->colptr; oldrow = spm->rowptr; @@ -245,8 +245,8 @@ z_spmSymmetrize( pastix_spm_t *spm ) j = rowtmp[0]-baseval; if ( i != j ) { /* Look for the element (j, i) */ - pastix_int_t frow = oldcol[ j ] - baseval; - pastix_int_t lrow = oldcol[ j+1 ] - baseval; + spm_int_t frow = oldcol[ j ] - baseval; + spm_int_t lrow = oldcol[ j+1 ] - baseval; int found = 0; for (k = frow; (k < lrow); k++) @@ -265,19 +265,19 @@ z_spmSymmetrize( pastix_spm_t *spm ) if ( !found ) { if ( newcol == NULL ) { - newcol = malloc( (spm->n+1) * sizeof(pastix_int_t) ); + newcol = malloc( (spm->n+1) * sizeof(spm_int_t) ); for (k=0; k<spm->n; k++) { newcol[k] = oldcol[k+1] - oldcol[k]; } /* Let's start with a buffer that will contain 5% of extra elements */ - toaddsze = pastix_imax( 0.05 * (double)spm->nnz, 1 ); - MALLOC_INTERN(toaddtab, 2*toaddsze, pastix_int_t); + toaddsze = spm_imax( 0.05 * (double)spm->nnz, 1 ); + toaddtab = malloc( 2*toaddsze * sizeof(spm_int_t) ); } if (toaddcnt >= toaddsze) { toaddsze *= 2; - toaddtab = (pastix_int_t*)memRealloc(toaddtab, 2*toaddsze*sizeof(pastix_int_t)); + toaddtab = (spm_int_t*)realloc( toaddtab, 2*toaddsze*sizeof(spm_int_t) ); } /* Newcol stores the number of elements per column */ @@ -292,7 +292,7 @@ z_spmSymmetrize( pastix_spm_t *spm ) } if (toaddcnt > 0) { - pastix_int_t newsize, oldsize; + spm_int_t newsize, oldsize; /* Sort the array per column */ spmIntSort2Asc1(toaddtab, toaddcnt); @@ -300,9 +300,9 @@ z_spmSymmetrize( pastix_spm_t *spm ) spm->nnz = spm->nnz + toaddcnt; spm->gnnz = spm->nnz; - newrow = malloc( spm->nnz * sizeof(pastix_int_t) ); + newrow = malloc( spm->nnz * sizeof(spm_int_t) ); #if !defined(PRECISION_p) - newval = malloc( spm->nnz * dof2 * sizeof(pastix_complex64_t) ); + newval = malloc( spm->nnz * dof2 * sizeof(spm_complex64_t) ); #endif coltmp = newcol; rowtmp = newrow; @@ -316,9 +316,9 @@ z_spmSymmetrize( pastix_spm_t *spm ) { /* Copy the existing elements */ oldsize = oldcol[1] - oldcol[0]; - memcpy( rowtmp, oldrow, oldsize * sizeof(pastix_int_t) ); + memcpy( rowtmp, oldrow, oldsize * sizeof(spm_int_t) ); #if !defined(PRECISION_p) - memcpy( valtmp, oldval, oldsize * dof2 * sizeof(pastix_complex64_t) ); + memcpy( valtmp, oldval, oldsize * dof2 * sizeof(spm_complex64_t) ); #endif oldrow += oldsize; @@ -344,7 +344,7 @@ z_spmSymmetrize( pastix_spm_t *spm ) #if !defined(PRECISION_p) /* Add 0.s for the associated values */ - memset( valtmp, 0, added * dof2 * sizeof(pastix_complex64_t) ); + memset( valtmp, 0, added * dof2 * sizeof(spm_complex64_t) ); valtmp += added * dof2; #endif } @@ -360,7 +360,7 @@ z_spmSymmetrize( pastix_spm_t *spm ) free( spm->colptr ); free( spm->rowptr ); free( spm->values ); - if (spm->fmttype == PastixCSC) { + if (spm->fmttype == SpmCSC) { spm->colptr = newcol; spm->rowptr = newrow; } diff --git a/src/z_spm.h b/src/z_spm.h index 7143bddea24c2c0b370cd8205f8391070021431f..de270d3113d990ea12d39fb5f37d093def9e9ff2 100644 --- a/src/z_spm.h +++ b/src/z_spm.h @@ -23,50 +23,50 @@ /** * Integer routines */ -void z_spmIntSortAsc(void ** const pbase, const pastix_int_t n); +void z_spmIntSortAsc(void ** const pbase, const spm_int_t n); /** * Conversion routines */ -int z_spmConvertCSC2CSR( pastix_spm_t *spm ); -int z_spmConvertCSC2IJV( pastix_spm_t *spm ); -int z_spmConvertCSR2CSC( pastix_spm_t *spm ); -int z_spmConvertCSR2IJV( pastix_spm_t *spm ); -int z_spmConvertIJV2CSC( pastix_spm_t *spm ); -int z_spmConvertIJV2CSR( pastix_spm_t *spm ); +int z_spmConvertCSC2CSR( spmatrix_t *spm ); +int z_spmConvertCSC2IJV( spmatrix_t *spm ); +int z_spmConvertCSR2CSC( spmatrix_t *spm ); +int z_spmConvertCSR2IJV( spmatrix_t *spm ); +int z_spmConvertIJV2CSC( spmatrix_t *spm ); +int z_spmConvertIJV2CSR( spmatrix_t *spm ); -pastix_complex64_t *z_spm2dense( const pastix_spm_t *spm ); +spm_complex64_t *z_spm2dense( const spmatrix_t *spm ); /** * Matrix-Vector and matrix-matrix product routines */ -int z_spmCSCMatVec(const pastix_trans_t trans, const void *alpha, const pastix_spm_t *spm, const void *x, const void *beta, void *y); -int z_spmCSCMatMat(const pastix_trans_t trans, pastix_int_t n, const void *alpha, const pastix_spm_t *A, const void *B, pastix_int_t ldb, const void *beta, void *Cptr, pastix_int_t ldc ); +int z_spmCSCMatVec(const spm_trans_t trans, const void *alpha, const spmatrix_t *spm, const void *x, const void *beta, void *y); +int z_spmCSCMatMat(const spm_trans_t trans, spm_int_t n, const void *alpha, const spmatrix_t *A, const void *B, spm_int_t ldb, const void *beta, void *Cptr, spm_int_t ldc ); /** * Norm computation routines */ -double z_spmNorm( int ntype, const pastix_spm_t *spm ); +double z_spmNorm( int ntype, const spmatrix_t *spm ); /** * Extra routines */ -void z_spmSort( pastix_spm_t *spm ); -pastix_int_t z_spmMergeDuplicate( pastix_spm_t *spm ); -pastix_int_t z_spmSymmetrize( pastix_spm_t *spm ); +void z_spmSort( spmatrix_t *spm ); +spm_int_t z_spmMergeDuplicate( spmatrix_t *spm ); +spm_int_t z_spmSymmetrize( spmatrix_t *spm ); -int z_spmGenRHS(pastix_rhstype_t type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb ); -int z_spmCheckAxb( pastix_fixdbl_t eps, int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx ); +int z_spmGenRHS(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *x, int ldx, void *b, int ldb ); +int z_spmCheckAxb( spm_fixdbl_t eps, int nrhs, const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx ); /** * Output routines */ -void z_spmDensePrint( FILE *f, pastix_int_t m, pastix_int_t n, const pastix_complex64_t *A, pastix_int_t lda ); -void z_spmPrint( FILE *f, const pastix_spm_t *spm ); +void z_spmDensePrint( FILE *f, spm_int_t m, spm_int_t n, const spm_complex64_t *A, spm_int_t lda ); +void z_spmPrint( FILE *f, const spmatrix_t *spm ); -pastix_spm_t *z_spmExpand(const pastix_spm_t *spm); -void z_spmDofExtend(pastix_spm_t *spm); -void z_spmScal( const double alpha, pastix_spm_t *spm ); +spmatrix_t *z_spmExpand(const spmatrix_t *spm); +void z_spmDofExtend(spmatrix_t *spm); +void z_spmScal( const double alpha, spmatrix_t *spm ); #endif /* _z_spm_h_ */ diff --git a/src/z_spm_2dense.c b/src/z_spm_2dense.c index cbca5947f0f0adf310740efbed43fb8496e127c6..e236ac6208ffee95bbfd8a00685b5ce6beb0b0fb 100644 --- a/src/z_spm_2dense.c +++ b/src/z_spm_2dense.c @@ -16,15 +16,7 @@ * @precisions normal z -> c d s * **/ -#include <stdint.h> -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> -#include <assert.h> -#include "pastix.h" #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -48,26 +40,26 @@ * @return A dense matrix in Lapack layout format * *******************************************************************************/ -pastix_complex64_t * -z_spmCSC2dense( const pastix_spm_t *spm ) +spm_complex64_t * +z_spmCSC2dense( const spmatrix_t *spm ) { - pastix_int_t i, j, k, lda, baseval; - pastix_complex64_t *A, *valptr; - pastix_int_t *colptr, *rowptr; + spm_int_t i, j, k, lda, baseval; + spm_complex64_t *A, *valptr; + spm_int_t *colptr, *rowptr; - assert( spm->fmttype == PastixCSC ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmCSC ); + assert( spm->flttype == SpmComplex64 ); lda = spm->gNexp; - A = (pastix_complex64_t*)malloc(lda * lda * sizeof(pastix_complex64_t)); - memset( A, 0, lda * lda * sizeof(pastix_complex64_t)); + A = (spm_complex64_t*)malloc(lda * lda * sizeof(spm_complex64_t)); + memset( A, 0, lda * lda * sizeof(spm_complex64_t)); baseval = spmFindBase( spm ); i = 0; j = 0; colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); /** * Constant degree of fredom of 1 @@ -75,7 +67,7 @@ z_spmCSC2dense( const pastix_spm_t *spm ) if ( spm->dof == 1 ) { switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(j=0; j<spm->n; j++, colptr++) { for(k=colptr[0]; k<colptr[1]; k++, rowptr++, valptr++) @@ -93,7 +85,7 @@ z_spmCSC2dense( const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(j=0; j<spm->n; j++, colptr++) { for(k=colptr[0]; k<colptr[1]; k++, rowptr++, valptr++) @@ -104,7 +96,7 @@ z_spmCSC2dense( const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(j=0; j<spm->n; j++, colptr++) { @@ -120,12 +112,12 @@ z_spmCSC2dense( const pastix_spm_t *spm ) * General degree of freedom (constant or variable) */ else { - pastix_int_t k, ii, jj, dofi, dofj, col, row; - pastix_int_t *dofs = spm->dofs; + spm_int_t k, ii, jj, dofi, dofj, col, row; + spm_int_t *dofs = spm->dofs; switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(j=0; j<spm->n; j++, colptr++) { dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; @@ -155,7 +147,7 @@ z_spmCSC2dense( const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(j=0; j<spm->n; j++, colptr++) { dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; @@ -178,7 +170,7 @@ z_spmCSC2dense( const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(j=0; j<spm->n; j++, colptr++) { @@ -226,26 +218,26 @@ z_spmCSC2dense( const pastix_spm_t *spm ) * @return A dense matrix in Lapack layout format * *******************************************************************************/ -pastix_complex64_t * -z_spmCSR2dense( const pastix_spm_t *spm ) +spm_complex64_t * +z_spmCSR2dense( const spmatrix_t *spm ) { - pastix_int_t i, j, k, lda, baseval; - pastix_complex64_t *A, *valptr; - pastix_int_t *colptr, *rowptr; + spm_int_t i, j, k, lda, baseval; + spm_complex64_t *A, *valptr; + spm_int_t *colptr, *rowptr; - assert( spm->fmttype == PastixCSR ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmCSR ); + assert( spm->flttype == SpmComplex64 ); lda = spm->gNexp; - A = (pastix_complex64_t*)malloc(lda * lda * sizeof(pastix_complex64_t)); - memset( A, 0, lda * lda * sizeof(pastix_complex64_t)); + A = (spm_complex64_t*)malloc(lda * lda * sizeof(spm_complex64_t)); + memset( A, 0, lda * lda * sizeof(spm_complex64_t)); baseval = spmFindBase( spm ); i = 0; j = 0; colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); /** * Constant degree of fredom of 1 @@ -253,7 +245,7 @@ z_spmCSR2dense( const pastix_spm_t *spm ) if ( spm->dof == 1 ) { switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(i=0; i<spm->n; i++, rowptr++) { for(k=rowptr[0]; k<rowptr[1]; k++, colptr++, valptr++) @@ -271,7 +263,7 @@ z_spmCSR2dense( const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(i=0; i<spm->n; i++, rowptr++) { for(k=rowptr[0]; k<rowptr[1]; k++, colptr++, valptr++) @@ -282,7 +274,7 @@ z_spmCSR2dense( const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(i=0; i<spm->n; i++, rowptr++) { @@ -298,12 +290,12 @@ z_spmCSR2dense( const pastix_spm_t *spm ) * General degree of freedom (constant or variable) */ else { - pastix_int_t k, ii, jj, dofi, dofj, col, row; - pastix_int_t *dofs = spm->dofs; + spm_int_t k, ii, jj, dofi, dofj, col, row; + spm_int_t *dofs = spm->dofs; switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(i=0; i<spm->n; i++, rowptr++) { dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; @@ -333,7 +325,7 @@ z_spmCSR2dense( const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(i=0; i<spm->n; i++, rowptr++) { dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; @@ -356,7 +348,7 @@ z_spmCSR2dense( const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(i=0; i<spm->n; i++, rowptr++) { @@ -404,26 +396,26 @@ z_spmCSR2dense( const pastix_spm_t *spm ) * @return A dense matrix in Lapack layout format * *******************************************************************************/ -pastix_complex64_t * -z_spmIJV2dense( const pastix_spm_t *spm ) +spm_complex64_t * +z_spmIJV2dense( const spmatrix_t *spm ) { - pastix_int_t i, j, k, lda, baseval; - pastix_complex64_t *A, *valptr; - pastix_int_t *colptr, *rowptr; + spm_int_t i, j, k, lda, baseval; + spm_complex64_t *A, *valptr; + spm_int_t *colptr, *rowptr; - assert( spm->fmttype == PastixIJV ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmIJV ); + assert( spm->flttype == SpmComplex64 ); lda = spm->gNexp; - A = (pastix_complex64_t*)malloc(lda * lda * sizeof(pastix_complex64_t)); - memset( A, 0, lda * lda * sizeof(pastix_complex64_t)); + A = (spm_complex64_t*)malloc(lda * lda * sizeof(spm_complex64_t)); + memset( A, 0, lda * lda * sizeof(spm_complex64_t)); baseval = spmFindBase( spm ); i = 0; j = 0; colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); /** * Constant degree of fredom of 1 @@ -431,7 +423,7 @@ z_spmIJV2dense( const pastix_spm_t *spm ) if ( spm->dof == 1 ) { switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(k=0; k<spm->nnz; k++, rowptr++, colptr++, valptr++) { i = *rowptr - baseval; @@ -448,7 +440,7 @@ z_spmIJV2dense( const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(k=0; k<spm->nnz; k++, rowptr++, colptr++, valptr++) { i = *rowptr - baseval; @@ -458,7 +450,7 @@ z_spmIJV2dense( const pastix_spm_t *spm ) A[ i * lda + j ] = *valptr; } break; - case PastixGeneral: + case SpmGeneral: default: for(k=0; k<spm->nnz; k++, rowptr++, colptr++, valptr++) { @@ -473,12 +465,12 @@ z_spmIJV2dense( const pastix_spm_t *spm ) * General degree of freedom (constant or variable) */ else { - pastix_int_t k, ii, jj, dofi, dofj, col, row; - pastix_int_t *dofs = spm->dofs; + spm_int_t k, ii, jj, dofi, dofj, col, row; + spm_int_t *dofs = spm->dofs; switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { i = *rowptr - baseval; @@ -514,7 +506,7 @@ z_spmIJV2dense( const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { i = *rowptr - baseval; @@ -544,7 +536,7 @@ z_spmIJV2dense( const pastix_spm_t *spm ) } break; - case PastixGeneral: + case SpmGeneral: default: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { @@ -598,15 +590,15 @@ z_spmIJV2dense( const pastix_spm_t *spm ) * @return A dense matrix in Lapack layout format * *******************************************************************************/ -pastix_complex64_t * -z_spm2dense( const pastix_spm_t *spm ) +spm_complex64_t * +z_spm2dense( const spmatrix_t *spm ) { switch (spm->fmttype) { - case PastixCSC: + case SpmCSC: return z_spmCSC2dense( spm ); - case PastixCSR: + case SpmCSR: return z_spmCSR2dense( spm ); - case PastixIJV: + case SpmIJV: return z_spmIJV2dense( spm ); } return NULL; @@ -639,9 +631,9 @@ z_spm2dense( const pastix_spm_t *spm ) * *******************************************************************************/ void -z_spmDensePrint( FILE *f, pastix_int_t m, pastix_int_t n, const pastix_complex64_t *A, pastix_int_t lda ) +z_spmDensePrint( FILE *f, spm_int_t m, spm_int_t n, const spm_complex64_t *A, spm_int_t lda ) { - pastix_int_t i, j; + spm_int_t i, j; for(j=0; j<n; j++) { diff --git a/src/z_spm_convert_to_csc.c b/src/z_spm_convert_to_csc.c index d6d56196cb87835b0470b0cf21049cbab67b01a4..971ddf0f5cbd1f9c24cdc4140963f560ee287be3 100644 --- a/src/z_spm_convert_to_csc.c +++ b/src/z_spm_convert_to_csc.c @@ -16,7 +16,6 @@ * **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -35,22 +34,22 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS + * @retval SPM_SUCCESS * *******************************************************************************/ int -z_spmConvertIJV2CSC( pastix_spm_t *spm ) +z_spmConvertIJV2CSC( spmatrix_t *spm ) { #if !defined(PRECISION_p) - pastix_complex64_t *navals = NULL; - pastix_complex64_t *oavals = NULL; + spm_complex64_t *navals = NULL; + spm_complex64_t *oavals = NULL; #endif - pastix_int_t *spmptx, *otmp; - pastix_int_t i, j, tmp, baseval, total; - pastix_spm_t oldspm; + spm_int_t *spmptx, *otmp; + spm_int_t i, j, tmp, baseval, total; + spmatrix_t oldspm; /* Backup the input */ - memcpy( &oldspm, spm, sizeof(pastix_spm_t) ); + memcpy( &oldspm, spm, sizeof(spmatrix_t) ); /* * Check the baseval, we consider that arrays are sorted by columns or rows @@ -58,7 +57,7 @@ z_spmConvertIJV2CSC( pastix_spm_t *spm ) baseval = spmFindBase( spm ); /* Compute the new colptr */ - spm->colptr = (pastix_int_t *) calloc(spm->n+1,sizeof(pastix_int_t)); + spm->colptr = (spm_int_t *) calloc(spm->n+1,sizeof(spm_int_t)); /* Compute the number of edges per row */ spmptx = spm->colptr - baseval; @@ -80,14 +79,14 @@ z_spmConvertIJV2CSC( pastix_spm_t *spm ) assert( total == spm->nnz ); /* Sort the rows and avals arrays by column */ - spm->rowptr = malloc(spm->nnz * sizeof(pastix_int_t)); + spm->rowptr = malloc(spm->nnz * sizeof(spm_int_t)); #if defined(PRECISION_p) spm->values = NULL; #else - spm->values = malloc(spm->nnz * sizeof(pastix_complex64_t)); - navals = (pastix_complex64_t*)(spm->values); - oavals = (pastix_complex64_t*)(oldspm.values); + spm->values = malloc(spm->nnz * sizeof(spm_complex64_t)); + navals = (spm_complex64_t*)(spm->values); + oavals = (spm_complex64_t*)(oldspm.values); #endif for (j=0; j<spm->nnz; j++) @@ -119,9 +118,9 @@ z_spmConvertIJV2CSC( pastix_spm_t *spm ) spmExit( &oldspm ); - spm->fmttype = PastixCSC; + spm->fmttype = SpmCSC; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -132,7 +131,7 @@ z_spmConvertIJV2CSC( pastix_spm_t *spm ) * @brief convert a matrix in CSR format to a matrix in CSC * format. * - * If the matrix is PastixSymmetric or PastixHermitian, then the + * If the matrix is SpmSymmetric or SpmHermitian, then the * transpose or respectively the conjugate is returned. * ******************************************************************************* @@ -143,26 +142,26 @@ z_spmConvertIJV2CSC( pastix_spm_t *spm ) * ******************************************************************************* * - * @retval PASTIX_SUCCESS + * @retval SPM_SUCCESS * *******************************************************************************/ int -z_spmConvertCSR2CSC( pastix_spm_t *spm ) +z_spmConvertCSR2CSC( spmatrix_t *spm ) { assert( spm->loc2glob == NULL ); - assert( spm->fmttype == PastixCSR ); + assert( spm->fmttype == SpmCSR ); - spm->fmttype = PastixCSC; + spm->fmttype = SpmCSC; switch( spm->mtxtype ) { #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: { - /* Similar to PastixSymmetric case with conjugate of the values */ - pastix_complex64_t *valptr = spm->values; - pastix_int_t *colptr = spm->colptr; - pastix_int_t *rowptr = spm->rowptr; - pastix_int_t i, j; + /* Similar to SpmSymmetric case with conjugate of the values */ + spm_complex64_t *valptr = spm->values; + spm_int_t *colptr = spm->colptr; + spm_int_t *rowptr = spm->rowptr; + spm_int_t i, j; for(i=0; i<spm->n; i++, rowptr++){ for(j=rowptr[0]; j<rowptr[1]; j++, colptr++, valptr++) { @@ -172,44 +171,44 @@ z_spmConvertCSR2CSC( pastix_spm_t *spm ) } } } - pastix_attr_fallthrough; + spm_attr_fallthrough; #endif - case PastixSymmetric: + case SpmSymmetric: { - pastix_int_t *tmp; + spm_int_t *tmp; /* Just need to swap the pointers */ tmp = spm->rowptr; spm->rowptr = spm->colptr; spm->colptr = tmp; - spm->fmttype = PastixCSC; + spm->fmttype = SpmCSC; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } break; - case PastixGeneral: + case SpmGeneral: default: { - pastix_int_t *row_csc; - pastix_int_t *col_csc; + spm_int_t *row_csc; + spm_int_t *col_csc; #if !defined(PRECISION_p) - pastix_complex64_t *val_csc; - pastix_complex64_t *valptr = (pastix_complex64_t*)(spm->values); + spm_complex64_t *val_csc; + spm_complex64_t *valptr = (spm_complex64_t*)(spm->values); #endif - pastix_int_t j, k, col, row, nnz, baseval; + spm_int_t j, k, col, row, nnz, baseval; baseval = spmFindBase( spm ); nnz = spm->nnz; - row_csc = malloc(nnz * sizeof(pastix_int_t)); - col_csc = calloc(spm->n+1,sizeof(pastix_int_t)); + row_csc = malloc(nnz * sizeof(spm_int_t)); + col_csc = calloc(spm->n+1,sizeof(spm_int_t)); assert( row_csc ); assert( col_csc ); #if !defined(PRECISION_p) - val_csc = malloc(nnz*sizeof(pastix_complex64_t)); + val_csc = malloc(nnz*sizeof(spm_complex64_t)); assert( val_csc ); #endif @@ -229,8 +228,8 @@ z_spmConvertCSR2CSC( pastix_spm_t *spm ) assert( (col_csc[spm->gN]) == nnz ); for (row=0; row<spm->n; row++) { - pastix_int_t fcol = spm->rowptr[row ] - baseval; - pastix_int_t lcol = spm->rowptr[row+1] - baseval; + spm_int_t fcol = spm->rowptr[row ] - baseval; + spm_int_t lcol = spm->rowptr[row+1] - baseval; for (k=fcol; k<lcol; k++) { col = spm->colptr[k] - baseval; @@ -246,7 +245,7 @@ z_spmConvertCSR2CSC( pastix_spm_t *spm ) /* Restore the colptr indexes */ { - pastix_int_t tmp, tmp2; + spm_int_t tmp, tmp2; tmp = col_csc[0]; col_csc[0] = baseval; @@ -268,5 +267,5 @@ z_spmConvertCSR2CSC( pastix_spm_t *spm ) } } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/z_spm_convert_to_csr.c b/src/z_spm_convert_to_csr.c index 2494461ccd1f8324095602e463e80fb3402ba1e8..9e412ff68701e8662583bc10208a0d6f44cc2aee 100644 --- a/src/z_spm_convert_to_csr.c +++ b/src/z_spm_convert_to_csr.c @@ -15,7 +15,6 @@ * @precisions normal z -> c d s p **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -25,7 +24,7 @@ * * @brief convert a matrix in CSC format to a matrix in CSR format. * - * If the matrix is PastixSymmetric or PastixHermitian, then the + * If the matrix is SpmSymmetric or SpmHermitian, then the * transpose or respectively the conjugate is returned. * ******************************************************************************* @@ -36,24 +35,24 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS + * @retval SPM_SUCCESS * *******************************************************************************/ int -z_spmConvertCSC2CSR( pastix_spm_t *spm ) +z_spmConvertCSC2CSR( spmatrix_t *spm ) { - pastix_int_t *tmp; - pastix_int_t result; + spm_int_t *tmp; + spm_int_t result; switch( spm->mtxtype ) { #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: { - /* Similar to PastixSymmetric case with conjugate of the values */ - pastix_complex64_t *valptr = spm->values; - pastix_int_t *colptr = spm->colptr; - pastix_int_t *rowptr = spm->rowptr; - pastix_int_t i, j; + /* Similar to SpmSymmetric case with conjugate of the values */ + spm_complex64_t *valptr = spm->values; + spm_int_t *colptr = spm->colptr; + spm_int_t *rowptr = spm->rowptr; + spm_int_t i, j; for(j=0; j<spm->n; j++, colptr++){ for(i=colptr[0]; i<colptr[1]; i++, rowptr++, valptr++) { @@ -63,30 +62,30 @@ z_spmConvertCSC2CSR( pastix_spm_t *spm ) } } } - pastix_attr_fallthrough; + spm_attr_fallthrough; #endif - case PastixSymmetric: + case SpmSymmetric: { - pastix_int_t *tmp; + spm_int_t *tmp; /* Just need to swap the pointers */ tmp = spm->rowptr; spm->rowptr = spm->colptr; spm->colptr = tmp; - spm->fmttype = PastixCSR; + spm->fmttype = SpmCSR; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } break; - case PastixGeneral: + case SpmGeneral: default: { /* Transpose the spm in CSC to trans(spm) in CSR */ tmp = spm->rowptr; spm->rowptr = spm->colptr; spm->colptr = tmp; - spm->fmttype = PastixCSR; + spm->fmttype = SpmCSR; /* Convert trans(spm) in CSR to trans(spm) in CSC */ result = z_spmConvertCSR2CSC( spm ); @@ -95,7 +94,7 @@ z_spmConvertCSC2CSR( pastix_spm_t *spm ) tmp = spm->rowptr; spm->rowptr = spm->colptr; spm->colptr = tmp; - spm->fmttype = PastixCSR; + spm->fmttype = SpmCSR; } } @@ -118,22 +117,22 @@ z_spmConvertCSC2CSR( pastix_spm_t *spm ) * ******************************************************************************* * - * @retval PASTIX_SUCCESS + * @retval SPM_SUCCESS * *******************************************************************************/ int -z_spmConvertIJV2CSR( pastix_spm_t *spm ) +z_spmConvertIJV2CSR( spmatrix_t *spm ) { #if !defined(PRECISION_p) - pastix_complex64_t *navals = NULL; - pastix_complex64_t *oavals = NULL; + spm_complex64_t *navals = NULL; + spm_complex64_t *oavals = NULL; #endif - pastix_int_t *spmptx, *otmp; - pastix_int_t i, j, tmp, baseval, total; - pastix_spm_t oldspm; + spm_int_t *spmptx, *otmp; + spm_int_t i, j, tmp, baseval, total; + spmatrix_t oldspm; /* Backup the input */ - memcpy( &oldspm, spm, sizeof(pastix_spm_t) ); + memcpy( &oldspm, spm, sizeof(spmatrix_t) ); /* * Check the baseval, we consider that arrays are sorted by columns or rows @@ -141,7 +140,7 @@ z_spmConvertIJV2CSR( pastix_spm_t *spm ) baseval = spmFindBase( spm ); /* Compute the new rowptr */ - spm->rowptr = (pastix_int_t *) calloc(spm->n+1,sizeof(pastix_int_t)); + spm->rowptr = (spm_int_t *) calloc(spm->n+1,sizeof(spm_int_t)); /* Compute the number of edges per row */ spmptx = spm->rowptr - baseval; @@ -163,14 +162,14 @@ z_spmConvertIJV2CSR( pastix_spm_t *spm ) assert( total == spm->nnz ); /* Sort the colptr and avals arrays by rows */ - spm->colptr = malloc(spm->nnz * sizeof(pastix_int_t)); + spm->colptr = malloc(spm->nnz * sizeof(spm_int_t)); #if defined(PRECISION_p) spm->values = NULL; #else - spm->values = malloc(spm->nnz * sizeof(pastix_complex64_t)); - navals = (pastix_complex64_t*)(spm->values); - oavals = (pastix_complex64_t*)(oldspm.values); + spm->values = malloc(spm->nnz * sizeof(spm_complex64_t)); + navals = (spm_complex64_t*)(spm->values); + oavals = (spm_complex64_t*)(oldspm.values); #endif for (j=0; j<spm->nnz; j++) @@ -202,7 +201,7 @@ z_spmConvertIJV2CSR( pastix_spm_t *spm ) spmExit( &oldspm ); - spm->fmttype = PastixCSR; + spm->fmttype = SpmCSR; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/z_spm_convert_to_ijv.c b/src/z_spm_convert_to_ijv.c index 07ecc32fc35c9258bf2e1da091e3738f15fbf22d..5d37086547f8737bec963f8a11c9be16417b94a6 100644 --- a/src/z_spm_convert_to_ijv.c +++ b/src/z_spm_convert_to_ijv.c @@ -15,7 +15,6 @@ * @precisions normal z -> c d s p **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -33,23 +32,23 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS + * @retval SPM_SUCCESS * *******************************************************************************/ int -z_spmConvertCSC2IJV( pastix_spm_t *spm ) +z_spmConvertCSC2IJV( spmatrix_t *spm ) { - pastix_int_t *col_ijv, *colptr; - pastix_int_t i, j, baseval, nnz; + spm_int_t *col_ijv, *colptr; + spm_int_t i, j, baseval, nnz; /* * Check the baseval */ baseval = spmFindBase( spm ); nnz = spm->nnz; - spm->fmttype = PastixIJV; + spm->fmttype = SpmIJV; - col_ijv = malloc(nnz*sizeof(pastix_int_t)); + col_ijv = malloc(nnz*sizeof(spm_int_t)); assert( col_ijv ); colptr = col_ijv; @@ -61,10 +60,10 @@ z_spmConvertCSC2IJV( pastix_spm_t *spm ) } } - memFree_null(spm->colptr); + free(spm->colptr); spm->colptr = col_ijv; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -82,23 +81,23 @@ z_spmConvertCSC2IJV( pastix_spm_t *spm ) * ******************************************************************************* * - * @retval PASTIX_SUCCESS + * @retval SPM_SUCCESS * *******************************************************************************/ int -z_spmConvertCSR2IJV( pastix_spm_t *spm ) +z_spmConvertCSR2IJV( spmatrix_t *spm ) { - pastix_int_t *row_ijv, *rowptr; - pastix_int_t i, j, baseval, nnz; + spm_int_t *row_ijv, *rowptr; + spm_int_t i, j, baseval, nnz; /* * Check the baseval */ baseval = spmFindBase( spm ); nnz = spm->nnz; - spm->fmttype = PastixIJV; + spm->fmttype = SpmIJV; - row_ijv = malloc(nnz*sizeof(pastix_int_t)); + row_ijv = malloc(nnz*sizeof(spm_int_t)); assert( row_ijv ); rowptr = row_ijv; @@ -110,8 +109,8 @@ z_spmConvertCSR2IJV( pastix_spm_t *spm ) } } - memFree_null(spm->rowptr); + free(spm->rowptr); spm->rowptr = row_ijv; - return PASTIX_SUCCESS; + return SPM_SUCCESS; } diff --git a/src/z_spm_dof_extend.c b/src/z_spm_dof_extend.c index 1bce155ca88ae65c8f2ec5f5e0dd87ce7cc9f724..2a397a5bcb652f82f80a7a8b7d96d6ffea1d7fef 100644 --- a/src/z_spm_dof_extend.c +++ b/src/z_spm_dof_extend.c @@ -15,7 +15,6 @@ * @precisions normal z -> c d s **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -32,14 +31,14 @@ * *******************************************************************************/ void -z_spmDofExtend(pastix_spm_t *spm) +z_spmDofExtend(spmatrix_t *spm) { - pastix_int_t i, j, k, ii, jj, dofi, dofj, baseval; - pastix_int_t *colptr, *rowptr, *dofs; - pastix_complex64_t *newval, *oldval, *oldvalptr; + spm_int_t i, j, k, ii, jj, dofi, dofj, baseval; + spm_int_t *colptr, *rowptr, *dofs; + spm_complex64_t *newval, *oldval, *oldvalptr; - oldval = oldvalptr = (pastix_complex64_t*)(spm->values); - newval = spm->values = malloc( spm->nnzexp * sizeof(pastix_complex64_t) ); + oldval = oldvalptr = (spm_complex64_t*)(spm->values); + newval = spm->values = malloc( spm->nnzexp * sizeof(spm_complex64_t) ); baseval = spmFindBase( spm ); colptr = spm->colptr; @@ -48,14 +47,14 @@ z_spmDofExtend(pastix_spm_t *spm) switch(spm->fmttype) { - case PastixCSR: + case SpmCSR: /* Swap pointers to call CSC */ colptr = spm->rowptr; rowptr = spm->colptr; - pastix_attr_fallthrough; + spm_attr_fallthrough; - case PastixCSC: + case SpmCSC: /** * Loop on col */ @@ -81,7 +80,7 @@ z_spmDofExtend(pastix_spm_t *spm) } } break; - /* case PastixCSR: */ + /* case SpmCSR: */ /* /\** */ /* * Loop on row */ /* *\/ */ @@ -107,7 +106,7 @@ z_spmDofExtend(pastix_spm_t *spm) /* } */ /* } */ /* break; */ - case PastixIJV: + case SpmIJV: /** * Loop on coordinates */ diff --git a/src/z_spm_expand.c b/src/z_spm_expand.c index cde62525dc2c16989a094283f8ce06b990bb47a7..0b3c31ae7d01cb4791bfdd945c36106eed9366b2 100644 --- a/src/z_spm_expand.c +++ b/src/z_spm_expand.c @@ -15,7 +15,6 @@ * @precisions normal z -> c d s p **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -40,40 +39,40 @@ * set. * *******************************************************************************/ -pastix_spm_t * -z_spmCSCExpand(const pastix_spm_t *spm) +spmatrix_t * +z_spmCSCExpand(const spmatrix_t *spm) { - pastix_spm_t *newspm; - pastix_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval, lda; - pastix_int_t diag, height; - pastix_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs; - pastix_complex64_t *newval, *oldval, *oldval2; + spmatrix_t *newspm; + spm_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval, lda; + spm_int_t diag, height; + spm_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs; + spm_complex64_t *newval, *oldval, *oldval2; - assert( spm->fmttype == PastixCSC ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmCSC ); + assert( spm->flttype == SpmComplex64 ); if ( spm->dof == 1 ) { - return (pastix_spm_t*)spm; + return (spmatrix_t*)spm; } - if ( spm->layout != PastixColMajor ) { - pastix_print_error( "Unsupported layout\n" ); + if ( spm->layout != SpmColMajor ) { + fprintf( stderr, "Unsupported layout\n" ); return NULL; } - newspm = malloc( sizeof(pastix_spm_t) ); - memcpy( newspm, spm, sizeof(pastix_spm_t) ); + newspm = malloc( sizeof(spmatrix_t) ); + memcpy( newspm, spm, sizeof(spmatrix_t) ); baseval = spmFindBase( spm ); oldcol = spm->colptr; oldrow = spm->rowptr; dofs = spm->dofs; #if !defined(PRECISION_p) - oldval = oldval2 = (pastix_complex64_t*)(spm->values); + oldval = oldval2 = (spm_complex64_t*)(spm->values); #endif newspm->n = spm->nexp; - newspm->colptr = newcol = malloc(sizeof(pastix_int_t)*(spm->nexp+1)); + newspm->colptr = newcol = malloc(sizeof(spm_int_t)*(spm->nexp+1)); /** * First loop to compute the new colptr @@ -95,7 +94,7 @@ z_spmCSCExpand(const pastix_spm_t *spm) diag = (diag || (i == j)); } - diag = (diag & (spm->mtxtype != PastixGeneral)); + diag = (diag & (spm->mtxtype != SpmGeneral)); height = newcol[1] - newcol[0]; newcol++; @@ -109,13 +108,13 @@ z_spmCSCExpand(const pastix_spm_t *spm) } } } - assert( ((spm->mtxtype == PastixGeneral) && ((newcol[0]-baseval) == spm->nnzexp)) || - ((spm->mtxtype != PastixGeneral) && ((newcol[0]-baseval) <= spm->nnzexp)) ); + assert( ((spm->mtxtype == SpmGeneral) && ((newcol[0]-baseval) == spm->nnzexp)) || + ((spm->mtxtype != SpmGeneral) && ((newcol[0]-baseval) <= spm->nnzexp)) ); newspm->nnz = newcol[0] - baseval; - newspm->rowptr = newrow = malloc(sizeof(pastix_int_t)*newspm->nnz); + newspm->rowptr = newrow = malloc(sizeof(spm_int_t)*newspm->nnz); #if !defined(PRECISION_p) - newspm->values = newval = malloc(sizeof(pastix_complex64_t)*newspm->nnz); + newspm->values = newval = malloc(sizeof(spm_complex64_t)*newspm->nnz); #endif /** @@ -144,8 +143,8 @@ z_spmCSCExpand(const pastix_spm_t *spm) for(jj=0; jj<dofj; jj++, col++, newcol++) { - assert( ((spm->mtxtype == PastixGeneral) && (lda == (newcol[1] - newcol[0]))) || - ((spm->mtxtype != PastixGeneral) && (lda >= (newcol[1] - newcol[0]))) ); + assert( ((spm->mtxtype == SpmGeneral) && (lda == (newcol[1] - newcol[0]))) || + ((spm->mtxtype != SpmGeneral) && (lda >= (newcol[1] - newcol[0]))) ); /* Move to the top of the column jj in coming element (i,j) */ oldval = oldval2; @@ -168,7 +167,7 @@ z_spmCSCExpand(const pastix_spm_t *spm) for(ii=0; ii<dofi; ii++, row++) { - if ( (spm->mtxtype == PastixGeneral) || + if ( (spm->mtxtype == SpmGeneral) || (i != j) || ((i == j) && (row >= col)) ) { @@ -195,7 +194,7 @@ z_spmCSCExpand(const pastix_spm_t *spm) newspm->dof = 1; newspm->dofs = NULL; - newspm->layout = PastixColMajor; + newspm->layout = SpmColMajor; assert(spm->loc2glob == NULL);//to do @@ -225,40 +224,40 @@ z_spmCSCExpand(const pastix_spm_t *spm) * set. * *******************************************************************************/ -pastix_spm_t * -z_spmCSRExpand(const pastix_spm_t *spm) +spmatrix_t * +z_spmCSRExpand(const spmatrix_t *spm) { - pastix_spm_t *newspm; - pastix_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval, lda; - pastix_int_t diag, height; - pastix_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs; - pastix_complex64_t *newval, *oldval, *oldval2; + spmatrix_t *newspm; + spm_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval, lda; + spm_int_t diag, height; + spm_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs; + spm_complex64_t *newval, *oldval, *oldval2; - assert( spm->fmttype == PastixCSR ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmCSR ); + assert( spm->flttype == SpmComplex64 ); if ( spm->dof == 1 ) { - return (pastix_spm_t*)spm; + return (spmatrix_t*)spm; } - if ( spm->layout != PastixColMajor ) { - pastix_print_error( "Unsupported layout\n" ); + if ( spm->layout != SpmColMajor ) { + fprintf( stderr, "Unsupported layout\n" ); return NULL; } - newspm = malloc( sizeof(pastix_spm_t) ); - memcpy( newspm, spm, sizeof(pastix_spm_t) ); + newspm = malloc( sizeof(spmatrix_t) ); + memcpy( newspm, spm, sizeof(spmatrix_t) ); baseval = spmFindBase( spm ); oldcol = spm->colptr; oldrow = spm->rowptr; dofs = spm->dofs; #if !defined(PRECISION_p) - oldval = oldval2 = (pastix_complex64_t*)(spm->values); + oldval = oldval2 = (spm_complex64_t*)(spm->values); #endif newspm->n = spm->nexp; - newspm->rowptr = newrow = malloc(sizeof(pastix_int_t)*(spm->nexp+1)); + newspm->rowptr = newrow = malloc(sizeof(spm_int_t)*(spm->nexp+1)); /** * First loop to compute the new rowptr @@ -280,7 +279,7 @@ z_spmCSRExpand(const pastix_spm_t *spm) diag = (diag || (i == j)); } - diag = (diag & (spm->mtxtype != PastixGeneral)); + diag = (diag & (spm->mtxtype != SpmGeneral)); height = newrow[1] - newrow[0]; newrow++; @@ -294,13 +293,13 @@ z_spmCSRExpand(const pastix_spm_t *spm) } } } - assert( ((spm->mtxtype == PastixGeneral) && ((newrow[0]-baseval) == spm->nnzexp)) || - ((spm->mtxtype != PastixGeneral) && ((newrow[0]-baseval) <= spm->nnzexp)) ); + assert( ((spm->mtxtype == SpmGeneral) && ((newrow[0]-baseval) == spm->nnzexp)) || + ((spm->mtxtype != SpmGeneral) && ((newrow[0]-baseval) <= spm->nnzexp)) ); newspm->nnz = newrow[0] - baseval; - newspm->colptr = newcol = malloc(sizeof(pastix_int_t)*newspm->nnz); + newspm->colptr = newcol = malloc(sizeof(spm_int_t)*newspm->nnz); #if !defined(PRECISION_p) - newspm->values = newval = malloc(sizeof(pastix_complex64_t)*newspm->nnz); + newspm->values = newval = malloc(sizeof(spm_complex64_t)*newspm->nnz); #endif /** @@ -329,8 +328,8 @@ z_spmCSRExpand(const pastix_spm_t *spm) for(ii=0; ii<dofi; ii++, row++, newrow++) { - assert( ((spm->mtxtype == PastixGeneral) && (lda == (newrow[1] - newrow[0]))) || - ((spm->mtxtype != PastixGeneral) && (lda >= (newrow[1] - newrow[0]))) ); + assert( ((spm->mtxtype == SpmGeneral) && (lda == (newrow[1] - newrow[0]))) || + ((spm->mtxtype != SpmGeneral) && (lda >= (newrow[1] - newrow[0]))) ); /* Move to the beginning of the row ii in coming element (i,j) */ oldval = oldval2 + ii; @@ -350,7 +349,7 @@ z_spmCSRExpand(const pastix_spm_t *spm) for(jj=0; jj<dofj; jj++, col++) { - if ( (spm->mtxtype == PastixGeneral) || + if ( (spm->mtxtype == SpmGeneral) || (i != j) || ((i == j) && (row <= col)) ) { @@ -378,7 +377,7 @@ z_spmCSRExpand(const pastix_spm_t *spm) newspm->dof = 1; newspm->dofs = NULL; - newspm->layout = PastixColMajor; + newspm->layout = SpmColMajor; assert(spm->loc2glob == NULL);//to do @@ -408,37 +407,37 @@ z_spmCSRExpand(const pastix_spm_t *spm) * set. * *******************************************************************************/ -pastix_spm_t * -z_spmIJVExpand(const pastix_spm_t *spm) +spmatrix_t * +z_spmIJVExpand(const spmatrix_t *spm) { - pastix_spm_t *newspm; - pastix_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval; - pastix_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs; - pastix_complex64_t *newval, *oldval=NULL; + spmatrix_t *newspm; + spm_int_t i, j, k, ii, jj, dofi, dofj, col, row, baseval; + spm_int_t *newcol, *newrow, *oldcol, *oldrow, *dofs; + spm_complex64_t *newval, *oldval=NULL; - assert( spm->fmttype == PastixIJV ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmIJV ); + assert( spm->flttype == SpmComplex64 ); if ( spm->dof == 1 ) { - return (pastix_spm_t*)spm; + return (spmatrix_t*)spm; } - newspm = malloc( sizeof(pastix_spm_t) ); - memcpy( newspm, spm, sizeof(pastix_spm_t) ); + newspm = malloc( sizeof(spmatrix_t) ); + memcpy( newspm, spm, sizeof(spmatrix_t) ); baseval = spmFindBase( spm ); oldcol = spm->colptr; oldrow = spm->rowptr; dofs = spm->dofs; #if !defined(PRECISION_p) - oldval = (pastix_complex64_t*)(spm->values); + oldval = (spm_complex64_t*)(spm->values); #endif /** * First loop to compute the size of the vectores */ newspm->n = spm->nexp; - if (spm->mtxtype == PastixGeneral) { + if (spm->mtxtype == SpmGeneral) { newspm->nnz = spm->nnzexp; } else { @@ -468,10 +467,10 @@ z_spmIJVExpand(const pastix_spm_t *spm) assert( newspm->nnz <= spm->nnzexp ); } - newspm->rowptr = newrow = malloc(sizeof(pastix_int_t)*newspm->nnz); - newspm->colptr = newcol = malloc(sizeof(pastix_int_t)*newspm->nnz); + newspm->rowptr = newrow = malloc(sizeof(spm_int_t)*newspm->nnz); + newspm->colptr = newcol = malloc(sizeof(spm_int_t)*newspm->nnz); #if !defined(PRECISION_p) - newspm->values = newval = malloc(sizeof(pastix_complex64_t)*newspm->nnz); + newspm->values = newval = malloc(sizeof(spm_complex64_t)*newspm->nnz); #endif /** @@ -497,12 +496,12 @@ z_spmIJVExpand(const pastix_spm_t *spm) col = dofs[j] - baseval; } - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, oldval++) { - if ( (spm->mtxtype == PastixGeneral) || + if ( (spm->mtxtype == SpmGeneral) || (i != j) || ((i == j) && (row+ii >= col+jj)) ) { @@ -522,7 +521,7 @@ z_spmIJVExpand(const pastix_spm_t *spm) { for(jj=0; jj<dofj; jj++, oldval++) { - if ( (spm->mtxtype == PastixGeneral) || + if ( (spm->mtxtype == SpmGeneral) || (i != j) || ((i == j) && (row+ii >= col+jj)) ) { @@ -551,7 +550,7 @@ z_spmIJVExpand(const pastix_spm_t *spm) newspm->dof = 1; newspm->dofs = NULL; - newspm->layout = PastixColMajor; + newspm->layout = SpmColMajor; assert(spm->loc2glob == NULL);//to do @@ -580,15 +579,15 @@ z_spmIJVExpand(const pastix_spm_t *spm) * @return The expanded matrix according to the dofs properties previously set. * *******************************************************************************/ -pastix_spm_t * -z_spmExpand( const pastix_spm_t *spm ) +spmatrix_t * +z_spmExpand( const spmatrix_t *spm ) { switch (spm->fmttype) { - case PastixCSC: + case SpmCSC: return z_spmCSCExpand( spm ); - case PastixCSR: + case SpmCSR: return z_spmCSRExpand( spm ); - case PastixIJV: + case SpmIJV: return z_spmIJVExpand( spm ); } return NULL; diff --git a/src/z_spm_genrhs.c b/src/z_spm_genrhs.c index 3f0edef732be0949250d9bfa161a3993e447f6d6..8e1227a46b2cec1c2e803bc0915ab745e00a9854 100644 --- a/src/z_spm_genrhs.c +++ b/src/z_spm_genrhs.c @@ -14,13 +14,10 @@ * * @precisions normal z -> c s d **/ -#include "cblas.h" -#include "lapacke.h" #include "common.h" -#include "solver.h" -#include "spm.h" #include "z_spm.h" -#include "kernels/pastix_zcores.h" +#include <cblas.h> +#include <lapacke.h> #ifndef DOXYGEN_SHOULD_SKIP_THIS #define Rnd64_A 6364136223846793005ULL @@ -29,9 +26,9 @@ #define RndD_Mul 5.4210108624275222e-20 -static pastix_complex64_t mzone = (pastix_complex64_t)-1.; -static pastix_complex64_t zone = (pastix_complex64_t) 1.; -static pastix_complex64_t zzero = (pastix_complex64_t) 0.; +static spm_complex64_t mzone = (spm_complex64_t)-1.; +static spm_complex64_t zone = (spm_complex64_t) 1.; +static spm_complex64_t zzero = (spm_complex64_t) 0.; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ /** @@ -120,10 +117,10 @@ Rnd64_jump(unsigned long long int n, unsigned long long int seed ) { * ******************************************************************************/ void -z_spmRndVect( double scale, int m, int n, pastix_complex64_t *A, int lda, +z_spmRndVect( double scale, int m, int n, spm_complex64_t *A, int lda, int gM, int m0, int n0, unsigned long long int seed ) { - pastix_complex64_t *tmp = A; + spm_complex64_t *tmp = A; int64_t i, j; unsigned long long int ran, jump; @@ -157,11 +154,11 @@ z_spmRndVect( double scale, int m, int n, pastix_complex64_t *A, int lda, * * @param[in] type * Defines how to compute the vector b. - * - PastixRhsOne: b is computed such that x = 1 [ + I ] - * - PastixRhsI: b is computed such that x = i [ + i * I ] - * - PastixRhsRndX: b is computed by matrix-vector product, such that + * - SpmRhsOne: b is computed such that x = 1 [ + I ] + * - SpmRhsI: b is computed such that x = i [ + i * I ] + * - SpmRhsRndX: b is computed by matrix-vector product, such that * is a random vector in the range [-0.5, 0.5] - * - PastixRhsRndB: b is computed randomly and x is not computed. + * - SpmRhsRndB: b is computed randomly and x is not computed. * * @param[in] nrhs * Defines the number of right hand side that must be generated. @@ -188,49 +185,49 @@ z_spmRndVect( double scale, int m, int n, pastix_complex64_t *A, int lda, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the b vector has been computed succesfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the b vector has been computed succesfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -z_spmGenRHS( pastix_rhstype_t type, int nrhs, - const pastix_spm_t *spm, +z_spmGenRHS( spm_rhstype_t type, int nrhs, + const spmatrix_t *spm, void *x, int ldx, void *b, int ldb ) { - pastix_complex64_t *xptr = (pastix_complex64_t*)x; - pastix_complex64_t *bptr = (pastix_complex64_t*)b; - pastix_int_t i, j; + spm_complex64_t *xptr = (spm_complex64_t*)x; + spm_complex64_t *bptr = (spm_complex64_t*)b; + spm_int_t i, j; int rc; if (( spm == NULL ) || ( spm->values == NULL )) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } /* Other format not supported for now */ - if( spm->fmttype != PastixCSC ) { - return PASTIX_ERR_BADPARAMETER; + if( spm->fmttype != SpmCSC ) { + return SPM_ERR_BADPARAMETER; } if( spm->gN <= 0 ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } if( nrhs <= 0 ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } if( (nrhs > 1) && (ldx < spm->n) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } if( (nrhs > 1) && (ldb < spm->n) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } if( spm->dof != 1 ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } if (nrhs == 1) { @@ -242,33 +239,33 @@ z_spmGenRHS( pastix_rhstype_t type, int nrhs, assert( spm->n == spm->gN ); /* If random b, we do it and exit */ - if ( type == PastixRhsRndB ) { + if ( type == SpmRhsRndB ) { /* Compute the spm norm to scale the b vector */ - double norm = z_spmNorm( PastixFrobeniusNorm, spm ); + double norm = z_spmNorm( SpmFrobeniusNorm, spm ); z_spmRndVect( norm, spm->n, nrhs, bptr, ldb, spm->gN, 0, 0, 24356 ); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } - if ( (type == PastixRhsOne ) || - (type == PastixRhsI ) || - (type == PastixRhsRndX ) ) + if ( (type == SpmRhsOne ) || + (type == SpmRhsI ) || + (type == SpmRhsRndX ) ) { if ( xptr == NULL ) { - MALLOC_INTERN( xptr, ldx * nrhs, pastix_complex64_t ); + xptr = malloc( ldx * nrhs * sizeof(spm_complex64_t) ); } switch( type ) { - case PastixRhsOne: + case SpmRhsOne: for( j=0; j<nrhs; j++ ) { for( i=0; i<spm->n; i++, xptr++ ) { #if defined(PRECISION_z) || defined(PRECISION_c) - *xptr = (pastix_complex64_t)(1.+1.*I); + *xptr = (spm_complex64_t)(1.+1.*I); #else - *xptr = (pastix_complex64_t)1.; + *xptr = (spm_complex64_t)1.; #endif } xptr += ldx-i; @@ -276,15 +273,15 @@ z_spmGenRHS( pastix_rhstype_t type, int nrhs, xptr -= nrhs * ldx; break; - case PastixRhsI: + case SpmRhsI: for( j=0; j<nrhs; j++ ) { for( i=0; i<spm->n; i++, xptr++ ) { #if defined(PRECISION_z) || defined(PRECISION_c) - *xptr = (pastix_complex64_t)(i + i * I); + *xptr = (spm_complex64_t)(i + i * I); #else - *xptr = (pastix_complex64_t)i; + *xptr = (spm_complex64_t)i; #endif } xptr += ldx-i; @@ -292,24 +289,24 @@ z_spmGenRHS( pastix_rhstype_t type, int nrhs, xptr -= nrhs * ldx; break; - case PastixRhsRndX: + case SpmRhsRndX: default: z_spmRndVect( 1., spm->n, nrhs, xptr, ldx, spm->gN, 0, 0, 24356 ); } /* Compute B */ - rc = z_spmCSCMatMat( PastixNoTrans, nrhs, &zone, spm, xptr, ldx, &zzero, bptr, ldb ); + rc = z_spmCSCMatMat( SpmNoTrans, nrhs, &zone, spm, xptr, ldx, &zzero, bptr, ldb ); if ( x == NULL ) { - memFree_null(xptr); + free(xptr); } return rc; } fprintf(stderr, "z_spmGenRHS: Generator not implemented yet\n"); - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -357,20 +354,20 @@ z_spmGenRHS( pastix_rhstype_t type, int nrhs, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the tests are succesfull + * @retval SPM_SUCCESS if the tests are succesfull * @retval 1, if one of the test failed * *******************************************************************************/ int -z_spmCheckAxb( pastix_fixdbl_t eps, int nrhs, - const pastix_spm_t *spm, +z_spmCheckAxb( spm_fixdbl_t eps, int nrhs, + const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx ) { - const pastix_complex64_t *zx = (const pastix_complex64_t *)x; - pastix_complex64_t *zx0 = (pastix_complex64_t *)x0; - pastix_complex64_t *zb = (pastix_complex64_t *)b; + const spm_complex64_t *zx = (const spm_complex64_t *)x; + spm_complex64_t *zx0 = (spm_complex64_t *)x0; + spm_complex64_t *zb = (spm_complex64_t *)b; double normA, normB, normX, normX0, normR; double backward, forward; int failure = 0; @@ -386,7 +383,7 @@ z_spmCheckAxb( pastix_fixdbl_t eps, int nrhs, /** * Compute the starting norms */ - normA = spmNorm( PastixOneNorm, spm ); + normA = spmNorm( SpmOneNorm, spm ); normB = 0.; normX = 0.; @@ -406,7 +403,7 @@ z_spmCheckAxb( pastix_fixdbl_t eps, int nrhs, /** * Compute r = b - A * x */ - spmMatMat( PastixNoTrans, nrhs, &mzone, spm, x, ldx, &zone, b, ldb ); + spmMatMat( SpmNoTrans, nrhs, &mzone, spm, x, ldx, &zone, b, ldb ); normR = 0.; backward = 0.; diff --git a/src/z_spm_integer.c b/src/z_spm_integer.c index 8eb4329ab12be5139767f7a0c359e550b60aea2c..cfe6513714f945e8ce1cc34ae247c22635bb06af 100644 --- a/src/z_spm_integer.c +++ b/src/z_spm_integer.c @@ -17,25 +17,22 @@ * @precisions normal z -> c d s * **/ -#include <ctype.h> -#include <limits.h> -#include <time.h> #include "common.h" /** ******************************************************************************* * - * @fn void z_spmIntSortAsc(void ** const pbase, const pastix_int_t n) + * @fn void z_spmIntSortAsc(void ** const pbase, const spm_int_t n) * @ingroup spm_dev_integer * @brief Sort 2 arrays simultaneously, the first array is an array of - * pastix_int_t and used as key for sorting. The second array is an array of - * pastix_complex64_t. + * spm_int_t and used as key for sorting. The second array is an array of + * spm_complex64_t. * ******************************************************************************* * * @param[inout] pbase * Couple of pointers to an array of integers and to an array of - * pastix_complex64_t to sort. + * spm_complex64_t to sort. * * @param[in] n * The number of elements in the array. @@ -43,26 +40,26 @@ ******************************************************************************* */ #ifndef DOXYGEN_SHOULD_SKIP_THIS -static size_t intsortsize[2] = { sizeof(pastix_int_t), sizeof(pastix_complex64_t) }; +static size_t intsortsize[2] = { sizeof(spm_int_t), sizeof(spm_complex64_t) }; #define INTSORTNAME z_spmIntSortAsc #define INTSORTSIZE(x) (intsortsize[x]) #define INTSORTNTAB 2 #define INTSORTSWAP(p,q) do { \ - pastix_int_t t; \ - long disp_p = (((pastix_int_t*)p)-((pastix_int_t*)base_ptr)); \ - long disp_q = (((pastix_int_t*)q)-((pastix_int_t*)base_ptr)); \ - pastix_complex64_t * floatptr = *(pbase+1); \ - pastix_complex64_t f; \ + spm_int_t t; \ + long disp_p = (((spm_int_t*)p)-((spm_int_t*)base_ptr)); \ + long disp_q = (((spm_int_t*)q)-((spm_int_t*)base_ptr)); \ + spm_complex64_t * floatptr = *(pbase+1); \ + spm_complex64_t f; \ /* swap integers */ \ - t = *((pastix_int_t *) (p)); \ - *((pastix_int_t *) (p)) = *((pastix_int_t *) (q)); \ - *((pastix_int_t *) (q)) = t; \ + t = *((spm_int_t *) (p)); \ + *((spm_int_t *) (p)) = *((spm_int_t *) (q)); \ + *((spm_int_t *) (q)) = t; \ /* swap corresponding values */ \ f = floatptr[disp_p]; \ floatptr[disp_p] = floatptr[disp_q]; \ floatptr[disp_q] = f; \ } while (0) -#define INTSORTCMP(p,q) (*((pastix_int_t *) (p)) < *((pastix_int_t *) (q))) +#define INTSORTCMP(p,q) (*((spm_int_t *) (p)) < *((spm_int_t *) (q))) #include "integer_sort_mtypes.c" #undef INTSORTNAME #undef INTSORTSIZE diff --git a/src/z_spm_laplacian.c b/src/z_spm_laplacian.c index e719f6182fa6b09536c32a492f984f2d479f5f83..c191ef409f6db5e63a480141547d675417f9ba08 100644 --- a/src/z_spm_laplacian.c +++ b/src/z_spm_laplacian.c @@ -14,10 +14,8 @@ * @precisions normal z -> c d s p * **/ - #include "common.h" -#include "spm.h" -#include "laplacian.h" +#include "drivers/laplacian.h" /** ******************************************************************************* @@ -61,42 +59,42 @@ * *******************************************************************************/ void -z_spmLaplacian_7points( pastix_spm_t *spm, - pastix_int_t dim1, - pastix_int_t dim2, - pastix_int_t dim3, - pastix_fixdbl_t alpha, - pastix_fixdbl_t beta ) +z_spmLaplacian_7points( spmatrix_t *spm, + spm_int_t dim1, + spm_int_t dim2, + spm_int_t dim3, + spm_fixdbl_t alpha, + spm_fixdbl_t beta ) { - pastix_complex64_t *valptr; - pastix_int_t *colptr, *rowptr; - pastix_int_t i, j, k, l; - pastix_int_t nnz = (2*(dim1)-1)*dim2*dim3 + (dim2-1)*dim1*dim3 + dim2*dim1*(dim3-1); + spm_complex64_t *valptr; + spm_int_t *colptr, *rowptr; + spm_int_t i, j, k, l; + spm_int_t nnz = (2*(dim1)-1)*dim2*dim3 + (dim2-1)*dim1*dim3 + dim2*dim1*(dim3-1); - spm->mtxtype = PastixHermitian; - spm->flttype = PastixComplex64; - spm->fmttype = PastixCSC; + spm->mtxtype = SpmHermitian; + spm->flttype = SpmComplex64; + spm->fmttype = SpmCSC; spm->nnz = nnz; spm->dof = 1; assert( spm->n == dim1*dim2*dim3 ); /* Allocating */ - spm->colptr = malloc((spm->n+1)*sizeof(pastix_int_t)); - spm->rowptr = malloc(nnz *sizeof(pastix_int_t)); + spm->colptr = malloc((spm->n+1)*sizeof(spm_int_t)); + spm->rowptr = malloc(nnz *sizeof(spm_int_t)); assert( spm->colptr ); assert( spm->rowptr ); #if !defined(PRECISION_p) - spm->values = malloc(nnz *sizeof(pastix_complex64_t)); + spm->values = malloc(nnz *sizeof(spm_complex64_t)); assert( spm->values ); #endif /* Building ia, ja and values*/ colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); /* Building ia, ja and values*/ *colptr = 1; @@ -186,38 +184,38 @@ z_spmLaplacian_7points( pastix_spm_t *spm, * *******************************************************************************/ void -z_spmExtendedLaplacian2D( pastix_spm_t *spm, - pastix_int_t dim1, - pastix_int_t dim2 ) +z_spmExtendedLaplacian2D( spmatrix_t *spm, + spm_int_t dim1, + spm_int_t dim2 ) { - pastix_complex64_t *valptr; - pastix_int_t *colptr, *rowptr; - pastix_int_t i, j, k; - pastix_int_t nnz = (2*(dim1)-1)*dim2 + (dim2-1)*(3*dim1-2); - - spm->mtxtype = PastixSymmetric; - spm->flttype = PastixComplex64; - spm->fmttype = PastixCSC; + spm_complex64_t *valptr; + spm_int_t *colptr, *rowptr; + spm_int_t i, j, k; + spm_int_t nnz = (2*(dim1)-1)*dim2 + (dim2-1)*(3*dim1-2); + + spm->mtxtype = SpmSymmetric; + spm->flttype = SpmComplex64; + spm->fmttype = SpmCSC; spm->nnz = nnz; spm->dof = 1; assert( spm->n == dim1*dim2 ); /* Allocating */ - spm->colptr = malloc((spm->n+1)*sizeof(pastix_int_t)); - spm->rowptr = malloc(nnz *sizeof(pastix_int_t)); + spm->colptr = malloc((spm->n+1)*sizeof(spm_int_t)); + spm->rowptr = malloc(nnz *sizeof(spm_int_t)); assert( spm->colptr ); assert( spm->rowptr ); #if !defined(PRECISION_p) - spm->values = malloc(nnz *sizeof(pastix_complex64_t)); + spm->values = malloc(nnz *sizeof(spm_complex64_t)); assert( spm->values ); #endif /* Building ia, ja and values*/ colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); /* Building ia, ja and values*/ *colptr = 1; @@ -232,11 +230,11 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, *rowptr = k; #if !defined(PRECISION_p) if ( (j == dim1 || j == 1) && (i == dim2 || i == 1) ) - *valptr = (pastix_complex64_t) 2.5; + *valptr = (spm_complex64_t) 2.5; else if (j == dim1 || j == 1 || i == dim2 || i == 1) - *valptr = (pastix_complex64_t) 4.; + *valptr = (spm_complex64_t) 4.; else - *valptr = (pastix_complex64_t) 6.; + *valptr = (spm_complex64_t) 6.; #endif valptr++; rowptr++; colptr[1]++; @@ -244,7 +242,7 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, if (j < dim1) { *rowptr = k+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-1.; + *valptr = (spm_complex64_t)-1.; #endif valptr++; rowptr++; colptr[1]++; } @@ -256,7 +254,7 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, { *rowptr = k+dim1-1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -264,7 +262,7 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, *rowptr = k+dim1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-1.; + *valptr = (spm_complex64_t)-1.; #endif valptr++; rowptr++; colptr[1]++; @@ -272,7 +270,7 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, { *rowptr = k+dim1+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -312,42 +310,42 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, * *******************************************************************************/ void -z_spmExtendedLaplacian3D( pastix_spm_t *spm, - pastix_int_t dim1, - pastix_int_t dim2, - pastix_int_t dim3 ) +z_spmExtendedLaplacian3D( spmatrix_t *spm, + spm_int_t dim1, + spm_int_t dim2, + spm_int_t dim3 ) { - pastix_complex64_t *valptr; - pastix_int_t *colptr, *rowptr; - pastix_int_t i, j, k, l; - pastix_int_t nnz = (2*dim1-1) * dim2 * dim3 + spm_complex64_t *valptr; + spm_int_t *colptr, *rowptr; + spm_int_t i, j, k, l; + spm_int_t nnz = (2*dim1-1) * dim2 * dim3 + (3*dim1-2) * (dim2-1) * dim3 + ((3*dim1-2) * dim2 + 2 * (3*dim1-2) *(dim2-1)) * (dim3-1); - spm->mtxtype = PastixSymmetric; - spm->flttype = PastixComplex64; - spm->fmttype = PastixCSC; + spm->mtxtype = SpmSymmetric; + spm->flttype = SpmComplex64; + spm->fmttype = SpmCSC; spm->nnz = nnz; spm->dof = 1; assert( spm->n == dim1*dim2*dim3 ); /* Allocating */ - spm->colptr = malloc((spm->n+1)*sizeof(pastix_int_t)); - spm->rowptr = malloc(nnz *sizeof(pastix_int_t)); + spm->colptr = malloc((spm->n+1)*sizeof(spm_int_t)); + spm->rowptr = malloc(nnz *sizeof(spm_int_t)); assert( spm->colptr ); assert( spm->rowptr ); #if !defined(PRECISION_p) - spm->values = malloc(nnz *sizeof(pastix_complex64_t)); + spm->values = malloc(nnz *sizeof(spm_complex64_t)); assert( spm->values ); #endif /* Building ia, ja and values*/ colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); /* Building ia, ja and values*/ *colptr = 1; @@ -364,21 +362,21 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, *rowptr = l; #if !defined(PRECISION_p) if ( (j == dim2 || j == 1) && (i == dim3 || i == 1) && (k == dim1 || i == 1) ) - *valptr = (pastix_complex64_t) 4.75; + *valptr = (spm_complex64_t) 4.75; else if ( (j != dim2 || j != 1) && (i == dim3 || i == 1) && (k == dim1 || i == 1) ) - *valptr = (pastix_complex64_t) 10.; + *valptr = (spm_complex64_t) 10.; else if ( (j == dim2 || j == 1) && (i != dim3 || i != 1) && (k == dim1 || i == 1) ) - *valptr = (pastix_complex64_t) 10.; + *valptr = (spm_complex64_t) 10.; else if ( (j == dim2 || j == 1) && (i == dim3 || i == 1) && (k != dim1 || i != 1) ) - *valptr = (pastix_complex64_t) 10.; + *valptr = (spm_complex64_t) 10.; else if ( (j != dim2 || j != 1) && (i != dim3 || i != 1) && (k == dim1 || i == 1) ) - *valptr = (pastix_complex64_t) 7.; + *valptr = (spm_complex64_t) 7.; else if ( (j == dim2 || j == 1) && (i != dim3 || i != 1) && (k != dim1 || i != 1) ) - *valptr = (pastix_complex64_t) 7.; + *valptr = (spm_complex64_t) 7.; else if ( (j != dim2 || j != 1) && (i == dim3 || i == 1) && (k != dim1 || i != 1) ) - *valptr = (pastix_complex64_t) 7.; + *valptr = (spm_complex64_t) 7.; else - *valptr = (pastix_complex64_t) 14.; + *valptr = (spm_complex64_t) 14.; #endif valptr++; rowptr++; colptr[1]++; @@ -386,7 +384,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, if (k < dim1) { *rowptr = l+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-1.; + *valptr = (spm_complex64_t)-1.; #endif valptr++; rowptr++; colptr[1]++; } @@ -398,7 +396,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1-1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -406,7 +404,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, *rowptr = l+dim1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-1.; + *valptr = (spm_complex64_t)-1.; #endif valptr++; rowptr++; colptr[1]++; @@ -414,7 +412,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -429,7 +427,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1*dim2-dim1-1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.25; + *valptr = (spm_complex64_t)-0.25; #endif valptr++; rowptr++; colptr[1]++; @@ -437,7 +435,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, *rowptr = l+dim1*dim2-dim1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -445,7 +443,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1*dim2-dim1+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.25; + *valptr = (spm_complex64_t)-0.25; #endif valptr++; rowptr++; colptr[1]++; @@ -455,7 +453,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1*dim2-1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -463,7 +461,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, *rowptr = l+dim1*dim2; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-1.; + *valptr = (spm_complex64_t)-1.; #endif valptr++; rowptr++; colptr[1]++; @@ -471,7 +469,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1*dim2+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -483,7 +481,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1*dim2+dim1-1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.25; + *valptr = (spm_complex64_t)-0.25; #endif valptr++; rowptr++; colptr[1]++; @@ -491,7 +489,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, *rowptr = l+dim1*dim2+dim1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.5; + *valptr = (spm_complex64_t)-0.5; #endif valptr++; rowptr++; colptr[1]++; @@ -499,7 +497,7 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, { *rowptr = l+dim1*dim2+dim1+1; #if !defined(PRECISION_p) - *valptr = (pastix_complex64_t)-0.25; + *valptr = (spm_complex64_t)-0.25; #endif valptr++; rowptr++; colptr[1]++; diff --git a/src/z_spm_matrixvector.c b/src/z_spm_matrixvector.c index 133040ca9687e02b86b946197abf8c1636a668ac..f0fc6c63dd8076a456ad0afab425820952a887aa 100644 --- a/src/z_spm_matrixvector.c +++ b/src/z_spm_matrixvector.c @@ -15,7 +15,6 @@ * @precisions normal z -> c d s **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -26,7 +25,7 @@ * @brief compute the matrix-vector product: * y = alpha * op( A ) * x + beta * y * - * A is a PastixGeneral spm, where op( X ) is one of + * A is a SpmGeneral spm, where op( X ) is one of * * op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ) * @@ -37,15 +36,15 @@ * @param[in] trans * Specifies whether the matrix spm is transposed, not transposed or * conjugate transposed: - * = PastixNoTrans: A is not transposed; - * = PastixTrans: A is transposed; - * = PastixConjTrans: A is conjugate transposed. + * = SpmNoTrans: A is not transposed; + * = SpmTrans: A is transposed; + * = SpmConjTrans: A is conjugate transposed. * * @param[in] alpha * alpha specifies the scalar alpha * * @param[in] spm - * The PastixGeneral spm. + * The SpmGeneral spm. * * @param[in] x * The vector x. @@ -58,38 +57,38 @@ * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed succesfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed succesfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -z_spmGeCSCv(const pastix_trans_t trans, - pastix_complex64_t alpha, - const pastix_spm_t *spm, - const pastix_complex64_t *x, - pastix_complex64_t beta, - pastix_complex64_t *y ) +z_spmGeCSCv(const spm_trans_t trans, + spm_complex64_t alpha, + const spmatrix_t *spm, + const spm_complex64_t *x, + spm_complex64_t beta, + spm_complex64_t *y ) { - const pastix_complex64_t *valptr = (pastix_complex64_t*)(spm->values); - const pastix_complex64_t *xptr = (const pastix_complex64_t*)x; - pastix_complex64_t *yptr = (pastix_complex64_t*)y; - pastix_int_t col, row, i, baseval; + const spm_complex64_t *valptr = (spm_complex64_t*)(spm->values); + const spm_complex64_t *xptr = (const spm_complex64_t*)x; + spm_complex64_t *yptr = (spm_complex64_t*)y; + spm_int_t col, row, i, baseval; if ( (spm == NULL) || (x == NULL) || (y == NULL ) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - if( spm->mtxtype != PastixGeneral ) + if( spm->mtxtype != SpmGeneral ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } baseval = spmFindBase( spm ); /* first, y = beta*y */ if( beta == 0. ) { - memset( yptr, 0, spm->gN * sizeof(pastix_complex64_t) ); + memset( yptr, 0, spm->gN * sizeof(spm_complex64_t) ); } else { for( i=0; i<spm->gN; i++, yptr++ ) { @@ -100,9 +99,9 @@ z_spmGeCSCv(const pastix_trans_t trans, if( alpha != 0. ) { /** - * PastixNoTrans + * SpmNoTrans */ - if( trans == PastixNoTrans ) + if( trans == SpmNoTrans ) { for( col=0; col < spm->gN; col++ ) { @@ -114,9 +113,9 @@ z_spmGeCSCv(const pastix_trans_t trans, } } /** - * PastixTrans + * SpmTrans */ - else if( trans == PastixTrans ) + else if( trans == SpmTrans ) { for( col=0; col < spm->gN; col++ ) { @@ -128,7 +127,7 @@ z_spmGeCSCv(const pastix_trans_t trans, } } #if defined(PRECISION_c) || defined(PRECISION_z) - else if( trans == PastixConjTrans ) + else if( trans == SpmConjTrans ) { for( col=0; col < spm->gN; col++ ) { @@ -142,11 +141,11 @@ z_spmGeCSCv(const pastix_trans_t trans, #endif else { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } /** @@ -157,7 +156,7 @@ z_spmGeCSCv(const pastix_trans_t trans, * @brief compute the matrix-vector product: * y = alpha * A + beta * y * - * A is a PastixSymmetric spm, alpha and beta are scalars, and x and y are + * A is a SpmSymmetric spm, alpha and beta are scalars, and x and y are * vectors, and A a symm. * ******************************************************************************* @@ -166,7 +165,7 @@ z_spmGeCSCv(const pastix_trans_t trans, * alpha specifies the scalar alpha * * @param[in] spm - * The PastixSymmetric spm. + * The SpmSymmetric spm. * * @param[in] x * The vector x. @@ -179,37 +178,37 @@ z_spmGeCSCv(const pastix_trans_t trans, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed succesfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed succesfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -z_spmSyCSCv( pastix_complex64_t alpha, - const pastix_spm_t *spm, - const pastix_complex64_t *x, - pastix_complex64_t beta, - pastix_complex64_t *y ) +z_spmSyCSCv( spm_complex64_t alpha, + const spmatrix_t *spm, + const spm_complex64_t *x, + spm_complex64_t beta, + spm_complex64_t *y ) { - const pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; - const pastix_complex64_t *xptr = x; - pastix_complex64_t *yptr = y; - pastix_int_t col, row, i, baseval; + const spm_complex64_t *valptr = (spm_complex64_t*)spm->values; + const spm_complex64_t *xptr = x; + spm_complex64_t *yptr = y; + spm_int_t col, row, i, baseval; if ( (spm == NULL) || (x == NULL) || (y == NULL ) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - if( spm->mtxtype != PastixSymmetric ) + if( spm->mtxtype != SpmSymmetric ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } baseval = spmFindBase( spm ); /* First, y = beta*y */ if( beta == 0. ) { - memset( yptr, 0, spm->gN * sizeof(pastix_complex64_t) ); + memset( yptr, 0, spm->gN * sizeof(spm_complex64_t) ); } else { for( i=0; i<spm->gN; i++, yptr++ ) { @@ -233,7 +232,7 @@ z_spmSyCSCv( pastix_complex64_t alpha, } } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } #if defined(PRECISION_c) || defined(PRECISION_z) @@ -245,7 +244,7 @@ z_spmSyCSCv( pastix_complex64_t alpha, * @brief compute the matrix-vector product: * y = alpha * A + beta * y * - * A is a PastixHermitian spm, alpha and beta are scalars, and x and y are + * A is a SpmHermitian spm, alpha and beta are scalars, and x and y are * vectors, and A a symm. * ******************************************************************************* @@ -254,7 +253,7 @@ z_spmSyCSCv( pastix_complex64_t alpha, * alpha specifies the scalar alpha * * @param[in] spm - * The PastixHermitian spm. + * The SpmHermitian spm. * * @param[in] x * The vector x. @@ -267,35 +266,35 @@ z_spmSyCSCv( pastix_complex64_t alpha, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed succesfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed succesfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -z_spmHeCSCv( pastix_complex64_t alpha, - const pastix_spm_t *spm, - const pastix_complex64_t *x, - pastix_complex64_t beta, - pastix_complex64_t *y ) +z_spmHeCSCv( spm_complex64_t alpha, + const spmatrix_t *spm, + const spm_complex64_t *x, + spm_complex64_t beta, + spm_complex64_t *y ) { - const pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; - const pastix_complex64_t *xptr = x; - pastix_complex64_t *yptr = y; - pastix_int_t col, row, i, baseval; + const spm_complex64_t *valptr = (spm_complex64_t*)spm->values; + const spm_complex64_t *xptr = x; + spm_complex64_t *yptr = y; + spm_int_t col, row, i, baseval; if ( (spm == NULL) || (x == NULL) || (y == NULL ) ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } - if( spm->mtxtype != PastixHermitian ) + if( spm->mtxtype != SpmHermitian ) { - return PASTIX_ERR_BADPARAMETER; + return SPM_ERR_BADPARAMETER; } /* First, y = beta*y */ if( beta == 0. ) { - memset( yptr, 0, spm->gN * sizeof(pastix_complex64_t) ); + memset( yptr, 0, spm->gN * sizeof(spm_complex64_t) ); } else { for( i=0; i<spm->gN; i++, yptr++ ) { @@ -323,7 +322,7 @@ z_spmHeCSCv( pastix_complex64_t alpha, } } - return PASTIX_SUCCESS; + return SPM_SUCCESS; } #endif @@ -335,7 +334,7 @@ z_spmHeCSCv( pastix_complex64_t alpha, * @brief compute the matrix-vector product: * y = alpha * A + beta * y * - * A is a PastixHermitian spm, alpha and beta are scalars, and x and y are + * A is a SpmHermitian spm, alpha and beta are scalars, and x and y are * vectors, and A a symm. * ******************************************************************************* @@ -347,7 +346,7 @@ z_spmHeCSCv( pastix_complex64_t alpha, * alpha specifies the scalar alpha * * @param[in] spm - * The PastixHermitian spm. + * The SpmHermitian spm. * * @param[in] xptr * The vector x. @@ -360,33 +359,33 @@ z_spmHeCSCv( pastix_complex64_t alpha, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed succesfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed succesfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -z_spmCSCMatVec(const pastix_trans_t trans, +z_spmCSCMatVec(const spm_trans_t trans, const void *alphaptr, - const pastix_spm_t *spm, + const spmatrix_t *spm, const void *xptr, const void *betaptr, void *yptr ) { - const pastix_complex64_t *x = (const pastix_complex64_t*)xptr; - pastix_complex64_t *y = (pastix_complex64_t*)yptr; - pastix_complex64_t alpha, beta; + const spm_complex64_t *x = (const spm_complex64_t*)xptr; + spm_complex64_t *y = (spm_complex64_t*)yptr; + spm_complex64_t alpha, beta; - alpha = *((const pastix_complex64_t *)alphaptr); - beta = *((const pastix_complex64_t *)betaptr); + alpha = *((const spm_complex64_t *)alphaptr); + beta = *((const spm_complex64_t *)betaptr); switch (spm->mtxtype) { #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: return z_spmHeCSCv( alpha, spm, x, beta, y ); #endif - case PastixSymmetric: + case SpmSymmetric: return z_spmSyCSCv( alpha, spm, x, beta, y ); - case PastixGeneral: + case SpmGeneral: default: return z_spmGeCSCv( trans, alpha, spm, x, beta, y ); } @@ -411,9 +410,9 @@ z_spmCSCMatVec(const pastix_trans_t trans, * * @param[in] trans * Specifies whether the matrix spm is transposed, not transposed or conjugate transposed: - * - PastixTrans - * - PastixNoTrans - * - PastixConjTrans + * - SpmTrans + * - SpmNoTrans + * - SpmConjTrans * * @param[in] n * The number of columns of the matrices B and C. @@ -441,43 +440,43 @@ z_spmCSCMatVec(const pastix_trans_t trans, * ******************************************************************************* * - * @retval PASTIX_SUCCESS if the y vector has been computed successfully, - * @retval PASTIX_ERR_BADPARAMETER otherwise. + * @retval SPM_SUCCESS if the y vector has been computed successfully, + * @retval SPM_ERR_BADPARAMETER otherwise. * *******************************************************************************/ int -z_spmCSCMatMat(const pastix_trans_t trans, - pastix_int_t n, +z_spmCSCMatMat(const spm_trans_t trans, + spm_int_t n, const void *alphaptr, - const pastix_spm_t *A, + const spmatrix_t *A, const void *Bptr, - pastix_int_t ldb, + spm_int_t ldb, const void *betaptr, void *Cptr, - pastix_int_t ldc ) + spm_int_t ldc ) { - const pastix_complex64_t *B = (const pastix_complex64_t*)Bptr; - pastix_complex64_t *C = (pastix_complex64_t*)Cptr; - pastix_complex64_t alpha, beta; - int i, rc = PASTIX_SUCCESS; + const spm_complex64_t *B = (const spm_complex64_t*)Bptr; + spm_complex64_t *C = (spm_complex64_t*)Cptr; + spm_complex64_t alpha, beta; + int i, rc = SPM_SUCCESS; - alpha = *((const pastix_complex64_t *)alphaptr); - beta = *((const pastix_complex64_t *)betaptr); + alpha = *((const spm_complex64_t *)alphaptr); + beta = *((const spm_complex64_t *)betaptr); switch (A->mtxtype) { #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for( i=0; i<n; i++ ){ rc = z_spmHeCSCv( alpha, A, B + i * ldb, beta, C + i *ldc ); } break; #endif - case PastixSymmetric: + case SpmSymmetric: for( i=0; i<n; i++ ){ rc = z_spmSyCSCv( alpha, A, B + i * ldb, beta, C + i *ldc ); } break; - case PastixGeneral: + case SpmGeneral: default: for( i=0; i<n; i++ ){ rc = z_spmGeCSCv( trans, alpha, A, B + i * ldb, beta, C + i *ldc ); diff --git a/src/z_spm_norm.c b/src/z_spm_norm.c index 72ed90759727f790b2df89b2b727a9a766b88b96..14203318ecf5acf464ed649da05f06de29bc5db4 100644 --- a/src/z_spm_norm.c +++ b/src/z_spm_norm.c @@ -19,7 +19,6 @@ * **/ #include "common.h" -#include "spm.h" #include "z_spm.h" #include "frobeniusupdate.h" @@ -42,14 +41,14 @@ * *******************************************************************************/ double -z_spmFrobeniusNorm( const pastix_spm_t *spm ) +z_spmFrobeniusNorm( const spmatrix_t *spm ) { - pastix_int_t i, j, baseval; + spm_int_t i, j, baseval; double *valptr = (double*)spm->values; double scale = 1.; double sumsq = 0.; - if (spm->mtxtype == PastixGeneral) { + if (spm->mtxtype == SpmGeneral) { for(i=0; i <spm->nnzexp; i++, valptr++) { frobenius_update( 1, &scale, &sumsq, valptr ); @@ -60,13 +59,13 @@ z_spmFrobeniusNorm( const pastix_spm_t *spm ) } } else { - pastix_int_t *colptr = spm->colptr; - pastix_int_t *rowptr = spm->rowptr; + spm_int_t *colptr = spm->colptr; + spm_int_t *rowptr = spm->rowptr; int nb; baseval = spmFindBase( spm ); switch( spm->fmttype ){ - case PastixCSC: + case SpmCSC: for(i=0; i<spm->n; i++, colptr++) { for(j=colptr[0]; j<colptr[1]; j++, rowptr++, valptr++) { nb = ( i == (*rowptr-baseval) ) ? 1 : 2; @@ -79,7 +78,7 @@ z_spmFrobeniusNorm( const pastix_spm_t *spm ) } } break; - case PastixCSR: + case SpmCSR: for(i=0; i<spm->n; i++, rowptr++) { for(j=rowptr[0]; j<rowptr[1]; j++, colptr++, valptr++) { nb = ( i == (*colptr-baseval) ) ? 1 : 2; @@ -92,7 +91,7 @@ z_spmFrobeniusNorm( const pastix_spm_t *spm ) } } break; - case PastixIJV: + case SpmIJV: for(i=0; i <spm->nnz; i++, valptr++, colptr++, rowptr++) { nb = ( *rowptr == *colptr ) ? 1 : 2; frobenius_update( nb, &scale, &sumsq, valptr ); @@ -130,10 +129,10 @@ z_spmFrobeniusNorm( const pastix_spm_t *spm ) * *******************************************************************************/ double -z_spmMaxNorm( const pastix_spm_t *spm ) +z_spmMaxNorm( const spmatrix_t *spm ) { - pastix_int_t i; - pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; + spm_int_t i; + spm_complex64_t *valptr = (spm_complex64_t*)spm->values; double tmp, norm = 0.; for(i=0; i <spm->nnzexp; i++, valptr++) { @@ -163,19 +162,19 @@ z_spmMaxNorm( const pastix_spm_t *spm ) * *******************************************************************************/ double -z_spmInfNorm( const pastix_spm_t *spm ) +z_spmInfNorm( const spmatrix_t *spm ) { - pastix_int_t col, row, i, baseval; - pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; + spm_int_t col, row, i, baseval; + spm_complex64_t *valptr = (spm_complex64_t*)spm->values; double norm = 0.; double *sumrow; - MALLOC_INTERN( sumrow, spm->gN, double ); + sumrow = malloc( spm->gN * sizeof(double) ); memset( sumrow, 0, spm->gN * sizeof(double) ); baseval = spmFindBase( spm ); switch( spm->fmttype ){ - case PastixCSC: + case SpmCSC: for( col=0; col < spm->gN; col++ ) { for( i=spm->colptr[col]-baseval; i<spm->colptr[col+1]-baseval; i++ ) @@ -184,7 +183,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) sumrow[row] += cabs( valptr[i] ); /* Add the symmetric/hermitian part */ - if ( ( spm->mtxtype != PastixGeneral ) && + if ( ( spm->mtxtype != SpmGeneral ) && ( row != col ) ) { sumrow[col] += cabs( valptr[i] ); @@ -193,7 +192,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) } break; - case PastixCSR: + case SpmCSR: for( row=0; row < spm->gN; row++ ) { for( i=spm->rowptr[row]-baseval; i<spm->rowptr[row+1]-baseval; i++ ) @@ -203,7 +202,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) } /* Add the symmetric/hermitian part */ - if ( spm->mtxtype != PastixGeneral ) + if ( spm->mtxtype != SpmGeneral ) { for( row=0; row < spm->gN; row++ ) { @@ -218,7 +217,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) } break; - case PastixIJV: + case SpmIJV: for(i=0; i < spm->nnz; i++) { row = spm->rowptr[i]-baseval; @@ -226,7 +225,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) } /* Add the symmetric/hermitian part */ - if ( spm->mtxtype != PastixGeneral ) + if ( spm->mtxtype != SpmGeneral ) { for(i=0; i < spm->nnz; i++) { @@ -240,8 +239,8 @@ z_spmInfNorm( const pastix_spm_t *spm ) break; default: - memFree_null( sumrow ); - return PASTIX_ERR_BADPARAMETER; + free( sumrow ); + return SPM_ERR_BADPARAMETER; } for( i=0; i<spm->gN; i++) @@ -251,7 +250,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) norm = sumrow[i]; } } - memFree_null( sumrow ); + free( sumrow ); return norm; } @@ -275,19 +274,19 @@ z_spmInfNorm( const pastix_spm_t *spm ) * *******************************************************************************/ double -z_spmOneNorm( const pastix_spm_t *spm ) +z_spmOneNorm( const spmatrix_t *spm ) { - pastix_int_t col, row, i, baseval; - pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; + spm_int_t col, row, i, baseval; + spm_complex64_t *valptr = (spm_complex64_t*)spm->values; double norm = 0.; double *sumcol; - MALLOC_INTERN( sumcol, spm->gN, double ); + sumcol = malloc( spm->gN * sizeof(double) ); memset( sumcol, 0, spm->gN * sizeof(double) ); baseval = spmFindBase( spm ); switch( spm->fmttype ){ - case PastixCSC: + case SpmCSC: for( col=0; col<spm->gN; col++ ) { for( i=spm->colptr[col]-baseval; i<spm->colptr[col+1]-baseval; i++ ) @@ -297,7 +296,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) } /* Add the symmetric/hermitian part */ - if ( spm->mtxtype != PastixGeneral ) + if ( spm->mtxtype != SpmGeneral ) { for( col=0; col < spm->gN; col++ ) { @@ -312,7 +311,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) } break; - case PastixCSR: + case SpmCSR: for( row=0; row < spm->gN; row++ ) { for( i=spm->rowptr[row]-baseval; i<spm->rowptr[row+1]-baseval; i++ ) @@ -321,7 +320,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) sumcol[col] += cabs( valptr[i] ); /* Add the symmetric/hermitian part */ - if ( ( spm->mtxtype != PastixGeneral ) && + if ( ( spm->mtxtype != SpmGeneral ) && ( row != col ) ) { sumcol[row] += cabs( valptr[i] ); @@ -330,14 +329,14 @@ z_spmOneNorm( const pastix_spm_t *spm ) } break; - case PastixIJV: + case SpmIJV: for(i=0; i < spm->nnz; i++) { sumcol[spm->colptr[i]-baseval] += cabs( valptr[i] ); } /* Add the symmetric/hermitian part */ - if ( spm->mtxtype != PastixGeneral ) + if ( spm->mtxtype != SpmGeneral ) { for(i=0; i < spm->nnz; i++) { @@ -348,8 +347,8 @@ z_spmOneNorm( const pastix_spm_t *spm ) break; default: - memFree_null( sumcol ); - return PASTIX_ERR_BADPARAMETER; + free( sumcol ); + return SPM_ERR_BADPARAMETER; } for( i=0; i<spm->gN; i++) @@ -359,7 +358,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) norm = sumcol[i]; } } - memFree_null( sumcol ); + free( sumcol ); return norm; } @@ -372,10 +371,10 @@ z_spmOneNorm( const pastix_spm_t *spm ) ******************************************************************************* * * @param[in] ntype - * = PastixMaxNorm: Max norm - * = PastixOneNorm: One norm - * = PastixInfNorm: Infinity norm - * = PastixFrobeniusNorm: Frobenius norm + * = SpmMaxNorm: Max norm + * = SpmOneNorm: One norm + * = SpmInfNorm: Infinity norm + * = SpmFrobeniusNorm: Frobenius norm * * @param[in] spm * The spm structure describing the matrix. @@ -387,7 +386,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) *******************************************************************************/ double z_spmNorm( int ntype, - const pastix_spm_t *spm ) + const spmatrix_t *spm ) { double norm = 0.; @@ -397,19 +396,19 @@ z_spmNorm( int ntype, } switch( ntype ) { - case PastixMaxNorm: + case SpmMaxNorm: norm = z_spmMaxNorm( spm ); break; - case PastixInfNorm: + case SpmInfNorm: norm = z_spmInfNorm( spm ); break; - case PastixOneNorm: + case SpmOneNorm: norm = z_spmOneNorm( spm ); break; - case PastixFrobeniusNorm: + case SpmFrobeniusNorm: norm = z_spmFrobeniusNorm( spm ); break; diff --git a/src/z_spm_print.c b/src/z_spm_print.c index 3f72aeb76e2cfac15fadef57e51ea4600eaffeee..502170cfbc6e2030df4b27967da89aa99fd5a95f 100644 --- a/src/z_spm_print.c +++ b/src/z_spm_print.c @@ -16,15 +16,7 @@ * @precisions normal z -> c d s p * **/ -#include <stdint.h> -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> -#include <assert.h> -#include "pastix.h" #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -44,27 +36,27 @@ * *******************************************************************************/ void -z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) +z_spmCSCPrint( FILE *f, const spmatrix_t *spm ) { - pastix_int_t i, j, baseval; - pastix_int_t k, ii, jj, dofi, dofj, col, row; - pastix_complex64_t *valptr; - pastix_int_t *colptr, *rowptr, *dofs; + spm_int_t i, j, baseval; + spm_int_t k, ii, jj, dofi, dofj, col, row; + spm_complex64_t *valptr; + spm_int_t *colptr, *rowptr, *dofs; - assert( spm->fmttype == PastixCSC ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmCSC ); + assert( spm->flttype == SpmComplex64 ); baseval = spmFindBase( spm ); i = 0; j = 0; colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); dofs = spm->dofs; switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(j=0; j<spm->n; j++, colptr++) { dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; @@ -76,7 +68,7 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; row = ( spm->dof > 0 ) ? spm->dof * i : dofs[i] - baseval; - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -120,7 +112,7 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(j=0; j<spm->n; j++, colptr++) { dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; @@ -132,7 +124,7 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; row = ( spm->dof > 0 ) ? spm->dof * i : dofs[i] - baseval; - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -175,7 +167,7 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(j=0; j<spm->n; j++, colptr++) { @@ -188,7 +180,7 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; row = ( spm->dof > 0 ) ? spm->dof * i : dofs[i] - baseval; - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -229,27 +221,27 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) * *******************************************************************************/ void -z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) +z_spmCSRPrint( FILE *f, const spmatrix_t *spm ) { - pastix_int_t i, j, baseval; - pastix_int_t k, ii, jj, dofi, dofj, col, row; - pastix_complex64_t *valptr; - pastix_int_t *colptr, *rowptr, *dofs; + spm_int_t i, j, baseval; + spm_int_t k, ii, jj, dofi, dofj, col, row; + spm_complex64_t *valptr; + spm_int_t *colptr, *rowptr, *dofs; - assert( spm->fmttype == PastixCSR ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmCSR ); + assert( spm->flttype == SpmComplex64 ); baseval = spmFindBase( spm ); i = 0; j = 0; colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); dofs = spm->dofs; switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(i=0; i<spm->n; i++, rowptr++) { dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; @@ -261,7 +253,7 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; col = ( spm->dof > 0 ) ? spm->dof * j : dofs[j] - baseval; - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -305,7 +297,7 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(i=0; i<spm->n; i++, rowptr++) { dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; @@ -317,7 +309,7 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; col = ( spm->dof > 0 ) ? spm->dof * j : dofs[j] - baseval; - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -360,7 +352,7 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(i=0; i<spm->n; i++, rowptr++) { @@ -373,7 +365,7 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) dofj = ( spm->dof > 0 ) ? spm->dof : dofs[j+1] - dofs[j]; col = ( spm->dof > 0 ) ? spm->dof * j : dofs[j] - baseval; - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -414,27 +406,27 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) * *******************************************************************************/ void -z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) +z_spmIJVPrint( FILE *f, const spmatrix_t *spm ) { - pastix_int_t i, j, baseval; - pastix_int_t k, ii, jj, dofi, dofj, col, row; - pastix_complex64_t *valptr; - pastix_int_t *colptr, *rowptr, *dofs; + spm_int_t i, j, baseval; + spm_int_t k, ii, jj, dofi, dofj, col, row; + spm_complex64_t *valptr; + spm_int_t *colptr, *rowptr, *dofs; - assert( spm->fmttype == PastixIJV ); - assert( spm->flttype == PastixComplex64 ); + assert( spm->fmttype == SpmIJV ); + assert( spm->flttype == SpmComplex64 ); baseval = spmFindBase( spm ); i = 0; j = 0; colptr = spm->colptr; rowptr = spm->rowptr; - valptr = (pastix_complex64_t*)(spm->values); + valptr = (spm_complex64_t*)(spm->values); dofs = spm->dofs; switch( spm->mtxtype ){ #if defined(PRECISION_z) || defined(PRECISION_c) - case PastixHermitian: + case SpmHermitian: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { i = *rowptr - baseval; @@ -453,7 +445,7 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) col = dofs[j] - baseval; } - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -496,7 +488,7 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) } break; #endif - case PastixSymmetric: + case SpmSymmetric: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { i = *rowptr - baseval; @@ -515,7 +507,7 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) col = dofs[j] - baseval; } - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -557,7 +549,7 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) } } break; - case PastixGeneral: + case SpmGeneral: default: for(k=0; k<spm->nnz; k++, rowptr++, colptr++) { @@ -577,7 +569,7 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) col = dofs[j] - baseval; } - if ( spm->layout == PastixColMajor ) { + if ( spm->layout == SpmColMajor ) { for(jj=0; jj<dofj; jj++) { for(ii=0; ii<dofi; ii++, valptr++) @@ -617,16 +609,16 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) * *******************************************************************************/ void -z_spmPrint( FILE *f, const pastix_spm_t *spm ) +z_spmPrint( FILE *f, const spmatrix_t *spm ) { switch (spm->fmttype) { - case PastixCSC: + case SpmCSC: z_spmCSCPrint( f, spm ); break; - case PastixCSR: + case SpmCSR: z_spmCSRPrint( f, spm ); break; - case PastixIJV: + case SpmIJV: z_spmIJVPrint( f, spm ); } return; diff --git a/src/z_spm_scal.c b/src/z_spm_scal.c index 1e568bd43c62addc87c8240d5791fb2df99d267c..3886729bf9d01dd5dff65ae432c5656bcc849dde 100644 --- a/src/z_spm_scal.c +++ b/src/z_spm_scal.c @@ -16,7 +16,6 @@ * **/ #include "common.h" -#include "spm.h" #include "z_spm.h" /** @@ -36,10 +35,10 @@ * *******************************************************************************/ void -z_spmScal( const double alpha, pastix_spm_t *spm ) +z_spmScal( const double alpha, spmatrix_t *spm ) { - pastix_int_t nnz, i; - pastix_complex64_t *values; + spm_int_t nnz, i; + spm_complex64_t *values; nnz = spm->nnz; values = spm->values;