24 #ifndef DOXYGEN_SHOULD_SKIP_THIS
28 #if defined(PASTIX_ORDERING_METIS)
36 #include <sys/types.h>
39 #if defined(PASTIX_WITH_PARSEC)
42 #if defined(PASTIX_WITH_STARPU)
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 #if defined(PASTIX_OS_WINDOWS)
48 #define pastix_mkdir( __str ) mkdir( (__str) )
50 #define pastix_mkdir( __str ) mkdir( (__str), 0700 )
54 #if defined(PASTIX_WITH_MPI)
55 static int pastix_mpi_in_use = 0;
56 static int pastix_mpi_init = 0;
57 static volatile pastix_atomic_lock_t pastix_mpi_lock = PASTIX_ATOMIC_UNLOCKED;
78 char **dir_global = &(pastix_data->
dir_global);
82 if ( *dir_global != NULL ) {
86 if ( pastix_data->
procnum == 0 )
88 char *name = pastix_getenv_get_value_str(
"PASTIX_OUTPUT_DIR",
"pastix" );
89 rc = asprintf( dir_global,
"%s-XXXXXX", name );
93 #if !defined(HAVE_MKDTEMP)
95 *dir_global = mktemp( *dir_global );
96 if ( (*dir_global)[0] ==
'\0' ) {
97 perror(
"pastix_gendirectories/global/mktemp" );
103 old_mask = umask(S_IWGRP | S_IWOTH);
104 rc = pastix_mkdir( *dir_global );
105 (void)umask(old_mask);
108 perror(
"pastix_gendirectories/global/mkdir" );
116 old_mask = umask(S_IWGRP | S_IWOTH);
117 *dir_global = mkdtemp( *dir_global );
118 (void)umask(old_mask);
119 if ( *dir_global == NULL ) {
120 perror(
"pastix_gendirectories/global/mkdtemp" );
126 len = strlen( *dir_global );
128 MPI_Bcast( &len, 1, MPI_INT,
130 MPI_Bcast( pastix_data->
dir_global, len+1, MPI_CHAR,
133 fprintf( stdout,
"OUTPUTDIR: %s\n", *dir_global );
137 MPI_Bcast( &len, 1, MPI_INT,
139 pastix_data->
dir_global = malloc( (len+1) *
sizeof(
char) );
140 MPI_Bcast( pastix_data->
dir_global, len+1, MPI_CHAR,
149 #if defined(PASTIX_WITH_MPI)
153 rc = asprintf( &localdir,
"%s/%0*d",
155 (
int)pastix_iceil( pastix_data->
procnbr, 10 ),
158 old_mask = umask(S_IWGRP | S_IWOTH);
159 rc = pastix_mkdir( localdir );
160 (void)umask(old_mask);
163 perror(
"pastix_gendirectories/local/mkdir" );
172 pastix_data->
dir_local = strdup( *dir_global );
200 const char *filename )
202 char *fullname = NULL;
208 rc = asprintf( &fullname,
"%s/%s", dirname, filename );
210 pastix_print_error(
"pastix_fname: Couldn't not generate the tempory filename for the output file" );
243 const char *filename,
257 f = fopen( fullname, mode );
262 perror(
"pastix_fopenw" );
263 pastix_print_error(
"pastix_fopenw: Couldn't open file: %s with mode %s\n",
291 FILE *f = fopen(filename,
"r");
295 perror(
"pastix_fopen");
296 pastix_print_error(
"pastix_fopen: Couldn't open file: %s with mode r\n",
320 pastix_print(
pastix->procnum, 0, OUT_HEADER,
321 PASTIX_VERSION_MAJOR, PASTIX_VERSION_MINOR, PASTIX_VERSION_MICRO,
323 (
pastix->isched ?
"Started" :
"Disabled"),
326 #
if defined(PASTIX_WITH_PARSEC)
327 (
pastix->parsec == NULL ?
"Enabled" :
"Started" ),
332 #
if defined(PASTIX_WITH_STARPU)
333 (
pastix->starpu == NULL ?
"Enabled" :
"Started" ),
353 pastix_print(
pastix->procnum, 0, OUT_HEADER_LR,
415 memset( dparm, 0, DPARM_SIZE *
sizeof(
double) );
434 #if defined(PASTIX_ORDERING_METIS)
437 #if defined(PASTIX_ORDERING_SCOTCH)
453 #if defined(PASTIX_ORDERING_METIS)
606 comm = MPI_COMM_WORLD;
608 pastix->pastix_comm = comm;
612 #if defined(PASTIX_WITH_MPI)
616 char procname[MPI_MAX_PROCESSOR_NAME];
617 int rc, key =
pastix->procnum;
626 rc = gethostname(procname, MPI_MAX_PROCESSOR_NAME-1);
628 procname[MPI_MAX_PROCESSOR_NAME-1] =
'\0';
629 len = strlen( procname );
633 for (i = 0; i < len; i++) {
634 color = color*256*
sizeof(char) + procname[i];
638 MPI_Comm_split(
pastix->pastix_comm, color, key, &(
pastix->intra_node_comm));
639 MPI_Comm_size(
pastix->intra_node_comm, &(
pastix->intra_node_procnbr));
640 MPI_Comm_rank(
pastix->intra_node_comm, &(
pastix->intra_node_procnum));
643 MPI_Comm_split(
pastix->pastix_comm,
pastix->intra_node_procnum, key, &(
pastix->inter_node_comm));
644 MPI_Comm_size(
pastix->inter_node_comm, &(
pastix->inter_node_procnbr));
645 MPI_Comm_rank(
pastix->inter_node_comm, &(
pastix->inter_node_procnum));
650 pastix->intra_node_comm = MPI_COMM_SELF;
651 pastix->intra_node_procnbr = 1;
652 pastix->intra_node_procnum = 0;
701 PASTIX_Comm pastix_comm,
725 #if defined(PASTIX_WITH_MPI)
727 int provided = MPI_THREAD_SINGLE;
730 pastix_atomic_lock( &pastix_mpi_lock );
733 MPI_Initialized(&flag);
735 MPI_Init_thread( NULL, NULL, MPI_THREAD_MULTIPLE, &provided );
739 MPI_Query_thread( &provided );
742 switch ( provided ) {
743 case MPI_THREAD_MULTIPLE:
746 case MPI_THREAD_SERIALIZED:
749 case MPI_THREAD_FUNNELED:
752 case MPI_THREAD_SINGLE:
758 pastix_atomic_unlock( &pastix_mpi_lock );
781 #if defined(PASTIX_WITH_PARSEC)
784 #if defined(PASTIX_WITH_STARPU)
790 if ( (
pastix->intra_node_procnbr > 1) &&
792 pastix_print(
pastix->procnum, 0,
793 "WARNING: Thread number forced by MPI autosplit feature\n" );
797 #if defined(PASTIX_GENERATE_MODEL)
798 pastix_print(
pastix->procnum, 0,
799 "WARNING: PaStiX compiled with -DPASTIX_GENERATE_MODEL forces single thread computations\n" );
817 #if defined(PASTIX_WITH_PARSEC)
818 if ( (
pastix->parsec == NULL) &&
828 #if defined(PASTIX_WITH_STARPU)
829 if ( (
pastix->starpu == NULL) &&
838 pastix->schur_list = NULL;
840 pastix->zeros_list = NULL;
848 pastix->cpu_models = NULL;
849 pastix->gpu_models = NULL;
851 pastix->dir_global = NULL;
861 pastix->steps = STEP_INIT;
866 #if defined(PASTIX_WITH_EZTRACE)
897 PASTIX_Comm pastix_comm,
902 iparm, dparm, NULL );
923 papiEnergyFinalize();
926 #if defined(PASTIX_WITH_EZTRACE)
932 ischedFinalize(
pastix->isched );
934 if (
pastix->graph != NULL )
937 memFree_null(
pastix->graph );
940 if (
pastix->ordemesh != NULL )
943 memFree_null(
pastix->ordemesh );
946 if (
pastix->symbmtx != NULL )
949 memFree_null(
pastix->symbmtx );
952 if (
pastix->solvloc != NULL )
955 memFree_null(
pastix->solvloc );
958 if (
pastix->solvglob != NULL )
961 memFree_null(
pastix->solvglob );
964 if (
pastix->solvmatr != NULL )
969 if (
pastix->bcsc != NULL )
972 memFree_null(
pastix->bcsc );
975 if (
pastix->schur_list != NULL )
977 memFree_null(
pastix->schur_list );
979 #if defined(PASTIX_WITH_PARSEC)
980 if (
pastix->parsec != NULL) {
984 #if defined(PASTIX_WITH_STARPU)
985 if (
pastix->starpu != NULL) {
990 #if defined(PASTIX_WITH_MPI)
991 pastix_atomic_lock( &pastix_mpi_lock );
993 if ( (pastix_mpi_in_use == 0) && pastix_mpi_init ) {
996 pastix_atomic_unlock( &pastix_mpi_lock );
999 if (
pastix->cpu_models != NULL ) {
1001 pastix->cpu_models = NULL;
1003 if (
pastix->gpu_models != NULL ) {
1005 pastix->gpu_models = NULL;
1008 if (
pastix->dir_global != NULL ) {
1009 free(
pastix->dir_global );
1011 if (
pastix->dir_local != NULL ) {
1012 free(
pastix->dir_local );
1014 memFree_null(*pastix_data);
1034 char *fullname = NULL;
1037 static volatile int32_t
id = 0;
1043 lidx = pastix_atomic_add_32b( &
id, 1 );
1044 rc = asprintf( &fullname,
"idparam_%d.csv", lidx );
1047 pastix_print_error(
"pastixDumpParam: Couldn't not generate the filename for the output file" );
1052 pastix_param2csv( pastix_data, csv );
1080 const double *dparm )
1085 if ( iparm != NULL ) {
1086 irc = iparm_check_values( iparm );
1088 if ( dparm != NULL ) {
1089 drc = dparm_check_values( dparm );
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.
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.
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.
char * pastix_fname(const char *dirname, const char *filename)
Generate the full filename within local or global directory.
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.
FILE * pastix_fopen(const char *filename)
Open a file in the current directory in read only mode.
void pastix_gendirectories(pastix_data_t *pastix_data)
Generate a unique temporary directory to store output files.
@ 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.