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

algorithms: drop volatile #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions StdMinMaxElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,10 @@ auto min_element(const std::string& label, (8)
bool operator()(const value_type & a, const value_type & b) const {
return /* true if a is less than b, based on your logic of "less than" */;
}

KOKKOS_INLINE_FUNCTION
bool operator()(const volatile value_type a, const volatile value_type b) const {
return /* true if a is less than b, based on your logic of "less than" */;
}
};
```
- the volatile overload is needed because the algorithm is
currently implemented as a reduction, where the `comp` functor is used
as the ``joiner'' to join two values. The current Kokkos implementation
of reductions requires any custom joiner to have
a volatile overload: see [this wiki page](https://github.com/kokkos/kokkos/wiki/Programming-Guide%3A-Custom-Reductions) for more info on reductions.
- the algorithm is currently implemented as a reduction, where the `comp` functor is used
as the ``joiner'' to join two values


### Return
Expand Down Expand Up @@ -153,13 +145,6 @@ struct CustomLessThanComparator {
return a < b;
}

KOKKOS_INLINE_FUNCTION
bool operator()(const volatile ValueType1& a,
const volatile ValueType1& b) const {
// here we use < but one can put any custom logic to return true if a is less than b
return a < b;
}

KOKKOS_INLINE_FUNCTION
CustomLessThanComparator() {}
};
Expand Down Expand Up @@ -272,13 +257,6 @@ struct CustomLessThanComparator {
return a < b;
}

KOKKOS_INLINE_FUNCTION
bool operator()(const volatile ValueType1& a,
const volatile ValueType1& b) const {
// here we use < but one can put any custom logic to return true if a is less than b
return a < b;
}

KOKKOS_INLINE_FUNCTION
CustomLessThanComparator() {}
};
Expand Down Expand Up @@ -396,13 +374,6 @@ struct CustomLessThanComparator {
return a < b;
}

KOKKOS_INLINE_FUNCTION
bool operator()(const volatile ValueType1& a,
const volatile ValueType1& b) const {
// here we use < but one can put any custom logic to return true if a is less than b
return a < b;
}

KOKKOS_INLINE_FUNCTION
CustomLessThanComparator() {}
};
Expand Down
20 changes: 0 additions & 20 deletions StdNumeric.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ ValueType reduce(const std::string& label, const ExecutionSpace& exespace,
constexpr ValueType operator()(const ValueType& a, const ValueType& b) const {
return /* ... */
}

KOKKOS_FUNCTION
constexpr ValueType operator()(const volatile ValueType& a,
const volatile ValueType& b) const {
return /* ... */
}
};
```
- The behavior is non-deterministic if the `joiner` operation
Expand Down Expand Up @@ -376,12 +370,6 @@ ValueType transform_reduce(const std::string& label,
const ValueType& b) const {
return /* ... */
}

KOKKOS_FUNCTION
constexpr ValueType operator()(const volatile ValueType& a,
const volatile ValueType& b) const {
return /* ... */
}
};
```
- The behavior is non-deterministic if the `joiner` operation
Expand Down Expand Up @@ -564,20 +552,12 @@ Exclusive means that the i-th input element is not included in the i-th sum.
const value_type & b) const {
return /* ... */;
}

return_type operator()(const volatile value_type & a,
const volatile value_type & b) const {
return /* ... */;
}
};
```
The return type `return_type` must be such that an object of type `OutputIteratorType`
for (1,2,5,6) or an object of type `value_type` where `value_type` is the
value type of `view_dest` for (3,4,7,8) can be dereferenced and assigned a value of type `return_type`.

- the volatile overload is needed for correctness by the current Kokkos
implementation of prefix scan operations


### Return

Expand Down