unsigned int memory::get_last_address(unsigned int funId, const application_managerRef AppMgr) const { const std::set<unsigned int> calledSet = AppMgr->CGetCallGraphManager()->get_called_by(funId); const std::map<unsigned int, memory_symbolRef> & internalVars = (internal.find(funId)->second); unsigned int maxAddress = 0; for (std::map<unsigned int, memory_symbolRef>::const_iterator itr = internalVars.begin(), end = internalVars.end(); itr != end; ++itr) { unsigned int var = itr->first; if (!is_private_memory(var) && !has_parameter_base_address(var, funId) && has_base_address(var)) { maxAddress = std::max(maxAddress, itr->second->get_address() + tree_helper::size(TreeM, var) / 8); } } if (AppMgr->hasToBeInterfaced(funId)) { const std::map<unsigned int, memory_symbolRef> & paramsVar = get_function_parameters(funId); for (std::map<unsigned int, memory_symbolRef>::const_iterator itr = paramsVar.begin(), end = paramsVar.end(); itr != end; ++itr) { unsigned int var = itr->first; maxAddress = std::max(maxAddress, itr->second->get_address() + tree_helper::size(TreeM, var) / 8); } } for (std::set<unsigned int>::const_iterator Itr = calledSet.begin(), End = calledSet.end(); Itr != End; ++Itr) { if (not AppMgr->hasToBeInterfaced(*Itr)) { maxAddress = std::max(get_last_address(*Itr, AppMgr), maxAddress); } } return maxAddress; }
bool ESHDFIonsParser::put(xmlNodePtr cur) { //add basic attributes of the speciesset SpeciesSet& tspecies(ref_.getSpeciesSet()); int icharge= tspecies.addAttribute("charge");//charge_tag); int iatnumber= tspecies.addAttribute(atomic_number_tag); int membersize= tspecies.addAttribute("membersize"); int massind= tspecies.addAttribute(mass_tag); if(myComm->rank()==0 && hfile_id>=-1) readESHDF(); if(myComm->size()==1) return true; int nspecies=tspecies.getTotalNum(); int natoms=ref_.getTotalNum(); ostringstream o; if(myComm->rank()==0) { int i=0; for(; i<nspecies-1; ++i) o<<tspecies.speciesName[i]<<","; o<<tspecies.speciesName[i]; } TinyVector<int,3> bsizes(nspecies,natoms,o.str().size()+1); myComm->bcast(bsizes); //send the names: UGLY!!!! nspecies=bsizes[0]; char *species_names=new char[bsizes[2]]; if(myComm->rank()==0) snprintf(species_names, bsizes[2], "%s",o.str().c_str()); myComm->bcast(species_names,bsizes[2]); if(myComm->rank()) { vector<string> vlist; parsewords(species_names,vlist); for(int i=0; i<vlist.size(); ++i) tspecies.addSpecies(vlist[i]); //create natoms particles ref_.create(bsizes[1]); } delete [] species_names; ParticleSet::Tensor_t lat(ref_.Lattice.R); ParticleSet::Buffer_t pbuffer; for(int i=0; i<tspecies.numAttributes(); ++i) pbuffer.add(tspecies.d_attrib[i]->begin(),tspecies.d_attrib[i]->end()); pbuffer.add(lat.begin(),lat.end()); pbuffer.add(get_first_address(ref_.R),get_last_address(ref_.R)); pbuffer.add(ref_.GroupID.begin(),ref_.GroupID.end()); myComm->bcast(pbuffer); ref_.R.InUnit=PosUnit::CartesianUnit; if(myComm->rank()) { pbuffer.rewind(); for(int i=0; i<tspecies.numAttributes(); ++i) pbuffer.get(tspecies.d_attrib[i]->begin(),tspecies.d_attrib[i]->end()); pbuffer.get(lat.begin(),lat.end()); pbuffer.get(get_first_address(ref_.R),get_last_address(ref_.R)); pbuffer.get(ref_.GroupID.begin(),ref_.GroupID.end()); ref_.Lattice.set(lat); } return true; }