Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class of View #80

Open
liyujin1999 opened this issue Apr 3, 2024 · 1 comment
Open

Class of View #80

liyujin1999 opened this issue Apr 3, 2024 · 1 comment

Comments

@liyujin1999
Copy link

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;
};

@Adrian-Diaz
Copy link
Collaborator

Adrian-Diaz commented Apr 9, 2024

Hello,

I'm assuming you mean a matar type templated on your class XeDefect like CArrayKokkos? 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants