OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
MultiBalancer.t.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  * This program was prepared by PSI.
7  * All rights in the program are reserved by PSI.
8  * Neither PSI nor the author(s)
9  * makes any warranty, express or implied, or assumes any liability or
10  * responsibility for the use of this software
11  *
12  * Visit www.amas.web.psi for more details
13  *
14  ***************************************************************************/
15 
16 // -*- C++ -*-
17 /***************************************************************************
18  *
19  * The IPPL Framework
20  *
21  *
22  * Visit http://people.web.psi.ch/adelmann/ for more details
23  *
24  ***************************************************************************/
25 
26 // include files
27 #include "MultiBalancer.h"
28 
29 #include <cmath>
30 #include <cstdio>
31 #include <cstdlib>
32 
33 
35 {
36  const int procs = 8;
37  const int vnodes = 32;
38  const int materials = 10;
39  int m,v,p;
40  double weights[materials][vnodes];
41 
42  MultiBalancer balancer(procs,vnodes);
43 
44  for (m=0; m<materials; ++m)
45  {
46  for (v=0; v<vnodes; ++v)
47  weights[m][v] = ( rand()<(RAND_MAX/4) ? 1.0 : 0.0 );
48  balancer.newMaterial();
49  balancer.appendWeights(weights[m],weights[m]+vnodes);
50  }
51  balancer.distribute();
52 
53  printf("\nInput weights:\n");
54  for (v=0; v<vnodes; ++v)
55  printf("%7d",v);
56  printf("\n");
57  for (m=0; m<materials; ++m)
58  {
59  for (v=0; v<vnodes; ++v)
60  printf("%7.3f",balancer.m_inputWeights[m][0][v]);
61  printf("\n");
62  }
63 
64  printf("\nProcessor destinations:\n");
65  for (v=0; v<vnodes; ++v)
66  printf("%7d",balancer.m_vnodeProcs[v]);
67  printf("\n");
68 
69  printf("\nProcessor weights:\n");
70  for (m=0; m<materials; ++m)
71  {
72  for (p=0; p<procs; ++p)
73  printf("%7.3f",balancer.m_materialProcWeights[m][0][p]);
74  printf("\n");
75  }
76  printf("Totals:\n");
77  for (p=0; p<procs; ++p)
78  printf("%7.3f",balancer.m_procWeights[p]);
79  printf("\n");
80 
81  printf("\nMaterial Max weights:\n");
82  for (m=0; m<materials; ++m)
83  printf("%7.3f",balancer.m_materialMaxWeights[m]);
84  printf("\n");
85 }
86 
87 int main()
88 {
90  return 0;
91 }
92 
93 
94 /***************************************************************************
95  * $RCSfile: MultiBalancer.t.cpp,v $ $Author: adelmann $
96  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:27 $
97  * IPPL_VERSION_ID: $Id: MultiBalancer.t.cpp,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $
98  ***************************************************************************/
ProcWeights_t m_procWeights
void appendWeights(double *begin, double *end)
MaterialVnodeWeights_t m_inputWeights
void multiBalancerTester()
MaterialWeights_t m_materialMaxWeights
MaterialProcWeights_t m_materialProcWeights
VnodeDestProcs_t m_vnodeProcs
int main(int argc, char *argv[])
Definition: Main.cpp:107