Skip to content

Commit e1c14d6

Browse files
authored
Add some documentation for recent additions to libcu++ (#1594)
* Add some documentation for recent additions to libcu++ * Add information about ranges, concepts too
1 parent 2578383 commit e1c14d6

File tree

12 files changed

+140
-27
lines changed

12 files changed

+140
-27
lines changed

libcudacxx/docs/standard_api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,26 @@ Feature availability:
2727
- `void_t`
2828
- Trait operations: `conjunction`,`negation`,`disjunction`
2929
- `invoke_result`
30+
- C++17 `<optional>` is available in C++14
31+
- all features are available in C++14 and at compile time if the payload type permits it
32+
- C++17 `<variant>` is available in C++14
33+
- all features are available in C++14 and at compile time if the payload types permit it
3034
- C++17/20 constexpr `<array>` is available in C++14.
3135
- all operation on array are made constexpr in C++14 with exception of `{c}rbegin` and `{c}rend`, which requires C++17.
3236
- C++20 constexpr `<complex>` is available in C++14.
3337
- all operation on complex are made constexpr if `is_constant_evaluated` is supported.
3438
- C++20 `<concepts>` are available in C++14.
3539
- 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.
40+
- C++20 `<ranges>` are available in C++17.
41+
- all `<ranges>` concepts are available in C++17. However, they need to be used similar to type traits as language concepts are not available.
42+
- range algorithms are not implemented.
43+
- views are not implemented.
3644
- C++20 `<span>` is mostly available in C++14.
3745
- 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.
3846
- C++20 features of `<functional>` have been partially ported to C++17.
3947
- `bind_front` is available in C++17.
48+
- C++23 `<expected>` is available in C++14.
49+
- all features are available in C++14
4050
- C++23 `<mdspan>` is available in C++17.
4151
- mdspan is feature complete in C++17 onwards.
4252
- mdspan on msvc is only supported in C++20 and onwards.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Concepts Library
2+
3+
| [`<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 |
4+
5+
[`<cuda/std/concepts>`]: https://en.cppreference.com/w/cpp/header/concepts
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
grand_parent: Standard API
3+
parent: Concepts Library
4+
nav_order: 0
5+
---
6+
7+
# `<cuda/std/concepts>`
8+
9+
## Extensions
10+
11+
* All library features are available from C++14 onwards. The concepts can be used like type traits prior to C++20.
12+
13+
```c++
14+
template<cuda::std::integral Integer>
15+
void do_something_with_integers_in_cpp20(Integer&& i) {...}
16+
17+
template<class Integer, cuda::std::enable_if_t<cuda::std::integral<Integer>, int> = 0>
18+
void do_something_with_integers_in_cpp17(Integer&& i) {...}
19+
20+
template<class Integer, cuda::std::enable_if_t<cuda::std::integral<Integer>, int> = 0>
21+
void do_something_with_integers_in_cpp14(Integer&& i) {...}
22+
```
23+
24+
## Restrictions
25+
26+
* Subsumption does not work prior to C++20
27+
* Subsumption is only partially implemented in the compiler until nvcc 12.4
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Concepts Library
2+
3+
| [`<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 |
4+
5+
[`<cuda/std/ranges>`]: https://en.cppreference.com/w/cpp/header/ranges
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
grand_parent: Standard API
3+
parent: Ranges Library
4+
nav_order: 0
5+
---
6+
7+
# `<cuda/std/ranges>`
8+
9+
## Omissions
10+
11+
* Iterator related concepts and machinery such as `cuda::std::forward_iterator` has been implemented in 2.3.0
12+
* Range related concepts and machinery such as `cuda::std::ranges::forward_range` and `cuda::std::ranges::subrange` has been implemented in 2.4.0
13+
14+
* Range based algorithms have *not* been implemented
15+
* Views have *not* been implemented
16+
17+
## Extensions
18+
19+
* All library features are available from C++17 onwards. The concepts can be used like type traits prior to C++20.
20+
21+
```c++
22+
template<cuda::std::contiguos_range Range>
23+
void do_something_with_ranges_in_cpp20(Range&& range) {...}
24+
25+
template<class Range, cuda::std::enable_if_t<cuda::std::contiguos_range<Range>, int> = 0>
26+
void do_something_with_ranges_in_cpp17(Range&& range) {...}
27+
```
28+
29+
## Restrictions
30+
31+
* Subsumption does not work prior to C++20
32+
* Subsumption is only partially implemented in the compiler until nvcc 12.4

libcudacxx/docs/standard_api/utility_library.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ libcu++ Specifics for details.
1010
| [`<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) |
1111
| [`<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`) |
1212
| [`<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 |
13-
13+
| [`<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 |
14+
| [`<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 |
15+
| [`<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 |
1416

1517
[`<cuda/std/type_traits>`]: https://en.cppreference.com/w/cpp/header/type_traits
1618
[`<cuda/std/tuple>`]: https://en.cppreference.com/w/cpp/header/tuple
1719
[`<cuda/std/functional>`]: https://en.cppreference.com/w/cpp/header/functional
1820
[`<cuda/std/utility>`]: https://en.cppreference.com/w/cpp/header/utility
1921
[`<cuda/std/version>`]: https://en.cppreference.com/w/cpp/header/version
22+
[`<cuda/std/optional>`]: https://en.cppreference.com/w/cpp/header/optional
23+
[`<cuda/std/variant>`]: https://en.cppreference.com/w/cpp/header/variant
24+
[`<cuda/std/expected>`]: https://en.cppreference.com/w/cpp/header/expected
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
grand_parent: Standard API
3+
parent: Utility Library
4+
nav_order: 5
5+
---
6+
7+
# `<cuda/std/expected>`
8+
9+
## Extensions
10+
11+
* All features are available from C++14 onwards.
12+
13+
## Restrictions
14+
15+
* On device no exceptions are thrown in case of a bad access.

libcudacxx/docs/standard_api/utility_library/functional.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ The following facilities in section [functional.syn] of ISO/IEC IS 14882 (the
1313

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

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

48-
### `std::reference_wrapper`
49-
50-
[`std::reference_wrapper`] is a [*CopyConstructible*] and
51-
[*CopyAssignable*] wrapper around a reference to an object or function of
52-
type `T`.
53-
There is nothing that makes this facility difficult to implement heterogeneously
54-
today.
55-
It is a value type that does not allocate memory, hold
56-
pointers, have virtual functions, or make calls to platform specific APIs.
57-
58-
No design or functional changes were required to port the upstream libc++
59-
implementations of this facility.
60-
We just had to add execution space specifiers to port it.
61-
62-
However, this feature failed tests involving function pointers with some of the
63-
compilers we support.
64-
So, we've omitted this feature for now.
65-
66-
6747
[functional.syn]: https://eel.is/c++draft/functional.syn
6848

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

7252
[`std::function`]: https://en.cppreference.com/w/cpp/utility/functional/function
7353
[`std::bind`]: https://en.cppreference.com/w/cpp/utility/functional/bind
74-
[`std::reference_wrapper`]: https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper
7554
[`std::hash`]: https://en.cppreference.com/w/cpp/utility/hash
7655

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
grand_parent: Standard API
3+
parent: Utility Library
4+
nav_order: 3
5+
---
6+
7+
# `<cuda/std/optional>`
8+
9+
## Extensions
10+
11+
* All features are available from C++14 onwards.
12+
* All features are available at compile time if the value type supports it.
13+
14+
## Restrictions
15+
16+
* On device no exceptions are thrown in case of a bad access.

libcudacxx/docs/standard_api/utility_library/tuple.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ nav_order: 0
1111
Before version 1.4.0, `tuple` is not available when using NVCC with MSVC as a
1212
host compiler, due to compiler bugs.
1313

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

0 commit comments

Comments
 (0)