[arrayfire] 41/248: Changes required to make unified library build the cpp bindings

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:53:52 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 4cb64cb9548ad5808578b8bef26bb3e809b2839a
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Fri Sep 4 19:04:57 2015 -0400

    Changes required to make unified library build the cpp bindings
---
 CMakeLists.txt                 |  1 +
 src/api/c/err_common.cpp       |  4 ++--
 src/api/unified/CMakeLists.txt | 16 ++++++++++++---
 src/backend/ArrayInfo.cpp      | 43 +++++++++++++++++++++++++++++++++++++++
 src/backend/dim4.cpp           | 46 +-----------------------------------------
 5 files changed, 60 insertions(+), 50 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c43e5ff..92e32e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -171,6 +171,7 @@ IF(${BUILD_OPENCL})
 ENDIF()
 
 IF(${BUILD_UNIFIED})
+    ADD_DEFINITIONS(-DAF_UNIFIED)
     ADD_SUBDIRECTORY(src/api/unified)
 ENDIF()
 
diff --git a/src/api/c/err_common.cpp b/src/api/c/err_common.cpp
index fdbe82f..4fa4bbb 100644
--- a/src/api/c/err_common.cpp
+++ b/src/api/c/err_common.cpp
@@ -16,7 +16,7 @@
 #include <cstdio>
 #include <algorithm>
 
-#if defined(WITH_GRAPHICS)
+#if defined(WITH_GRAPHICS) && !defined(AF_UNIFIED)
 #include <graphics_common.hpp>
 #endif
 
@@ -229,7 +229,7 @@ af_err processException()
 
         print_error(ss);
         err = ex.getError();
-#if defined(WITH_GRAPHICS)
+#if defined(WITH_GRAPHICS) && !defined(AF_UNIFIED)
     } catch (const fg::Error &ex) {
         ss << ex << "\n";
         print_error(ss);
diff --git a/src/api/unified/CMakeLists.txt b/src/api/unified/CMakeLists.txt
index f5683e0..1f380e0 100644
--- a/src/api/unified/CMakeLists.txt
+++ b/src/api/unified/CMakeLists.txt
@@ -6,12 +6,22 @@ FILE(GLOB unified_headers
 FILE(GLOB unified_sources
     "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
 
-FILE(GLOB backend_sources
-    "../c/util.cpp")
+FILE(GLOB cpp_sources
+    "../cpp/*.cpp")
+
+FILE(GLOB common_sources
+    "../c/util.cpp"
+    "../c/err_common.cpp"
+    "../c/type_util.cpp"
+    "../../backend/dim4.cpp"
+    )
 
 ADD_LIBRARY(af SHARED
             ${unified_headers}
-            ${unified_sources})
+            ${unified_sources}
+            ${common_sources}
+            ${cpp_sources}
+            )
 
 IF(${BUILD_CPU})
     ADD_DEPENDENCIES(af afcpu)
diff --git a/src/backend/ArrayInfo.cpp b/src/backend/ArrayInfo.cpp
index 20c5bd8..2fc56a9 100644
--- a/src/backend/ArrayInfo.cpp
+++ b/src/backend/ArrayInfo.cpp
@@ -172,3 +172,46 @@ dim4 getOutDims(const dim4 &ldims, const dim4 &rdims, bool batchMode)
 
     return dim4(4, odims);
 }
+
+using std::vector;
+
+dim4
+toDims(const vector<af_seq>& seqs, const dim4 &parentDims)
+{
+    dim4 outDims(1, 1, 1, 1);
+    for(unsigned i = 0; i < seqs.size(); i++ ) {
+        outDims[i] = af::calcDim(seqs[i], parentDims[i]);
+        if (outDims[i] > parentDims[i])
+            AF_ERROR("Size mismatch between input and output", AF_ERR_SIZE);
+    }
+    return outDims;
+}
+
+dim4
+toOffset(const vector<af_seq>& seqs, const dim4 &parentDims)
+{
+    dim4 outOffsets(0, 0, 0, 0);
+    for(unsigned i = 0; i < seqs.size(); i++ ) {
+        if (seqs[i].step !=0 && seqs[i].begin >= 0) {
+            outOffsets[i] = seqs[i].begin;
+        } else if (seqs[i].begin <= -1) {
+            outOffsets[i] = parentDims[i] + seqs[i].begin;
+        } else {
+            outOffsets[i] = 0;
+        }
+
+        if (outOffsets[i] >= parentDims[i])
+            AF_ERROR("Index out of range", AF_ERR_SIZE);
+    }
+    return outOffsets;
+}
+
+dim4
+toStride(const vector<af_seq>& seqs, const af::dim4 &parentDims)
+{
+    dim4 out(calcStrides(parentDims));
+    for(unsigned i = 0; i < seqs.size(); i++ ) {
+        if  (seqs[i].step != 0) {   out[i] *= seqs[i].step; }
+    }
+    return out;
+}
diff --git a/src/backend/dim4.cpp b/src/backend/dim4.cpp
index 41ea56a..cad5444 100644
--- a/src/backend/dim4.cpp
+++ b/src/backend/dim4.cpp
@@ -12,11 +12,11 @@
 #include <cmath>
 #include <cfloat>
 #include <af/dim4.hpp>
-#include <ArrayInfo.hpp>
 #include <err_common.hpp>
 
 namespace af
 {
+
 #if __cplusplus > 199711l
     static_assert(std::is_standard_layout<dim4>::value, "af::dim4 must be a standard layout type");
 #endif
@@ -217,47 +217,3 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
     return outDim;
 }
 }
-
-using af::dim4;
-using std::vector;
-
-dim4
-toDims(const vector<af_seq>& seqs, const dim4 &parentDims)
-{
-    dim4 outDims(1, 1, 1, 1);
-    for(unsigned i = 0; i < seqs.size(); i++ ) {
-        outDims[i] = af::calcDim(seqs[i], parentDims[i]);
-        if (outDims[i] > parentDims[i])
-            AF_ERROR("Size mismatch between input and output", AF_ERR_SIZE);
-    }
-    return outDims;
-}
-
-dim4
-toOffset(const vector<af_seq>& seqs, const dim4 &parentDims)
-{
-    dim4 outOffsets(0, 0, 0, 0);
-    for(unsigned i = 0; i < seqs.size(); i++ ) {
-        if (seqs[i].step !=0 && seqs[i].begin >= 0) {
-            outOffsets[i] = seqs[i].begin;
-        } else if (seqs[i].begin <= -1) {
-            outOffsets[i] = parentDims[i] + seqs[i].begin;
-        } else {
-            outOffsets[i] = 0;
-        }
-
-        if (outOffsets[i] >= parentDims[i])
-            AF_ERROR("Index out of range", AF_ERR_SIZE);
-    }
-    return outOffsets;
-}
-
-dim4
-toStride(const vector<af_seq>& seqs, const af::dim4 &parentDims)
-{
-    dim4 out(calcStrides(parentDims));
-    for(unsigned i = 0; i < seqs.size(); i++ ) {
-        if  (seqs[i].step != 0) {   out[i] *= seqs[i].step; }
-    }
-    return out;
-}

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