24#ifndef DOXYGEN_SHOULD_SKIP_THIS
28#if defined(PASTIX_ORDERING_METIS)
39#if defined(PASTIX_WITH_PARSEC)
42#if defined(PASTIX_WITH_STARPU)
45#if defined(HAVE_BLAS_SET_NUM_THREADS)
46#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
48#elif defined(HAVE_MKL_SET_NUM_THREADS)
49#include <mkl_service.h>
50#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
55#ifndef DOXYGEN_SHOULD_SKIP_THIS
56#if defined(PASTIX_OS_WINDOWS)
57#define pastix_mkdir( __str ) mkdir( (__str) )
59#define pastix_mkdir( __str ) mkdir( (__str), 0700 )
63#if defined(PASTIX_WITH_MPI)
64static int pastix_mpi_in_use = 0;
65static int pastix_mpi_init = 0;
66static volatile pastix_atomic_lock_t pastix_mpi_lock = PASTIX_ATOMIC_UNLOCKED;
87 char **dir_global = &(pastix_data->
dir_global);
91 if ( *dir_global != NULL ) {
95 if ( pastix_data->
procnum == 0 )
97 char *name = pastix_getenv_get_value_str(
"PASTIX_OUTPUT_DIR",
"pastix" );
98 rc = asprintf( dir_global,
"%s-XXXXXX", name );
102#if !defined(HAVE_MKDTEMP)
104 *dir_global = mktemp( *dir_global );
105 if ( (*dir_global)[0] ==
'\0' ) {
106 perror(
"pastix_gendirectories/global/mktemp" );
112 old_mask = umask(S_IWGRP | S_IWOTH);
113 rc = pastix_mkdir( *dir_global );
114 (void)umask(old_mask);
117 perror(
"pastix_gendirectories/global/mkdir" );
125 old_mask = umask(S_IWGRP | S_IWOTH);
126 *dir_global = mkdtemp( *dir_global );
127 (void)umask(old_mask);
128 if ( *dir_global == NULL ) {
129 perror(
"pastix_gendirectories/global/mkdtemp" );
137 MPI_Bcast( &len, 1, MPI_INT,
139 MPI_Bcast( pastix_data->
dir_global, len+1, MPI_CHAR,
142 fprintf( stdout,
"OUTPUTDIR: %s\n", pastix_data->
dir_global );
146 MPI_Bcast( &len, 1, MPI_INT,
148 pastix_data->
dir_global = malloc( (len+1) *
sizeof(
char) );
149 MPI_Bcast( pastix_data->
dir_global, len+1, MPI_CHAR,
158#if defined(PASTIX_WITH_MPI)
162 rc = asprintf( &localdir,
"%s/%0*d",
164 (
int)pastix_iceil( pastix_data->
procnbr, 10 ),
167 old_mask = umask(S_IWGRP | S_IWOTH);
168 rc = pastix_mkdir( localdir );
169 (void)umask(old_mask);
172 perror(
"pastix_gendirectories/local/mkdir" );
209 const char *filename )
211 char *fullname = NULL;
217 rc = asprintf( &fullname,
"%s/%s", dirname, filename );
219 pastix_print_error(
"pastix_fname: Couldn't not generate the tempory filename for the output file" );
252 const char *filename,
266 f = fopen( fullname, mode );
271 perror(
"pastix_fopenw" );
272 pastix_print_error(
"pastix_fopenw: Couldn't open file: %s with mode %s\n",
300 FILE *f = fopen(filename,
"r");
304 perror(
"pastix_fopen");
305 pastix_print_error(
"pastix_fopen: Couldn't open file: %s with mode r\n",
329 pastix_print(
pastix->procnum, 0, OUT_HEADER,
330 PASTIX_VERSION_MAJOR, PASTIX_VERSION_MINOR, PASTIX_VERSION_MICRO,
332 (
pastix->isched ?
"Started" :
"Disabled"),
335#
if defined(PASTIX_WITH_PARSEC)
336 (
pastix->parsec == NULL ?
"Enabled" :
"Started" ),
341#
if defined(PASTIX_WITH_STARPU)
342 (
pastix->starpu == NULL ?
"Enabled" :
"Started" ),
362 pastix_print(
pastix->procnum, 0, OUT_HEADER_LR,
424 memset( dparm, 0, DPARM_SIZE *
sizeof(
double) );
442#if defined(PASTIX_ORDERING_SCOTCH)
444#elif defined(PASTIX_ORDERING_METIS)
462#if defined(PASTIX_ORDERING_METIS)
615 comm = MPI_COMM_WORLD;
617 pastix->pastix_comm = comm;
621#if defined(PASTIX_WITH_MPI)
625 char procname[MPI_MAX_PROCESSOR_NAME];
626 int rc, key =
pastix->procnum;
635 rc = gethostname(procname, MPI_MAX_PROCESSOR_NAME-1);
637 procname[MPI_MAX_PROCESSOR_NAME-1] =
'\0';
638 len = strlen( procname );
642 for (i = 0; i < len; i++) {
643 color = color*256*
sizeof(char) + procname[i];
647 MPI_Comm_split(
pastix->pastix_comm, color, key, &(
pastix->intra_node_comm));
648 MPI_Comm_size(
pastix->intra_node_comm, &(
pastix->intra_node_procnbr));
649 MPI_Comm_rank(
pastix->intra_node_comm, &(
pastix->intra_node_procnum));
652 MPI_Comm_split(
pastix->pastix_comm,
pastix->intra_node_procnum, key, &(
pastix->inter_node_comm));
653 MPI_Comm_size(
pastix->inter_node_comm, &(
pastix->inter_node_procnbr));
654 MPI_Comm_rank(
pastix->inter_node_comm, &(
pastix->inter_node_procnum));
659 pastix->intra_node_comm = MPI_COMM_SELF;
660 pastix->intra_node_procnbr = 1;
661 pastix->intra_node_procnum = 0;
710 PASTIX_Comm pastix_comm,
734#if defined(PASTIX_WITH_MPI)
736 int provided = MPI_THREAD_SINGLE;
739 pastix_atomic_lock( &pastix_mpi_lock );
742 MPI_Initialized(&flag);
744 MPI_Init_thread( NULL, NULL, MPI_THREAD_MULTIPLE, &provided );
748 MPI_Query_thread( &provided );
751 switch ( provided ) {
752 case MPI_THREAD_MULTIPLE:
755 case MPI_THREAD_SERIALIZED:
758 case MPI_THREAD_FUNNELED:
761 case MPI_THREAD_SINGLE:
767 pastix_atomic_unlock( &pastix_mpi_lock );
790#if defined(PASTIX_WITH_PARSEC)
793#if defined(PASTIX_WITH_STARPU)
799 if ( (
pastix->intra_node_procnbr > 1) &&
801 pastix_print(
pastix->procnum, 0,
802 "WARNING: Thread number forced by MPI autosplit feature\n" );
806#if defined(PASTIX_GENERATE_MODEL)
807 pastix_print(
pastix->procnum, 0,
808 "WARNING: PaStiX compiled with -DPASTIX_GENERATE_MODEL forces single thread computations\n" );
826#if defined(PASTIX_WITH_PARSEC)
827 if ( (
pastix->parsec == NULL) &&
837#if defined(PASTIX_WITH_STARPU)
838 if ( (
pastix->starpu == NULL) &&
847 pastix->schur_list = NULL;
849 pastix->zeros_list = NULL;
857 pastix->cpu_models = NULL;
858 pastix->gpu_models = NULL;
860 pastix->dir_global = NULL;
870 pastix->steps = STEP_INIT;
875#if defined(PASTIX_WITH_EZTRACE)
906 PASTIX_Comm pastix_comm,
911 iparm, dparm, NULL );
932 papiEnergyFinalize();
935#if defined(PASTIX_WITH_EZTRACE)
941 ischedFinalize(
pastix->isched );
943 if (
pastix->graph != NULL )
946 memFree_null(
pastix->graph );
949 if (
pastix->ordemesh != NULL )
952 memFree_null(
pastix->ordemesh );
955 if (
pastix->symbmtx != NULL )
958 memFree_null(
pastix->symbmtx );
961 if (
pastix->solvloc != NULL )
964 memFree_null(
pastix->solvloc );
967 if (
pastix->solvglob != NULL )
970 memFree_null(
pastix->solvglob );
973 if (
pastix->solvmatr != NULL )
978 if (
pastix->bcsc != NULL )
981 memFree_null(
pastix->bcsc );
984 if (
pastix->schur_list != NULL )
986 memFree_null(
pastix->schur_list );
988#if defined(PASTIX_WITH_PARSEC)
989 if (
pastix->parsec != NULL) {
993#if defined(PASTIX_WITH_STARPU)
994 if (
pastix->starpu != NULL) {
999#if defined(PASTIX_WITH_MPI)
1000 pastix_atomic_lock( &pastix_mpi_lock );
1001 pastix_mpi_in_use--;
1002 if ( (pastix_mpi_in_use == 0) && pastix_mpi_init ) {
1005 pastix_atomic_unlock( &pastix_mpi_lock );
1008 if (
pastix->cpu_models != NULL ) {
1010 pastix->cpu_models = NULL;
1012 if (
pastix->gpu_models != NULL ) {
1014 pastix->gpu_models = NULL;
1017 if (
pastix->dir_global != NULL ) {
1018 free(
pastix->dir_global );
1020 if (
pastix->dir_local != NULL ) {
1021 free(
pastix->dir_local );
1023 memFree_null(*pastix_data);
1043 char *fullname = NULL;
1046 static volatile int32_t
id = 0;
1052 lidx = pastix_atomic_add_32b( &
id, 1 );
1053 rc = asprintf( &fullname,
"idparam_%d.csv", lidx );
1056 pastix_print_error(
"pastixDumpParam: Couldn't not generate the filename for the output file" );
1061 pastix_param2csv( pastix_data, csv );
1089 const double *dparm )
1094 if ( iparm != NULL ) {
1095 irc = iparm_check_values( iparm );
1097 if ( dparm != NULL ) {
1098 drc = dparm_check_values( dparm );
1119#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
1120 return bli_thread_get_num_threads();
1121#elif defined(HAVE_MKL_SET_NUM_THREADS)
1122 return mkl_get_max_threads();
1123#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
1124 return openblas_get_num_threads();
1150#if defined(HAVE_BLI_THREAD_SET_NUM_THREADS)
1151 bli_thread_set_num_threads( nt );
1152#elif defined(HAVE_MKL_SET_NUM_THREADS)
1153 mkl_set_num_threads( nt );
1154#elif defined(HAVE_OPENBLAS_SET_NUM_THREADS)
1155 openblas_set_num_threads( nt );
static void apiInitMPI(pastix_data_t *pastix, PASTIX_Comm comm, int autosplit)
Internal function that setups the multiple communicators in order to perform the ordering step in MPI...
BEGIN_C_DECLS typedef int pastix_int_t
void bcscExit(pastix_bcsc_t *bcsc)
Frees the block csc structure but do not free the bcsc pointer.
void solverExit(SolverMatrix *solvmtx)
Free the content of the solver matrix structure.
void kernelsTraceFinalize(const pastix_data_t *pastix_data)
Stops the trace module.
void kernelsTraceInit(const pastix_data_t *pastix_data, pastix_trace_t trace)
Starts the trace module.
const char * compmeth_shnames[PastixCompressMethodNbr]
List of short names for the compression kernels.
void pastixDumpParam(const pastix_data_t *pastix_data)
Dump the iparm and dparm parameters in a CSV file.
void pastixFinalize(pastix_data_t **pastix_data)
Finalize the solver instance.
int pastixBlasSetNumThreadsOne(void)
Set the number of threads for blas calls (BLIS, MKL, OpenBLAS) to 1 and return the previous number of...
void pastixSummary(const pastix_data_t *pastix)
Print summary information.
void pastixInitParam(pastix_int_t *iparm, double *dparm)
Initialize the iparm and dparm arrays to their default values.
void pastixModelsFree(pastix_model_t *model)
Free a model data structure.
FILE * pastix_fopenw(const char *dirname, const char *filename, const char *mode)
Open a file in the unique directory of the pastix instance.
void pastixModelsLoad(pastix_data_t *pastix_data)
Load the performance models that will be used by the solver.
char * pastix_fname(const char *dirname, const char *filename)
Generate the full filename within local or global directory.
void pastixInit(pastix_data_t **pastix_data, PASTIX_Comm pastix_comm, pastix_int_t *iparm, double *dparm)
Initialize the solver instance.
int pastixCheckParam(const pastix_int_t *iparm, const double *dparm)
Check the values of iparm and dparm arrays.
BEGIN_C_DECLS int pastix(pastix_data_t **pastix_data, PASTIX_Comm pastix_comm, pastix_int_t n, pastix_int_t *colptr, pastix_int_t *rowptr, void *values, pastix_int_t *perm, pastix_int_t *invp, void *B, pastix_int_t nrhs, pastix_int_t *iparm, double *dparm)
Main function for compatibility with former releases.
int pastixBlasSetNumThreads(int nt)
Set the number of threads for blas calls (BLIS, MKL, OpenBLAS) and return the previous number of blas...
void pastixWelcome(const pastix_data_t *pastix)
Print information about the solver configuration.
void pastixInitWithAffinity(pastix_data_t **pastix_data, PASTIX_Comm pastix_comm, pastix_int_t *iparm, double *dparm, const int *bindtab)
Initialize the solver instance with a bintab array to specify the thread binding.
int pastixBlasGetNumThreads(void)
Return the current number of threads used for blas calls.
void pastix_gendirectories(pastix_data_t *pastix_data)
Generate a unique temporary directory to store output files.
FILE * pastix_fopen(const char *filename)
Open a file in the current directory in read only mode.
@ DPARM_EPSILON_MAGN_CTRL
@ DPARM_EPSILON_REFINEMENT
@ DPARM_COMPRESS_TOLERANCE
@ DPARM_COMPRESS_MIN_RATIO
@ PastixCompressWhenBegin
@ IPARM_COMPRESS_MIN_WIDTH
@ IPARM_GPU_MEMORY_BLOCK_SIZE
@ IPARM_COMPRESS_MIN_HEIGHT
@ IPARM_AMALGAMATION_LVLBLAS
@ IPARM_SPLITTING_PROJECTIONS_DISTANCE
@ IPARM_GPU_MEMORY_PERCENTAGE
@ IPARM_SCOTCH_SWITCH_LEVEL
@ IPARM_NNZEROS_BLOCK_LOCAL
@ IPARM_SPLITTING_LEVELS_PROJECTIONS
@ IPARM_AMALGAMATION_LVLCBLK
@ IPARM_SPLITTING_STRATEGY
@ IPARM_SPLITTING_LEVELS_KWAY
@ IPARM_SPLITTING_PROJECTIONS_WIDTH
@ IPARM_SPLITTING_PROJECTIONS_DEPTH
@ IPARM_COMPRESS_PRESELECT
@ IPARM_GLOBAL_ALLOCATION
@ PastixMpiThreadMultiple
@ PastixMpiThreadFunneled
@ PastixMpiThreadSerialized
@ PastixCompressMethodPQRCP
void graphExit(pastix_graph_t *graph)
Free the content of the graph structure.
void pastixOrderExit(pastix_order_t *ordeptr)
Free the arrays initialized in the order structure.
void pastix_parsec_init(pastix_data_t *pastix, int *argc, char **argv[], const int *bindtab)
Startup the PaRSEC runtime system.
void pastix_parsec_finalize(pastix_data_t *pastix)
Finalize the PaRSEC runtime system.
void pastix_starpu_init(pastix_data_t *pastix, int *argc, char **argv[], const int *bindtab)
Startup the StarPU runtime system.
void pastix_starpu_finalize(pastix_data_t *pastix)
Finalize the StarPU runtime system.
void pastixSymbolExit(symbol_matrix_t *symbptr)
Free the content of symbolic matrix.
PASTIX_Comm inter_node_comm
Main PaStiX data structure.