![]() |
Eigen-unsupported
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Mehdi Goli Codeplay Software Ltd. 00005 // Ralph Potter Codeplay Software Ltd. 00006 // Luke Iwanski Codeplay Software Ltd. 00007 // Contact: <eigen@codeplay.com> 00008 // 00009 // This Source Code Form is subject to the terms of the Mozilla 00010 // Public License v. 2.0. If a copy of the MPL was not distributed 00011 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00012 00013 /***************************************************************** 00014 * TensorSyclConvertToDeviceExpression.h 00015 * 00016 * \brief: 00017 * Conversion from host pointer to device pointer 00018 * inside leaf nodes of the expression. 00019 * 00020 *****************************************************************/ 00021 00022 #ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP 00023 #define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP 00024 00025 namespace Eigen { 00026 namespace TensorSycl { 00027 namespace internal { 00028 00034 template <typename Expr> 00035 struct ConvertToDeviceExpression; 00036 00037 template<template<class...> class NonOpCategory, bool IsConst, typename... Args> 00038 struct NonOpConversion{ 00039 typedef typename GetType<IsConst, NonOpCategory<typename ConvertToDeviceExpression<Args>::Type...> >::Type Type; 00040 }; 00041 00042 00043 template<template<class, template <class> class > class NonOpCategory, bool IsConst, typename Args> 00044 struct DeviceConvertor{ 00045 typedef typename GetType<IsConst, NonOpCategory<typename ConvertToDeviceExpression<Args>::Type, MakeGlobalPointer> >::Type Type; 00046 }; 00047 00050 #define TENSORMAPCONVERT(CVQual)\ 00051 template <typename Scalar_, int Options_, int Options2_, int NumIndices_, typename IndexType_, template <class> class MakePointer_>\ 00052 struct ConvertToDeviceExpression<CVQual TensorMap<Tensor<Scalar_, NumIndices_, Options_, IndexType_>, Options2_, MakePointer_> > {\ 00053 typedef CVQual TensorMap<Tensor<Scalar_, NumIndices_, Options_, IndexType_>, Options2_, MakeGlobalPointer> Type;\ 00054 }; 00055 00056 TENSORMAPCONVERT(const) 00057 TENSORMAPCONVERT() 00058 #undef TENSORMAPCONVERT 00059 00062 #define CATEGORYCONVERT(CVQual)\ 00063 template <template<class, class...> class Category, typename OP, typename... subExprs>\ 00064 struct ConvertToDeviceExpression<CVQual Category<OP, subExprs...> > {\ 00065 typedef CVQual Category<OP, typename ConvertToDeviceExpression<subExprs>::Type... > Type;\ 00066 }; 00067 CATEGORYCONVERT(const) 00068 CATEGORYCONVERT() 00069 #undef CATEGORYCONVERT 00070 00071 00074 #define SELECTOPCONVERT(CVQual, Res)\ 00075 template <typename IfExpr, typename ThenExpr, typename ElseExpr>\ 00076 struct ConvertToDeviceExpression<CVQual TensorSelectOp<IfExpr, ThenExpr, ElseExpr> >\ 00077 : NonOpConversion<TensorSelectOp, Res, IfExpr, ThenExpr, ElseExpr> {}; 00078 SELECTOPCONVERT(const, true) 00079 SELECTOPCONVERT(, false) 00080 #undef SELECTOPCONVERT 00081 00084 #define ASSIGNCONVERT(CVQual, Res)\ 00085 template <typename LHSExpr, typename RHSExpr>\ 00086 struct ConvertToDeviceExpression<CVQual TensorAssignOp<LHSExpr, RHSExpr> >\ 00087 : NonOpConversion<TensorAssignOp, Res, LHSExpr, RHSExpr>{}; 00088 00089 ASSIGNCONVERT(const, true) 00090 ASSIGNCONVERT(, false) 00091 #undef ASSIGNCONVERT 00092 00095 #define KERNELBROKERCONVERT(CVQual, Res, ExprNode)\ 00096 template <typename Expr>\ 00097 struct ConvertToDeviceExpression<CVQual ExprNode<Expr> > \ 00098 : DeviceConvertor<ExprNode, Res, Expr>{}; 00099 00100 KERNELBROKERCONVERT(const, true, TensorForcedEvalOp) 00101 KERNELBROKERCONVERT(, false, TensorForcedEvalOp) 00102 KERNELBROKERCONVERT(const, true, TensorEvalToOp) 00103 KERNELBROKERCONVERT(, false, TensorEvalToOp) 00104 #undef KERNELBROKERCONVERT 00105 00107 #define KERNELBROKERCONVERTREDUCTION(CVQual)\ 00108 template <typename OP, typename Dim, typename subExpr, template <class> class MakePointer_>\ 00109 struct ConvertToDeviceExpression<CVQual TensorReductionOp<OP, Dim, subExpr, MakePointer_> > {\ 00110 typedef CVQual TensorReductionOp<OP, Dim, typename ConvertToDeviceExpression<subExpr>::Type, MakeGlobalPointer> Type;\ 00111 }; 00112 00113 KERNELBROKERCONVERTREDUCTION(const) 00114 KERNELBROKERCONVERTREDUCTION() 00115 #undef KERNELBROKERCONVERTREDUCTION 00116 00117 } // namespace internal 00118 } // namespace TensorSycl 00119 } // namespace Eigen 00120 00121 #endif // UNSUPPORTED_EIGEN_CXX1