Skip to content

Commit 2a95bb9

Browse files
author
David Wootton
committed
Part 3 of resolving global symbol name pollution #10708 - treematch
Fix review comments Signed-off-by: David Wootton <drwootton@us.ibm.com>
1 parent 3221782 commit 2a95bb9

30 files changed

+568
-562
lines changed

3rd-party/treematch/IntConstantInitializedVector.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdio.h>
33
#include "IntConstantInitializedVector.h"
44

5-
int intCIV_isInitialized(int_CIVector * v, int i)
5+
int tm_intCIV_isInitialized(int_CIVector * v, int i)
66
{
77
if(v->top == 0)
88
return 0;
@@ -14,7 +14,7 @@ int intCIV_isInitialized(int_CIVector * v, int i)
1414

1515

1616

17-
void intCIV_init(int_CIVector * v, int size, int init_value)
17+
void tm_intCIV_init(int_CIVector * v, int size, int init_value)
1818
{
1919
v->init_value = init_value;
2020
v->size = size;
@@ -24,20 +24,20 @@ void intCIV_init(int_CIVector * v, int size, int init_value)
2424
v->vec = malloc(sizeof(int)*size);
2525
}
2626

27-
void intCIV_exit(int_CIVector * v)
27+
static inline void intCIV_exit(int_CIVector * v)
2828
{
2929
free(v->to);
3030
free(v->from);
3131
free(v->vec);
3232
}
3333

34-
int intCIV_set(int_CIVector * v, int i, int val)
34+
int tm_intCIV_set(int_CIVector * v, int i, int val)
3535
{
3636
if(v == NULL)
3737
return -1;
3838
if(i < 0 || i >= v->size)
3939
return -1;
40-
if(!intCIV_isInitialized(v,i))
40+
if(!tm_intCIV_isInitialized(v,i))
4141
{
4242
v->from[i] = v->top;
4343
v->to[v->top] = i;
@@ -47,13 +47,13 @@ int intCIV_set(int_CIVector * v, int i, int val)
4747
return 0;
4848
}
4949

50-
int intCIV_get(int_CIVector * v, int i)
50+
int tm_intCIV_get(int_CIVector * v, int i)
5151
{
5252
if(v == NULL)
5353
return -1;
5454
if(i < 0 || i >= v->size)
5555
return -1;
56-
if(intCIV_isInitialized(v,i))
56+
if(tm_intCIV_isInitialized(v,i))
5757
return v->vec[i];
5858
return v->init_value;
5959
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#ifndef INTEGER_CONSTANT_INITIALIZED_VECTOR
22
#define INTEGER_CONSTANT_INITIALIZED_VECTOR
33

4+
#include "ompi_config.h"
5+
46
typedef struct int_CIVector_
57
{
68
int init_value, size, top, *to, *from, *vec;
79
} int_CIVector;
810

9-
int intCIV_isInitialized(int_CIVector * v, int i);
10-
void intCIV_init(int_CIVector * v, int size, int init_value);
11-
void intCIV_exit(int_CIVector * v);
12-
int intCIV_set(int_CIVector * v, int i, int val);
13-
int intCIV_get(int_CIVector * v, int i);
11+
OMPI_HIDDEN int tm_intCIV_isInitialized(int_CIVector * v, int i);
12+
OMPI_HIDDEN void tm_intCIV_init(int_CIVector * v, int size, int init_value);
13+
OMPI_HIDDEN int tm_intCIV_set(int_CIVector * v, int i, int val);
14+
OMPI_HIDDEN int tm_intCIV_get(int_CIVector * v, int i);
1415

1516
#endif /*INTEGER_CONSTANT_INITIALIZED_VECTOR*/

3rd-party/treematch/PriorityQueue.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int PQ_init(PriorityQueue * const q, int size)
2121
q->elements = malloc(sizeof(QueueElement *) * size);
2222
for(i=0; i < size; i++)
2323
q->elements[i]=NULL;
24-
return fiboTreeInit((FiboTree *)q, compFunc);
24+
return tm_fiboTreeInit((FiboTree *)q, compFunc);
2525
}
2626

2727
void PQ_exit(PriorityQueue * const q)
@@ -35,7 +35,7 @@ void PQ_exit(PriorityQueue * const q)
3535
}
3636
if(q->elements != NULL)
3737
free(q->elements);
38-
fiboTreeExit((FiboTree *)q);
38+
tm_fiboTreeExit((FiboTree *)q);
3939
}
4040
void PQ_free(PriorityQueue * const q)
4141
{
@@ -45,7 +45,7 @@ void PQ_free(PriorityQueue * const q)
4545
if(q->elements[i] != NULL)
4646
free(q->elements[i]);
4747
}
48-
fiboTreeFree((FiboTree *)q);
48+
tm_fiboTreeFree((FiboTree *)q);
4949
}
5050

