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

Add configurable capacity UniqueToken for #979. #3051

Merged
merged 9 commits into from
Jul 23, 2020

Conversation

vbrunini
Copy link
Contributor

Limited to UniqueTokenScope::Instance specializations. Currently
implemented for Serial, OpenMP, and Cuda execution spaces.

@crtrott

@dalg24-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@crtrott crtrott force-pushed the configurable_capacity_unique_token branch from 2c9e183 to 9b73f5c Compare June 19, 2020 04:02
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.

This is still failing on HPX. I will work on that, just a reminder not to merge.

core/src/Kokkos_Serial.hpp Show resolved Hide resolved
core/src/Kokkos_UniqueToken.hpp Outdated Show resolved Hide resolved
Comment on lines +119 to +120
using exec_space = ExecutionSpace;
using size_type = typename exec_space::size_type;
Copy link
Member

Choose a reason for hiding this comment

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

I feel like you should deduce these from token_type.

Copy link
Member

Choose a reason for hiding this comment

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

done

core/src/OpenMP/Kokkos_OpenMP_Exec.hpp Outdated Show resolved Hide resolved
core/src/OpenMP/Kokkos_OpenMP_Exec.hpp Show resolved Hide resolved
bool ok = true;

ok = ok && 0 <= t;
ok = ok && t < tokens.size();
Copy link
Member

Choose a reason for hiding this comment

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

Do these need to be atomic_and?

Copy link
Member

Choose a reason for hiding this comment

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

No: this error check happens in each thread independently.

vbrunini and others added 3 commits July 2, 2020 17:17
Limited to UniqueTokenScope::Instance specializations. Currently
implemented for Serial, OpenMP, and Cuda execution spaces.
Both per-thread and per-team. Improve the testing of the configurable
capacity version of UniqueToken to reflect the token per-team use
case using the RAII helper.
@crtrott crtrott force-pushed the configurable_capacity_unique_token branch from 11559c9 to bd5f266 Compare July 2, 2020 23:21
Fixed bug in Test for backends with concurrency>1 but max_team_size==1
Also addressed review comments
@crtrott crtrott force-pushed the configurable_capacity_unique_token branch from bd5f266 to 97c8d1b Compare July 2, 2020 23:44
@crtrott
Copy link
Member

crtrott commented Jul 3, 2020

Ran spotcheck on apollo:

#######################################################
PASSED TESTS
#######################################################
clang-3.9.0-Pthread_Serial-release build_time=66 run_time=687
clang-6.0-Cuda_Pthread-release build_time=109 run_time=575
clang-6.0-OpenMP-release build_time=48 run_time=177
cuda-9.1-Cuda_OpenMP-release build_time=169 run_time=279
gcc-4.8.4-OpenMP-release build_time=50 run_time=366
gcc-4.8.4-Pthread-release build_time=39 run_time=1176
gcc-5.3.0-Serial-release build_time=53 run_time=261
hpx-1.3.0-HPX-release build_time=1362 run_time=543
intel-16.0.1-OpenMP-release build_time=126 run_time=259

@crtrott
Copy link
Member

crtrott commented Jul 3, 2020

Retest this please!

@crtrott
Copy link
Member

crtrott commented Jul 3, 2020

Ah the HIP version is still missing.

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Did you consider other names for your RAII-wrapper?

core/src/Cuda/Kokkos_Cuda_UniqueToken.hpp Show resolved Hide resolved
core/src/Kokkos_AcquireUniqueTokenImpl.hpp Show resolved Hide resolved
core/src/Kokkos_UniqueToken.hpp Outdated Show resolved Hide resolved
core/src/Kokkos_Serial.hpp Outdated Show resolved Hide resolved
@dalg24
Copy link
Member

dalg24 commented Jul 6, 2020

Retest this please

core/src/Kokkos_Serial.hpp Outdated Show resolved Hide resolved
void release(int) const noexcept {}
/// \brief create object size for concurrency on the given instance
///
/// This object should not be shared between instances
Copy link
Member

Choose a reason for hiding this comment

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

I have trouble parsing this comment. Please improve here and at places it was copied from.

core/src/Kokkos_AcquireUniqueTokenImpl.hpp Show resolved Hide resolved
@masterleinad masterleinad self-requested a review July 8, 2020 12:56
@vbrunini
Copy link
Contributor Author

vbrunini commented Jul 8, 2020

Did you consider other names for your RAII-wrapper?

Just copied what we've been using in our app code, no objections to changing it if you've got an alternative you'd prefer.

@crtrott crtrott added the Blocks Promotion Overview issue for release-blocking bugs label Jul 8, 2020
@dalg24 dalg24 requested a review from nliber July 14, 2020 04:32
@nliber
Copy link
Contributor

nliber commented Jul 15, 2020

Like @dalg24, I'm a bit uneasy with splitting the files, because it effectively means it isn't useable w/o #including Kokkos_AcquireUniqueTokenImpl.hpp (because they are functions in a templated type). Putting it in its own header would be much cleaner.

The name isn't all that clear either "Guard" tends to indicate an RAII class, although I'm not sure a name like UniqueTokenGuard quite fits (although I could be wrong).

Minor: I noticed that some of the namespaces are referenced as ::Kokkos::ns and others as Kokkos::ns. Any particular reason? It is unusual to reference them with a preceding ::.

@vbrunini
Copy link
Contributor Author

As a user I would love for Kokkos as a whole to have more headers that can be individually included, but my experience is that almost everything requires just including Kokkos_Core.hpp, and in the past I've been told that is really all Kokkos supports. Given that the existing Kokkos_UniqueToken.hpp only defines the base template and the specializations per execution space are in different headers I think getting to the point where any of this is useable without including Kokkos_Core.hpp is a bigger task?

Personally I think ThreadUniqueToken and TeamUniqueToken might be the most clear names for the RAII helpers, and the existing UniqueToken might be better named UniqueTokenContainer? But there are probably backwards compatibility concerns there?

Some of the existing UniqueToken implementation had the preceding ::Kokkos, I was just trying to be consistent with that. I was unsure if there was a general Kokkos policy about including that to avoid ADL or something?

dalg24
dalg24 previously requested changes Jul 15, 2020
Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Please

  • move the declaration/definition of the RAII-wrappers in a separate header instead of the current workaround
  • consider other names for the RAII-wrappers
  • fix the typos

@dalg24 dalg24 self-assigned this Jul 22, 2020
@dalg24 dalg24 dismissed their stale review July 23, 2020 14:36

I added comments about the current points of friction in the design

@@ -677,15 +728,28 @@ class UniqueToken<Threads, UniqueTokenScope::Global> {
UniqueToken(execution_space const & = execution_space()) noexcept {}

/// \brief upper bound for acquired values, i.e. 0 <= value < size()
inline int size() const noexcept { return Threads::impl_thread_pool_size(); }
KOKKOS_INLINE_FUNCTION
int size() const noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this pattern of KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST in the Threads backend, but think it's a problem with our macros, not this implementation. Capturing here #3209

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.

Other than the comment (which I don't think is primarily about this PR) there are no obvious interface/implementation problems, and the functionality seems well tested

@dalg24
Copy link
Member

dalg24 commented Jul 23, 2020

Retest this please

@crtrott crtrott merged commit 43b7756 into kokkos:develop Jul 23, 2020
@vbrunini vbrunini deleted the configurable_capacity_unique_token branch July 23, 2020 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocks Promotion Overview issue for release-blocking bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants