[arrayfire] 31/61: TEST: Adding tests to verify unnecessary copies aren't being done
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Dec 8 11:55:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.
commit 967545dc16cdc33bd88af6578546ee6098544487
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Mon Nov 30 19:40:22 2015 -0500
TEST: Adding tests to verify unnecessary copies aren't being done
---
test/index.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
diff --git a/test/index.cpp b/test/index.cpp
index d6d1a64..0bfd71a 100644
--- a/test/index.cpp
+++ b/test/index.cpp
@@ -1386,3 +1386,98 @@ TEST(Index, OutOfBounds)
for(int i=0; i<7; ++i)
ASSERT_EQ(gold[i], output[i]);
}
+
+TEST(Index, ISSUE_1101_FULL)
+{
+ using namespace af;
+ deviceGC();
+ array a = randu(5,5);
+ std::vector<float> ha(a.elements());
+ a.host(&ha[0]);
+
+ size_t aby, abu, lby, lbu;
+ deviceMemInfo(&aby, &abu, &lby, &lbu);
+
+ array b = a(span, span);
+
+ size_t aby1, abu1, lby1, lbu1;
+ deviceMemInfo(&aby1, &abu1, &lby1, &lbu1);
+
+ ASSERT_EQ(aby, aby1);
+ ASSERT_EQ(abu, abu1);
+ ASSERT_EQ(lby, lby1);
+ ASSERT_EQ(lbu, lbu1);
+
+ std::vector<float> hb(b.elements());
+ b.host(&hb[0]);
+ for (int i = 0; i < b.elements(); i++) {
+ ASSERT_EQ(ha[i], hb[i]);
+ }
+}
+
+TEST(Index, ISSUE_1101_COL0)
+{
+ using namespace af;
+ deviceGC();
+ array a = randu(5,5);
+ std::vector<float> ha(a.elements());
+ a.host(&ha[0]);
+
+ size_t aby, abu, lby, lbu;
+ deviceMemInfo(&aby, &abu, &lby, &lbu);
+
+ array b = a(span, 0);
+
+ size_t aby1, abu1, lby1, lbu1;
+ deviceMemInfo(&aby1, &abu1, &lby1, &lbu1);
+
+ ASSERT_EQ(aby, aby1);
+ ASSERT_EQ(abu, abu1);
+ ASSERT_EQ(lby, lby1);
+ ASSERT_EQ(lbu, lbu1);
+
+ std::vector<float> hb(b.elements());
+ b.host(&hb[0]);
+ for (int i = 0; i < b.elements(); i++) {
+ ASSERT_EQ(ha[i], hb[i]);
+ }
+
+}
+
+TEST(Index, ISSUE_1101_MODDIMS)
+{
+ using namespace af;
+ deviceGC();
+ array a = randu(5,5);
+ std::vector<float> ha(a.elements());
+ a.host(&ha[0]);
+
+ size_t aby, abu, lby, lbu;
+ deviceMemInfo(&aby, &abu, &lby, &lbu);
+
+ int st = 0;
+ int en = 9;
+ int nx = 2;
+ int ny = 5;
+ array b = a(seq(st, en));
+ array c = moddims(b, nx, ny);
+ size_t aby1, abu1, lby1, lbu1;
+ deviceMemInfo(&aby1, &abu1, &lby1, &lbu1);
+
+ ASSERT_EQ(aby, aby1);
+ ASSERT_EQ(abu, abu1);
+ ASSERT_EQ(lby, lby1);
+ ASSERT_EQ(lbu, lbu1);
+
+ std::vector<float> hb(b.elements());
+ b.host(&hb[0]);
+ for (int i = 0; i < b.elements(); i++) {
+ ASSERT_EQ(ha[i + st], hb[i]);
+ }
+
+ std::vector<float> hc(c.elements());
+ c.host(&hc[0]);
+ for (int i = 0; i < c.elements(); i++) {
+ ASSERT_EQ(ha[i + st], hc[i]);
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list