[arrayfire] 67/84: TEST add a test for unified api

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository arrayfire.

commit 05471d19543af8f9f4500be5e56c3cb18c341901
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Tue Dec 29 14:34:43 2015 -0500

    TEST add a test for unified api
---
 test/unified.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/test/unified.cpp b/test/unified.cpp
new file mode 100644
index 0000000..fc9ec02
--- /dev/null
+++ b/test/unified.cpp
@@ -0,0 +1,68 @@
+/*******************************************************
+ * Copyright (c) 2014, ArrayFire
+ * All rights reserved.
+ *
+ * This file is distributed under 3-clause BSD license.
+ * The complete license agreement can be obtained at:
+ * http://arrayfire.com/licenses/BSD-3-Clause
+ ********************************************************/
+
+#include <gtest/gtest.h>
+#include <arrayfire.h>
+#include <af/data.h>
+#include <af/dim4.hpp>
+#include <af/traits.hpp>
+#include <string>
+#include <vector>
+#include <testHelpers.hpp>
+
+#include <af/device.h>
+
+using std::string;
+using std::vector;
+
+template<typename T>
+void testFunction()
+{
+    af_info();
+
+    af_array outArray = 0;
+    dim_t dims[] = {32, 32};
+    ASSERT_EQ(AF_SUCCESS, af_randu(&outArray, 2, dims, (af_dtype) af::dtype_traits<T>::af_type));
+    // cleanup
+    if(outArray != 0) ASSERT_EQ(AF_SUCCESS, af_release_array(outArray));
+}
+
+void unifiedTest()
+{
+    int backends = af::getAvailableBackends();
+
+    bool cpu    = backends & AF_BACKEND_CPU;
+    bool cuda   = backends & AF_BACKEND_CUDA;
+    bool opencl = backends & AF_BACKEND_OPENCL;
+
+    if(cpu) {
+        printf("Running CPU Backend...\n");
+        af::setBackend(AF_BACKEND_CPU);
+        testFunction<float>();
+    }
+
+    if(cuda) {
+        printf("Running CUDA Backend...\n");
+        af::setBackend(AF_BACKEND_CUDA);
+        testFunction<float>();
+    }
+
+    if(opencl) {
+        printf("Running OpenCL Backend...\n");
+        af::setBackend(AF_BACKEND_OPENCL);
+        testFunction<float>();
+    }
+
+    af::setBackend(AF_BACKEND_DEFAULT);
+}
+
+TEST(UNIFIED_TEST, Basic)
+{
+    unifiedTest();
+}

-- 
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