PaStiX Handbook  6.3.2
analyze.c
Go to the documentation of this file.
1 /**
2  * @file analyze.c
3  *
4  * @brief A simple example that performs only the analyses steps onto the given graph.
5  *
6  * These tests doesn't require the values of the matrix.
7  *
8  * @copyright 2015-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
9  * Univ. Bordeaux. All rights reserved.
10  *
11  * @version 6.3.2
12  * @author Pierre Ramet
13  * @author Gregoire Pichon
14  * @author Mathieu Faverge
15  * @author Theophile Terraz
16  * @author Tony Delarue
17  * @author Alycia Lisito
18  * @date 2023-07-21
19  *
20  * @ingroup pastix_examples
21  * @code
22  *
23  */
24 #include <pastix.h>
25 #include <spm.h>
26 #include <limits.h>
27 
28 int main (int argc, char **argv)
29 {
30  pastix_data_t *pastix_data = NULL; /*< Pointer to the storage structure required by pastix */
31  pastix_int_t iparm[IPARM_SIZE]; /*< Integer in/out parameters for pastix */
32  double dparm[DPARM_SIZE]; /*< Floating in/out parameters for pastix */
33  spm_driver_t driver;
34  char *filename = NULL;
35  spmatrix_t *spm, spm2;
36  int rc;
37  int scatter = 0;
38 
39  /**
40  * Initialize parameters to default values
41  */
42  pastixInitParam( iparm, dparm );
43 
44  /**
45  * Get options from command line
46  */
47  pastixGetOptions( argc, argv,
48  iparm, dparm,
49  NULL, &scatter, &driver, &filename );
50 
51  /**
52  * Startup PaStiX
53  */
54  pastixInit( &pastix_data, MPI_COMM_WORLD, iparm, dparm );
55 
56  /**
57  * Read the sparse matrix with the driver
58  */
59  spm = malloc( sizeof( spmatrix_t ) );
60  if ( scatter ) {
61  rc = spmReadDriverDist( driver, filename, spm, MPI_COMM_WORLD );
62  }
63  else {
64  rc = spmReadDriver( driver, filename, spm );
65  }
66  free( filename );
67  if ( rc != SPM_SUCCESS ) {
68  pastixFinalize( &pastix_data );
69  return rc;
70  }
71 
72  spmPrintInfo( spm, stdout );
73 
74  rc = spmCheckAndCorrect( spm, &spm2 );
75  if ( rc != 0 ) {
76  spmExit( spm );
77  *spm = spm2;
78  rc = 0;
79  }
80 
81  /**
82  * Perform ordering, symbolic factorization, and analyze steps
83  */
84  pastix_task_analyze( pastix_data, spm );
85 
86  spmExit( spm );
87  free( spm );
88  pastixFinalize( &pastix_data );
89 
90  return EXIT_SUCCESS;
91 }
92 
93 /**
94  * @endcode
95  */
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
void pastixFinalize(pastix_data_t **pastix_data)
Finalize the solver instance.
Definition: api.c:919
void pastixInitParam(pastix_int_t *iparm, double *dparm)
Initialize the iparm and dparm arrays to their default values.
Definition: api.c:411
void pastixInit(pastix_data_t **pastix_data, PASTIX_Comm pastix_comm, pastix_int_t *iparm, double *dparm)
Initialize the solver instance.
Definition: api.c:896
void pastixGetOptions(int argc, char **argv, pastix_int_t *iparm, double *dparm, int *check, int *scatter, spm_driver_t *driver, char **filename)
PaStiX helper function to read command line options in examples.
Definition: get_options.c:149
int pastix_task_analyze(pastix_data_t *pastix_data, const spmatrix_t *spm)
Perform all the preprocessing steps: ordering, symbolic factorization, reordering,...
Main PaStiX data structure.
Definition: pastixdata.h:67