MATAR icon indicating copy to clipboard operation
MATAR copied to clipboard

Class of View

Open liyujin1999 opened this issue 1 year ago • 1 comments

If I have the following class structure, I want to construct the class View Kokkos::View<XeDefect*> xes("xes", 10); So how do I allocate space for each attribute in an object in xes? The default space is CudaSpace.Thank in advance

class XeDefect { public: class ReactionPair { public: double a0, a1; Kokkos::View<double*> kConstant; KOKKOS_INLINE_FUNCTION ReactionPair() {} }; KOKKOS_INLINE_FUNCTION XeDefect(){} KOKKOS_INLINE_FUNCTION ~XeDefect() {} private: Kokkos::View<double*> diff; Kokkos::View<ReactionPair*> reactionPairs; };

liyujin1999 avatar Apr 03 '24 08:04 liyujin1999

Hello,

I'm assuming you mean a matar type templated on your class XeDefect like CArrayKokkos<XeDefect>? either way that will store data in a kokkos view templated on XeDefect. The issue here to my knowledge is that kokkos views have to be declared in the host space, if you make a kokkos view templated on XeDefect it will try to allocate your class members (which contain kokkos views that default to the cudaspace) whilst already on the cudaspace instead of hostspace. If your class contained non kokkos types like ViewCArray or CArray (or stack arrays or pointers to heap you can kokkosmalloc/cudamalloc) for the data storage then it should be possible to template the matar kokkos type using your class, XeDefect, on the cuda space.

Adrian-Diaz avatar Apr 09 '24 15:04 Adrian-Diaz