News for hackers. Stuff that matters.
Re:Stable Diffusion in pure C/C++ by danybittel on Saturday August 19, 2023 @10:46AM (#37189337)
Since when does C++ optimally exploit the underlying hardware? It has no vector instructions, does not run on the GPU and is arguably too hard to make multithreaded. Which leaves you with about 0.5% performance of a current PCs.
Re:Stable Diffusion in pure C/C++ by jcelerier on Saturday August 19, 2023 @10:56AM (#37189428)
> does not run on the GPU

both Cuda and the Metal shader language are C++, so is OpenCL since 2.0 (https://www.khronos.org/opencl/), so is AMD ROCm's HIP (https://github.com/ROCm-Developer-Tools/HIP), so is SYCL (https://www.khronos.org/sycl/)? C++ is pretty much the language that runs most on GPUs.

> no vector instructions,

There's a thousand different possibilities for SIMD in C++, from #pragma omp simd, to libs such as std::experimental::simd (https://en.cppreference.com/w/cpp/experimental/simd/simd), Eve (https://github.com/jfalcou/eve), Highway (https://github.com/google/highway), Vc (https://github.com/VcDevel/Vc)...

Re:Stable Diffusion in pure C/C++ by waynecochran on Saturday August 19, 2023 @12:25PM (#37190380)
Vector types / instructions would be nice. The C++20 STL algorithms are very friendly to vectorization with the various parallel policies (e.g. std::execution::unsequenced_policy) that open up your code to be vectorized. Wonderful libs like Eigen handle a lot of my numeric needs for linear algebra. I think you are forgetting the CUDA is C/C++.
Re:Stable Diffusion in pure C/C++ by Someone on Saturday August 19, 2023 @01:26PM (#37191016)
> Vector types / instructions would be nice

It’s technically not a C++ feature, but both gcc (https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html) and Clang (https://releases.llvm.org/3.1/tools/clang/docs/LanguageExten...) have vector types, and clang even supports the gcc way of writing them, so it gets pretty close.

Re:Stable Diffusion in pure C/C++ by astrange on Saturday August 19, 2023 @06:09PM (#37193809)
Those are traditionally dangerous since they tend to compile poorly; not as bad as autovectorization but not as good as just writing in assembly. And since vectorization is platform-dependent anyway (because it's so different across platforms), assembly really isn't nearly as bad as it sounds.

Though it's certainly gotten better, the reason people push those is that they're written by compiler authors, who don't want to hear that their compiler doesn't work.

Some of the reason for this is that C doesn't let you specify memory aliasing as precisely as you want to. Fortran is better about this.

Re:Stable Diffusion in pure C/C++ by pjmlp on Saturday August 19, 2023 @03:15PM (#37192104)
When compared against Python, more than enough.

C++ is one of the supported CUDA languages, even standard C++17 does run just fine on the GPU.

Metal uses C++14 alongside some extensions.