Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "DistributeMat.h"
struct opts Options ;
extern int DetermineSplit(long *weight, long maxweight, int k, int *procs,
int *isplit, long *weightlo, long *weighthi, const struct opts *pOptions);
int main(int argc, char **argv) {
long w, *weight, maxweight, weightlo, weighthi ;
int k, r, a, b, i, *procs ;
printf("Test DetermineSplit: ");
/* k, r, a, can be varied, but b is hardwired */
k = 20; /* number of parts >= 1 */
r = 10 ;
w = 5*r; /* average weight per processor */
a = 4 ; /* size of smallest part, measured in w */
b = 21 ; /* size of largest part, measured in w */
procs = (int *) malloc(k * sizeof(int)) ;
weight = (long *) malloc(k * sizeof(long)) ;
if ( procs == NULL || weight == NULL){
printf("Error\n") ;
exit(1);
}
weight[0] = b*w; /* largest part */
procs[0] = b;
for (i=1; i<k; i++){
weight[i] = a*w;
procs[i] = a;
}
maxweight = 2*w;
/* Compute the number of processors for each part */
Options.LoadbalanceStrategy = Constant ;
DetermineSplit(weight, maxweight, k, procs, &i, &weightlo, &weighthi, &Options) ;
/* Check result values */
if ( i != 0 || (weightlo != 60*r && weightlo != 60*r -1)
|| (weighthi != 66*r && weighthi != 66*r -1) ) {
printf("Error\n") ;
exit(1);
}
printf("OK\n") ;
exit(0);
} /* end main */