#include <math.h>
#include "face.h"
#include "makeflo.h"
#include <algorithm>
Go to the source code of this file.
const char* splitBlocks |
( |
vector< block * > & |
blocks, |
|
|
int |
nPieces |
|
) |
| |
Definition at line 205 of file split.cpp.
References bRec::less(), parameters, makefloParam::splithalf, and volume().
Referenced by main().
208 if ((
int)blocks.size()>=nPieces)
215 unsigned int b,nBlocks=blocks.size();
217 int *nSplit=
new int[nBlocks];
221 for (b=0;b<nBlocks;b++) {
227 vector<bRec> heap(nBlocks);
228 for (b=0;b<nBlocks;b++) {
233 std::make_heap(heap.begin(),heap.end(),
bRec::less);
236 int nRemaining=nPieces-nBlocks;
237 while (nRemaining-->0) {
238 std::pop_heap(heap.begin(),heap.end(),
bRec::less);
239 bRec &r=heap[nBlocks-1];
241 std::push_heap(heap.begin(),heap.end(),
bRec::less);
246 vector<block *> split;
247 for (b=0;b<nBlocks;b++) {
248 printf(
"Input block %d splits into %d pieces (%d-%d)\n",
249 b+1,nSplit[b],(
int)(1+split.size()),(
int)(1+split.size()+nSplit[b]-1));
250 blocks[b]->split(nSplit[b],split);
255 double maxVol=-1e100,minVol=1e100,sumVol=0;
256 for (b=0;b<split.size();b++) {
257 double vol=
volume(split[b]);
259 if (maxVol<vol) maxVol=vol;
260 if (minVol>vol) minVol=vol;
262 double avgVol=sumVol/split.size();
263 printf(
"Static load balance results:\n"
264 " %.2f blocks per processor, %.0f nodes per block\n"
265 " Heaviest block is %.02f times the average\n"
266 " Lightest block is %.02f times the average\n",
267 ((
double)split.size())/nPieces,avgVol,
268 maxVol/avgVol,minVol/avgVol);
int volume(const block *b)
static bool less(const bRec &a, const bRec &b)
int volume |
( |
const block * |
b | ) |
|