From 4d53703c67fcce4f076acf542c759589aecfffc1 Mon Sep 17 00:00:00 2001 From: paboyle Date: Mon, 5 Mar 2018 11:39:52 +0000 Subject: [PATCH] Scalar type differeing allowed, eg. precisoin change --- lib/tensors/Tensor_extract_merge.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/tensors/Tensor_extract_merge.h b/lib/tensors/Tensor_extract_merge.h index 6cc72012..a055ae22 100644 --- a/lib/tensors/Tensor_extract_merge.h +++ b/lib/tensors/Tensor_extract_merge.h @@ -49,9 +49,10 @@ template using ExtractBuffer = AcceleratorVector<__T ,GRID_MAX //////////////////////////////////////////////////////////////////////// // Extract to contiguous array scalar object //////////////////////////////////////////////////////////////////////// -template accelerator_inline +template accelerator void extract(const vobj &vec,ExtractBuffer &extracted) { + typedef typename GridTypeMapper::scalar_type sobj_scalar_type; typedef typename GridTypeMapper::scalar_type scalar_type; typedef typename GridTypeMapper::vector_type vector_type; @@ -60,21 +61,23 @@ void extract(const vobj &vec,ExtractBuffer &extracted) const int Nextr=extracted.size(); const int s=Nsimd/Nextr; - scalar_type *sp = (scalar_type *)&extracted[0]; + sobj_scalar_type *sp = (sobj_scalar_type *)&extracted[0]; scalar_type *vp = (scalar_type *)&vec; for(int w=0;w accelerator_inline +template accelerator void merge(vobj &vec,ExtractBuffer &extracted) { + typedef typename GridTypeMapper::scalar_type sobj_scalar_type; typedef typename GridTypeMapper::scalar_type scalar_type; typedef typename GridTypeMapper::vector_type vector_type; @@ -83,7 +86,7 @@ void merge(vobj &vec,ExtractBuffer &extracted) const int Nextr = extracted.size(); const int s=Nsimd/Nextr; - scalar_type *sp = (scalar_type *)&extracted[0]; + sobj_scalar_type *sp = (sobj_scalar_type *)&extracted[0]; scalar_type *vp = (scalar_type *)&vec; for(int w=0;w &extracted) //////////////////////////////////////////////////////////////////////// // Extract to a bunch of scalar object pointers of different scalar type, with offset. Useful for precision change //////////////////////////////////////////////////////////////////////// -template accelerator_inline +template accelerator void extract(const vobj &vec,ExtractPointerArray &extracted, int offset) { typedef typename GridTypeMapper::scalar_type sobj_scalar_type; @@ -115,7 +118,7 @@ void extract(const vobj &vec,ExtractPointerArray &extracted, int offset) for(int i=0;i &extracted, int offset) //////////////////////////////////////////////////////////////////////// // Merge bunch of scalar object pointers of different scalar type, with offset. Useful for precision change //////////////////////////////////////////////////////////////////////// -template accelerator_inline +template accelerator void merge(vobj &vec,ExtractPointerArray &extracted, int offset) { + typedef typename GridTypeMapper::scalar_type sobj_scalar_type; typedef typename GridTypeMapper::scalar_type scalar_type; typedef typename GridTypeMapper::vector_type vector_type; @@ -136,10 +140,9 @@ void merge(vobj &vec,ExtractPointerArray &extracted, int offset) const int s = Nsimd/Nextr; scalar_type * vp = (scalar_type *)&vec; - for(int w=0;w