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

shmem_size for LayoutStride #1291

Closed
bfzinser opened this issue Dec 20, 2017 · 5 comments
Closed

shmem_size for LayoutStride #1291

bfzinser opened this issue Dec 20, 2017 · 5 comments
Assignees
Labels
Enhancement Improve existing capability; will potentially require voting
Milestone

Comments

@bfzinser
Copy link

We have a multidimensional view that should be LayoutRight (int order [] = {2, 1, 0}) on CPU and LayoutStride (int order [] = {2, 0, 1}) on GPU. (We are using the first dimension to switch between the type of element information in order to reduce the number of views we create. Examples of element information include vertices and height vectors.) We decided to implement both as LayoutStride. We also want this view in shared memory, but we cannot call shmem_size for a view with LayoutStride. We can provide a short example, but we were told that shmem_size is not implemented for LayoutStride so an example does not seem necessary.

Our current toy problem stores doubles in the view. In the interest of a workaround, what downsides can we expect by calculating the shared memory requirement as (number of doubles) * (size of doubles)? Failing that, we can temporarily use LayoutLeft or LayoutRight on GPU, but this sounds expensive in terms of performance. In the future, we are interested in replacing doubles with floats or structs that represent complex numbers or 3D points.

@crtrott
Copy link
Member

crtrott commented Dec 22, 2017

I see. Yeah this makes sense. I will have a look at this.

@crtrott crtrott self-assigned this Dec 22, 2017
@crtrott crtrott added the Enhancement Improve existing capability; will potentially require voting label Dec 22, 2017
@crtrott crtrott removed their assignment Dec 22, 2017
@crtrott
Copy link
Member

crtrott commented Dec 22, 2017

Or rather I will find someone to take a look at this ;-)

@crtrott crtrott added this to the 2018 February milestone Dec 22, 2017
@ibaned ibaned assigned swbova, ndellingwood and ibaned and unassigned swbova Jan 31, 2018
@ibaned
Copy link
Contributor

ibaned commented Feb 7, 2018

The main issue here is that LayoutStride needs to be given the array of strides (or an ordering array), and shmem_size is a static method. With some enable_if I could in theory get the following to work:

Kokkos::View<double***, Kokkos::LayoutStride>::shmem_size(extent0, stride0, extent1, stride1, extent2, stride2);
int rank;
int order[3];
int extents[3];
Kokkos::View<double***, Kokkos::LayoutStride>::shmem_size(rank, order, extents);

Does that sound like the right approach?

@bfzinser
Copy link
Author

bfzinser commented Feb 7, 2018

We think that this looks like a good approach. Thanks!

As you pointed out, shmem_size is a static method so we just need a way to get the relevant information to it. Our primary motivation in using shmem_size instead of calculating the memory requirement ourselves is to have Kokkos calculate any required padding for us.

@ibaned
Copy link
Contributor

ibaned commented Feb 7, 2018

On second thought, to be consistent with constructors, maybe a better approach is this:

Kokkos::View<double***, Kokkos::LayoutStride>::shmem_size(Kokkos::LayoutStride(extent0, stride0, extent1, stride1, extent2, stride2));
int rank;
int order[3];
int extents[3];
Kokkos::View<double***, Kokkos::LayoutStride>::shmem_size(Kokkos::LayoutStride::order_dimensions(rank, order, extents));

Although its more verbose, I think its more consistent with the idea that the arguments to shmem_size() should be similar to the arguments to the View constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improve existing capability; will potentially require voting
Projects
None yet
Development

No branches or pull requests

5 participants