llvm.org GIT mirror llvm / 99e0885
Add an option do not dump the generated object on disk Reviewers: courbet Subscribers: llvm-commits, bdb Tags: #llvm Differential Revision: https://reviews.llvm.org/D60317 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357769 91177308-0d34-0410-b5e6-96231b3b80d8 Guillaume Chatelet 1 year, 7 months ago
4 changed file(s) with 44 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
246246
247247 If set, ignore instructions that do not have a sched class (class idx = 0).
248248
249 .. option:: -mcpu=
250
251 If set, measure the cpu characteristics using the counters for this CPU. This
252 is useful when creating new sched models (the host CPU is unknown to LLVM).
249 .. option:: -mcpu=
250
251 If set, measure the cpu characteristics using the counters for this CPU. This
252 is useful when creating new sched models (the host CPU is unknown to LLVM).
253
254 .. option:: --dump-object-to-disk=true
255
256 By default, llvm-exegesis will dump the generated code to a temporary file to
257 enable code inspection. You may disable it to speed up the execution and save
258 disk space.
253259
254260 EXIT STATUS
255261 -----------
6565 CounterName = CounterName.trim();
6666 pfm::PerfEvent PerfEvent(CounterName);
6767 if (!PerfEvent.valid())
68 llvm::report_fatal_error(
69 llvm::Twine("invalid perf event '").concat(CounterName).concat("'"));
68 llvm::report_fatal_error(llvm::Twine("invalid perf event '")
69 .concat(CounterName)
70 .concat("'"));
7071 pfm::Counter Counter(PerfEvent);
7172 Scratch->clear();
7273 {
9596
9697 InstructionBenchmark
9798 BenchmarkRunner::runConfiguration(const BenchmarkCode &BC,
98 unsigned NumRepetitions) const {
99 unsigned NumRepetitions,
100 bool DumpObjectToDisk) const {
99101 InstructionBenchmark InstrBenchmark;
100102 InstrBenchmark.Mode = Mode;
101103 InstrBenchmark.CpuName = State.getTargetMachine().getTargetCPU();
128130
129131 // Assemble NumRepetitions instructions repetitions of the snippet for
130132 // measurements.
131 auto ObjectFilePath = writeObjectFile(
132 BC, GenerateInstructions(BC, InstrBenchmark.NumRepetitions));
133 if (llvm::Error E = ObjectFilePath.takeError()) {
134 InstrBenchmark.Error = llvm::toString(std::move(E));
135 return InstrBenchmark;
133 const auto Code = GenerateInstructions(BC, InstrBenchmark.NumRepetitions);
134
135 llvm::object::OwningBinary ObjectFile;
136 if (DumpObjectToDisk) {
137 auto ObjectFilePath = writeObjectFile(BC, Code);
138 if (llvm::Error E = ObjectFilePath.takeError()) {
139 InstrBenchmark.Error = llvm::toString(std::move(E));
140 return InstrBenchmark;
141 }
142 llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
143 << *ObjectFilePath << "\n";
144 ObjectFile = getObjectFromFile(*ObjectFilePath);
145 } else {
146 llvm::SmallString<0> Buffer;
147 llvm::raw_svector_ostream OS(Buffer);
148 assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
149 BC.LiveIns, BC.RegisterInitialValues, Code, OS);
150 ObjectFile = getObjectFromBuffer(OS.str());
136151 }
137 llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
138 << *ObjectFilePath << "\n";
139 const FunctionExecutorImpl Executor(State, getObjectFromFile(*ObjectFilePath),
152
153 const FunctionExecutorImpl Executor(State, std::move(ObjectFile),
140154 Scratch.get());
141155 auto Measurements = runMeasurements(Executor);
142156 if (llvm::Error E = Measurements.takeError()) {
4444 virtual ~BenchmarkRunner();
4545
4646 InstructionBenchmark runConfiguration(const BenchmarkCode &Configuration,
47 unsigned NumRepetitions) const;
47 unsigned NumRepetitions,
48 bool DumpObjectToDisk) const;
4849
4950 // Scratch space to run instructions that touch memory.
5051 struct ScratchSpace {
8485 writeObjectFile(const BenchmarkCode &Configuration,
8586 llvm::ArrayRef Code) const;
8687
87
8888 const std::unique_ptr Scratch;
8989 };
9090
135135 "mcpu",
136136 cl::desc("cpu name to use for pfm counters, leave empty to autodetect"),
137137 cl::cat(Options), cl::init(""));
138
139 static cl::opt
140 DumpObjectToDisk("dump-object-to-disk",
141 cl::desc("dumps the generated benchmark object to disk "
142 "and prints a message to access it"),
143 cl::cat(BenchmarkOptions), cl::init(true));
138144
139145 static ExitOnError ExitOnErr;
140146
405411
406412 for (const BenchmarkCode &Conf : Configurations) {
407413 InstructionBenchmark Result =
408 Runner->runConfiguration(Conf, NumRepetitions);
414 Runner->runConfiguration(Conf, NumRepetitions, DumpObjectToDisk);
409415 ExitOnErr(Result.writeYaml(State, BenchmarkFile));
410416 }
411417 exegesis::pfm::pfmTerminate();