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

Use runtime values in KokkosExp_MDRangePolicy.hpp #3626

Merged
merged 24 commits into from
Jan 15, 2021

Conversation

masterleinad
Copy link
Contributor

This pull request queries the maximum number of threads at runtime and uses that value for setting up default tile sizes. Also, unify the implementation a little better.

core/src/KokkosExp_MDRangePolicy.hpp Outdated Show resolved Hide resolved
core/src/KokkosExp_MDRangePolicy.hpp Outdated Show resolved Hide resolved
@masterleinad masterleinad marked this pull request as ready for review December 1, 2020 22:53
@masterleinad
Copy link
Contributor Author

Retest this please.

@masterleinad masterleinad force-pushed the improve_md_range_gpu branch 2 times, most recently from b38a6f7 to 1e504d8 Compare December 2, 2020 16:37
@masterleinad
Copy link
Contributor Author

Retest this please.

@dalg24
Copy link
Member

dalg24 commented Dec 18, 2020

Please resolve conflicts now that #3481 has been merged

@masterleinad
Copy link
Contributor Author

Please resolve conflicts now that #3481 has been merged

Done.

@dalg24
Copy link
Member

dalg24 commented Dec 18, 2020

That was fast :)

Copy link
Contributor

@DavidPoliakoff DavidPoliakoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't break anything I need, as far as I can tell (commenting that the merge from my PR seems good)

Copy link
Member

@crtrott crtrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK: one question and one naming request:

question: should we move the partial specializations into the execution space specific files? That will also play better with additions of external execution spaces. In fact: shouldn't there now be a thing we can use to include the header files for the defined execspaces?

Renaming: some of the names in the init variants feel very misleading. Like max_tile_size is not actually max_tile_size a user could request for example. Can we identify better names for that?

static constexpr Iterate value = Iterate::Right;
};

#ifdef KOKKOS_ENABLE_CUDA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be in the execution space specific files, so that there is less ifdefing in this one? Just declare the default version above the inclusion of the ExecSpace headers and stick the specializations maybe even into Kokkos_Cuda.hpp etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

const index_type default_tile_size = 2;
init_helper(max_threads, max_tile_size, default_tile_size, max_threads);
}

#if defined(KOKKOS_ENABLE_CUDA)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this should this live in execution space specific headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

template <typename ExecutionSpace>
void init(const ExecutionSpace&) {
const index_type max_threads = std::numeric_limits<int>::max();
const index_type max_tile_size = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The largest tile size was the maximum of the extent and 1. The other execution spaces use a value independent of the extent, though. To make both of these cases work, I decided to treat the case max_tile_size==0 differently below.

void init(const Kokkos::Cuda& space) {
const index_type max_threads =
space.impl_internal_space_instance()->m_maxThreadsPerSM;
const index_type max_tile_size = 16;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that doesn't make much sense to me, why don't we allow for 32x8 ??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is this just whats left for the laregest dimension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is what we are using for the largest dimension.

const index_type max_threads =
space.impl_internal_space_instance()->m_maxThreadsPerSM;
const index_type max_tile_size = 16;
const index_type default_tile_size = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is default tile size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tile size for the dimensions that are not the largest one.

@masterleinad
Copy link
Contributor Author

question: should we move the partial specializations into the execution space specific files? That will also play better with additions of external execution spaces.

Done.

In fact: shouldn't there now be a thing we can use to include the header files for the defined execspaces?

This is #3603.

Renaming: some of the names in the init variants feel very misleading. Like max_tile_size is not actually max_tile_size a user could request for example. Can we identify better names for that?

I changed max_tile_size -> default_largest_tile_size. I am happy to change the others, too, if someone has better suggestions.

@masterleinad
Copy link
Contributor Author

Ready from my side. I addressed the issues in @crtrott's blocking review.

@masterleinad
Copy link
Contributor Author

Also, has three approvals already.

@crtrott crtrott merged commit 4e5a3a7 into kokkos:develop Jan 15, 2021
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

Successfully merging this pull request may close these issues.

None yet

6 participants