Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Zwinkau
libfirm
Commits
10b740dd
Commit
10b740dd
authored
Jun 07, 2013
by
sebastian.buchwald1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use gauss jordan.
parent
35443ba4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
ir/ana/execfreq.c
ir/ana/execfreq.c
+14
-8
No files found.
ir/ana/execfreq.c
View file @
10b740dd
...
...
@@ -30,6 +30,7 @@
#include <limits.h>
#include <math.h>
#include "gaussjordan.h"
#include "gaussseidel.h"
#include "set.h"
...
...
@@ -96,7 +97,7 @@ void exit_execfreq(void)
}
static
double
*
solve_lgs
(
gs_matrix_t
*
mat
,
double
*
x
,
int
size
)
static
double
*
solve_lgs
(
double
*
mat
,
double
*
x
,
int
size
)
{
/* better convergence. */
double
init
=
1
.
0
/
size
;
...
...
@@ -109,7 +110,7 @@ static double *solve_lgs(gs_matrix_t *mat, double *x, int size)
double
dev
;
do
{
++
iter
;
dev
=
gs_matrix_gauss_seidel
(
mat
,
x
,
size
);
dev
=
firm_gaussjordansolve
(
mat
,
x
,
size
);
}
while
(
fabs
(
dev
)
>
SEIDEL_TOLERANCE
);
stat_ev_tim_pop
(
"execfreq_seidel_time"
);
stat_ev_dbl
(
"execfreq_seidel_iter"
,
iter
);
...
...
@@ -270,6 +271,11 @@ static void block_walk_no_keeps(ir_node *block)
}
}
static
void
matrix_set
(
double
*
m
,
int
size
,
int
row
,
int
col
,
double
val
)
{
m
[
row
*
size
+
col
]
=
val
;
}
void
ir_estimate_execfreq
(
ir_graph
*
irg
)
{
double
loop_weight
=
10
.
0
;
...
...
@@ -287,7 +293,7 @@ void ir_estimate_execfreq(ir_graph *irg)
dfs_t
*
dfs
=
dfs_new
(
&
absgraph_irg_cfg_succ
,
irg
);
int
size
=
dfs_get_n_nodes
(
dfs
);
gs_matrix_t
*
mat
=
gs_new_matrix
(
size
,
size
);
double
*
mat
=
(
double
*
)
malloc
(
size
*
size
*
sizeof
(
double
)
);
ir_node
*
const
start_block
=
get_irg_start_block
(
irg
);
ir_node
*
const
end_block
=
get_irg_end_block
(
irg
);
...
...
@@ -319,17 +325,17 @@ void ir_estimate_execfreq(ir_graph *irg)
const
ir_node
*
pred
=
get_Block_cfgpred_block
(
bb
,
i
);
int
pred_idx
=
size
-
dfs_get_post_num
(
dfs
,
pred
)
-
1
;
double
cf_probability
=
get_cf_probability
(
bb
,
i
,
inv_loop_weight
);
gs_
matrix_set
(
mat
,
idx
,
pred_idx
,
cf_probability
);
matrix_set
(
mat
,
size
,
idx
,
pred_idx
,
cf_probability
);
}
/* ... equals my execution frequency */
gs_
matrix_set
(
mat
,
idx
,
idx
,
-
1
.
0
);
matrix_set
(
mat
,
size
,
idx
,
idx
,
-
1
.
0
);
if
(
bb
==
end_block
)
{
/* Add an edge from end to start.
* The problem is then an eigenvalue problem:
* Solve A*x = 1*x => (A-I)x = 0
*/
gs_
matrix_set
(
mat
,
start_idx
,
idx
,
1
.
0
);
matrix_set
(
mat
,
size
,
start_idx
,
idx
,
1
.
0
);
/* add artifical edges from "kept blocks without a path to end"
* to end */
...
...
@@ -342,7 +348,7 @@ void ir_estimate_execfreq(ir_graph *irg)
double
fac
=
KEEP_FAC
/
sum
;
int
keep_idx
=
size
-
dfs_get_post_num
(
dfs
,
keep
)
-
1
;
//ir_printf("SEdge %+F -> %+F, fak: %f\n", keep, end_block, fac);
gs_
matrix_set
(
mat
,
idx
,
keep_idx
,
fac
);
matrix_set
(
mat
,
size
,
idx
,
keep_idx
,
fac
);
//gs_matrix_set(mat, start_idx, keep_idx, fac);
}
}
...
...
@@ -353,7 +359,7 @@ void ir_estimate_execfreq(ir_graph *irg)
//ir_fprintf(stderr, "%+F:\n", irg);
//gs_matrix_dump(mat, 100, 100, stderr);
solve_lgs
(
mat
,
x
,
size
);
gs_delete_matrix
(
mat
);
free
(
mat
);
/* compute the normalization factor.
* 1.0 / exec freq of start block.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment