void SparseTileLayoutData<Dim>::initialize(const Domain_t &bbox, const Partitioner &gpar, const ContextMapper<Dim> &cmap) { this->blocks_m = Loc<Dim>(); initialize(bbox,gpar.internalGuards(),gpar.externalGuards()); gpar.partition(bbox,this->all_m,cmap); syncPatch(); }
int main(int argc, char *argv[]) { // Parse command-line int argno=1; for (/*void*/; argno<argc && '-'==argv[argno][0]; ++argno) { if (!strcmp(argv[argno], "--")) { ++argno; break; } else { std::cerr <<argv[0] <<": unrecognized switch: " <<argv[argno] <<"\n"; exit(1); } } if (argno+1!=argc) { std::cerr <<"usage: " <<argv[0] <<" [SWITCHES] [--] SPECIMEN\n"; exit(1); } std::string specimen_name = argv[argno++]; // Open the file rose_addr_t start_va = 0; MemoryMap map; size_t file_size = map.insertFile(specimen_name, start_va); map.at(start_va).limit(file_size).changeAccess(MemoryMap::EXECUTABLE, 0); // Try to disassemble every byte, and print the CALL/FARCALL targets InstructionMap insns; size_t nerrors=0; Disassembler *disassembler = new DisassemblerX86(4); for (rose_addr_t offset=0; offset<file_size; ++offset) { try { rose_addr_t insn_va = start_va + offset; if (SgAsmX86Instruction *insn = isSgAsmX86Instruction(disassembler->disassembleOne(&map, insn_va))) insns[insn_va] = insn; } catch (const Disassembler::Exception &e) { ++nerrors; } } // Partition those instructions into basic blocks and functions Partitioner partitioner; SgAsmBlock *gblock = partitioner.partition(NULL, insns, &map); // Print addresses of functions struct T1: AstSimpleProcessing { void visit(SgNode *node) { if (SgAsmFunction *func = isSgAsmFunction(node)) std::cout <<StringUtility::addrToString(func->get_entry_va()) <<"\n"; } }; T1().traverse(gblock, preorder); std::cerr <<specimen_name <<": " <<insns.size() <<" instructions; " <<nerrors <<" errors\n"; return 0; }
void UniformGridLayoutData<Dim>::partition(const Partitioner &gpar, const ContextMapper<Dim> &cmap) { int i; // In spite of being templated, this only works with uniform-grid // partitioners. CTAssert(Partitioner::uniform); // We must have something to partition, and the domain lists must be // empty. PAssert(this->domain_m.size() > 0); PAssert(this->innerdomain_m.size() > 0); PAssert(this->all_m.size() == 0); PAssert(this->local_m.size() == 0); PAssert(this->remote_m.size() == 0); // Save the first and block size info from the current domain. this->blocks_m = gpar.blocks(); // Note, for the purposes of partitioning, we pretend like we're // only working with the inner domain. The total domain includes the // external guards, and those do not affect the partitioning. blockstride_m[0] = 1; int blocks[Dim]; for (i = 0; i < Dim; ++i) { this->firsti_m[i] = this->innerdomain_m[i].first(); this->firste_m[i] = this->domain_m[i].first(); blocks[i] = gpar.blocks()[i].first(); allDomain_m[i] = Interval<1>(blocks[i]); blocksizes_m[i] = this->innerdomain_m[i].length() / blocks[i]; if (i > 0) blockstride_m[i] = blockstride_m[i-1] * blocks[i-1]; } // Invoke the partitioner. gpar.partition(this->innerdomain_m, this->all_m, cmap); // fill local and remote lists typename List_t::const_iterator start = this->all_m.begin(); typename List_t::const_iterator end = this->all_m.end(); for ( ; start!=end ; ++start) { if ( (*start)->context() == Pooma::context() || (*start)->context() == -1 ) { (*start)->localID() = this->local_m.size(); this->local_m.push_back(*start); } else this->remote_m.push_back(*start); } if (this->hasInternalGuards_m) { this->gcFillList_m.clear(); calcGCFillList(); } }