Commits

Kumar Golap authored 75114f88555
Some minor tweaks to required memory calculation for mosaic
No tags

code/synthesis/ImagerObjects/SynthesisImager.cc

Modified
1494 1494
1495 1495 // Do calculation here.
1496 1496 // This runs once per image field (for multi-field imaging)
1497 1497 // This runs once per cube partition, and will see only its own partition's shape
1498 1498 chanchunks=1;
1499 1499
1500 1500 CompositeNumber cn(uInt(imshape[0] * 2));
1501 1501 // heuristic factors multiplied to imshape based on gridder
1502 1502 size_t fudge_factor = 15;
1503 1503 if (ftm->name()=="MosaicFTNew") {
1504 - fudge_factor = 15;
1504 + fudge_factor = 17;
1505 1505 }
1506 1506 else if (ftm->name()=="GridFT") {
1507 1507 fudge_factor = 9;
1508 1508 }
1509 1509
1510 - size_t required_mem = fudge_factor * sizeof(Float);
1510 + Double required_mem = fudge_factor * sizeof(Float);
1511 1511 for (size_t i = 0; i < imshape.nelements(); i++) {
1512 1512 // gridding pads image and increases to composite number
1513 1513 if (i < 2) {
1514 1514 required_mem *= cn.nextLargerEven(Int(padding*Float(imshape[i])-0.5));
1515 1515 }
1516 1516 else {
1517 1517 required_mem *= imshape[i];
1518 1518 }
1519 1519 }
1520 1520
1521 1521 // get number of tclean processes running on the same machine
1522 1522 size_t nlocal_procs = 1;
1523 1523 if (getenv("OMPI_COMM_WORLD_LOCAL_SIZE")) {
1524 1524 std::stringstream ss(getenv("OMPI_COMM_WORLD_LOCAL_SIZE"));
1525 1525 ss >> nlocal_procs;
1526 1526 }
1527 1527 // assumes all processes need the same amount of memory
1528 1528 required_mem *= nlocal_procs;
1529 -
1530 1529 Double usr_memfrac, usr_mem;
1531 1530 AipsrcValue<Double>::find(usr_memfrac, "system.resources.memfrac", 80.);
1532 1531 AipsrcValue<Double>::find(usr_mem, "system.resources.memory", -1024.);
1533 1532 Double memory_avail;
1534 1533 if (usr_mem > 0.) {
1535 1534 memory_avail = usr_mem * 1024. * 1024.;
1536 1535 }
1537 1536 else {
1538 - memory_avail = HostInfo::memoryTotal(false) * (usr_memfrac / 100.) * 1024.;
1537 + memory_avail = Double(HostInfo::memoryFree()) * (usr_memfrac / 100.) * 1024.;
1539 1538 }
1540 1539
1541 -
1542 1540 // compute required chanchunks to fit into the available memory
1543 1541 chanchunks = (int)std::ceil((Double)required_mem / memory_avail);
1544 1542 if (imshape.nelements() == 4 && imshape[3] < chanchunks) {
1545 1543 chanchunks = imshape[3];
1546 1544 // TODO make chanchunks a divisor of nchannels?
1547 1545 }
1548 1546 chanchunks = chanchunks < 1 ? 1 : chanchunks;
1549 1547
1550 1548 log_l << "Required memory " << required_mem / nlocal_procs / 1024. / 1024. / 1024.
1551 1549 << "\nAvailable memory " << memory_avail / 1024. / 1024 / 1024.

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut