[arrayfire] 85/284: cpu::Array::eval queue work moved to kerenel namespace
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/experimental
in repository arrayfire.
commit e651cad87b6a703119587c27626dbd6fc2c404b5
Author: pradeep <pradeep at arrayfire.com>
Date: Thu Dec 17 19:32:22 2015 -0500
cpu::Array::eval queue work moved to kerenel namespace
---
src/backend/cpu/Array.cpp | 38 ++-------------------------
src/backend/cpu/Array.hpp | 14 ++++++++++
src/backend/cpu/kernel/Array.hpp | 56 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 36 deletions(-)
diff --git a/src/backend/cpu/Array.cpp b/src/backend/cpu/Array.cpp
index 64fca1a..40d25ac 100644
--- a/src/backend/cpu/Array.cpp
+++ b/src/backend/cpu/Array.cpp
@@ -11,6 +11,7 @@
#include <err_common.hpp>
#include <Array.hpp>
#include <copy.hpp>
+#include <kernel/Array.hpp>
#include <TNJ/BufferNode.hpp>
#include <TNJ/ScalarNode.hpp>
#include <memory.hpp>
@@ -77,42 +78,7 @@ void Array<T>::eval()
data = std::shared_ptr<T>(memAlloc<T>(elements()), memFree<T>);
- auto func = [] (Array<T> in) {
- in.setId(getActiveDeviceId());
- T *ptr = in.data.get();
-
- dim4 odims = in.dims();
- dim4 ostrs = in.strides();
-
- bool is_linear = in.node->isLinear(odims.get());
-
- if (is_linear) {
- int num = in.elements();
- for (int i = 0; i < num; i++) {
- ptr[i] = *(T *)in.node->calc(i);
- }
- } else {
- for (int w = 0; w < (int)odims[3]; w++) {
- dim_t offw = w * ostrs[3];
-
- for (int z = 0; z < (int)odims[2]; z++) {
- dim_t offz = z * ostrs[2] + offw;
-
- for (int y = 0; y < (int)odims[1]; y++) {
- dim_t offy = y * ostrs[1] + offz;
-
- for (int x = 0; x < (int)odims[0]; x++) {
- dim_t id = x + offy;
-
- ptr[id] = *(T *)in.node->calc(x, y, z, w);
- }
- }
- }
- }
- }
- };
-
- getQueue().enqueue(func, *this);
+ getQueue().enqueue(kernel::evalArray<T>, *this);
ready = true;
Node_ptr prev = node;
diff --git a/src/backend/cpu/Array.hpp b/src/backend/cpu/Array.hpp
index ece989e..437c47f 100644
--- a/src/backend/cpu/Array.hpp
+++ b/src/backend/cpu/Array.hpp
@@ -23,6 +23,18 @@
#include <platform.hpp>
#include <async_queue.hpp>
+// cpu::Array class forward declaration
+namespace cpu
+{
+template<typename T> class Array;
+}
+
+// kernel::evalArray fn forward declaration
+namespace kernel
+{
+template<typename T> void evalArray(cpu::Array<T> in);
+}
+
namespace cpu
{
@@ -204,6 +216,8 @@ namespace cpu
const std::vector<af_seq> &index,
bool copy);
+ friend void kernel::evalArray<T>(Array<T> in);
+
friend void destroyArray<T>(Array<T> *arr);
friend void *getDevicePtr<T>(const Array<T>& arr);
};
diff --git a/src/backend/cpu/kernel/Array.hpp b/src/backend/cpu/kernel/Array.hpp
new file mode 100644
index 0000000..0666d43
--- /dev/null
+++ b/src/backend/cpu/kernel/Array.hpp
@@ -0,0 +1,56 @@
+/*******************************************************
+ * 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 <Array.hpp>
+#include <platform.hpp>
+
+namespace kernel
+{
+
+using af::dim4;
+using cpu::Array;
+
+template<typename T>
+void evalArray(Array<T> in)
+{
+ in.setId(cpu::getActiveDeviceId());
+ T *ptr = in.data.get();
+
+ dim4 odims = in.dims();
+ dim4 ostrs = in.strides();
+
+ bool is_linear = in.node->isLinear(odims.get());
+
+ if (is_linear) {
+ int num = in.elements();
+ for (int i = 0; i < num; i++) {
+ ptr[i] = *(T *)in.node->calc(i);
+ }
+ } else {
+ for (int w = 0; w < (int)odims[3]; w++) {
+ dim_t offw = w * ostrs[3];
+
+ for (int z = 0; z < (int)odims[2]; z++) {
+ dim_t offz = z * ostrs[2] + offw;
+
+ for (int y = 0; y < (int)odims[1]; y++) {
+ dim_t offy = y * ostrs[1] + offz;
+
+ for (int x = 0; x < (int)odims[0]; x++) {
+ dim_t id = x + offy;
+
+ ptr[id] = *(T *)in.node->calc(x, y, z, w);
+ }
+ }
+ }
+ }
+ }
+}
+
+}
--
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