Fix all treematch issues idenfied by Coverity.
Этот коммит содержится в:
родитель
6ab5f68fc3
Коммит
02624bd0b6
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@ -73,7 +73,7 @@ tm_topology_t * tgt_to_tm(char *filename, double **pcost)
|
||||
build_synthetic_proc_id(topology);
|
||||
|
||||
*pcost = cost;
|
||||
/* FREE(cost); */
|
||||
fclose(pf);
|
||||
/*
|
||||
topology->arity[0]=nb_proc;
|
||||
topology->nb_levels=decompose((int)ceil((1.0*nb_obj)/nb_proc),1,topology->arity);
|
||||
@ -82,7 +82,6 @@ tm_topology_t * tgt_to_tm(char *filename, double **pcost)
|
||||
if(get_verbose_level() >= INFO)
|
||||
printf("Topology built from %s!\n",filename);
|
||||
|
||||
|
||||
return topology;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ void kpartition_build_level_topology(tree_t *cur_node, com_mat_t *com_mat, int N
|
||||
const_tab = split_constraints (constraints, nb_constraints, k, topology, depth);
|
||||
|
||||
/* create the table of k nodes of the resulting sub-tree */
|
||||
tab_child = (tree_t **) CALLOC (k,sizeof(tree_t));
|
||||
tab_child = (tree_t **) CALLOC (k,sizeof(tree_t*));
|
||||
for( i = 0 ; i < k ; i++){
|
||||
tab_child[i] = (tree_t *) MALLOC(sizeof(tree_t));
|
||||
}
|
||||
|
@ -170,24 +170,24 @@ void print_1D_tab(int *tab,int N)
|
||||
|
||||
int nb_lines(char *filename)
|
||||
{
|
||||
FILE *pf = NULL;
|
||||
char line[LINE_SIZE];
|
||||
int N = 0;
|
||||
FILE *pf = NULL;
|
||||
char line[LINE_SIZE];
|
||||
int N = 0;
|
||||
|
||||
if(!(pf = fopen(filename,"r"))){
|
||||
if(get_verbose_level() >= CRITICAL)
|
||||
fprintf(stderr,"Cannot open %s\n",filename);
|
||||
exit(-1);
|
||||
}
|
||||
if(!(pf = fopen(filename,"r"))){
|
||||
if(get_verbose_level() >= CRITICAL)
|
||||
fprintf(stderr,"Cannot open %s\n",filename);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
while(fgets(line,LINE_SIZE,pf))
|
||||
N++;
|
||||
while(fgets(line,LINE_SIZE,pf))
|
||||
N++;
|
||||
|
||||
if(get_verbose_level() >= DEBUG)
|
||||
printf("Number of lines of file %s = %d\n",filename,N);
|
||||
if(get_verbose_level() >= DEBUG)
|
||||
printf("Number of lines of file %s = %d\n",filename,N);
|
||||
|
||||
fclose(pf);
|
||||
return N;
|
||||
fclose(pf);
|
||||
return N;
|
||||
}
|
||||
|
||||
void init_comm(char *filename,int N,double **comm)
|
||||
@ -299,6 +299,7 @@ int build_binding_constraints(char *filename, int **ptab)
|
||||
}
|
||||
|
||||
*ptab = tab;
|
||||
fclose(pf);
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -562,8 +563,18 @@ void map_MPIPP(tm_topology_t *topology,int nb_seed,int N,int *Value,double **com
|
||||
}
|
||||
}while( max > 0 );
|
||||
|
||||
FREE(sol);
|
||||
sol=generate_random_sol(topology,N,topology->nb_levels-1,seed++);
|
||||
}
|
||||
FREE(sol);
|
||||
FREE(temp);
|
||||
FREE(state);
|
||||
for( i = 0 ; i < N ; i++){
|
||||
FREE(gain[i]);
|
||||
FREE(history[i]);
|
||||
}
|
||||
FREE(gain);
|
||||
FREE(history);
|
||||
}
|
||||
|
||||
/* void map_tree(tree_t* t1,tree_t *t2) */
|
||||
@ -624,74 +635,74 @@ int nb_leaves(tree_t *comm_tree)
|
||||
*/
|
||||
|
||||
void map_topology(tm_topology_t *topology,tree_t *comm_tree,int nb_compute_units,
|
||||
int level,int *sigma, int nb_processes, int *k)
|
||||
int level,int *sigma, int nb_processes, int *k)
|
||||
{
|
||||
int *nodes_id = NULL;
|
||||
int *proc_list = NULL;
|
||||
int i,N,M,block_size;
|
||||
unsigned int vl = get_verbose_level();
|
||||
int *nodes_id = NULL;
|
||||
int *proc_list = NULL;
|
||||
int i,N,M,block_size;
|
||||
unsigned int vl = get_verbose_level();
|
||||
|
||||
M = nb_leaves(comm_tree);
|
||||
nodes_id = topology->node_id[level];
|
||||
N = topology->nb_nodes[level];
|
||||
M = nb_leaves(comm_tree);
|
||||
nodes_id = topology->node_id[level];
|
||||
N = topology->nb_nodes[level];
|
||||
|
||||
if(vl >= INFO){
|
||||
printf("nb_leaves=%d\n",M);
|
||||
printf("level=%d, nodes_id=%p, N=%d\n",level,(void *)nodes_id,N);
|
||||
printf("N=%d,nb_compute_units=%d\n",N,nb_compute_units);
|
||||
}
|
||||
|
||||
/* The number of node at level "level" in the tree should be equal to the number of processors*/
|
||||
assert(N==nb_compute_units);
|
||||
|
||||
proc_list = (int*)MALLOC(sizeof(int)*M);
|
||||
i = 0;
|
||||
depth_first(comm_tree,proc_list,&i);
|
||||
|
||||
if(vl >= DEBUG)
|
||||
for(i=0;i<M;i++){
|
||||
printf ("%d\n",proc_list[i]);
|
||||
if(vl >= INFO){
|
||||
printf("nb_leaves=%d\n",M);
|
||||
printf("level=%d, nodes_id=%p, N=%d\n",level,(void *)nodes_id,N);
|
||||
printf("N=%d,nb_compute_units=%d\n",N,nb_compute_units);
|
||||
}
|
||||
|
||||
block_size = M/N;
|
||||
/* The number of node at level "level" in the tree should be equal to the number of processors*/
|
||||
assert(N==nb_compute_units);
|
||||
|
||||
if(k){/*if we need the k vector*/
|
||||
if(vl >= INFO)
|
||||
printf("M=%d, N=%d, BS=%d\n",M,N,block_size);
|
||||
for( i = 0 ; i < nb_processing_units(topology) ; i++ )
|
||||
k[i] = -1;
|
||||
proc_list = (int*)MALLOC(sizeof(int)*M);
|
||||
i = 0;
|
||||
depth_first(comm_tree,proc_list,&i);
|
||||
|
||||
for( i = 0 ; i < M ; i++ )
|
||||
if(proc_list[i] != -1){
|
||||
if(vl >= DEBUG)
|
||||
printf ("%d->%d\n",proc_list[i],nodes_id[i/block_size]);
|
||||
if(vl >= DEBUG)
|
||||
for(i=0;i<M;i++){
|
||||
printf ("%d\n",proc_list[i]);
|
||||
}
|
||||
|
||||
if( proc_list[i] < nb_processes ){
|
||||
sigma[proc_list[i]] = nodes_id[i/block_size];
|
||||
k[nodes_id[i/block_size]] = proc_list[i];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(vl >= INFO)
|
||||
printf("M=%d, N=%d, BS=%d\n",M,N,block_size);
|
||||
for( i = 0 ; i < M ; i++ )
|
||||
if(proc_list[i] != -1){
|
||||
if(vl >= DEBUG)
|
||||
printf ("%d->%d\n",proc_list[i],nodes_id[i/block_size]);
|
||||
if( proc_list[i] < nb_processes )
|
||||
sigma[proc_list[i]] = nodes_id[i/block_size];
|
||||
}
|
||||
}
|
||||
block_size = M/N;
|
||||
|
||||
if(vl >= DEBUG){
|
||||
printf("k: ");
|
||||
for( i = 0 ; i < nb_processing_units(topology) ; i++ )
|
||||
printf("%d ",k[i]);
|
||||
printf("\n");
|
||||
}
|
||||
if(k){/*if we need the k vector*/
|
||||
if(vl >= INFO)
|
||||
printf("M=%d, N=%d, BS=%d\n",M,N,block_size);
|
||||
for( i = 0 ; i < nb_processing_units(topology) ; i++ )
|
||||
k[i] = -1;
|
||||
|
||||
for( i = 0 ; i < M ; i++ )
|
||||
if(proc_list[i] != -1){
|
||||
if(vl >= DEBUG)
|
||||
printf ("%d->%d\n",proc_list[i],nodes_id[i/block_size]);
|
||||
|
||||
if( proc_list[i] < nb_processes ){
|
||||
sigma[proc_list[i]] = nodes_id[i/block_size];
|
||||
k[nodes_id[i/block_size]] = proc_list[i];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(vl >= INFO)
|
||||
printf("M=%d, N=%d, BS=%d\n",M,N,block_size);
|
||||
for( i = 0 ; i < M ; i++ )
|
||||
if(proc_list[i] != -1){
|
||||
if(vl >= DEBUG)
|
||||
printf ("%d->%d\n",proc_list[i],nodes_id[i/block_size]);
|
||||
if( proc_list[i] < nb_processes )
|
||||
sigma[proc_list[i]] = nodes_id[i/block_size];
|
||||
}
|
||||
}
|
||||
|
||||
if((vl >= DEBUG) && (k)){
|
||||
printf("k: ");
|
||||
for( i = 0 ; i < nb_processing_units(topology) ; i++ )
|
||||
printf("%d ",k[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
FREE(proc_list);
|
||||
FREE(proc_list);
|
||||
}
|
||||
|
||||
void map_topology_simple(tm_topology_t *topology,tree_t *comm_tree, int *sigma, int nb_processes, int *k)
|
||||
@ -1203,8 +1214,10 @@ int constraint_dsc(const void* x1,const void* x2)
|
||||
void display_contsraint_tab(constraint_t *const_tab, int n)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < n; i++ )
|
||||
printf("tab %d:",i);print_1D_tab(const_tab[i].constraints, const_tab[i].length);
|
||||
for( i = 0; i < n; i++ ) {
|
||||
printf("tab %d:",i);
|
||||
print_1D_tab(const_tab[i].constraints, const_tab[i].length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,15 +105,15 @@ affinity_mat_t *new_affinity_mat(double **mat, double *sum_row, int order){
|
||||
|
||||
void FREE_list_child(tree_t *tree)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if(tree)
|
||||
if(NULL == tree) return;
|
||||
for(i=0;i<tree->arity;i++)
|
||||
FREE_list_child(tree->child[i]);
|
||||
FREE_list_child(tree->child[i]);
|
||||
|
||||
FREE(tree->child);
|
||||
if(tree->dumb)
|
||||
FREE(tree);
|
||||
FREE(tree->child);
|
||||
if(tree->dumb)
|
||||
FREE(tree);
|
||||
}
|
||||
|
||||
void FREE_tab_child(tree_t *tree)
|
||||
@ -948,62 +948,62 @@ int adjacency_dsc(const void* x1,const void* x2)
|
||||
|
||||
void super_fast_grouping(affinity_mat_t *aff_mat,tree_t *tab_node, tree_t *new_tab_node, int arity, int M)
|
||||
{
|
||||
double val = 0,duration;
|
||||
adjacency_t *graph;
|
||||
int i,j,e,l,nb_groups;
|
||||
int N = aff_mat->order;
|
||||
double **mat = aff_mat->mat;
|
||||
double val = 0,duration;
|
||||
adjacency_t *graph;
|
||||
int i,j,e,l,nb_groups;
|
||||
int N = aff_mat->order;
|
||||
double **mat = aff_mat->mat;
|
||||
|
||||
assert( 2 == arity);
|
||||
assert( 2 == arity);
|
||||
|
||||
TIC;
|
||||
graph = (adjacency_t*)MALLOC(sizeof(adjacency_t)*((N*N-N)/2));
|
||||
e = 0;
|
||||
for( i = 0 ; i < N ; i++ )
|
||||
for( j = i+1 ; j < N ; j++){
|
||||
graph[e].i = i;
|
||||
graph[e].j = j;
|
||||
graph[e].val = mat[i][j];
|
||||
e++;
|
||||
TIC;
|
||||
graph = (adjacency_t*)MALLOC(sizeof(adjacency_t)*((N*N-N)/2));
|
||||
e = 0;
|
||||
for( i = 0 ; i < N ; i++ )
|
||||
for( j = i+1 ; j < N ; j++){
|
||||
graph[e].i = i;
|
||||
graph[e].j = j;
|
||||
graph[e].val = mat[i][j];
|
||||
e++;
|
||||
}
|
||||
|
||||
duration = TOC;
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("linearization=%fs\n",duration);
|
||||
|
||||
|
||||
assert( e == (N*N-N)/2);
|
||||
TIC;
|
||||
qsort(graph,e,sizeof(adjacency_t),adjacency_dsc);
|
||||
duration = TOC;
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("sorting=%fs\n",duration);
|
||||
|
||||
TIC;
|
||||
|
||||
TIC;
|
||||
l = 0;
|
||||
nb_groups = 0;
|
||||
for( i = 0 ; (i < e) && (l < M) ; i++ )
|
||||
if(try_add_edge(tab_node,&new_tab_node[l],arity,graph[i].i,graph[i].j,&nb_groups))
|
||||
l++;
|
||||
|
||||
for( l = 0 ; l < M ; l++ ){
|
||||
update_val(aff_mat,&new_tab_node[l]);
|
||||
val += new_tab_node[l].val;
|
||||
}
|
||||
|
||||
duration = TOC;
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("linearization=%fs\n",duration);
|
||||
duration = TOC;
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("Grouping=%fs\n",duration);
|
||||
|
||||
|
||||
assert( e == (N*N-N)/2);
|
||||
TIC;
|
||||
qsort(graph,e,sizeof(adjacency_t),adjacency_dsc);
|
||||
duration = TOC;
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("sorting=%fs\n",duration);
|
||||
|
||||
TIC;
|
||||
|
||||
TIC;
|
||||
l = 0;
|
||||
nb_groups = 0;
|
||||
for( i = 0 ; (i < e) && (l < M) ; i++ )
|
||||
if(try_add_edge(tab_node,&new_tab_node[l],arity,graph[i].i,graph[i].j,&nb_groups))
|
||||
l++;
|
||||
|
||||
for( l = 0 ; l < M ; l++ ){
|
||||
update_val(aff_mat,&new_tab_node[l]);
|
||||
val += new_tab_node[l].val;
|
||||
}
|
||||
|
||||
duration = TOC;
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("Grouping=%fs\n",duration);
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("val=%f\n",val);
|
||||
|
||||
|
||||
if(verbose_level>=DEBUG)
|
||||
printf("val=%f\n",val);
|
||||
|
||||
|
||||
display_grouping(new_tab_node,M,arity,val);
|
||||
|
||||
display_grouping(new_tab_node,M,arity,val);
|
||||
FREE(graph);
|
||||
}
|
||||
|
||||
|
||||
@ -1495,67 +1495,68 @@ double speed(int depth)
|
||||
|
||||
int check_constraints(tm_topology_t *topology, int **constraints)
|
||||
{
|
||||
int j,i,n = nb_processing_units(topology);
|
||||
int *tab_constraints = NULL, nb_constraints = 0;
|
||||
int *tab_node = NULL;
|
||||
int *count = NULL;
|
||||
int j,i,n = nb_processing_units(topology);
|
||||
int *tab_constraints = NULL, nb_constraints = 0;
|
||||
int *tab_node = NULL;
|
||||
int *count = NULL;
|
||||
|
||||
/* tab_node: array of core numbers.
|
||||
tab_node[i]=-1 if this core is forbiden
|
||||
numbering is such that
|
||||
0<=tab_node[i]<n
|
||||
and that there is only one core of a given number
|
||||
*/
|
||||
tab_node = topology->node_id[topology->nb_levels-1];
|
||||
/* tab_node: array of core numbers.
|
||||
tab_node[i]=-1 if this core is forbiden
|
||||
numbering is such that
|
||||
0<=tab_node[i]<n
|
||||
and that there is only one core of a given number
|
||||
*/
|
||||
tab_node = topology->node_id[topology->nb_levels-1];
|
||||
|
||||
/* "count" counts the number of cores of a given number.
|
||||
count[i]: number of cores of number i.
|
||||
0<=count[i]<=1
|
||||
*/
|
||||
count = (int *)CALLOC(n,sizeof(int));
|
||||
for( i = 0 ; i < n ; i++ )
|
||||
if (tab_node[i] != -1){
|
||||
if( (tab_node[i] >= 0) && (tab_node[i] < n)){
|
||||
/* In the remaining, we assume that the core numbering is logical from 0 to n
|
||||
so if tab_node[i]!=-1 this mean sthat we have to use core number i*/
|
||||
count[i]++;
|
||||
nb_constraints++;
|
||||
}else{
|
||||
if(verbose_level >= ERROR)
|
||||
fprintf(stderr, "*** Error: Core numbering not between 0 and %d: tab_node[%d]=%d\n", n , i, tab_node[i]);
|
||||
*constraints = NULL;
|
||||
return 0;
|
||||
}
|
||||
/* "count" counts the number of cores of a given number.
|
||||
count[i]: number of cores of number i.
|
||||
0<=count[i]<=1
|
||||
*/
|
||||
count = (int *)CALLOC(n,sizeof(int));
|
||||
for( i = 0 ; i < n ; i++ )
|
||||
if (tab_node[i] != -1){
|
||||
if( (tab_node[i] >= 0) && (tab_node[i] < n)){
|
||||
/* In the remaining, we assume that the core numbering is logical from 0 to n
|
||||
so if tab_node[i]!=-1 this mean sthat we have to use core number i*/
|
||||
count[i]++;
|
||||
nb_constraints++;
|
||||
}else{
|
||||
if(verbose_level >= ERROR)
|
||||
fprintf(stderr, "*** Error: Core numbering not between 0 and %d: tab_node[%d]=%d\n", n , i, tab_node[i]);
|
||||
*constraints = NULL;
|
||||
FREE(count);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(nb_constraints == 0){
|
||||
FREE(count);
|
||||
*constraints = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(nb_constraints == 0){
|
||||
tab_constraints = (int*) MALLOC(sizeof(int)*nb_constraints);
|
||||
|
||||
/* we can now use the "counting sort" to sort the constraint tab in increasing order in linear time*/
|
||||
j = 0;
|
||||
for( i = 0 ; i < n ; i++ )
|
||||
if(count[i])
|
||||
tab_constraints[j++] = i;
|
||||
|
||||
/* if the constraint_tab is not full, this means that some count[i]>1*/
|
||||
if( j != nb_constraints ){
|
||||
if(verbose_level >= ERROR)
|
||||
fprintf(stderr,"*** Error: Duplicate numbering: j=%d, nb_constraints= %d\n",j, nb_constraints);
|
||||
FREE(tab_constraints);
|
||||
FREE(count);
|
||||
*constraints = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FREE local variables, assign result, return result*/
|
||||
FREE(count);
|
||||
*constraints = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
tab_constraints = (int*) MALLOC(sizeof(int)*nb_constraints);
|
||||
|
||||
/* we can now use the "counting sort" to sort the constraint tab in increasing order in linear time*/
|
||||
j = 0;
|
||||
for( i = 0 ; i < n ; i++ )
|
||||
if(count[i])
|
||||
tab_constraints[j++] = i;
|
||||
|
||||
/* if the constraint_tab is not full, this means that some count[i]>1*/
|
||||
if( j != nb_constraints ){
|
||||
if(verbose_level >= ERROR)
|
||||
fprintf(stderr,"*** Error: Duplicate numbering: j=%d, nb_constraints= %d\n",j, nb_constraints);
|
||||
FREE(tab_constraints);
|
||||
FREE(count);
|
||||
*constraints = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FREE local variables, assign result, return result*/
|
||||
FREE(count);
|
||||
*constraints = tab_constraints;
|
||||
return nb_constraints;
|
||||
*constraints = tab_constraints;
|
||||
return nb_constraints;
|
||||
}
|
||||
|
||||
affinity_mat_t * build_affinity_mat(double **mat, int order){
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user