summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2012-11-29 14:37:59 -0800
committerTim Murray <timmurray@google.com>2012-12-04 18:32:49 -0800
commit4d252d6e807b89764dad123ac845df298c52ca97 (patch)
tree7b07cab9e7278b108b9ab15663221bd18da00f8e /tests
parent2e1a94df812f0caa42ff24eaefeba8f90fbdf1ac (diff)
downloadrs-4d252d6e807b89764dad123ac845df298c52ca97.tar.gz
enable synchronous mode (functional)
Change-Id: I613610013e7e4d1623620ab94d2d25d8a1bd82b3 Bug: 5972398
Diffstat (limited to 'tests')
-rw-r--r--tests/latency/latency.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/latency/latency.cpp b/tests/latency/latency.cpp
index 124fb20a..86d1a291 100644
--- a/tests/latency/latency.cpp
+++ b/tests/latency/latency.cpp
@@ -11,6 +11,7 @@ int main(int argc, char** argv)
int iters = 100;
int numElems = 1000;
bool forceCpu = false;
+ bool synchronous = false;
if (argc >= 2) {
iters = atoi(argv[1]);
@@ -36,14 +37,23 @@ int main(int argc, char** argv)
forceCpu = true;
}
+ if (argc >= 5) {
+ int temp = atoi(argv[4]);
+ if (temp != 0)
+ synchronous = true;
+ }
+
if (forceCpu)
printf("forcing CPU\n");
+ if (synchronous)
+ printf("forcing synchronous\n");
+
printf("numElems = %d\n", numElems);
sp<RS> rs = new RS();
- bool r = rs->init(forceCpu); // force CPU execution
+ bool r = rs->init(forceCpu, synchronous);
sp<const Element> e = Element::U32(rs);
@@ -51,6 +61,8 @@ int main(int argc, char** argv)
tb.setX(numElems);
sp<const Type> t = tb.create();
+ uint32_t *buf = new uint32_t[numElems];
+
sp<Allocation> ain = Allocation::createTyped(rs, t);
sp<Allocation> aout = Allocation::createTyped(rs, t);
@@ -72,6 +84,21 @@ int main(int argc, char** argv)
printf("elapsed time : %lld microseconds\n", elapsed);
printf("time per iter: %f microseconds\n", (double)elapsed / iters);
+ gettimeofday(&start, NULL);
+
+ for (int i = 0; i < iters; i++) {
+ ain->copy1DFrom(buf);
+ sc->forEach_root(ain, aout);
+ aout->copy1DTo(buf);
+ }
+
+ rs->finish();
+
+ gettimeofday(&stop, NULL);
+ elapsed = (stop.tv_sec * 1000000) - (start.tv_sec * 1000000) + (stop.tv_usec - start.tv_usec);
+ printf("elapsed time with copy : %lld microseconds\n", elapsed);
+ printf("time per iter with copy: %f microseconds\n", (double)elapsed / iters);
+
sc.clear();
t.clear();
e.clear();