Add libclcore_neon.bc as a built-in dependency.
Change-Id: If23d3b4950ab3f28f8186313ada18d9eeec0e3e6
diff --git a/Android.mk b/Android.mk
index fbac8fb..2a2a7c1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -48,6 +48,11 @@
$(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRS.so \
$(call intermediates-dir-for,SHARED_LIBRARIES,libclcore.bc,,)/libclcore.bc
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+libbcc_SHA1_SRCS += \
+ $(call intermediates-dir-for,SHARED_LIBRARIES,libclcore_neon.bc,,)/libclcore_neon.bc
+endif
+
libbcc_GEN_SHA1_STAMP := $(LOCAL_PATH)/tools/build/gen-sha1-stamp.py
intermediates := $(call local-intermediates-dir)
diff --git a/include/bcc/RenderScript/RSInfo.h b/include/bcc/RenderScript/RSInfo.h
index 766d50c..d2fecb1 100644
--- a/include/bcc/RenderScript/RSInfo.h
+++ b/include/bcc/RenderScript/RSInfo.h
@@ -162,6 +162,9 @@
static const char LibBCCPath[];
static const char LibRSPath[];
static const char LibCLCorePath[];
+#if defined(ARCH_ARM_HAVE_NEON)
+ static const char LibCLCoreNEONPath[];
+#endif
private:
// SHA-1 of the built-in dependencies. Will be initialized in
@@ -169,6 +172,9 @@
static const uint8_t *LibBCCSHA1;
static const uint8_t *LibRSSHA1;
static const uint8_t *LibCLCoreSHA1;
+#if defined(ARCH_ARM_HAVE_NEON)
+ static const uint8_t *LibCLCoreNEONSHA1;
+#endif
static bool CheckDependency(const RSInfo &pInfo,
const char *pInputFilename,
diff --git a/lib/RenderScript/RSInfo.cpp b/lib/RenderScript/RSInfo.cpp
index 02f6f6a..3939ee2 100644
--- a/lib/RenderScript/RSInfo.cpp
+++ b/lib/RenderScript/RSInfo.cpp
@@ -30,10 +30,16 @@
const char RSInfo::LibBCCPath[] = "/system/lib/libbcc.so";
const char RSInfo::LibRSPath[] = "/system/lib/libRS.so";
const char RSInfo::LibCLCorePath[] = "/system/lib/libclcore.bc";
+#if defined(ARCH_ARM_HAVE_NEON)
+const char RSInfo::LibCLCoreNEONPath[] = "/system/lib/libclcore_neon.bc";
+#endif
const uint8_t *RSInfo::LibBCCSHA1 = NULL;
const uint8_t *RSInfo::LibRSSHA1 = NULL;
const uint8_t *RSInfo::LibCLCoreSHA1 = NULL;
+#if defined(ARCH_ARM_HAVE_NEON)
+const uint8_t *RSInfo::LibCLCoreNEONSHA1 = NULL;
+#endif
void RSInfo::LoadBuiltInSHA1Information() {
if (LibBCCSHA1 != NULL) {
@@ -52,6 +58,10 @@
LibRSSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libRS_so_SHA1"));
LibCLCoreSHA1 =
reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_bc_SHA1"));
+#if defined(ARCH_ARM_HAVE_NEON)
+ LibCLCoreNEONSHA1 =
+ reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_neon_bc_SHA1"));
+#endif
return;
}
@@ -74,8 +84,13 @@
bool RSInfo::CheckDependency(const RSInfo &pInfo,
const char *pInputFilename,
const DependencyTableTy &pDeps) {
- // Built-in dependencies are libbcc.so, libRS.so and libclcore.bc.
+ // Built-in dependencies are libbcc.so, libRS.so and libclcore.bc plus
+ // libclcore_neon.bc if NEON is available on the target device.
+#if !defined(ARCH_ARM_HAVE_NEON)
static const unsigned NumBuiltInDependencies = 3;
+#else
+ static const unsigned NumBuiltInDependencies = 4;
+#endif
LoadBuiltInSHA1Information();
@@ -92,6 +107,10 @@
pInfo.mDependencyTable[1];
const std::pair<const char *, const uint8_t *> &cache_libclcore_dep =
pInfo.mDependencyTable[2];
+#if defined(ARCH_ARM_HAVE_NEON)
+ const std::pair<const char *, const uint8_t *> &cache_libclcore_neon_dep =
+ pInfo.mDependencyTable[3];
+#endif
// Check libbcc.so.
if (::memcmp(cache_libbcc_dep.second, LibBCCSHA1, SHA1_DIGEST_LENGTH) != 0) {
@@ -124,6 +143,19 @@
return false;
}
+#if defined(ARCH_ARM_HAVE_NEON)
+ // Check libclcore_neon.bc if NEON is available.
+ if (::memcmp(cache_libclcore_neon_dep.second, LibCLCoreNEONSHA1,
+ SHA1_DIGEST_LENGTH) != 0) {
+ ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
+ LibRSPath);
+ PRINT_DEPENDENCY("current - ", LibCLCoreNEONPath, LibCLCoreNEONSHA1);
+ PRINT_DEPENDENCY("cache - ", cache_libclcore_neon_dep.first,
+ cache_libclcore_neon_dep.second);
+ return false;
+ }
+#endif
+
for (unsigned i = 0; i < pDeps.size(); i++) {
const std::pair<const char *, const uint8_t *> &cache_dep =
pInfo.mDependencyTable[i + NumBuiltInDependencies];
diff --git a/lib/RenderScript/RSInfoExtractor.cpp b/lib/RenderScript/RSInfoExtractor.cpp
index 1033267..f05fa68 100644
--- a/lib/RenderScript/RSInfoExtractor.cpp
+++ b/lib/RenderScript/RSInfoExtractor.cpp
@@ -168,6 +168,9 @@
string_pool_size += ::strlen(LibBCCPath) + 1 + SHA1_DIGEST_LENGTH;
string_pool_size += ::strlen(LibRSPath) + 1 + SHA1_DIGEST_LENGTH;
string_pool_size += ::strlen(LibCLCorePath) + 1 + SHA1_DIGEST_LENGTH;
+#if defined(ARCH_ARM_HAVE_NEON)
+ string_pool_size += ::strlen(LibCLCoreNEONPath) + 1 + SHA1_DIGEST_LENGTH;
+#endif
for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
// +1 for null-terminator
string_pool_size += ::strlen(/* name */pDeps[i].first) + 1;
@@ -375,6 +378,14 @@
goto bail;
}
+#if defined(ARCH_ARM_HAVE_NEON)
+ if (!writeDependency(LibCLCoreNEONPath, LibCLCoreNEONSHA1,
+ result->mStringPool, &cur_string_pool_offset,
+ result->mDependencyTable)) {
+ goto bail;
+ }
+#endif
+
//===--------------------------------------------------------------------===//
// Record dependency information.
//===--------------------------------------------------------------------===//