Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 05c3ba78 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Merge branch 'hotfix/updates_from_pastix' into 'master'

Hotfix/updates from pastix

See merge request !5
parents fe491778 449b65b9
No related branches found
No related tags found
1 merge request!5Hotfix/updates from pastix
...@@ -13,7 +13,7 @@ project (SPM C Fortran) ...@@ -13,7 +13,7 @@ project (SPM C Fortran)
# Check if compiled independently or within another project # Check if compiled independently or within another project
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
set( BUILD_SUBPROJECT OFF ) set( BUILD_AS_SUBPROJECT OFF )
option(BUILD_SHARED_LIBS option(BUILD_SHARED_LIBS
"Build shared libraries" OFF) "Build shared libraries" OFF)
...@@ -22,8 +22,7 @@ if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) ...@@ -22,8 +22,7 @@ if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
endif(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE)
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules) if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules)
set( MORSE_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules ) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules/morse_cmake/modules)
list(APPEND CMAKE_MODULE_PATH ${MORSE_CMAKE_MODULE_PATH})
include(MorseInit) include(MorseInit)
else() else()
message(FATAL_ERROR "Submodule cmake_morse not initialized - run `git submodule update --init`") message(FATAL_ERROR "Submodule cmake_morse not initialized - run `git submodule update --init`")
...@@ -33,8 +32,37 @@ if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) ...@@ -33,8 +32,37 @@ if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
enable_testing() enable_testing()
include(CTest) include(CTest)
include (CheckCCompilerFlag)
# 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 )
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 )
else() else()
set( BUILD_SUBPROJECT ON ) set( BUILD_AS_SUBPROJECT ON )
# Check if within pastix which provides Scotch
if (PASTIX_ORDERING_SCOTCH)
set(HAVE_SCOTCH ON)
endif()
endif() endif()
# Define a subproject name fr ctest # Define a subproject name fr ctest
...@@ -84,22 +112,33 @@ include(RulesPrecisions) ...@@ -84,22 +112,33 @@ include(RulesPrecisions)
### System parameter detection ### System parameter detection
include(CheckSystem) include(CheckSystem)
# PaStiX depends on CBLAS # SPM depends on Lapacke and CBLAS
#---------------------------- #---------------------------------
find_package(CBLAS) # Should be REQUIRED for BLAS sequential only find_package(LAPACKE REQUIRED)
if(CBLAS_FOUND)
message(STATUS "cblas: ${CBLAS_INCLUDE_DIRS}")
include_directories(${CBLAS_INCLUDE_DIRS})
endif()
find_package(LAPACKE) # Should be also REQUIRED
if(LAPACKE_FOUND) if(LAPACKE_FOUND)
message(STATUS "lapacke: ${LAPACKE_INCLUDE_DIRS}") message(STATUS "lapacke: ${LAPACKE_INCLUDE_DIRS}")
include_directories(${LAPACKE_INCLUDE_DIRS}) include_directories(${LAPACKE_INCLUDE_DIRS})
endif() endif()
#Configuration header find_package(CBLAS REQUIRED)
#-------------------- if(CBLAS_FOUND)
message(STATUS "cblas: ${CBLAS_INCLUDE_DIRS}")
include_directories(${CBLAS_INCLUDE_DIRS})
endif()
### Store dependencies not handled with pkg-config
set( DEPS_LIBRARIES
${LAPACKE_LIBRARIES_DEP}
${CBLAS_LIBRARIES_DEP}
)
list(APPEND CMAKE_INSTALL_RPATH
${LAPACKE_LIBRARY_DIRS_DEP}
${CBLAS_LIBRARY_DIRS_DEP}
)
# Configuration header
#---------------------
configure_file ( configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/include/spm_config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/include/spm_config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/spm_config.h") "${CMAKE_CURRENT_BINARY_DIR}/src/spm_config.h")
...@@ -108,10 +147,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/src/spm_config.h" DESTINATION include ...@@ -108,10 +147,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/src/spm_config.h" DESTINATION include
include_directories(include) include_directories(include)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/src") include_directories("${CMAKE_CURRENT_BINARY_DIR}/src")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/drivers")
### reset variables ### reset variables
set(generated_sources "")
set(generated_headers "") set(generated_headers "")
### Generate the headers in all precisions ### Generate the headers in all precisions
...@@ -134,6 +171,8 @@ add_custom_target(spm_headers_tgt ...@@ -134,6 +171,8 @@ add_custom_target(spm_headers_tgt
DEPENDS ${spm_headers} ) DEPENDS ${spm_headers} )
### Generate the sources in all precisions ### Generate the sources in all precisions
set(generated_sources "")
set(SOURCES set(SOURCES
src/z_spm.c src/z_spm.c
src/z_spm_2dense.c src/z_spm_2dense.c
...@@ -186,10 +225,8 @@ add_library(spm ...@@ -186,10 +225,8 @@ add_library(spm
) )
target_link_libraries(spm target_link_libraries(spm
${LAPACKE_LIBRARIES} ${LAPACKE_LIBRARIES_DEP}
${LAPACK_SEQ_LIBRARIES} ${CBLAS_LIBRARIES_DEP}
${CBLAS_LIBRARIES}
${BLAS_SEQ_LIBRARIES}
) )
add_dependencies(spm add_dependencies(spm
......
Subproject commit f4ead635e331c6a43b81d9e0a56b082fe47be36c Subproject commit 1deddb2781f62dbbf0ee9199f569e49f7346397a
...@@ -132,6 +132,8 @@ void spmIntSort1Asc1( void * const pbase, const spm_int_t n ); ...@@ -132,6 +132,8 @@ void spmIntSort1Asc1( void * const pbase, const spm_int_t n );
void spmIntSort2Asc1( 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 ); void spmIntSort2Asc2( void * const pbase, const spm_int_t n );
void spmIntMSortIntAsc(void ** const pbase, const spm_int_t n);
/** /**
* @} * @}
* @name SPM IO subroutines * @name SPM IO subroutines
......
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
/* Datatypes used */ /* Datatypes used */
#cmakedefine SPM_INT64 #cmakedefine SPM_INT64
/* Exploit the scotch version from the library compiling spm */
#cmakedefine HAVE_SCOTCH
#if defined(HAVE_FALLTHROUGH) #if defined(HAVE_FALLTHROUGH)
#define spm_attr_fallthrough __attribute__((fallthrough)) #define spm_attr_fallthrough __attribute__((fallthrough))
#else #else
......
...@@ -111,6 +111,5 @@ spm_cleanenv( char *str ) { ...@@ -111,6 +111,5 @@ spm_cleanenv( char *str ) {
#endif #endif
#endif /* _spm_common_h_ */ #endif /* _spm_common_h_ */
...@@ -238,9 +238,6 @@ void spmIntSort3Asc1(void *const pbase, const spm_int_t n); ...@@ -238,9 +238,6 @@ void spmIntSort3Asc1(void *const pbase, const spm_int_t n);
* *
******************************************************************************* *******************************************************************************
*/ */
/* Declare here for now, because unused */
void spmIntMSortIntAsc(void ** const pbase, const spm_int_t n);
#ifndef DOXYGEN_SHOULD_SKIP_THIS #ifndef DOXYGEN_SHOULD_SKIP_THIS
#define INTSORTNAME spmIntMSortIntAsc #define INTSORTNAME spmIntMSortIntAsc
#define INTSORTSIZE(x) (sizeof (spm_int_t)) #define INTSORTSIZE(x) (sizeof (spm_int_t))
......
...@@ -52,7 +52,7 @@ double z_spmNorm( int ntype, const spmatrix_t *spm ); ...@@ -52,7 +52,7 @@ double z_spmNorm( int ntype, const spmatrix_t *spm );
/** /**
* Extra routines * Extra routines
*/ */
void z_spmSort( spmatrix_t *spm ); void z_spmSort( spmatrix_t *spm );
spm_int_t z_spmMergeDuplicate( spmatrix_t *spm ); spm_int_t z_spmMergeDuplicate( spmatrix_t *spm );
spm_int_t z_spmSymmetrize( spmatrix_t *spm ); spm_int_t z_spmSymmetrize( spmatrix_t *spm );
...@@ -66,8 +66,8 @@ void z_spmDensePrint( FILE *f, spm_int_t m, spm_int_t n, const spm_complex64_t * ...@@ -66,8 +66,8 @@ void z_spmDensePrint( FILE *f, spm_int_t m, spm_int_t n, const spm_complex64_t *
void z_spmPrint( FILE *f, const spmatrix_t *spm ); void z_spmPrint( FILE *f, const spmatrix_t *spm );
spmatrix_t *z_spmExpand(const spmatrix_t *spm); spmatrix_t *z_spmExpand(const spmatrix_t *spm);
void z_spmDofExtend(spmatrix_t *spm); void z_spmDofExtend(spmatrix_t *spm);
void z_spmScal( const double alpha, spmatrix_t *spm ); void z_spmScal( const double alpha, spmatrix_t *spm );
#endif /* _z_spm_h_ */ #endif /* _z_spm_h_ */
...@@ -131,7 +131,7 @@ z_spmRndVect( double scale, int m, int n, spm_complex64_t *A, int lda, ...@@ -131,7 +131,7 @@ z_spmRndVect( double scale, int m, int n, spm_complex64_t *A, int lda,
for (i = 0; i < m; ++i) { for (i = 0; i < m; ++i) {
*tmp = (0.5f - ran * RndF_Mul) * scale; *tmp = (0.5f - ran * RndF_Mul) * scale;
ran = Rnd64_A * ran + Rnd64_C; ran = Rnd64_A * ran + Rnd64_C;
#ifdef COMPLEX #if defined(PRECISION_z) || defined(PRECISION_c)
*tmp += (I*(0.5f - ran * RndF_Mul)) * scale; *tmp += (I*(0.5f - ran * RndF_Mul)) * scale;
ran = Rnd64_A * ran + Rnd64_C; ran = Rnd64_A * ran + Rnd64_C;
#endif #endif
...@@ -368,7 +368,8 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs, ...@@ -368,7 +368,8 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
const spm_complex64_t *zx = (const spm_complex64_t *)x; const spm_complex64_t *zx = (const spm_complex64_t *)x;
spm_complex64_t *zx0 = (spm_complex64_t *)x0; spm_complex64_t *zx0 = (spm_complex64_t *)x0;
spm_complex64_t *zb = (spm_complex64_t *)b; spm_complex64_t *zb = (spm_complex64_t *)b;
double normA, normB, normX, normX0, normR; double *nb2 = malloc( nrhs * sizeof(double) );
double normA, normB, normX, normX0, normR, normR2;
double backward, forward; double backward, forward;
int failure = 0; int failure = 0;
int i; int i;
...@@ -394,6 +395,8 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs, ...@@ -394,6 +395,8 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
normB = (norm > normB ) ? norm : normB; normB = (norm > normB ) ? norm : normB;
norm = LAPACKE_zlange( LAPACK_COL_MAJOR, 'I', spm->n, 1, zx + i * ldx, ldx ); norm = LAPACKE_zlange( LAPACK_COL_MAJOR, 'I', spm->n, 1, zx + i * ldx, ldx );
normX = (norm > normX ) ? norm : normX; normX = (norm > normX ) ? norm : normX;
nb2[i] = cblas_dznrm2( spm->n, zb + i * ldb, 1 );
} }
printf( " || A ||_1 %e\n" printf( " || A ||_1 %e\n"
" max(|| b_i ||_oo) %e\n" " max(|| b_i ||_oo) %e\n"
...@@ -406,22 +409,27 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs, ...@@ -406,22 +409,27 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
spmMatMat( SpmNoTrans, nrhs, &mzone, spm, x, ldx, &zone, b, ldb ); spmMatMat( SpmNoTrans, nrhs, &mzone, spm, x, ldx, &zone, b, ldb );
normR = 0.; normR = 0.;
normR2 = 0.;
backward = 0.; backward = 0.;
failure = 0; failure = 0;
for( i=0; i<nrhs; i++ ) { for( i=0; i<nrhs; i++ ) {
double nx = cblas_dzasum( spm->n, zx + i * ldx, 1 ); double nx = cblas_dzasum( spm->n, zx + i * ldx, 1 );
double nr = cblas_dzasum( spm->n, zb + i * ldb, 1 ); double nr = cblas_dzasum( spm->n, zb + i * ldb, 1 );
double nr2 = cblas_dznrm2( spm->n, zb + i * ldb, 1 ) / nb2[i];
double back = ((nr / normA) / nx) / eps; double back = ((nr / normA) / nx) / eps;
int fail = 0; int fail = 0;
normR = (nr > normR ) ? nr : normR; normR = (nr > normR ) ? nr : normR;
normR2 = (nr2 > normR2 ) ? nr2 : normR2;
backward = (back > backward) ? back : backward; backward = (back > backward) ? back : backward;
fail = isnan(nr) || isinf(nr) || isnan(back) || isinf(back) || (back > 1.e2); fail = isnan(nr) || isinf(nr) || isnan(back) || isinf(back) || (back > 1.e2);
if ( fail ) { if ( fail ) {
printf( " || b_%d - A x_%d ||_1 %e\n" printf( " || b_%d - A x_%d ||_2 / || b_%d ||_2 %e\n"
" || b_%d - A x_%d ||_1 %e\n"
" || b_%d - A x_%d ||_1 / (||A||_1 * ||x_%d||_oo * eps) %e (%s)\n", " || b_%d - A x_%d ||_1 / (||A||_1 * ||x_%d||_oo * eps) %e (%s)\n",
i, i, i, nr2,
i, i, nr, i, i, nr,
i, i, i, back, i, i, i, back,
fail ? "FAILED" : "SUCCESS" ); fail ? "FAILED" : "SUCCESS" );
...@@ -430,11 +438,14 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs, ...@@ -430,11 +438,14 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
failure = failure || fail; failure = failure || fail;
} }
printf( " max(|| b_i - A x_i ||_1) %e\n" printf( " max(|| b_i - A x_i ||_2 / || b_i ||_2) %e\n"
" max(|| b_i - A x_i ||_1) %e\n"
" max(|| b_i - A x_i ||_1 / (||A||_1 * ||x_i||_oo * eps)) %e (%s)\n", " max(|| b_i - A x_i ||_1 / (||A||_1 * ||x_i||_oo * eps)) %e (%s)\n",
normR, backward, normR2, normR, backward,
failure ? "FAILED" : "SUCCESS" ); failure ? "FAILED" : "SUCCESS" );
free(nb2);
/** /**
* Compute r = x0 - x * Compute r = x0 - x
*/ */
......
...@@ -34,8 +34,8 @@ add_library(spm_test ...@@ -34,8 +34,8 @@ add_library(spm_test
target_link_libraries( spm_test target_link_libraries( spm_test
spm spm
${LAPACKE_LIBRARIES} ${LAPACKE_LIBRARIES_DEP}
${LAPACK_SEQ_LIBRARIES} ) ${CBLAS_LIBRARIES_DEP} )
## Generate all test executables ## Generate all test executables
set (TESTS set (TESTS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment