src/FieldLayout/MultiBalancer.t.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 // include files
00027 #include "MultiBalancer.h"
00028 
00029 #include <math.h>
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 
00033 
00034 void multiBalancerTester()
00035 {
00036   const int procs = 8;
00037   const int vnodes = 32;
00038   const int materials = 10;
00039   int m,v,p;
00040   double weights[materials][vnodes];
00041   
00042   MultiBalancer balancer(procs,vnodes);
00043 
00044   for (m=0; m<materials; ++m)
00045     {
00046       for (v=0; v<vnodes; ++v)
00047         weights[m][v] = ( rand()<(RAND_MAX/4) ? 1.0 : 0.0 );
00048       balancer.newMaterial();
00049       balancer.appendWeights(weights[m],weights[m]+vnodes);
00050     }
00051   balancer.distribute();
00052   
00053   printf("\nInput weights:\n");
00054   for (v=0; v<vnodes; ++v)
00055     printf("%7d",v);
00056   printf("\n");
00057   for (m=0; m<materials; ++m)
00058     {
00059       for (v=0; v<vnodes; ++v)
00060         printf("%7.3f",balancer.m_inputWeights[m][0][v]);
00061       printf("\n");
00062     }
00063   
00064   printf("\nProcessor destinations:\n");
00065   for (v=0; v<vnodes; ++v)
00066     printf("%7d",balancer.m_vnodeProcs[v]);
00067   printf("\n");
00068 
00069   printf("\nProcessor weights:\n");
00070   for (m=0; m<materials; ++m)
00071     {
00072       for (p=0; p<procs; ++p)
00073         printf("%7.3f",balancer.m_materialProcWeights[m][0][p]);
00074       printf("\n");
00075     }
00076   printf("Totals:\n");
00077   for (p=0; p<procs; ++p)
00078     printf("%7.3f",balancer.m_procWeights[p]);
00079   printf("\n");
00080 
00081   printf("\nMaterial Max weights:\n");
00082   for (m=0; m<materials; ++m)
00083     printf("%7.3f",balancer.m_materialMaxWeights[m]);
00084   printf("\n");
00085 }
00086 
00087 int main()
00088 {
00089   multiBalancerTester();
00090   return 0;
00091 }
00092 
00093 
00094 /***************************************************************************
00095  * $RCSfile: MultiBalancer.t.cpp,v $   $Author: adelmann $
00096  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:27 $
00097  * IPPL_VERSION_ID: $Id: MultiBalancer.t.cpp,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $ 
00098  ***************************************************************************/

Generated on Mon Jan 16 13:23:47 2006 for IPPL by  doxygen 1.4.6