PaStiX Handbook  6.3.2
cost.c
Go to the documentation of this file.
1 /**
2  *
3  * @file cost.c
4  *
5  * PaStiX analyse functions for the cost matrix arrays.
6  *
7  * @copyright 1998-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.3.2
11  * @author Pascal Henon
12  * @author Mathieu Faverge
13  * @date 2023-07-21
14  *
15  * @addtogroup blend_dev_cost
16  * @{
17  *
18  **/
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 #include "common.h"
23 #include "symbol/symbol.h"
24 #include "blend/cost.h"
25 
26 /**
27  *******************************************************************************
28  *
29  * @brief Initialize the cost matrix structure
30  *
31  *******************************************************************************
32  *
33  * @param[inout] costmtx
34  * The cost matrix structure to initialize.
35  *
36  *******************************************************************************/
37 void
39 {
40  costmtx->blokcost = NULL;
41  costmtx->cblkcost = NULL;
42  return;
43 }
44 
45 /**
46  *******************************************************************************
47  *
48  * @brief Free the cost matrix structure
49  *
50  *******************************************************************************
51  *
52  * @param[inout] costmtx
53  * The cost matrix structure to free.
54  *
55  *******************************************************************************/
56 void
58 {
59  if(costmtx->blokcost != NULL) {
60  memFree_null(costmtx->blokcost);
61  }
62 
63  if(costmtx->cblkcost != NULL) {
64  memFree_null(costmtx->cblkcost);
65  }
66 }
67 
68 /**
69  *******************************************************************************
70  *
71  * @brief Build the cost matrix structure from the symbol matrix structure.
72  *
73  *******************************************************************************
74  *
75  * @param[in] symbmtx
76  * The symbol matrix structure.
77  *
78  * @param[in] flttype
79  * The floating point arithmetic that will be used to adapt the cost models.
80  *
81  * @param[in] factotype
82  * The factorization that will be appplied to adapt the cost models.
83  *
84  *******************************************************************************
85  *
86  * @return The cost matrix structure initialized with the cost of each block
87  * operation, and each cblk operation.
88  *
89  *******************************************************************************/
90 CostMatrix *
92  pastix_coeftype_t flttype,
93  pastix_factotype_t factotype )
94 {
95  CostMatrix *costmtx = NULL;
96 
97  MALLOC_INTERN(costmtx, 1, CostMatrix);
98  costMatrixInit(costmtx);
99 
100  MALLOC_INTERN( costmtx->cblkcost, symbmtx->cblknbr, double );
101  MALLOC_INTERN( costmtx->blokcost, symbmtx->bloknbr, double );
102 
103  pastixSymbolGetTimes( symbmtx, flttype, factotype,
104  costmtx->cblkcost, costmtx->blokcost );
105 
106  return costmtx;
107 }
108 
109 /**
110  * @}
111  */
double * cblkcost
Definition: cost.h:33
double * blokcost
Definition: cost.h:31
void costMatrixInit(CostMatrix *costmtx)
Initialize the cost matrix structure.
Definition: cost.c:38
void costMatrixExit(CostMatrix *costmtx)
Free the cost matrix structure.
Definition: cost.c:57
CostMatrix * costMatrixBuild(const symbol_matrix_t *symbmtx, pastix_coeftype_t flttype, pastix_factotype_t factotype)
Build the cost matrix structure from the symbol matrix structure.
Definition: cost.c:91
Arrays of double to store the cost of each element in the matrix.
Definition: cost.h:30
spm_coeftype_t pastix_coeftype_t
Arithmetic types.
Definition: api.h:294
enum pastix_factotype_e pastix_factotype_t
Factorization algorithms available for IPARM_FACTORIZATION parameter.
pastix_int_t bloknbr
Definition: symbol.h:80
pastix_int_t cblknbr
Definition: symbol.h:79
void pastixSymbolGetTimes(const symbol_matrix_t *symbmtx, pastix_coeftype_t flttype, pastix_factotype_t factotype, double *cblkcost, double *blokcost)
Computes the cost of structure for the costMatrixBuild() function.
Definition: symbol_cost.c:480
Symbol matrix structure.
Definition: symbol.h:77