// 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: // // 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/. /***************************************************************** * TensorSyclConvertToDeviceExpression.h * * \brief: * Conversion from host pointer to device pointer * inside leaf nodes of the expression. * *****************************************************************/ #ifndef UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP #define UNSUPPORTED_EIGEN_CXX11_SRC_TENSOR_TENSORSYCL_CONVERT_TO_DEVICE_EXPRESSION_HPP namespace Eigen { namespace TensorSycl { namespace internal { /// \struct ConvertToDeviceExpression /// \brief This struct is used to convert the MakePointer in the host expression /// to the MakeGlobalPointer for the device expression. For the leafNodes /// containing the pointer. This is due to the fact that the address space of /// the pointer T* is different on the host and the device. template struct ConvertToDeviceExpression; template class NonOpCategory, bool IsConst, typename... Args> struct NonOpConversion{ typedef typename GetType::Type...> >::Type Type; }; template class > class NonOpCategory, bool IsConst, typename Args> struct DeviceConvertor{ typedef typename GetType::Type, MakeGlobalPointer> >::Type Type; }; /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is TensorMap #define TENSORMAPCONVERT(CVQual)\ template class MakePointer_>\ struct ConvertToDeviceExpression > {\ typedef CVQual TensorMap Type;\ }; TENSORMAPCONVERT(const) TENSORMAPCONVERT() #undef TENSORMAPCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is TensorCwiseNullaryOp, TensorCwiseUnaryOp, TensorCwiseBinaryOp, TensorCwiseTernaryOp, TensorBroadcastingOp #define CATEGORYCONVERT(CVQual)\ template class Category, typename OP, typename... subExprs>\ struct ConvertToDeviceExpression > {\ typedef CVQual Category::Type... > Type;\ }; CATEGORYCONVERT(const) CATEGORYCONVERT() #undef CATEGORYCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is TensorCwiseSelectOp #define SELECTOPCONVERT(CVQual, Res)\ template \ struct ConvertToDeviceExpression >\ : NonOpConversion {}; SELECTOPCONVERT(const, true) SELECTOPCONVERT(, false) #undef SELECTOPCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is const AssingOP #define ASSIGNCONVERT(CVQual, Res)\ template \ struct ConvertToDeviceExpression >\ : NonOpConversion{}; ASSIGNCONVERT(const, true) ASSIGNCONVERT(, false) #undef ASSIGNCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node /// type is TensorEvalToOp #define KERNELBROKERCONVERT(CVQual, Res, ExprNode)\ template \ struct ConvertToDeviceExpression > \ : DeviceConvertor{}; KERNELBROKERCONVERT(const, true, TensorEvalToOp) KERNELBROKERCONVERT(, false, TensorEvalToOp) #undef KERNELBROKERCONVERT /// specialisation of the \ref ConvertToDeviceExpression struct when the node types are TensorForcedEvalOp and TensorLayoutSwapOp #define KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(CVQual, ExprNode)\ template \ struct ConvertToDeviceExpression > {\ typedef CVQual ExprNode< typename ConvertToDeviceExpression::Type> Type;\ }; // TensorForcedEvalOp KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(const,TensorForcedEvalOp) KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(,TensorForcedEvalOp) // TensorLayoutSwapOp KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(const,TensorLayoutSwapOp) KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(,TensorLayoutSwapOp) //TensorIndexTupleOp KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(const,TensorIndexTupleOp) KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP(,TensorIndexTupleOp) #undef KERNELBROKERCONVERTFORCEDEVALLAYOUTSWAPINDEXTUPLEOP /// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorReductionOp #define KERNELBROKERCONVERTREDUCTION(CVQual)\ template class MakePointer_>\ struct ConvertToDeviceExpression > {\ typedef CVQual TensorReductionOp::Type, MakeGlobalPointer> Type;\ }; KERNELBROKERCONVERTREDUCTION(const) KERNELBROKERCONVERTREDUCTION() #undef KERNELBROKERCONVERTREDUCTION /// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorReductionOp #define KERNELBROKERCONVERTTUPLEREDUCTION(CVQual)\ template \ struct ConvertToDeviceExpression > {\ typedef CVQual TensorTupleReducerOp::Type> Type;\ }; KERNELBROKERCONVERTTUPLEREDUCTION(const) KERNELBROKERCONVERTTUPLEREDUCTION() #undef KERNELBROKERCONVERTTUPLEREDUCTION //TensorSlicingOp #define KERNELBROKERCONVERTSLICEOP(CVQual)\ template\ struct ConvertToDeviceExpression >{\ typedef CVQual TensorSlicingOp::Type> Type;\ }; KERNELBROKERCONVERTSLICEOP(const) KERNELBROKERCONVERTSLICEOP() #undef KERNELBROKERCONVERTSLICEOP //TensorStridingSlicingOp #define KERNELBROKERCONVERTERSLICESTRIDEOP(CVQual)\ template\ struct ConvertToDeviceExpression >{\ typedef CVQual TensorStridingSlicingOp::Type> Type;\ }; KERNELBROKERCONVERTERSLICESTRIDEOP(const) KERNELBROKERCONVERTERSLICESTRIDEOP() #undef KERNELBROKERCONVERTERSLICESTRIDEOP /// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorChippingOp #define KERNELBROKERCONVERTCHIPPINGOP(CVQual)\ template \ struct ConvertToDeviceExpression > {\ typedef CVQual TensorChippingOp::Type> Type;\ }; KERNELBROKERCONVERTCHIPPINGOP(const) KERNELBROKERCONVERTCHIPPINGOP() #undef KERNELBROKERCONVERTCHIPPINGOP /// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorImagePatchOp #define KERNELBROKERCONVERTIMAGEPATCHOP(CVQual)\ template\ struct ConvertToDeviceExpression >{\ typedef CVQual TensorImagePatchOp::Type> Type;\ }; KERNELBROKERCONVERTIMAGEPATCHOP(const) KERNELBROKERCONVERTIMAGEPATCHOP() #undef KERNELBROKERCONVERTIMAGEPATCHOP /// specialisation of the \ref ConvertToDeviceExpression struct when the node type is TensorVolumePatchOp #define KERNELBROKERCONVERTVOLUMEPATCHOP(CVQual)\ template\ struct ConvertToDeviceExpression >{\ typedef CVQual TensorVolumePatchOp::Type> Type;\ }; KERNELBROKERCONVERTVOLUMEPATCHOP(const) KERNELBROKERCONVERTVOLUMEPATCHOP() #undef KERNELBROKERCONVERTVOLUMEPATCHOP } // namespace internal } // namespace TensorSycl } // namespace Eigen #endif // UNSUPPORTED_EIGEN_CXX1