5151
int PQ_isEmpty(PriorityQueue * const q)
@@ -68,7 +68,7 @@ void PQ_insertElement(PriorityQueue * const q, QueueElement * const e)
6868
}
6969
void PQ_deleteElement(PriorityQueue * const q, QueueElement * const e)
7070
{
71-
fiboTreeDel((FiboTree *)q, (FiboNode *)(e));
71+
tm_fiboTreeDel((FiboTree *)q, (FiboNode *)(e));
7272
q->elements[e->value] = NULL;
7373
e->isInQueue = 0;
7474
}
@@ -93,12 +93,12 @@ void PQ_delete(PriorityQueue * const q, int val)
9393

9494
QueueElement * PQ_findMaxElement(PriorityQueue * const q)
9595
{
96-
QueueElement * e = (QueueElement *)(fiboTreeMin((FiboTree *)q));
96+
QueueElement * e = (QueueElement *)(tm_fiboTreeMin((FiboTree *)q));
9797
return e;
9898
}
9999
QueueElement * PQ_deleteMaxElement(PriorityQueue * const q)
100100
{
101-
QueueElement * e = (QueueElement *)(fiboTreeMin((FiboTree *)q));
101+
QueueElement * e = (QueueElement *)(tm_fiboTreeMin((FiboTree *)q));
102102
if(e != NULL)
103103
{
104104
PQ_deleteElement(q, e);

3rd-party/treematch/fibo.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
**
2929
** The fact that you are presently reading this means that you have had
3030
** knowledge of the CeCILL-B license and that you accept its terms.
31+
**
3132
*/
3233
/************************************************************/
3334
/** **/
@@ -69,6 +70,8 @@
6970
#define memFree free
7071
#endif /* memAlloc */
7172

73+
static FiboNode *fiboTreeConsolidate (FiboTree * const);
74+
7275
/*********************************************/
7376
/* */
7477
/* These routines deal with Fibonacci trees. */
@@ -83,7 +86,7 @@
8386
*/
8487

8588
int
86-
fiboTreeInit (
89+
tm_fiboTreeInit (
8790
FiboTree * const treeptr,
8891
int (* cmpfptr) (const FiboNode * const, const FiboNode * const))
8992
{
@@ -106,7 +109,7 @@ int (* cmpfptr) (const FiboNode * const, const FiboNode * c
106109
*/
107110

108111
void
109-
fiboTreeExit (
112+
tm_fiboTreeExit (
110113
FiboTree * const treeptr)
111114
{
112115
if (treeptr->degrtab != NULL)
@@ -122,7 +125,7 @@ FiboTree * const treeptr)
122125
*/
123126

124127
void
125-
fiboTreeFree (
128+
tm_fiboTreeFree (
126129
FiboTree * const treeptr)
127130
{
128131
treeptr->rootdat.linkdat.prevptr = /* Link root node to itself */
@@ -138,7 +141,7 @@ FiboTree * const treeptr)
138141
** - NULL : Fibonacci tree is empty.
139142
*/
140143

141-
FiboNode *
144+
static FiboNode *
142145
fiboTreeConsolidate (
143146
FiboTree * const treeptr)
144147
{
@@ -229,7 +232,7 @@ FiboTree * const treeptr)
229232
#ifndef fiboTreeMin
230233

231234
FiboNode *
232-
fiboTreeMin (
235+
tm_fiboTreeMin (
233236
FiboTree * const treeptr)
234237
{
235238
FiboNode * bestptr;
@@ -279,7 +282,7 @@ FiboNode * const nodeptr)
279282
#ifndef fiboTreeDel
280283

281284
void
282-
fiboTreeDel (
285+
tm_fiboTreeDel (
283286
FiboTree * const treeptr,
284287
FiboNode * const nodeptr)
285288
{

3rd-party/treematch/fibo.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
**
2929
** The fact that you are presently reading this means that you have had
3030
** knowledge of the CeCILL-B license and that you accept its terms.
31+
**
3132
*/
3233
/************************************************************/
3334
/** **/
@@ -56,6 +57,8 @@
5657
/** **/
5758
/************************************************************/
5859

60+
#include "ompi_config.h"
61+
5962
/*
6063
** The type and structure definitions.
6164
*/
@@ -184,19 +187,18 @@ typedef struct FiboTree_ {
184187
#define static
185188
#endif
186189

187-
int fiboTreeInit (FiboTree * const, int (*) (const FiboNode * const, const FiboNode * const));
188-
void fiboTreeExit (FiboTree * const);
189-
void fiboTreeFree (FiboTree * const);
190-
FiboNode * fiboTreeConsolidate (FiboTree * const);
190+
OMPI_HIDDEN int tm_fiboTreeInit (FiboTree * const, int (*) (const FiboNode * const, const FiboNode * const));
191+
OMPI_HIDDEN void tm_fiboTreeExit (FiboTree * const);
192+
OMPI_HIDDEN void tm_fiboTreeFree (FiboTree * const);
191193
#ifndef fiboTreeAdd
192194
void fiboTreeAdd (FiboTree * const, FiboNode * const);
193195
#endif /* fiboTreeAdd */
194196
#ifndef fiboTreeDel
195-
void fiboTreeDel (FiboTree * const, FiboNode * const);
197+
OMPI_HIDDEN void tm_fiboTreeDel (FiboTree * const, FiboNode * const);
196198
#endif /* fiboTreeDel */
197-
#ifndef fiboTreeMin
198-
FiboNode * fiboTreeMin (FiboTree * const);
199-
#endif /* fiboTreeMin */
199+
#ifndef treematch_fiboTreeMin
200+
OMPI_HIDDEN FiboNode * tm_fiboTreeMin (FiboTree * const);
201+
#endif /* treematch_fiboTreeMin */
200202
#ifdef FIBO_DEBUG
201203
int fiboTreeCheck (const FiboTree * const);
202204
static int fiboTreeCheck2 (const FiboNode * const);

3rd-party/treematch/k-partitioning.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include "tm_mt.h"
55
#include "tm_verbose.h"
66

7-
void memory_allocation(PriorityQueue ** Q, PriorityQueue ** Qinst, double *** D, int n, int k);
8-
void initialization(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int k, int * const deficit, int * const surplus);
9-
void algo(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int * const deficit, int * const surplus);
10-
double nextGain(PriorityQueue * const Qpart, PriorityQueue * const Q, int * const deficit, int * const surplus);
11-
void balancing(int n, int deficit, int surplus, double ** const D, int * const part);
12-
void destruction(PriorityQueue * Qpart, PriorityQueue * Q, PriorityQueue * Qinst, double ** D, int n, int k);
13-
14-
void allocate_vertex2(int u, int *res, double **comm, int n, int *size, int max_size);
15-
double eval_cost2(int *,int,double **);
16-
int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *constraints, int nb_constraints);
17-
int* build_p_vector(double **comm, int n, int k, int greedy_trials, int * constraints, int nb_constraints);
18-
19-
int* kPartitioning(double ** comm, int n, int k, int * constraints, int nb_constraints, int greedy_trials)
7+
static void memory_allocation(PriorityQueue ** Q, PriorityQueue ** Qinst, double *** D, int n, int k);
8+
static void initialization(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int k, int * const deficit, int * const surplus);
9+
static void algo(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int * const deficit, int * const surplus);
10+
static double nextGain(PriorityQueue * const Qpart, PriorityQueue * const Q, int * const deficit, int * const surplus);
11+
static void balancing(int n, int deficit, int surplus, double ** const D, int * const part);
12+
static void destruction(PriorityQueue * Qpart, PriorityQueue * Q, PriorityQueue * Qinst, double ** D, int n, int k);
13+
14+
static void allocate_vertex2(int u, int *res, double **comm, int n, int *size, int max_size);
15+
static double eval_cost2(int *,int,double **);
16+
static int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *constraints, int nb_constraints);
17+
static int* build_p_vector(double **comm, int n, int k, int greedy_trials, int * constraints, int nb_constraints);
18+
19+
int* tm_kPartitioning(double ** comm, int n, int k, int * constraints, int nb_constraints, int greedy_trials)
2020
{
2121
/* ##### declarations & allocations ##### */
2222

@@ -48,7 +48,7 @@ int* kPartitioning(double ** comm, int n, int k, int * constraints, int nb_const
4848
return part;
4949
}
5050

51-
void memory_allocation(PriorityQueue ** Q, PriorityQueue ** Qinst, double *** D, int n, int k)
51+
static void memory_allocation(PriorityQueue ** Q, PriorityQueue ** Qinst, double *** D, int n, int k)
5252
{
5353
int i;
5454
*Q = calloc(k, sizeof(PriorityQueue)); /*one Q for each partition*/
@@ -58,7 +58,7 @@ void memory_allocation(PriorityQueue ** Q, PriorityQueue ** Qinst, double *** D,
5858
(*D)[i] = calloc(k, sizeof(double));
5959
}
6060

61-
void initialization(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int k, int * const deficit, int * const surplus)
61+
static void initialization(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int k, int * const deficit, int * const surplus)
6262
{
6363
int i,j;
6464

@@ -103,7 +103,7 @@ void initialization(int * const part, double ** const matrice, PriorityQueue * c
103103
*surplus = *deficit = 0;
104104
}
105105

106-
void algo(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int * const deficit, int * const surplus)
106+
static void algo(int * const part, double ** const matrice, PriorityQueue * const Qpart, PriorityQueue * const Q, PriorityQueue * const Qinst, double ** const D, int n, int * const deficit, int * const surplus)
107107
{
108108
int p,u,v,j;
109109
double d;
@@ -149,7 +149,7 @@ void algo(int * const part, double ** const matrice, PriorityQueue * const Qpart
149149
PQ_adjustKey(Qpart, part[u], d); /*we update the new highest possible gain in u's subset*/
150150
}
151151

152-
double nextGain(PriorityQueue * const Qpart, PriorityQueue * const Q, int * const deficit, int * const surplus)
152+
static double nextGain(PriorityQueue * const Qpart, PriorityQueue * const Q, int * const deficit, int * const surplus)
153153
{
154154
double res;
155155
if(*deficit == *surplus) /*if the current partition is balanced*/
@@ -159,7 +159,7 @@ double nextGain(PriorityQueue * const Qpart, PriorityQueue * const Q, int * cons
159159
return res;
160160
}
161161

162-
void balancing(int n, int deficit, int surplus, double ** const D, int * const part)
162+
static void balancing(int n, int deficit, int surplus, double ** const D, int * const part)
163163
{
164164
if(surplus != deficit) /*if the current partition is not balanced*/
165165
{
@@ -176,7 +176,7 @@ void balancing(int n, int deficit, int surplus, double ** const D, int * const p
176176
}
177177
}
178178

179-
void destruction(PriorityQueue * Qpart, PriorityQueue * Q, PriorityQueue * Qinst, double ** D, int n, int k)
179+
static void destruction(PriorityQueue * Qpart, PriorityQueue * Q, PriorityQueue * Qinst, double ** D, int n, int k)
180180
{
181181
int i;
182182
PQ_exit(Qpart);
@@ -195,7 +195,7 @@ void destruction(PriorityQueue * Qpart, PriorityQueue * Q, PriorityQueue * Qinst
195195
}
196196

197197

198-
int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *constraints, int nb_constraints)
198+
static int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *constraints, int nb_constraints)
199199
{
200200
int *res = NULL, *best_res=NULL, *size = NULL;
201201
int i,j,nb_trials;
@@ -229,7 +229,7 @@ int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *const
229229
/* find a vertex not already partitionned*/
230230
do{
231231
/* call the mersenne twister PRNG of tm_mt.c*/
232-
j = genrand_int32() % n;
232+
j = tm_genrand_int32() % n;
233233
} while ( res[j] != -1 );
234234
/* allocate and update size of partition*/
235235
res[j] = i;
@@ -261,7 +261,7 @@ int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *const
261261
return best_res;
262262
}
263263

264-
void allocate_vertex2(int u, int *res, double **comm, int n, int *size, int max_size)
264+
static void allocate_vertex2(int u, int *res, double **comm, int n, int *size, int max_size)
265265
{
266266
int i,best_part = -1;
267267
double cost, best_cost = -1;
@@ -285,7 +285,7 @@ void allocate_vertex2(int u, int *res, double **comm, int n, int *size, int max_
285285
size[best_part]++;
286286
}
287287

288-
double eval_cost2(int *partition, int n, double **comm)
288+
static double eval_cost2(int *partition, int n, double **comm)
289289
{
290290
double cost = 0;
291291
int i,j;
@@ -298,7 +298,7 @@ double eval_cost2(int *partition, int n, double **comm)
298298
return cost;
299299
}
300300

301-
int* build_p_vector(double **comm, int n, int k, int greedy_trials, int * constraints, int nb_constraints)
301+
static int* build_p_vector(double **comm, int n, int k, int greedy_trials, int * constraints, int nb_constraints)
302302
{
303303
int * part = NULL;
304304
if(greedy_trials>0) /*if greedy_trials > 0 then we use kpartition_greedy with greedy_trials trials*/

3rd-party/treematch/k-partitioning.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef K_PARTITIONING
22
#define K_PARTITIONING
33

4+
#include "ompi_config.h"
5+
46
#include "PriorityQueue.h"
57

68
/*
@@ -14,7 +16,7 @@
1416
- 0 : cyclic distribution of vertices
1517
- > 0 : use of kpartition_greedy with greedy_trials number of trials
1618
*/
17-
18-
int* kPartitioning(double ** comm, int n, int k, int * const constraints, int nb_constraints, int greedy_trials);
19+
20+
OMPI_HIDDEN int* tm_kPartitioning(double ** comm, int n, int k, int * const constraints, int nb_constraints, int greedy_trials);
1921

2022
#endif /*K_PARTITIONING*/

0 commit comments

Comments
 (0)