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

[REVIEW] improve device atomic overloads for potential issues #1691

Closed
wants to merge 19 commits into from

Conversation

kovaltan
Copy link
Contributor

@kovaltan kovaltan commented May 9, 2019

Update/improve device atomic overloads for potential issues, and simplify the implementation.
Then, it would be easy to implement when cudf changes the underlying type of the wrappers,
or cudf introduces a new data type.
And this PR also introduce cuda native atomicAdd support for signed int64_t. I didn't implemented it yet since cuda does not have signed long long int overload, however, two's complement representation of signed integer has the advantage that the fundamental arithmetic operations of addition, subtraction, and multiplication are identical to those for unsigned binary numbers. See also: https://en.wikipedia.org/wiki/Two%27s_complement

  • separate device binary operators definition into device_operators.cuh
  • move atomicCASImpl(int8 or int16) into typesAtomicCASImpl
  • device atomic overloads independent from the specific underlying type of the wrappers
  • remove genericAtomicOperationUnderlyingType
  • remove typesAtomicOperation32|64
  • add cudf::bool8 test cases
  • add cuda native atomicAdd support for signed int64_t

Closes #1398
Related #1685

split the file into `device_atomics.cuh` and `device_operators.cuh`
separated the difinition of the device operators
move atomicCASImpl(int8 or int16) into typesAtomicCASImpl
simplify atomicMin, atomixMax
add cudf::bool8 for atomic test case for atomicAdd,Min,Max
add cudf::bool8 specialization for genericAtomicOperation
@kovaltan kovaltan requested a review from a team as a code owner May 9, 2019 10:44
Copy link
Contributor

@jrhemstad jrhemstad left a comment

Choose a reason for hiding this comment

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

I love these simplifications. Much cleaner and easier to understand.

cpp/src/utilities/device_atomics.cuh Show resolved Hide resolved
@kovaltan kovaltan self-assigned this May 10, 2019
@kovaltan kovaltan changed the title [WIP] improve device atomic overloads for potential issues [REVIEW] improve device atomic overloads for potential issues May 10, 2019
@kovaltan kovaltan added 3 - Ready for Review Ready for review by team 4 - Needs Review Waiting for reviewer to review or respond libcudf Affects libcudf (C++/CUDA) code. labels May 10, 2019
@kovaltan kovaltan requested a review from jrhemstad May 10, 2019 07:56
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Looks good in general. One concern and one question.

cpp/src/utilities/device_atomics.cuh Show resolved Hide resolved
cpp/src/utilities/device_atomics.cuh Outdated Show resolved Hide resolved
Add '__forceinline__ __device__' to `W genericAtomicOperator(W)`
Add size check assert between `long long int` and `int64_t`
remove redundant `sizeof(T)` when calling 'typesAtomicCASImpl`
remove redundant `sizeof(T)` when calling 'genericAtomicOperationImpl`
@kovaltan
Copy link
Contributor Author

rerun tests

@kovaltan kovaltan requested a review from harrism May 13, 2019 13:03
@kovaltan
Copy link
Contributor Author

rerun tests

Add native atomicAdd(uint64_t) call for sint64_t
Add comment for `genericAtomicOperationImpl<int64_t, DeviceSum, 8>`
 why it uses atomicAdd(uint64) inside
Removed `genericAtomicOperation(W)` since it is not invoked for
 cudf::wrapper types.
Merged it into `genericAtomicOperation(T)`

Add size check assert at `type_reinterpret`.
@jrhemstad jrhemstad changed the base branch from branch-0.8 to release-0.7.2 May 14, 2019 14:25
}

// specialization for cudf::detail::wrapper types
template <typename T, gdf_dtype dtype, typename BinaryOp, typename W = cudf::detail::wrapper<T, dtype> >
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be removed. I rely on it in #1478

It will need to be added back in a future PR.

@jrhemstad jrhemstad requested review from a team as code owners May 14, 2019 14:29
@jrhemstad jrhemstad changed the base branch from release-0.7.2 to branch-0.8 May 14, 2019 14:47
@kovaltan kovaltan requested a review from a team May 14, 2019 14:49
@kkraus14
Copy link
Collaborator

Fixed by #1735

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team 4 - Needs Review Waiting for reviewer to review or respond libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Issues with device atomic overloads for wrapper types
4 participants