23 #if defined(PASTIX_ORDERING_METIS)
31 #include <sys/types.h>
34 #if defined(PASTIX_WITH_PARSEC)
37 #if defined(PASTIX_WITH_STARPU)
41 #if defined(PASTIX_OS_WINDOWS)
42 #define pastix_mkdir( __str ) mkdir( (__str) )
44 #define pastix_mkdir( __str ) mkdir( (__str), 0700 )
47 #if defined(PASTIX_WITH_MPI)
48 static int pastix_mpi_in_use = 0;
49 static int pastix_mpi_init = 0;
50 static volatile pastix_atomic_lock_t pastix_mpi_lock = PASTIX_ATOMIC_UNLOCKED;
71 char **dir_global = &(pastix_data->dir_global);
75 if ( *dir_global != NULL ) {
79 if ( pastix_data->procnum == 0 )
81 *dir_global = strdup(
"pastix-XXXXXX" );
83 #if !defined(HAVE_MKDTEMP)
85 *dir_global = mktemp( *dir_global );
86 if ( (*dir_global)[0] ==
'\0' ) {
87 perror(
"pastix_gendirectories/global/mktemp" );
93 old_mask = umask(S_IWGRP | S_IWOTH);
94 rc = pastix_mkdir( *dir_global );
95 (void)umask(old_mask);
98 perror(
"pastix_gendirectories/global/mkdir" );
106 old_mask = umask(S_IWGRP | S_IWOTH);
107 *dir_global = mkdtemp( *dir_global );
108 (void)umask(old_mask);
109 if ( *dir_global == NULL ) {
110 perror(
"pastix_gendirectories/global/mkdtemp" );
116 len = strlen( *dir_global );
118 MPI_Bcast( &len, 1, MPI_INT,
119 0, pastix_data->inter_node_comm );
120 MPI_Bcast( pastix_data->dir_global, len+1, MPI_CHAR,
121 0, pastix_data->inter_node_comm );
123 fprintf( stdout,
"OUTPUTDIR: %s\n", *dir_global );
127 MPI_Bcast( &len, 1, MPI_INT,
128 0, pastix_data->inter_node_comm );
129 pastix_data->dir_global = malloc( (len+1) *
sizeof(
char) );
130 MPI_Bcast( pastix_data->dir_global, len+1, MPI_CHAR,
131 0, pastix_data->inter_node_comm );
134 assert( *dir_global != NULL );
139 #if defined(PASTIX_WITH_MPI)
140 if (pastix_data->procnbr > 1)
143 rc = asprintf( &localdir,
"%s/%0*d",
145 (
int)pastix_iceil( pastix_data->procnbr, 10 ),
146 pastix_data->procnum );
148 old_mask = umask(S_IWGRP | S_IWOTH);
149 rc = pastix_mkdir( localdir );
150 (void)umask(old_mask);
153 perror(
"pastix_gendirectories/local/mkdir" );
157 pastix_data->dir_local = localdir;
162 pastix_data->dir_local = strdup( *dir_global );
190 const char *filename )
192 char *fullname = NULL;
198 rc = asprintf( &fullname,
"%s/%s", dirname, filename );
200 pastix_print_error(
"pastix_fname: Couldn't not generate the tempory filename for the output file" );
233 const char *filename,
247 f = fopen( fullname, mode );
252 perror(
"pastix_fopenw" );
253 pastix_print_error(
"pastix_fopenw: Couldn't open file: %s with mode %s\n",
281 FILE *f = fopen(filename,
"r");
285 perror(
"pastix_fopen");
286 pastix_print_error(
"pastix_fopen: Couldn't open file: %s with mode r\n",
310 pastix_print(
pastix->procnum, 0, OUT_HEADER,
311 PASTIX_VERSION_MAJOR, PASTIX_VERSION_MINOR, PASTIX_VERSION_MICRO,
313 (
pastix->isched ?
"Started" :
"Disabled"),
316 #
if defined(PASTIX_WITH_PARSEC)
317 (
pastix->parsec == NULL ?
"Enabled" :
"Started" ),
322 #
if defined(PASTIX_WITH_STARPU)
323 (
pastix->starpu == NULL ?
"Enabled" :
"Started" ),
343 pastix_print(
pastix->procnum, 0, OUT_HEADER_LR,
404 memset( iparm, 0, IPARM_SIZE *
sizeof(pastix_int_t) );
405 memset( dparm, 0, DPARM_SIZE *
sizeof(
double) );
424 #if defined(PASTIX_ORDERING_METIS)
427 #if defined(PASTIX_ORDERING_SCOTCH)
443 #if defined(PASTIX_ORDERING_METIS)
588 comm = MPI_COMM_WORLD;
590 pastix->pastix_comm = comm;
594 #if defined(PASTIX_WITH_MPI)
598 char procname[MPI_MAX_PROCESSOR_NAME];
599 int rc, key =
pastix->procnum;
608 rc = gethostname(procname, MPI_MAX_PROCESSOR_NAME-1);
610 procname[MPI_MAX_PROCESSOR_NAME-1] =
'\0';
611 len = strlen( procname );
615 for (i = 0; i < len; i++) {
616 color = color*256*
sizeof(char) + procname[i];
620 MPI_Comm_split(
pastix->pastix_comm, color, key, &(
pastix->intra_node_comm));
621 MPI_Comm_size(
pastix->intra_node_comm, &(
pastix->intra_node_procnbr));
622 MPI_Comm_rank(
pastix->intra_node_comm, &(
pastix->intra_node_procnum));
625 MPI_Comm_split(
pastix->pastix_comm,
pastix->intra_node_procnum, key, &(
pastix->inter_node_comm));
626 MPI_Comm_size(
pastix->inter_node_comm, &(
pastix->inter_node_procnbr));
627 MPI_Comm_rank(
pastix->inter_node_comm, &(
pastix->inter_node_procnum));
632 pastix->intra_node_comm = MPI_COMM_SELF;
633 pastix->intra_node_procnbr = 1;
634 pastix->intra_node_procnum = 0;
683 PASTIX_Comm pastix_comm,
693 MALLOC_INTERN(
pastix, 1, pastix_data_t);
694 memset(
pastix, 0,
sizeof(pastix_data_t) );
707 #if defined(PASTIX_WITH_MPI)
709 int provided = MPI_THREAD_SINGLE;
712 pastix_atomic_lock( &pastix_mpi_lock );
715 MPI_Initialized(&flag);
717 MPI_Init_thread( NULL, NULL, MPI_THREAD_MULTIPLE, &provided );
721 MPI_Query_thread( &provided );
724 switch ( provided ) {
725 case MPI_THREAD_MULTIPLE:
728 case MPI_THREAD_SERIALIZED:
731 case MPI_THREAD_FUNNELED:
734 case MPI_THREAD_SINGLE:
740 pastix_atomic_unlock( &pastix_mpi_lock );
756 #if defined(PASTIX_WITH_PARSEC)
759 #if defined(PASTIX_WITH_STARPU)
765 if ( (
pastix->intra_node_procnbr > 1) &&
767 pastix_print(
pastix->procnum, 0,
768 "WARNING: Thread number forced by MPI autosplit feature\n" );
772 #if defined(PASTIX_GENERATE_MODEL)
773 pastix_print(
pastix->procnum, 0,
774 "WARNING: PaStiX compiled with -DPASTIX_GENERATE_MODEL forces single thread computations\n" );
787 #if defined(PASTIX_WITH_PARSEC)
788 if ( (
pastix->parsec == NULL) &&
798 #if defined(PASTIX_WITH_STARPU)
799 if ( (
pastix->starpu == NULL) &&
808 pastix->schur_list = NULL;
810 pastix->zeros_list = NULL;
818 pastix->cpu_models = NULL;
819 pastix->gpu_models = NULL;
821 pastix->dir_global = NULL;
831 pastix->steps = STEP_INIT;
860 PASTIX_Comm pastix_comm,
865 iparm, dparm, NULL );
884 pastix_data_t *
pastix = *pastix_data;
888 ischedFinalize(
pastix->isched );
890 if (
pastix->graph != NULL )
893 memFree_null(
pastix->graph );
896 if (
pastix->ordemesh != NULL )
899 memFree_null(
pastix->ordemesh );
902 if (
pastix->symbmtx != NULL )
905 memFree_null(
pastix->symbmtx );
908 if (
pastix->solvloc != NULL )
911 memFree_null(
pastix->solvloc );
914 if (
pastix->solvglob != NULL )
917 memFree_null(
pastix->solvglob );
920 if (
pastix->solvmatr != NULL )
925 if (
pastix->bcsc != NULL )
928 memFree_null(
pastix->bcsc );
931 if (
pastix->schur_list != NULL )
933 memFree_null(
pastix->schur_list );
935 #if defined(PASTIX_WITH_PARSEC)
936 if (
pastix->parsec != NULL) {
940 #if defined(PASTIX_WITH_STARPU)
941 if (
pastix->starpu != NULL) {
946 #if defined(PASTIX_WITH_MPI)
947 pastix_atomic_lock( &pastix_mpi_lock );
949 if ( (pastix_mpi_in_use == 0) && pastix_mpi_init ) {
952 pastix_atomic_unlock( &pastix_mpi_lock );
955 if (
pastix->cpu_models != NULL ) {
957 pastix->cpu_models = NULL;
959 if (
pastix->gpu_models != NULL ) {
961 pastix->gpu_models = NULL;
964 if (
pastix->dir_global != NULL ) {
965 free(
pastix->dir_global );
967 if (
pastix->dir_local != NULL ) {
968 free(
pastix->dir_local );
970 memFree_null(*pastix_data);
990 char *fullname = NULL;
993 static volatile int32_t
id = 0;
995 if( pastix_data->inter_node_procnum != 0 ) {
999 lidx = pastix_atomic_add_32b( &
id, 1 );
1000 rc = asprintf( &fullname,
"idparam_%d.csv", lidx );
1003 pastix_print_error(
"pastixDumpParam: Couldn't not generate the filename for the output file" );
1007 csv =
pastix_fopenw( pastix_data->dir_global, fullname,
"w" );
1008 pastix_param2csv( pastix_data, csv );
1036 const double *dparm )
1041 if ( iparm != NULL ) {
1042 irc = iparm_check_values( iparm );
1044 if ( dparm != NULL ) {
1045 drc = dparm_check_values( dparm );