[arrayfire] 31/248: Moved HAPI examples into standard examples location

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:53:51 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 53d327e1c6b5d9fbfda0ab10b76f69b6892fcd71
Author: pradeep <pradeep at arrayfire.com>
Date:   Mon Aug 31 17:40:34 2015 -0400

    Moved HAPI examples into standard examples location
---
 CMakeLists.txt                                    |  1 -
 examples/CMakeLists.txt                           | 17 +++++++++++++++++
 hapi_examples/test.cpp => examples/hapi/basic.cpp |  8 ++++----
 hapi_examples/CMakeLists.txt                      | 16 ----------------
 src/api/c/device.cpp                              |  5 +++++
 5 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d986c10..ca098e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -172,7 +172,6 @@ ENDIF()
 
 IF(${BUILD_AF})
     ADD_SUBDIRECTORY(src/api/hapi)
-    ADD_SUBDIRECTORY(hapi_examples)
 ENDIF()
 
 IF(${BUILD_DOCS})
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 0c66486..0456c59 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -68,8 +68,25 @@ ENDMACRO()
 
 # Collect the source
 FILE(GLOB FILES "*/*.cpp")
+FILE(GLOB HAPI_FILES "hapi/*.cpp")
 ADD_DEFINITIONS("-DASSETS_DIR=\"${ASSETS_DIR}\"")
 
+IF(${ArrayFire_HAPI_FOUND})
+    MESSAGE(STATUS "HAPI examples")
+    IF(WIN32)
+        BUILD_ALL("${HAPI_FILES}" hapi ${ArrayFire_HAPI_LIBRARIES})
+    ELSE()
+        BUILD_ALL("${HAPI_FILES}" hapi ${ArrayFire_HAPI_LIBRARIES} dl)
+    ENDIF()
+ELSEIF(TARGET af)
+    MESSAGE(STATUS "HAPI examples")
+    IF(WIN32)
+        BUILD_ALL("${HAPI_FILES}" hapi af)
+    ELSE()
+        BUILD_ALL("${HAPI_FILES}" hapi af dl)
+    ENDIF()
+ENDIF()
+
 # Next we build each example using every backend.
 if(${ArrayFire_CPU_FOUND})  # variable defined by FIND(ArrayFire ...)
   MESSAGE(STATUS "EXAMPLES: CPU backend is ON.")
diff --git a/hapi_examples/test.cpp b/examples/hapi/basic.cpp
similarity index 88%
rename from hapi_examples/test.cpp
rename to examples/hapi/basic.cpp
index a7ee36c..366bb53 100644
--- a/hapi_examples/test.cpp
+++ b/examples/hapi/basic.cpp
@@ -49,11 +49,11 @@ int main(int argc, char *argv[])
 {
     std::generate(input.begin(), input.end(), unifRand);
 
-    af_set_backend(AF_BACKEND_CPU);
-    testBackend();
+    if (AF_SUCCESS == af_set_backend(AF_BACKEND_CPU))
+        testBackend();
 
-    af_set_backend(AF_BACKEND_OPENCL);
-    testBackend();
+    if (AF_SUCCESS == af_set_backend(AF_BACKEND_OPENCL))
+        testBackend();
 
     #ifdef WIN32 // pause in Windows
     if (!(argc == 2 && argv[1][0] == '-')) {
diff --git a/hapi_examples/CMakeLists.txt b/hapi_examples/CMakeLists.txt
deleted file mode 100644
index ce947d7..0000000
--- a/hapi_examples/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-PROJECT(arrayfire-hapi-examples)
-
-ADD_DEFINITIONS(-std=c++11)
-
-IF(NOT TARGET af)
-    FIND_PACKAGE(ArrayFire REQUIRED)
-    INCLUDE_DIRECTORIES(${ArrayFire_INCLUDE_DIRS})
-ENDIF()
-
-ADD_EXECUTABLE(hapi_test test.cpp)
-
-TARGET_LINK_LIBRARIES(hapi_test af)
-IF(UNIX)
-    TARGET_LINK_LIBRARIES(hapi_test dl)
-ENDIF()
diff --git a/src/api/c/device.cpp b/src/api/c/device.cpp
index 0e59bfb..f3b0bea 100644
--- a/src/api/c/device.cpp
+++ b/src/api/c/device.cpp
@@ -10,6 +10,7 @@
 #include <af/dim4.hpp>
 #include <af/device.h>
 #include <af/version.h>
+#include <af/hapi.h>
 #include <backend.hpp>
 #include <platform.hpp>
 #include <Array.hpp>
@@ -21,6 +22,7 @@ using namespace detail;
 
 af_err af_set_backend(const af_backend bknd)
 {
+    try {
 #if defined(AF_CPU)
     ARG_ASSERT(0, bknd==AF_BACKEND_CPU);
 #endif
@@ -30,6 +32,9 @@ af_err af_set_backend(const af_backend bknd)
 #if defined(AF_OPENCL)
     ARG_ASSERT(0, bknd==AF_BACKEND_OPENCL);
 #endif
+    }
+    CATCHALL;
+
     return AF_SUCCESS;
 }
 

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