[arrayfire] 106/284: moved dot cpu implementation to kernel namespace
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:23 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 483121596dd76d4d9c7227d2057b49863d073275
Author: pradeep <pradeep at arrayfire.com>
Date: Mon Dec 28 16:47:42 2015 -0500
moved dot cpu implementation to kernel namespace
---
src/backend/cpu/blas.cpp | 47 ++++++++++--------------------------------
src/backend/cpu/kernel/dot.hpp | 46 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 36 deletions(-)
diff --git a/src/backend/cpu/blas.cpp b/src/backend/cpu/blas.cpp
index 26ec8b4..d6f5dee 100644
--- a/src/backend/cpu/blas.cpp
+++ b/src/backend/cpu/blas.cpp
@@ -11,20 +11,20 @@
#include <af/dim4.hpp>
#include <handle.hpp>
#include <cassert>
-#include <err_cpu.hpp>
#include <err_common.hpp>
+#include <kernel/dot.hpp>
#include <platform.hpp>
#include <async_queue.hpp>
namespace cpu
{
- using std::add_const;
- using std::add_pointer;
- using std::enable_if;
- using std::is_floating_point;
- using std::remove_const;
- using std::conditional;
+using std::add_const;
+using std::add_pointer;
+using std::enable_if;
+using std::is_floating_point;
+using std::remove_const;
+using std::conditional;
// Some implementations of BLAS require void* for complex pointers while others use float*/double*
//
@@ -199,31 +199,6 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
return out;
}
-template<typename T> T
-conj(T x) { return x; }
-
-template<> cfloat conj<cfloat> (cfloat c) { return std::conj(c); }
-template<> cdouble conj<cdouble>(cdouble c) { return std::conj(c); }
-
-template<typename T, bool conjugate, bool both_conjugate>
-void dot_(Array<T> output, const Array<T> &lhs, const Array<T> &rhs,
- af_mat_prop optLhs, af_mat_prop optRhs)
-{
- int N = lhs.dims()[0];
-
- T out = 0;
- const T *pL = lhs.get();
- const T *pR = rhs.get();
-
- for(int i = 0; i < N; i++)
- out += (conjugate ? cpu::conj(pL[i]) : pL[i]) * pR[i];
-
- if(both_conjugate) out = cpu::conj(out);
-
- *output.get() = out;
-
-}
-
template<typename T>
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
af_mat_prop optLhs, af_mat_prop optRhs)
@@ -233,13 +208,13 @@ Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
Array<T> out = createEmptyArray<T>(af::dim4(1));
if(optLhs == AF_MAT_CONJ && optRhs == AF_MAT_CONJ) {
- getQueue().enqueue(dot_<T, false, true>, out, lhs, rhs, optLhs, optRhs);
+ getQueue().enqueue(kernel::dot<T, false, true>, out, lhs, rhs, optLhs, optRhs);
} else if (optLhs == AF_MAT_CONJ && optRhs == AF_MAT_NONE) {
- getQueue().enqueue(dot_<T, true, false>,out, lhs, rhs, optLhs, optRhs);
+ getQueue().enqueue(kernel::dot<T, true, false>,out, lhs, rhs, optLhs, optRhs);
} else if (optLhs == AF_MAT_NONE && optRhs == AF_MAT_CONJ) {
- getQueue().enqueue(dot_<T, true, false>,out, rhs, lhs, optRhs, optLhs);
+ getQueue().enqueue(kernel::dot<T, true, false>,out, rhs, lhs, optRhs, optLhs);
} else {
- getQueue().enqueue(dot_<T, false, false>,out, lhs, rhs, optLhs, optRhs);
+ getQueue().enqueue(kernel::dot<T, false, false>,out, lhs, rhs, optLhs, optRhs);
}
return out;
}
diff --git a/src/backend/cpu/kernel/dot.hpp b/src/backend/cpu/kernel/dot.hpp
new file mode 100644
index 0000000..ef51841
--- /dev/null
+++ b/src/backend/cpu/kernel/dot.hpp
@@ -0,0 +1,46 @@
+/*******************************************************
+ * Copyright (c) 2015, 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
+ ********************************************************/
+
+#pragma once
+#include <af/defines.h>
+#include <Array.hpp>
+#include <complex>
+
+namespace cpu
+{
+namespace kernel
+{
+
+template<typename T> T
+conj(T x) { return x; }
+
+template<> cfloat conj<cfloat> (cfloat c) { return std::conj(c); }
+template<> cdouble conj<cdouble>(cdouble c) { return std::conj(c); }
+
+template<typename T, bool conjugate, bool both_conjugate>
+void dot(Array<T> output, const Array<T> &lhs, const Array<T> &rhs,
+ af_mat_prop optLhs, af_mat_prop optRhs)
+{
+ int N = lhs.dims()[0];
+
+ T out = 0;
+ const T *pL = lhs.get();
+ const T *pR = rhs.get();
+
+ for(int i = 0; i < N; i++)
+ out += (conjugate ? kernel::conj(pL[i]) : pL[i]) * pR[i];
+
+ if(both_conjugate) out = kernel::conj(out);
+
+ *output.get() = 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