aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2015-03-12 15:49:30 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-03-12 15:49:30 +0000
commiteb86025a0464c378a453f391f6d27aaad6a1798c (patch)
tree9af10f9c33ce0fe1a2eaa5028edd8cbb15bafaeb
parent3b016184a955f498ef23f4f6cf944f590341b4d9 (diff)
parent6da4e253a513feef3405759fef6d0760828808ca (diff)
downloadlibbcc-eb86025a0464c378a453f391f6d27aaad6a1798c.tar.gz
Merge "Handle FP precision in kernel fusion"
-rw-r--r--include/bcc/Renderscript/RSCompilerDriver.h3
-rw-r--r--lib/Renderscript/RSCompilerDriver.cpp24
-rw-r--r--tools/bcc/Main.cpp9
3 files changed, 29 insertions, 7 deletions
diff --git a/include/bcc/Renderscript/RSCompilerDriver.h b/include/bcc/Renderscript/RSCompilerDriver.h
index 68f5fd4..5c0d6e8 100644
--- a/include/bcc/Renderscript/RSCompilerDriver.h
+++ b/include/bcc/Renderscript/RSCompilerDriver.h
@@ -121,7 +121,8 @@ public:
bool buildScriptGroup(
BCCContext& Context, const char* pOutputFilepath, const char* pRuntimePath,
- bool dumpIR, const std::vector<Source*>& sources,
+ const char* pRuntimeRelaxedPath, bool dumpIR,
+ const std::vector<Source*>& sources,
const std::list<std::list<std::pair<int, int>>>& toFuse,
const std::list<std::string>& fused,
const std::list<std::list<std::pair<int, int>>>& invokes,
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index 21beaa2..757d920 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -155,7 +155,8 @@ Compiler::ErrorCode RSCompilerDriver::compileScript(RSScript& pScript, const cha
// Link RS script with Renderscript runtime.
//===--------------------------------------------------------------------===//
if (!RSScript::LinkRuntime(pScript, pRuntimePath)) {
- ALOGE("Failed to link script '%s' with Renderscript runtime!", pScriptName);
+ ALOGE("Failed to link script '%s' with Renderscript runtime %s!",
+ pScriptName, pRuntimePath);
return Compiler::kErrInvalidSource;
}
@@ -331,7 +332,8 @@ bool RSCompilerDriver::build(BCCContext &pContext,
bool RSCompilerDriver::buildScriptGroup(
BCCContext& Context, const char* pOutputFilepath, const char* pRuntimePath,
- bool dumpIR, const std::vector<Source*>& sources,
+ const char* pRuntimeRelaxedPath, bool dumpIR,
+ const std::vector<Source*>& sources,
const std::list<std::list<std::pair<int, int>>>& toFuse,
const std::list<std::string>& fused,
const std::list<std::list<std::pair<int, int>>>& invokes,
@@ -414,7 +416,17 @@ bool RSCompilerDriver::buildScriptGroup(
llvm::SmallString<80> output_path(pOutputFilepath);
llvm::sys::path::replace_extension(output_path, ".o");
- compileScript(script, pOutputFilepath, output_path.c_str(), pRuntimePath,
+ // Pick the right runtime lib
+ const char* coreLibPath = pRuntimePath;
+ if (strcmp(pRuntimeRelaxedPath, "")) {
+ bcinfo::MetadataExtractor me(&module);
+ me.extract();
+ if (me.getRSFloatPrecision() == bcinfo::RS_FP_Relaxed) {
+ coreLibPath = pRuntimeRelaxedPath;
+ }
+ }
+
+ compileScript(script, pOutputFilepath, output_path.c_str(), coreLibPath,
bitcode_sha1, compileCommandLineToEmbed, buildChecksum,
true, dumpIR);
@@ -443,8 +455,10 @@ bool RSCompilerDriver::buildForCompatLib(RSScript &pScript, const char *pOut,
// offline (host) compilation.
pScript.setEmbedInfo(true);
- Compiler::ErrorCode status = compileScript(pScript, pOut, pOut, pRuntimePath, bitcode_sha1,
- compileCommandLineToEmbed, pBuildChecksum, false, pDumpIR);
+ Compiler::ErrorCode status = compileScript(pScript, pOut, pOut, pRuntimePath,
+ bitcode_sha1,
+ compileCommandLineToEmbed,
+ pBuildChecksum, false, pDumpIR);
if (status != Compiler::kSuccess) {
return false;
}
diff --git a/tools/bcc/Main.cpp b/tools/bcc/Main.cpp
index 6e2c8a4..a047e88 100644
--- a/tools/bcc/Main.cpp
+++ b/tools/bcc/Main.cpp
@@ -79,6 +79,12 @@ OptBCLibFilename("bclib", llvm::cl::desc("Specify the bclib filename"),
llvm::cl::value_desc("bclib"));
llvm::cl::opt<std::string>
+OptBCLibRelaxedFilename("bclib_relaxed", llvm::cl::desc("Specify the bclib filename optimized for "
+ "relaxed precision floating point maths"),
+ llvm::cl::init(""),
+ llvm::cl::value_desc("bclib_relaxed"));
+
+llvm::cl::opt<std::string>
OptOutputPath("output_path", llvm::cl::desc("Specify the output path"),
llvm::cl::value_desc("output path"),
llvm::cl::init("."));
@@ -195,7 +201,8 @@ bool compileScriptGroup(BCCContext& Context, RSCompilerDriver& RSCD) {
outputFilepath.append(OptOutputFilename);
bool success = RSCD.buildScriptGroup(
- Context, outputFilepath.c_str(), OptBCLibFilename.c_str(), true,
+ Context, outputFilepath.c_str(), OptBCLibFilename.c_str(),
+ OptBCLibRelaxedFilename.c_str(), true,
sources, sourcesAndSlots, fusedKernelNames,
invokeSourcesAndSlots, invokeBatchNames);