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 some documentation for recent additions to libcu++ #1594

Merged
merged 2 commits into from
Apr 8, 2024
Merged
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
10 changes: 10 additions & 0 deletions libcudacxx/docs/standard_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,26 @@ Feature availability:
- `void_t`
- Trait operations: `conjunction`,`negation`,`disjunction`
- `invoke_result`
- C++17 `<optional>` is available in C++14
- all features are available in C++14 and at compile time if the payload type permits it
- C++17 `<variant>` is available in C++14
- all features are available in C++14 and at compile time if the payload types permit it
- C++17/20 constexpr `<array>` is available in C++14.
- all operation on array are made constexpr in C++14 with exception of `{c}rbegin` and `{c}rend`, which requires C++17.
- C++20 constexpr `<complex>` is available in C++14.
- all operation on complex are made constexpr if `is_constant_evaluated` is supported.
- C++20 `<concepts>` are available in C++14.
- all standard concepts are available in C++14 and C++17. However, they need to be used similar to type traits as language concepts are not available.
- C++20 `<ranges>` are available in C++17.
- all `<ranges>` concepts are available in C++17. However, they need to be used similar to type traits as language concepts are not available.
- range algorithms are not implemented.
- views are not implemented.
- C++20 `<span>` is mostly available in C++14.
- With the exception of the range based constructors all features are available in C++14 and C++17. The range based constructors are emulated but not 100% equivalent.
- C++20 features of `<functional>` have been partially ported to C++17.
- `bind_front` is available in C++17.
- C++23 `<expected>` is available in C++14.
- all features are available in C++14
- C++23 `<mdspan>` is available in C++17.
- mdspan is feature complete in C++17 onwards.
- mdspan on msvc is only supported in C++20 and onwards.
Expand Down
5 changes: 5 additions & 0 deletions libcudacxx/docs/standard_api/concepts_library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Concepts Library
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure why we need a separate file for that but that is the precedent


| [`<cuda/std/concepts>`]* | Fundamental library concepts (see also: [libcu++ Specifics]({{ "standard_api/concepts_library/concepts.html" | relative_url }})). <br/><br/> 2.3.0 / CUDA 12.4 |

[`<cuda/std/concepts>`]: https://en.cppreference.com/w/cpp/header/concepts
27 changes: 27 additions & 0 deletions libcudacxx/docs/standard_api/concepts_library/concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
grand_parent: Standard API
parent: Concepts Library
nav_order: 0
---

# `<cuda/std/concepts>`

## Extensions

* All library features are available from C++14 onwards. The concepts can be used like type traits prior to C++20.

```c++
template<cuda::std::integral Integer>
void do_something_with_integers_in_cpp20(Integer&& i) {...}

template<class Integer, cuda::std::enable_if_t<cuda::std::integral<Integer>, int> = 0>
void do_something_with_integers_in_cpp17(Integer&& i) {...}

template<class Integer, cuda::std::enable_if_t<cuda::std::integral<Integer>, int> = 0>
void do_something_with_integers_in_cpp14(Integer&& i) {...}
```

## Restrictions

* Subsumption does not work prior to C++20
* Subsumption is only partially implemented in the compiler until nvcc 12.4
5 changes: 5 additions & 0 deletions libcudacxx/docs/standard_api/ranges_library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Concepts Library

| [`<cuda/std/ranges>`]* | Range based algorithms and concepts (see also: [libcu++ Specifics]({{ "standard_api/ranges_library/ranges.html" | relative_url }})). <br/><br/> 2.3.0 / CUDA 12.4 |

[`<cuda/std/ranges>`]: https://en.cppreference.com/w/cpp/header/ranges
32 changes: 32 additions & 0 deletions libcudacxx/docs/standard_api/ranges_library/ranges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
grand_parent: Standard API
parent: Ranges Library
nav_order: 0
---

# `<cuda/std/ranges>`

## Omissions

* Iterator related concepts and machinery such as `cuda::std::forward_iterator` has been implemented in 2.3.0
* Range related concepts and machinery such as `cuda::std::ranges::forward_range` and `cuda::std::ranges::subrange` has been implemented in 2.4.0

* Range based algorithms have *not* been implemented
* Views have *not* been implemented

## Extensions

* All library features are available from C++17 onwards. The concepts can be used like type traits prior to C++20.

```c++
template<cuda::std::contiguos_range Range>
void do_something_with_ranges_in_cpp20(Range&& range) {...}

template<class Range, cuda::std::enable_if_t<cuda::std::contiguos_range<Range>, int> = 0>
void do_something_with_ranges_in_cpp17(Range&& range) {...}
```

## Restrictions

* Subsumption does not work prior to C++20
* Subsumption is only partially implemented in the compiler until nvcc 12.4
7 changes: 6 additions & 1 deletion libcudacxx/docs/standard_api/utility_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ libcu++ Specifics for details.
| [`<cuda/std/functional>`]* | Function objects and function wrappers (see also: [libcu++ Specifics]({{ "standard_api/utility_library/functional.html" | relative_url }})). <br/><br/> 1.1.0 / CUDA 11.0 (Function Objects) |
| [`<cuda/std/utility>`]* | Various utility components (see also: [libcu++ Specifics]({{ "standard_api/utility_library/utility.html" | relative_url }})). <br/><br/> 1.3.0 / CUDA 11.2 (`pair`) |
| [`<cuda/std/version>`] | Compile-time version information (see also: [libcu++ Specifics]({{ "standard_api/utility_library/version.html" | relative_url }})). <br/><br/> 1.2.0 / CUDA 11.1 |

