Commit f5c89181 authored by Diego Caballero's avatar Diego Caballero Committed by Scott Cyphers

[MLIR] Add flag to dump jitted MLIR to object file (#3607)

* [MLIR] Add flag to dump jitted MLIR to object file

This PR adds a flag to be able to dump the jitted MLIR code to an object
file and another flag to be able to specify the object file name.

* Add curly braces

* Fix wrong merge
parent f40f3981
...@@ -121,6 +121,17 @@ static llvm::cl::opt<unsigned> clLoopTilingCacheSize( ...@@ -121,6 +121,17 @@ static llvm::cl::opt<unsigned> clLoopTilingCacheSize(
"inferred from the host CPU using for the cache level specified by " "inferred from the host CPU using for the cache level specified by "
"-loop-tile-cache-level.")); "-loop-tile-cache-level."));
// *** Debug flags ***
static llvm::cl::opt<bool>
clDumpObjectFile("dump-mlir-object-file",
llvm::cl::desc("Dump MLIR JITted-compiled object to file specified with "
"-object-filename (<input file>.o by default)."));
static llvm::cl::opt<std::string>
clObjectFilename("mlir-object-filename",
llvm::cl::desc("Dump MLIR JITted-compiled object to file jitted_mlir.o"));
#define COMPILE_OP_DECL(op_name) \ #define COMPILE_OP_DECL(op_name) \
createOp<op_name>(MLIRCompiler & compiler, const ngraph::Node* ngNode) createOp<op_name>(MLIRCompiler & compiler, const ngraph::Node* ngNode)
...@@ -729,6 +740,12 @@ void MLIRCompiler::execute() ...@@ -729,6 +740,12 @@ void MLIRCompiler::execute()
// Please, note that 'invoke' method is overloaded with a parameter pack version. // Please, note that 'invoke' method is overloaded with a parameter pack version.
// Make sure the MutableArrayRef version is invoked. // Make sure the MutableArrayRef version is invoked.
auto invocationResult = m_engine->invoke("main", llvm::MutableArrayRef<void*>(m_invokeArgs)); auto invocationResult = m_engine->invoke("main", llvm::MutableArrayRef<void*>(m_invokeArgs));
if (clDumpObjectFile)
{
m_engine->dumpToObjectFile(clObjectFilename.empty() ? "jitted_mlir.o"
: clObjectFilename.getValue());
}
NGRAPH_CHECK(!invocationResult, "JIT invocation of 'main' failed\n"); NGRAPH_CHECK(!invocationResult, "JIT invocation of 'main' failed\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment