2016-09-19 12:44:13 +01:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
|
|
|
|
// Mehdi Goli Codeplay Software Ltd.
|
|
|
|
|
// Ralph Potter Codeplay Software Ltd.
|
|
|
|
|
// Luke Iwanski Codeplay Software Ltd.
|
|
|
|
|
// Contact: eigen@codeplay.com
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
|
// General include header of SYCL target for Tensor Module
|
2016-10-14 12:09:55 +01:00
|
|
|
#ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_H
|
|
|
|
|
#define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_H
|
2016-09-19 12:44:13 +01:00
|
|
|
|
|
|
|
|
#ifdef EIGEN_USE_SYCL
|
|
|
|
|
|
|
|
|
|
// global pointer to set different attribute state for a class
|
|
|
|
|
template <class T>
|
|
|
|
|
struct MakeGlobalPointer {
|
|
|
|
|
typedef typename cl::sycl::global_ptr<T>::pointer_t Type;
|
2016-12-16 19:46:45 +00:00
|
|
|
typedef typename cl::sycl::global_ptr<T>::reference_t RefType;
|
2016-09-19 12:44:13 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-04 18:18:19 +00:00
|
|
|
// global pointer to set different attribute state for a class
|
|
|
|
|
template <class T>
|
|
|
|
|
struct MakeLocalPointer {
|
|
|
|
|
typedef typename cl::sycl::local_ptr<T>::pointer_t Type;
|
2016-12-16 19:46:45 +00:00
|
|
|
typedef typename cl::sycl::local_ptr<T>::reference_t RefType;
|
2016-11-04 18:18:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2016-10-14 12:09:55 +01:00
|
|
|
namespace Eigen {
|
2017-03-07 14:27:10 +00:00
|
|
|
template<typename StrideDims, typename XprType> class TensorTupleReducerDeviceOp;
|
|
|
|
|
template<typename StrideDims, typename ArgType> struct TensorEvaluator<const TensorTupleReducerDeviceOp<StrideDims, ArgType>, SyclKernelDevice>;
|
2016-10-14 12:09:55 +01:00
|
|
|
namespace internal {
|
|
|
|
|
|
2017-06-28 17:55:23 +00:00
|
|
|
#ifdef __SYCL_DEVICE_ONLY__
|
|
|
|
|
template<typename A, typename B> struct TypeConversion {
|
|
|
|
|
template<typename T>
|
|
|
|
|
static typename MakeGlobalPointer<A>::Type get_address_space_pointer(typename MakeGlobalPointer<T>::Type p);
|
|
|
|
|
template<typename T>
|
|
|
|
|
static typename MakeLocalPointer<A>::Type get_address_space_pointer(typename MakeLocalPointer<T>::Type p);
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
static A* get_address_space_pointer(T* p);
|
|
|
|
|
typedef decltype(get_address_space_pointer(B())) type;
|
|
|
|
|
};
|
2016-12-16 19:46:45 +00:00
|
|
|
|
2017-06-28 17:55:23 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
namespace TensorSycl {
|
|
|
|
|
namespace internal {
|
2016-12-16 19:46:45 +00:00
|
|
|
|
2017-06-28 17:55:23 +00:00
|
|
|
template<typename CoeffReturnType, typename OP, typename OutputAccessor, typename InputAccessor, typename LocalAccessor> struct GenericKernelReducer;
|
2016-10-14 12:09:55 +01:00
|
|
|
/// This struct is used for special expression nodes with no operations (for example assign and selectOP).
|
|
|
|
|
struct NoOP;
|
|
|
|
|
|
|
|
|
|
template<bool IsConst, typename T> struct GetType{
|
|
|
|
|
typedef const T Type;
|
|
|
|
|
};
|
|
|
|
|
template<typename T> struct GetType<false, T>{
|
|
|
|
|
typedef T Type;
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-07 14:27:10 +00:00
|
|
|
template <bool Conds, size_t X , size_t Y > struct ValueCondition {
|
2017-06-28 17:55:23 +00:00
|
|
|
static constexpr size_t Res =X;
|
2017-03-07 14:27:10 +00:00
|
|
|
};
|
2017-06-28 17:55:23 +00:00
|
|
|
template<size_t X, size_t Y> struct ValueCondition<false, X, Y> {
|
|
|
|
|
static constexpr size_t Res =Y;
|
2017-03-07 14:27:10 +00:00
|
|
|
};
|
|
|
|
|
|
2016-10-14 12:09:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-30 20:21:18 -08:00
|
|
|
// tuple construction
|
|
|
|
|
#include "TensorSyclTuple.h"
|
2016-09-19 12:44:13 +01:00
|
|
|
|
2016-11-04 18:18:19 +00:00
|
|
|
// counting number of leaf at compile time
|
2016-09-19 12:44:13 +01:00
|
|
|
#include "TensorSyclLeafCount.h"
|
|
|
|
|
|
|
|
|
|
// The index PlaceHolder takes the actual expression and replaces the actual
|
|
|
|
|
// data on it with the place holder. It uses the same pre-order expression tree
|
|
|
|
|
// traverse as the leaf count in order to give the right access number to each
|
|
|
|
|
// node in the expression
|
|
|
|
|
#include "TensorSyclPlaceHolderExpr.h"
|
|
|
|
|
|
|
|
|
|
// creation of an accessor tuple from a tuple of SYCL buffers
|
|
|
|
|
#include "TensorSyclExtractAccessor.h"
|
|
|
|
|
|
|
|
|
|
// this is used to change the address space type in tensor map for GPU
|
|
|
|
|
#include "TensorSyclConvertToDeviceExpression.h"
|
|
|
|
|
|
|
|
|
|
// this is used to extract the functors
|
|
|
|
|
#include "TensorSyclExtractFunctors.h"
|
|
|
|
|
|
|
|
|
|
// this is used to create tensormap on the device
|
|
|
|
|
// this is used to construct the expression on the device
|
|
|
|
|
#include "TensorSyclExprConstructor.h"
|
|
|
|
|
|
2016-11-04 18:18:19 +00:00
|
|
|
/// this is used for extracting tensor reduction
|
|
|
|
|
#include "TensorReductionSycl.h"
|
|
|
|
|
|
2017-03-07 14:27:10 +00:00
|
|
|
// TensorArgMaxSycl.h
|
|
|
|
|
#include "TensorArgMaxSycl.h"
|
|
|
|
|
|
2017-01-19 11:30:59 +00:00
|
|
|
/// this is used for extracting tensor convolution
|
|
|
|
|
#include "TensorConvolutionSycl.h"
|
|
|
|
|
|
2016-09-19 12:44:13 +01:00
|
|
|
// kernel execution using fusion
|
|
|
|
|
#include "TensorSyclRun.h"
|
2016-11-25 16:19:07 +00:00
|
|
|
//sycl functors
|
|
|
|
|
#include "TensorSyclFunctors.h"
|
2016-09-19 12:44:13 +01:00
|
|
|
|
2016-12-14 15:30:37 +00:00
|
|
|
#include "TensorContractionSycl.h"
|
|
|
|
|
|
2016-09-19 12:44:13 +01:00
|
|
|
#endif // end of EIGEN_USE_SYCL
|
2016-10-14 12:09:55 +01:00
|
|
|
#endif // UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_H
|