| [`<cuda/std/optional>`]* | Optional value (see also: [libcu++ Specifics]({{ "standard_api/utility_library/optional.html" | relative_url }})). <br/><br/> 2.3.0 / CUDA 12.4 |
| [`<cuda/std/variant>`]* | Type safe union type (see also: [libcu++ Specifics]({{ "standard_api/utility_library/variant.html" | relative_url }})). <br/><br/> 2.3.0 / CUDA 12.4 |
| [`<cuda/std/expected>`]* | Optional value with error channel (see also: [libcu++ Specifics]({{ "standard_api/utility_library/expected.html" | relative_url }})). <br/><br/> 2.3.0 / CUDA 12.4 |

[`<cuda/std/type_traits>`]: https://en.cppreference.com/w/cpp/header/type_traits
[`<cuda/std/tuple>`]: https://en.cppreference.com/w/cpp/header/tuple
[`<cuda/std/functional>`]: https://en.cppreference.com/w/cpp/header/functional
[`<cuda/std/utility>`]: https://en.cppreference.com/w/cpp/header/utility
[`<cuda/std/version>`]: https://en.cppreference.com/w/cpp/header/version
[`<cuda/std/optional>`]: https://en.cppreference.com/w/cpp/header/optional
[`<cuda/std/variant>`]: https://en.cppreference.com/w/cpp/header/variant
[`<cuda/std/expected>`]: https://en.cppreference.com/w/cpp/header/expected
15 changes: 15 additions & 0 deletions libcudacxx/docs/standard_api/utility_library/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
grand_parent: Standard API
parent: Utility Library
nav_order: 5
---

# `<cuda/std/expected>`

## Extensions

* All features are available from C++14 onwards.

## Restrictions

* On device no exceptions are thrown in case of a bad access.
21 changes: 0 additions & 21 deletions libcudacxx/docs/standard_api/utility_library/functional.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The following facilities in section [functional.syn] of ISO/IEC IS 14882 (the

- [`std::function`] - Polymorphic function object wrapper.
- [`std::bind`] - Generic function object binder / lambda facility.
- [`std::reference_wrapper`] - Reference wrapper type.
- [`std::hash`] - Hash function object.

### `std::function`
Expand Down Expand Up @@ -45,32 +44,12 @@ That implementation might be different from the default that the upstream
Further research and investigation is required before we can provide this
feature.

### `std::reference_wrapper`

[`std::reference_wrapper`] is a [*CopyConstructible*] and
[*CopyAssignable*] wrapper around a reference to an object or function of
type `T`.
There is nothing that makes this facility difficult to implement heterogeneously
today.
It is a value type that does not allocate memory, hold
pointers, have virtual functions, or make calls to platform specific APIs.

No design or functional changes were required to port the upstream libc++
implementations of this facility.
We just had to add execution space specifiers to port it.

However, this feature failed tests involving function pointers with some of the
compilers we support.
So, we've omitted this feature for now.


[functional.syn]: https://eel.is/c++draft/functional.syn

[*CopyConstructible*]: https://eel.is/c++draft/utility.arg.requirements#:requirements,Cpp17CopyConstructible
[*CopyAssignable*]: https://eel.is/c++draft/utility.arg.requirements#:requirements,Cpp17CopyAssignable

[`std::function`]: https://en.cppreference.com/w/cpp/utility/functional/function
[`std::bind`]: https://en.cppreference.com/w/cpp/utility/functional/bind
[`std::reference_wrapper`]: https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper
[`std::hash`]: https://en.cppreference.com/w/cpp/utility/hash

16 changes: 16 additions & 0 deletions libcudacxx/docs/standard_api/utility_library/optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
grand_parent: Standard API
parent: Utility Library
nav_order: 3
---

# `<cuda/std/optional>`

## Extensions

* All features are available from C++14 onwards.
* All features are available at compile time if the value type supports it.

## Restrictions

* On device no exceptions are thrown in case of a bad access.
3 changes: 1 addition & 2 deletions libcudacxx/docs/standard_api/utility_library/tuple.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ nav_order: 0
Before version 1.4.0, `tuple` is not available when using NVCC with MSVC as a
host compiler, due to compiler bugs.

Internal compiler errors may be encountered when using `tuple` with
Before version 2.3.0 internal compiler errors may be encountered when using `tuple` with
older updates of MSVC 2017 and MSVC 2019.
For MSVC 2017, please use version 15.8 or later (`_MSC_VER >= 1915`).
For MSVC 2019, please use version 16.6 or later (`_MSC_VER >= 1926`).

6 changes: 3 additions & 3 deletions libcudacxx/docs/standard_api/utility_library/utility.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nav_order: 1

## Omissions

Only `pair` is available at this time.
There is no inherent challenge in providing many of the things in `<utility>`;
they simply have not been our highest priority.
Prior to version 2.3.0 only `pair` is available.

Since 2.3.0 we have implemented almost all functionality of `<utility>`.
Notably support for operator spaceship is missing due to the specification relying on `std` types that are not accessible on device.
20 changes: 20 additions & 0 deletions libcudacxx/docs/standard_api/utility_library/variant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
grand_parent: Standard API
parent: Utility Library
nav_order: 4
---

# `<cuda/std/variant>`

## Extensions

* All features are available from C++14 onwards.
* All features are available at compile time if the different value types support it.

## Restrictions

* On device no exceptions are thrown in case of a bad access.

## Cuda specific changes

* `cuda::std::visit` utilizes recursion instead of the usual function pointer array. This greatly improves runtime behavior, but comes at the cost of increased compile times.
Loading