[libcxx-dev] An extension of libcxx
Ben Craig via libcxx-dev
libcxx-dev at lists.llvm.org
Tue Dec 11 11:11:40 PST 2018
These are annoying, because they throw exceptions from <stdexcept>, and <stdexcept> exceptions have constructors which take a std::string. You could omit the throwing methods (as I have done in P0829), or you could patch over it by making those calls terminate instead.
I think you mean <utility>. You should be able to get all or <utility>. I’m unsure on how much internal header shuffling is required.
most if not all of <functional>
I exclude std::function and the string searchers in P0829, as they allocate on the heap. You may have different priorities here.
most of <algorithm>
You probably want most of <numeric> as well. The places I avoided were the execution policy overloads and the algorithms that allocate temporary buffers (stable_sort, stable_partition, inplace_merge).
The “quick” rundown of what is in my paper can be found by searching for “Technical Specifications” in https://wg21.link/P0829, then stopping when you get to “Notable Omissions”. That is “merely” 3 printed pages, but a lot of it is quick to scroll through.
I suspect that NVIDIA is fine with heap allocations, and probably really wants floating point operations. My preference is to layer that on to my proposal, but I’m not the one doing the libcxx work right now 😊
From: libcxx-dev <libcxx-dev-bounces at lists.llvm.org> On Behalf Of JF Bastien via libcxx-dev
Sent: Tuesday, December 11, 2018 11:39 AM
To: Olivier Giroux <OGiroux at nvidia.com>; Louis Dionne <ldionne at apple.com>
Cc: libcxx-dev at lists.llvm.org
Subject: Re: [libcxx-dev] An extension of libcxx
I’m very excited to have NVIDIA collaborate on libc++. It’s worth supporting your weirdo macro hack as a transitional tool.
I’m especially interested in working on freestanding in clang / libc++, bringing the good parts of it from the current C++ standard, and working with you and other on the Committee to make C++23 freestanding actually nice (Ben Craig has been working on wg21.link/P0829R3<https://urldefense.proofpoint.com/v2/url?u=http-3A__wg21.link_P0829R3&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8mub81SfUi-UCZRX0Vl1g&m=xIsI5tZPi_j9dWe80yZsu0Je1ipYU9-4bN8-oNRA-RY&s=W8wn3J8vLGkuDBY4KLs2V-ehpa_PcksOwk-SJjWy9GM&e=>). I hope that we can experiment on what’s “nice” in clang / libc++ in the next few months.
One design constraint around freestanding: I want to make sure that clang can keep supporting other STL implementations.
I’d like to understand if we can have a different ABI for freestanding, given that it’s not supported in libc++ today. This might be an opportunity to fix some mistakes.
On “freestanding” macro, clang does the following today:
Otherwise, clang’s lib/Headers do some stuff with HOSTED as well, which might interfere with freestanding.
Good header hygiene indeed seems necessary, especially for <algorithm>. Louis mentioned that he was interested in looking into this.
Louis did a survey and found the following:
Freestanding in the current C++20 draft requires the following headers:
Of those headers, I think the following are easy to provide with minimal changes to libc++ and without having to ship a libc++ shared object (or compiler-rt), and they use the following parts of the C Standard Library:
<cfloat> : float.h
<limits> : stddef.h
As a result, I think the following are low-hanging fruit that do not require any runtime support AFAICT:
Other things we might be able to throw in with minimal effort:
Other things that we SHOULD be able to have, but that would require refactoring in libc++ (and most of them are not part of the current freestanding):
most if not all of <functional>
most of <algorithm>
lock-free parts of <atomic>
On Dec 10, 2018, at 9:23 PM, Olivier Giroux via libcxx-dev <libcxx-dev at lists.llvm.org<mailto:libcxx-dev at lists.llvm.org>> wrote:
In the discussion of https://reviews.llvm.org/D55517<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D55517&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8mub81SfUi-UCZRX0Vl1g&m=xIsI5tZPi_j9dWe80yZsu0Je1ipYU9-4bN8-oNRA-RY&s=dJUe6OvwtjDYuiclVdwSA2_qQdfs6NOhqqyKqewfFFY&e=>, I mentioned that we are attempting a vendor variant of libcxx that uses _VSTD differently. Eric pointed out that I should have started here, so we could talk about design goals. He’s right, I’m sorry.
Not one to bury the lede, I’d like to talk about a CUDA C++ standard library.
The ultimate goal of something like that should be that most things in C++, if not bolted too-tightly onto the operating system, should be able to be passed and used between CPU and GPU. There’s no fundamental reason why we don’t have a big chunk of C++ working like this, today, if we’re talking about contemporary HPC-friendly GPUs. The reason we don’t have much is that it’s a huge pile of work and everyone has managed to avoid doing it so far.
One exploration vehicle was shown at CppCon in September (by me, see: YouTube, and https://github.com/ogiroux/freestanding<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ogiroux_freestanding&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8mub81SfUi-UCZRX0Vl1g&m=xIsI5tZPi_j9dWe80yZsu0Je1ipYU9-4bN8-oNRA-RY&s=O_6KSxLn8rM2YJHMLpOzOCLzRxZiBAt_gPR3mCHv30A&e=>) and then we made but failed to present a more detailed poster at the LLVM dev meeting in October. And now we’re here. 😊
After making a few exploration vehicles (2 overall, 4 for <atomic>), we now think we’ll create version 1 this way:
1. Wrap select libcxx <*> headers with <cuda/*> to introduce symbols in cuda::* instead of std::*, and…
* These facilities are always heterogeneous, NORTTI, and NOEXCEPTIONS.
* Enable users to include them on top of their host library (that being CPU only).
1. “Select” here means prioritizing headers in Freestanding now, or soon, basically the header-only facilities.
2. Subsequently help maintain the intersection of libcxx and Freestanding.
In terms of libcxx design, we think that we could layer on this surface:
* A freestanding mode, say LIBCXX_FREESTANDING, with a design goal of placing low-OS-coupling variants of code for facilities under this mode, and some agreement that Freestanding libraries have different ABI goals than their closest Hosted relative.
* For example, in <atomic>, it would be preferable for Freestanding implementations (and users) if the lock-in-atomic strategy was used for non-lock-free atomics (instead of the sharded-lock-table strategy tucked inside __cxa_atomic_*) because that then frees the program from dependencies on libatomic.
* It is my intention to contribute the code for this 3rd strategy, and other maintenance to <atomic>, some of which I’ve already made in my branch.
* An extension point that allows std::* symbols to be put into another namespace, both for ABI and to co-exist.
* This is in tension with Eric’s proposed change.
* An extension point that allows us to tune visibility control, e.g. add __device__ linkage to local-linkage symbols in those headers included in the subset (Freestanding minimum, or the implementation-defined choice).
* This was at one point in tension with changes Louis was making, but I think we’re Ok right now.
* And, generally speaking, good header inclusion hygiene that tries to minimize what’s pulled into a facility’s header.
That should isolate most of the ugly stuff in our code; version 1 will indeed be fairly ugly, no doubt about that. But then, hopefully, this all ends with libcxx gaining a new implementer!
Thanks for reading, I’ll try to answer your questions as best I can.
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
libcxx-dev mailing list
libcxx-dev at lists.llvm.org<mailto:libcxx-dev at lists.llvm.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the libcxx-dev