Region2D regionFromXml(XMLreaderProxy const &r) { std::string id; plint x0,x1,y0,y1; try{ r["id"].read(id); } catch (PlbIOException &e){ throw PlbIOException("Invalid Region command: No id specified"); } try{ r["x0"].read(x0); r["x1"].read(x1); r["y0"].read(y0); r["y1"].read(y1); } catch(PlbIOException &e){ throw PlbIOException("Invalid Region command: size specifications missing"); } if( id.compare("") == 0 ) throw PlbIOException("Invalid Region command: Unnamed region"); if( x0<0 || y0<0 || x1<0 || y1<0 || x1<x0 || y1<y0 ){ std::string errmsg("Invalid Region command: Bad size in region "); errmsg.append(id); throw PlbIOException(errmsg); } return Region2D(id,Box2D(x0,x1,y0,y1)); }
void Distribution2D::distribute(const size_t& size_x, const size_t& size_y, const size_t& num_of_nodes_by_x, const size_t& num_of_nodes_by_y) { std::vector<Region> regions_by_x, regions_by_y; computeRegions(size_x, num_of_nodes_by_x, regions_by_x); computeRegions(size_y, num_of_nodes_by_y, regions_by_y); for ( size_t node_y = 0; node_y < num_of_nodes_by_y; node_y++) { for ( size_t node_x = 0; node_x < num_of_nodes_by_x; node_x++) { const Region& rx = regions_by_x[node_x]; const Region& ry = regions_by_y[node_y]; this->set(node_y*num_of_nodes_by_x + node_x, Region2D(rx.getStart(), ry.getStart(), rx.getEnd(), ry.getEnd())); } } }