3 ms·
Given your criteria, you might want to consider (modern) C++. * Fast - in many cases faster than Rust, although the difference is inconsequential relative to P
by einpoklum 4y ago
Given your criteria, you might want to consider (modern) C++.
* Fast - in many cases faster than Rust, although the difference is inconsequential relative to Python-to-Rust improvement I guess.
* _Really_ utilize CUDA, OpenCL, Vulcan etc. Specifically, Rust GPU is limited in its supported features, see: https://github.com/Rust-GPU/Rust-CUDA/blob/master/guide/src/features.md https://github.com/Rust-GPU/Rust-CUDA/blob/master/guide/src/... ...
* Host-side use of CUDA is at least as nice, and probably nicer, than what you'll get with Rust. That is, provided you use my own Modern C++ wrappers for the CUDA APIs: https://github.com/eyalroz/cuda-api-wrappers/ https://github.com/eyalroz/cuda-api-wrappers/ :-) ... sorry for the shameless self-plug.
* ... which brings me to another point: Richer offering of libraries for various needs than Rust, for you to possibly utilize.
* Easier to share than Rust. A target system is less likely to have an appropriate version of Rust and the surrounding ecosystem.
There are downsides, of course, but I was just applying your criteria.
- the__alchemist 4y agoI want to get into that for CUDA. I've been using Vulkan via WGPU. But there, everything has to pass between CPU and GPU as byte arrays, when I've heard CUDA lets you maintain the same data structures. On the to-do list. Would also def benefit from the larger selection of C++ libs, especially for GUI and graphics. Given the main computation issue is doing the same operation on many values in a 3D array, using the GPU more would be great. And my current setup for that is clumsy. I disagree on easier to share. Binaries work the same either way. Compiling from source on rust is generally install Rustc, and do `cargo b --release`. Compiling someone else's code in C++ is... complicated.
- einpoklum 4y ago> when I've heard CUDA lets you maintain the same data structure Yes, that's possible with a combination of: * Unified address space for pointers (and C++ references are basically pointers) * Paged virtual memory on GPUs ... however, remember that many/most data structures which make sense on the CPU may not make sense to use on a GPU. And - NVIDIA very often implements and promotes certain features because they sound good in marketing, not because they're actually that useful. Or because they let you make a super-slow program into a meh-speed program, not because you would use them in a really-fast program. > Compiling from source on rust is generally install Rustc, and do `cargo b --release`. Well, I guess you may have a point, but let me still make a couple more arguments. First, installing Rust (and related libraries/tools/whatever) is not trivial for people who don't know rust, and some OS distributions only offer you an older version of rust using their distro-package-managers. It's more likely that a C++ environment is already set up on someone's machine... TBH, though, if the distro is older, that might not be a perfect fit for what you're building. Second C++ package managers becoming more popular, e.g. Conan: https://conan.io/ https://conan.io/ ; and that helps for when your OS distro doesn't cover you. > Compiling someone else's code in C++ is... complicated. This has actually improved a whole lot over the past... say, decade or so! * Unzip/untar * Configure the build with CMake (cross-platform build system generator - almost ubiquitous these days in C++ projects): `cmake -B build_dir/` * Assuming you have the dependencies set up - it should "just build": `cmake --build build_dir` * Run the thing from the build directory or install it with `cmake --install build_dir`. ... and if you want to tweak package options more easily than via the command-line, you can use a TUI (ccmake) or GUI (cmake-gui). The problems start when you're missing dependencies, or if the author didn't make their code platform-independent / multi-platform.
- vlovich123 4y ago> Fast - in many cases faster than Rust, although the difference is inconsequential relative to Python-to-Rust improvement I guess. Do you have any examples? AFAIK properly tuned rust and c++ will perform largely the same. Actually, Rust should have a bit of an edge due to the prohibition of aliasing. In practice it can vary if a standard library implementation is suboptimal or the compiler has suboptimal codegen into Bitcode but that’s generally going to be rare these days I think. > Richer offering of libraries for various needs than Rust, for you to possibly utilize. Are you talking for computational chemistry specifically or general libraries?. Don’t know about the former. For the latter I’ve found not only are more interesting libraries available, there seem to be generally high quality versions. Additionally, “cargo add xxx” is infinitely faster than integrating some random third party c++ dependency. Not to mention that C++ falls on the floor if one dependency requires transitive dependency X and another (or you) requires X at an incompatible version? Rust handles that elegantly where two different modules can depend on the same package at different versions without conflict without you needing to worry about it beyond the size of the executable. > Easier to share than Rust. A target system is less likely to have an appropriate version of Rust and the surrounding ecosystem. Again, haven’t that found to be my experience. Rustup lets you obtain any version of the rust tool chain, no muss no fuss. Additionally, it does a phenomenal job of not worrying about which compiler vendor you’re using (there’s only one) and more importantly there’s no versioning issues with libraries written against an older version of the language - 2021 and 2018. Oh, if you’re on windows, you also don’t have to worry about whether the target person has the right c++ runtime library version installed. With rust they just run the exe.
- Const-me 4y ago> not only are more interesting libraries available, there seem to be generally high quality versions I wonder what's an equivalent of Eigen? https://eigen.tuxfamily.org/index.php?title=Main_Page https://eigen.tuxfamily.org/index.php?title=Main_Page > if you’re on windows, you also don’t have to worry about whether the target person has the right c++ runtime library version installed It's usually easy to build such binaries for Windows. That's a single combobox in project settings. Here's an example, just running the .exe works: https://github.com/Const-me/Whisper https://github.com/Const-me/Whisper