r/programming • u/AggravatingReindeer8 • Sep 19 '20
Libcu++: Nvidia C++ Standard Library
https://github.com/NVIDIA/libcudacxx4
u/vikigenius Sep 20 '20
This is actually pretty neat, and from the documentation, seems incredibly easy to use.
4
u/StromaeNotDed Sep 20 '20
What would be a use case of this?
7
u/13steinj Sep 20 '20 edited Sep 20 '20
Say you need an atomic variable. Also say for whatever reason you need this to do an atomic operation on this variable at some point on the host, on another point on the device. Under normal circumstances you'd have pain points, because you'd essentially need to create a wrapper class that uses a std::atomic on the host and otherwise still "works" when passed to the device. Here they made that wrapper for you.
Hopefully eventually, container support gets added. So like the thrust library for cuda, but without having to manually copy things over host to device and visa versa.
E: to clarify, traditionally, you'll see code that offloads to a GPU, maybe involves some atomic variables to do the work. But besides the difficulty in implementation, there's no reason you can't theoretically also use CPU threads.
So, assuming you meet cuda's memory-based restrictions, this additionally allows for a use of an atomic variable that works both in the CPU and the GPU, at the same steps of execution. Which is the (arguably) bigger deal.
8
u/BladedD Sep 20 '20
Seems awesome. Can’t wait to check it out tomorrow
going to try cuda::std::cout <<“Hello World”;
11
u/josefx Sep 20 '20
At least you didn't put a std::endl at the end. The performance impact of several thousand forced parallel io flushes to the same stream gives me a headache just thinking about it. Always remember: use '\n' to denote an end of line, std::flush to flush and never use std::endl unless you are printf debugging your program.
2
u/PsyLich Sep 20 '20
I was told by a senior programmer that ‘\n’ doesn’t always work as there may be operating systems that don’t have it as a default “end of line”. Can you confirm that?
9
u/josefx Sep 20 '20
The implementation of std::endl is defined based on '\n' and flush. So they should both break for the same reasons. Either your senior programmer had a run in with a buggy standard library that got '\n' wrong without also breaking std::endl or he has a habbit of opening text streams in binary mode, in which case std::endl shouldn't work either.
6
u/max0x7ba Sep 20 '20
On Linux, standard output is line buffered on a terminal and block buffered when redirected into a file or a pipe. The latter is probably why
\nwasn't enough for that senior programmer.1
0
u/13steinj Sep 20 '20
Uh, unfortunate part is AFAIK iostreams are not currently supported? Unless I'm misunderstanding something. Seems to be on the backburner.
2
u/BladedD Sep 20 '20
My comment was more of a joke lol
Not really sure what benefit Cuda could have for iostreams haha, but I didn’t know it wasn’t supported at all. Good info to know though, thanks
2
2
2
Sep 20 '20
Would this be different from something like, say Boost?
4
u/13steinj Sep 20 '20
AFAIK, boost has no cuda-specific device available code. What this provides is
libc++
additions to libc++ allowing you to use the same type, and in some cases, same object, in both host and device code, the latter letting you "fully utilize your machine" with greater ease, so to speak (currently this is limited to a specific but growing subset of the STL)
cuda-specific extensions to STL objects (which only make sense on device)
1
-6
-8
u/Mgladiethor Sep 20 '20
Until cuda dies, fuck no
10
u/13steinj Sep 20 '20
I don't follow. This is to be used with cuda code; as in, cuda and C++ compliant standard library usable in both host and device code. More specifically, a large amount is an offshoot of libc++ standard library, with a growing subset gaining quick, easy, cuda interoperability.
E: unfortunate part is lack of documentation, seems to be a lot of "TODO".
0
Sep 19 '20
[deleted]
9
18
u/txdv Sep 19 '20
would tou be so kind to eaborate?
66
u/ElectroDr Sep 19 '20
Cu means ass in Portuguese
64
u/Glacia Sep 19 '20
Like this? https://github.com/libass/libass
23
11
u/Theemuts Sep 19 '20
Get it
10
u/panties_in_my_ass Sep 20 '20
Information about the ASS format:
ASS specification (incomplete)
ASS override
5
u/megayippie Sep 20 '20
Everything means ass or penis in portuguese. Never order bread in São Paulo...
3
7
u/patlefort Sep 19 '20
Also means ass in Quebec french slang :)
11
u/foreheadteeth Sep 19 '20
It's not Québec slang, it's plain old French. It may be used in a vulgar fashion to refer to someone's ass, but it can also be used in a non-vulgar way ("cul de sac").
0
2
2
6
1
-5
-21
u/squareswordfish Sep 19 '20
Are you also 10?
12
2
u/_-ammar-_ Sep 20 '20
yes.
-4
u/squareswordfish Sep 20 '20
Apparently the whole sub is lol. This word is as funny as “assassin” (it has ass in it twice hahahahah!!!)
1
0
Sep 20 '20
[deleted]
3
u/PsyLich Sep 20 '20
Weirdest comment I’ve seen in a while and there is quite the competition...
To answer your question, he either works for some security company(may be even government) on a very high level, or he is doing something illegal with his hacking/coding skills, there is also the small chance of him cheating on you.
38
u/allinwonderornot Sep 20 '20
"I love open source so much, I embrace hardware vendor lock-in!"