summaryrefslogtreecommitdiff
path: root/cpu_ref
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2017-02-27 23:35:35 -0800
committerMiao Wang <miaowang@google.com>2017-03-15 19:05:19 +0000
commit82e135c4bbe18855d8ed02632bb074f8da0b96e0 (patch)
treeb49c8e9d9ba3afbc68bb0c9bbd8d39c87db4c589 /cpu_ref
parentee2aeb32af1bba3da2dc97d203a36e1c91c1edd6 (diff)
downloadrs-82e135c4bbe18855d8ed02632bb074f8da0b96e0.tar.gz
Remove libutils.so dependency from libRSDriver, libRSCpuRef, and most
parts of libRS_internal. NOTE: we're resolving dependencies to provide a model for vendors. For us, all this code is above the HAL, thus the dependencies are acceptable; whereas for vendors, their equivalent of this code is below the HAL, and so the dependencies are not acceptable. This CL resolves the libutils dependency by: - Implement the timings functions in android::renderscript namespace using NDK APIs, instead of using libutils counterparts. - Replace android::Vector and android::String8 by std::vector and std::string. - PROPERTY_VALUE_MAX is replaced as PROP_VALUE_MAX. This CL didn't resolve the libutils dependency of rsFont.cpp and rsDebugger.cpp in libRS_internal: The dependent functionality in rsDebugHelper.h is off by default, and only intended for use during development; and rsFont.cpp is part of graphics API which is not implemented below the HAL and is not used as a model by vendors. Additionally, this CL fixed the bug that mNodes was sorted in a decreasing order. Nodes in ScriptGroup should be executed in ascending order. The bad sort was only for support lib; so there was a previously-unknown bug in support lib implementation of ScriptGroup. Background: libutils contains a collection of things like Vector, String8, CallStack. It served the purpose similar to a STL library, when there was no stable STL implementation available in Android. And most importantly, it is not part of NDK. Support lib used to use our own implementations of android::Vector and android::String8, because it can only depend on NDK, similarly for the timing related functions. As part of the Treble requirements, native RS, including vendor version libRS_internal, libRSDriver, libRSCpuRef could only depend on NDK too. So we need to break the dependency on libutils. And since we now have reasonable support of STLs, we should use that instead. Bug: 34396220 Test: mm, and all CTS tests pass on Bullhead; RsTest and RSTest_CompatLib (both native and compat path) also pass. Change-Id: Ib9a37d16235c1dcd0f5bae3b95c374e394483c91
Diffstat (limited to 'cpu_ref')
-rw-r--r--cpu_ref/Android.mk2
-rw-r--r--cpu_ref/rsCpuCore.h8
-rw-r--r--cpu_ref/rsCpuExecutable.cpp6
-rw-r--r--cpu_ref/rsCpuExecutable.h6
-rw-r--r--cpu_ref/rsCpuScript.cpp6
-rw-r--r--cpu_ref/rsCpuScript.h6
-rw-r--r--cpu_ref/rsCpuScriptGroup.cpp50
-rw-r--r--cpu_ref/rsCpuScriptGroup.h4
-rw-r--r--cpu_ref/rsCpuScriptGroup2.cpp2
9 files changed, 49 insertions, 41 deletions
diff --git a/cpu_ref/Android.mk b/cpu_ref/Android.mk
index 5d1b223c..d50a77ed 100644
--- a/cpu_ref/Android.mk
+++ b/cpu_ref/Android.mk
@@ -83,7 +83,7 @@ ifeq ($(ARCH_X86_HAVE_SSSE3),true)
rsCpuIntrinsics_x86.cpp
endif
-LOCAL_SHARED_LIBRARIES += libRS_internal libc++ liblog libutils libz
+LOCAL_SHARED_LIBRARIES += libRS_internal libc++ liblog libz
LOCAL_SHARED_LIBRARIES += libbcinfo libblas
LOCAL_STATIC_LIBRARIES := libbnnmlowp
diff --git a/cpu_ref/rsCpuCore.h b/cpu_ref/rsCpuCore.h
index 8c5653f8..59e6c4bb 100644
--- a/cpu_ref/rsCpuCore.h
+++ b/cpu_ref/rsCpuCore.h
@@ -25,6 +25,8 @@
#include "rsScriptC.h"
#include "rsCpuCoreRuntime.h"
+#include <string>
+
namespace android {
namespace renderscript {
@@ -188,10 +190,10 @@ public:
}
virtual void setBccPluginName(const char *name) {
- mBccPluginName.setTo(name);
+ mBccPluginName.assign(name);
}
virtual const char *getBccPluginName() const {
- return mBccPluginName.string();
+ return mBccPluginName.c_str();
}
bool getInKernel() override { return mInKernel; }
@@ -243,7 +245,7 @@ protected:
ScriptTLSStruct mTlsStruct;
RSSelectRTCallback mSelectRTCallback;
- String8 mBccPluginName;
+ std::string mBccPluginName;
// Specifies whether we should embed global variable information in the
// code via special RS variables that can be examined later by the driver.
diff --git a/cpu_ref/rsCpuExecutable.cpp b/cpu_ref/rsCpuExecutable.cpp
index 426d89e2..400a465d 100644
--- a/cpu_ref/rsCpuExecutable.cpp
+++ b/cpu_ref/rsCpuExecutable.cpp
@@ -165,7 +165,7 @@ void* SharedLibraryUtils::loadSharedLibrary(const char *cacheDir,
return loaded;
}
-String8 SharedLibraryUtils::getRandomString(size_t len) {
+std::string SharedLibraryUtils::getRandomString(size_t len) {
char buf[len + 1];
for (size_t i = 0; i < len; i++) {
uint32_t r = arc4random() & 0xffff;
@@ -182,7 +182,7 @@ String8 SharedLibraryUtils::getRandomString(size_t len) {
}
}
buf[len] = '\0';
- return String8(buf);
+ return std::string(buf);
}
void* SharedLibraryUtils::loadSOHelper(const char *origName, const char *cacheDir,
@@ -237,7 +237,7 @@ void* SharedLibraryUtils::loadSOHelper(const char *origName, const char *cacheDi
newName.append("librs.");
newName.append(resName);
newName.append("#");
- newName.append(getRandomString(6).string()); // 62^6 potential filename variants.
+ newName.append(getRandomString(6).c_str()); // 62^6 potential filename variants.
newName.append(".so");
int r = copyFile(newName.c_str(), origName);
diff --git a/cpu_ref/rsCpuExecutable.h b/cpu_ref/rsCpuExecutable.h
index 90d37591..ee58e377 100644
--- a/cpu_ref/rsCpuExecutable.h
+++ b/cpu_ref/rsCpuExecutable.h
@@ -17,10 +17,12 @@
#ifndef ANDROID_RENDERSCRIPT_EXECUTABLE_H
#define ANDROID_RENDERSCRIPT_EXECUTABLE_H
-#include <stdlib.h>
#include "rsCpuScript.h"
+#include <stdlib.h>
+#include <string>
+
namespace android {
namespace renderscript {
@@ -47,7 +49,7 @@ public:
bool *alreadyLoaded = nullptr);
// Create a len length string containing random characters from [A-Za-z0-9].
- static String8 getRandomString(size_t len);
+ static std::string getRandomString(size_t len);
private:
// Attempt to load the shared library from origName, but then fall back to
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 5bd24240..545e92f3 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -58,7 +58,7 @@ static bool allocationLODIsNull(const android::renderscript::Allocation *alloc)
#ifndef RS_COMPATIBILITY_LIB
static bool is_force_recompile() {
- char buf[PROPERTY_VALUE_MAX];
+ char buf[PROP_VALUE_MAX];
// Re-compile if floating point precision has been overridden.
android::renderscript::property_get("debug.rs.precision", buf, "");
@@ -176,7 +176,7 @@ bool isChecksumNeeded(const char *cacheDir) {
if ((::strcmp(SYSLIBPATH, cacheDir) == 0) ||
(::strcmp(SYSLIBPATH_VENDOR, cacheDir) == 0))
return false;
- char buf[PROPERTY_VALUE_MAX];
+ char buf[PROP_VALUE_MAX];
android::renderscript::property_get("ro.debuggable", buf, "");
return (buf[0] == '1');
}
@@ -422,7 +422,7 @@ bool RsdCpuScriptImpl::init(char const *resName, char const *cacheDir,
}
}
- mBitcodeFilePath.setTo(bcFileName.c_str());
+ mBitcodeFilePath.assign(bcFileName.c_str());
#else // RS_COMPATIBILITY_LIB is defined
const char *nativeLibDir = mCtx->getContext()->getNativeLibDir();
diff --git a/cpu_ref/rsCpuScript.h b/cpu_ref/rsCpuScript.h
index c6f96245..1814d5ff 100644
--- a/cpu_ref/rsCpuScript.h
+++ b/cpu_ref/rsCpuScript.h
@@ -26,6 +26,8 @@
#include "rsCpuCore.h"
+#include <string>
+
namespace bcinfo {
class MetadataExtractor;
} // namespace bcinfo
@@ -130,14 +132,14 @@ protected:
public:
static const char* BCC_EXE_PATH;
- const char* getBitcodeFilePath() const { return mBitcodeFilePath.string(); }
+ const char* getBitcodeFilePath() const { return mBitcodeFilePath.c_str(); }
private:
bool setUpMtlsDimensions(MTLaunchStructCommon *mtls,
const RsLaunchDimensions &baseDim,
const RsScriptCall *sc);
- String8 mBitcodeFilePath;
+ std::string mBitcodeFilePath;
uint32_t mBuildChecksum;
bool mChecksumNeeded;
};
diff --git a/cpu_ref/rsCpuScriptGroup.cpp b/cpu_ref/rsCpuScriptGroup.cpp
index f7a330a2..cc2933c1 100644
--- a/cpu_ref/rsCpuScriptGroup.cpp
+++ b/cpu_ref/rsCpuScriptGroup.cpp
@@ -19,6 +19,8 @@
#include "rsScriptGroup.h"
#include "rsCpuScriptGroup.h"
+#include <vector>
+
namespace android {
namespace renderscript {
@@ -124,11 +126,11 @@ void CpuScriptGroupImpl::scriptGroupRoot(const RsExpandKernelDriverInfo *kinfo,
void CpuScriptGroupImpl::execute() {
- Vector<Allocation *> ins;
- Vector<bool> inExts;
- Vector<Allocation *> outs;
- Vector<bool> outExts;
- Vector<const ScriptKernelID *> kernels;
+ std::vector<Allocation *> ins;
+ std::vector<uint8_t> inExts;
+ std::vector<Allocation *> outs;
+ std::vector<uint8_t> outExts;
+ std::vector<const ScriptKernelID *> kernels;
bool fieldDep = false;
for (size_t ct=0; ct < mSG->mNodes.size(); ct++) {
@@ -194,11 +196,11 @@ void CpuScriptGroupImpl::execute() {
rsAssert((k->mHasKernelOutput == (aout != nullptr)) &&
(k->mHasKernelInput == (ain != nullptr)));
- ins.add(ain);
- inExts.add(inExt);
- outs.add(aout);
- outExts.add(outExt);
- kernels.add(k);
+ ins.push_back(ain);
+ inExts.push_back(inExt);
+ outs.push_back(aout);
+ outExts.push_back(outExt);
+ kernels.push_back(k);
}
}
@@ -237,9 +239,9 @@ void CpuScriptGroupImpl::execute() {
}
} else {
ScriptList sl;
- sl.ins = ins.array();
- sl.outs = outs.array();
- sl.kernels = kernels.array();
+ sl.ins = ins.data();
+ sl.outs = outs.data();
+ sl.kernels = kernels.data();
sl.count = kernels.size();
uint32_t inLen;
@@ -254,25 +256,25 @@ void CpuScriptGroupImpl::execute() {
ains = const_cast<const Allocation**>(&ins[0]);
}
- Vector<const void *> usrPtrs;
- Vector<const void *> fnPtrs;
- Vector<uint32_t> sigs;
+ std::vector<const void *> usrPtrs;
+ std::vector<const void *> fnPtrs;
+ std::vector<uint32_t> sigs;
for (size_t ct=0; ct < kernels.size(); ct++) {
Script *s = kernels[ct]->mScript;
RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s);
si->forEachKernelSetup(kernels[ct]->mSlot, &mtls);
- fnPtrs.add((void *)mtls.kernel);
- usrPtrs.add(mtls.fep.usr);
- sigs.add(mtls.fep.usrLen);
+ fnPtrs.push_back((void *)mtls.kernel);
+ usrPtrs.push_back(mtls.fep.usr);
+ sigs.push_back(mtls.fep.usrLen);
si->preLaunch(kernels[ct]->mSlot, ains, inLen, outs[ct],
mtls.fep.usr, mtls.fep.usrLen, nullptr);
}
- sl.sigs = sigs.array();
- sl.usrPtrs = usrPtrs.array();
- sl.fnPtrs = fnPtrs.array();
- sl.inExts = inExts.array();
- sl.outExts = outExts.array();
+ sl.sigs = sigs.data();
+ sl.usrPtrs = usrPtrs.data();
+ sl.fnPtrs = fnPtrs.data();
+ sl.inExts = inExts.data();
+ sl.outExts = outExts.data();
Script *s = kernels[0]->mScript;
RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s);
diff --git a/cpu_ref/rsCpuScriptGroup.h b/cpu_ref/rsCpuScriptGroup.h
index a749ea43..7e1386d7 100644
--- a/cpu_ref/rsCpuScriptGroup.h
+++ b/cpu_ref/rsCpuScriptGroup.h
@@ -41,9 +41,9 @@ protected:
struct ScriptList {
size_t count;
Allocation *const* ins;
- bool const* inExts;
+ uint8_t const* inExts;
Allocation *const* outs;
- bool const* outExts;
+ uint8_t const* outExts;
const void *const* usrPtrs;
size_t const *usrSizes;
uint32_t const *sigs;
diff --git a/cpu_ref/rsCpuScriptGroup2.cpp b/cpu_ref/rsCpuScriptGroup2.cpp
index 9d9929a9..a8b72c41 100644
--- a/cpu_ref/rsCpuScriptGroup2.cpp
+++ b/cpu_ref/rsCpuScriptGroup2.cpp
@@ -483,7 +483,7 @@ void CpuScriptGroup2Impl::compile(const char* cacheDir) {
cloneName.append(resName);
cloneName.append("#");
- cloneName.append(SharedLibraryUtils::getRandomString(6).string());
+ cloneName.append(SharedLibraryUtils::getRandomString(6).c_str());
// The last element in arguments is the output filename.
arguments.pop_back();