4
4
#include "tm_mt.h"
5
5
#include "tm_verbose.h"
6
6
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 )
20
20
{
21
21
/* ##### declarations & allocations ##### */
22
22
@@ -48,7 +48,7 @@ int* kPartitioning(double ** comm, int n, int k, int * constraints, int nb_const
48
48
return part ;
49
49
}
50
50
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 )
52
52
{
53
53
int i ;
54
54
* Q = calloc (k , sizeof (PriorityQueue )); /*one Q for each partition*/
@@ -58,7 +58,7 @@ void memory_allocation(PriorityQueue ** Q, PriorityQueue ** Qinst, double *** D,
58
58
(* D )[i ] = calloc (k , sizeof (double ));
59
59
}
60
60
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 )
62
62
{
63
63
int i ,j ;
64
64
@@ -103,7 +103,7 @@ void initialization(int * const part, double ** const matrice, PriorityQueue * c
103
103
* surplus = * deficit = 0 ;
104
104
}
105
105
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 )
107
107
{
108
108
int p ,u ,v ,j ;
109
109
double d ;
@@ -149,7 +149,7 @@ void algo(int * const part, double ** const matrice, PriorityQueue * const Qpart
149
149
PQ_adjustKey (Qpart , part [u ], d ); /*we update the new highest possible gain in u's subset*/
150
150
}
151
151
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 )
153
153
{
154
154
double res ;
155
155
if (* deficit == * surplus ) /*if the current partition is balanced*/
@@ -159,7 +159,7 @@ double nextGain(PriorityQueue * const Qpart, PriorityQueue * const Q, int * cons
159
159
return res ;
160
160
}
161
161
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 )
163
163
{
164
164
if (surplus != deficit ) /*if the current partition is not balanced*/
165
165
{
@@ -176,7 +176,7 @@ void balancing(int n, int deficit, int surplus, double ** const D, int * const p
176
176
}
177
177
}
178
178
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 )
180
180
{
181
181
int i ;
182
182
PQ_exit (Qpart );
@@ -195,7 +195,7 @@ void destruction(PriorityQueue * Qpart, PriorityQueue * Q, PriorityQueue * Qinst
195
195
}
196
196
197
197
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 )
199
199
{
200
200
int * res = NULL , * best_res = NULL , * size = NULL ;
201
201
int i ,j ,nb_trials ;
@@ -229,7 +229,7 @@ int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *const
229
229
/* find a vertex not already partitionned*/
230
230
do {
231
231
/* call the mersenne twister PRNG of tm_mt.c*/
232
- j = genrand_int32 () % n ;
232
+ j = tm_genrand_int32 () % n ;
233
233
} while ( res [j ] != -1 );
234
234
/* allocate and update size of partition*/
235
235
res [j ] = i ;
@@ -261,7 +261,7 @@ int *kpartition_greedy2(int k, double **comm, int n, int nb_try_max, int *const
261
261
return best_res ;
262
262
}
263
263
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 )
265
265
{
266
266
int i ,best_part = -1 ;
267
267
double cost , best_cost = -1 ;
@@ -285,7 +285,7 @@ void allocate_vertex2(int u, int *res, double **comm, int n, int *size, int max_
285
285
size [best_part ]++ ;
286
286
}
287
287
288
- double eval_cost2 (int * partition , int n , double * * comm )
288
+ static double eval_cost2 (int * partition , int n , double * * comm )
289
289
{
290
290
double cost = 0 ;
291
291
int i ,j ;
@@ -298,7 +298,7 @@ double eval_cost2(int *partition, int n, double **comm)
298
298
return cost ;
299
299
}
300
300
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 )
302
302
{
303
303
int * part = NULL ;
304
304
if (greedy_trials > 0 ) /*if greedy_trials > 0 then we use kpartition_greedy with greedy_trials trials*/
0 commit comments