am ca1ff5fb: am b4464f50: Merge "Update GlobalSync test to handle invokable->kernel verification." into jb-mr2-dev
* commit 'ca1ff5fb67b36e2d6f3073505e21b8cc29133276':
Update GlobalSync test to handle invokable->kernel verification.
diff --git a/tests/src/android/renderscript/cts/global_sync.rs b/tests/src/android/renderscript/cts/global_sync.rs
index c947fa2..e384143 100644
--- a/tests/src/android/renderscript/cts/global_sync.rs
+++ b/tests/src/android/renderscript/cts/global_sync.rs
@@ -6,18 +6,26 @@
rs_allocation aFailed;
-void test_global(int expected) {
+void test_read_global(int expected) {
if (gInt != expected) {
rsSetElementAt_uchar(aFailed, 1, 0);
}
}
-void test_static_global(int expected) {
+void test_read_static_global(int expected) {
if (sInt != expected) {
rsSetElementAt_uchar(aFailed, 1, 0);
}
}
+void test_write_global(int i) {
+ gInt = i;
+}
+
+void test_write_static_global(int i) {
+ sInt = i;
+}
+
void __attribute__((kernel)) write_global(int ain, uint32_t x) {
if (x == 0) {
gInt = ain;
@@ -30,3 +38,16 @@
}
}
+int __attribute__((kernel)) read_global(int ain, uint32_t x) {
+ if (gInt != ain) {
+ return 1;
+ }
+ return 0;
+}
+
+int __attribute__((kernel)) read_static_global(int ain, uint32_t x) {
+ if (sInt != ain) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
index f895661..c446ba1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GlobalSync.java
@@ -40,20 +40,19 @@
int [] In = new int [1];
In[0] = v;
AIn.copyFrom(In);
-
}
/**
* Test whether we are properly synchronizing extern global data
- * when dealing with mixed kernels/invokables.
+ * when going from kernel to invokable.
*/
- public void testGlobalSync() {
+ public void testKIGlobalSync() {
ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
int v = 7;
setupGlobalSync(mRS, gs, v);
gs.forEach_write_global(AIn);
- gs.invoke_test_global(v);
+ gs.invoke_test_read_global(v);
AFailed.copyTo(Failed);
if (Failed[0] != 0) {
@@ -66,15 +65,57 @@
/**
* Test whether we are properly synchronizing static global data
- * when dealing with mixed kernels/invokables.
+ * when going from invokable to kernel.
*/
- public void testStaticGlobalSync() {
+ public void testKIStaticGlobalSync() {
ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
int v = 9;
setupGlobalSync(mRS, gs, v);
gs.forEach_write_static_global(AIn);
- gs.invoke_test_static_global(v);
+ gs.invoke_test_read_static_global(v);
+
+ AFailed.copyTo(Failed);
+ if (Failed[0] != 0) {
+ FoundError = true;
+ }
+
+ gs.destroy();
+ checkForErrors();
+ }
+
+ /**
+ * Test whether we are properly synchronizing extern global data
+ * when going from invokable to kernel.
+ */
+ public void testIKGlobalSync() {
+ ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
+
+ int v = 7;
+ setupGlobalSync(mRS, gs, v);
+ gs.invoke_test_write_global(v);
+ gs.forEach_read_global(AIn, AFailed);
+
+ AFailed.copyTo(Failed);
+ if (Failed[0] != 0) {
+ FoundError = true;
+ }
+
+ gs.destroy();
+ checkForErrors();
+ }
+
+ /**
+ * Test whether we are properly synchronizing static global data
+ * when going from kernel to invokable.
+ */
+ public void testIKStaticGlobalSync() {
+ ScriptC_global_sync gs = new ScriptC_global_sync(mRS);
+
+ int v = 9;
+ setupGlobalSync(mRS, gs, v);
+ gs.invoke_test_write_static_global(v);
+ gs.forEach_read_static_global(AIn, AFailed);
AFailed.copyTo(Failed);
if (Failed[0] != 0) {
@@ -85,4 +126,3 @@
checkForErrors();
}
}
-