r/cpp • u/_rob_h_ • Feb 22 '26
Libraries and tools for a lightweight task manager for GPU in a simulated environment.
TLDR: I am trying to create what I could refer to as a lightweight task manager for GPU cloud systems but in a simulated environment.
I need to be able to create and decide scheduling policies for the workloads I will assign to the system. I also need to be able to monitor GPU processes as well as VRAM usage for each of the given workloads, and the software needs to be able to act as admission control so I can prevent Out-of-memory errors by throttling workloads which are intensive.
Essentially, I am trying to make something that simulates NVIDIA MIG and uses NVIDIA SMI or any other process to monitor these in a simulated environment. ( I do not possess a graphics card with NVIDIA MIG capabilities, but it has NVIDIA SMI )
So far the resources I have to put something like this together is
- CUDA
- I need a library for simulation of the GPU at code level.
- Need something like tensor flow but with C++
- Need a lightweight GUI library that isn't QT.
Considering this is a lightweight application and only meant to demonstrate the elements that go into consideration when making GPU-accelerated systems are there any librarie,s articles or books that would be helpful in making this feasible?
Also considering I am not so experienced in C++ is this a feasible project or is it better to stick with python? I am fully open to learning what is needed but I am on a time constraint of about 3 months give or take.
P.S I have gone through the theoretical aspect and about 30+ articles and papers on the theory issues and problems. I just need practical pointers to libraries, tools and code that would help in the actual building.
r/cpp • u/rhidian-12_ • Feb 21 '26
Implementing your own asynchronous runtime for C++ coroutines
Hi all! Last time I wrote a blog post about writing your own C++ coroutines. Now, I wanted to highlight how to write your own C++ asynchronous runtime for your coroutines.
https://rhidian-server.com/how-to-create-your-own-asynchronous-runtime-in-c/
Thanks for reading, and let me know if you have any comments!
r/cpp • u/emilios_tassios • Feb 20 '26
Parallel C++ for Scientific Applications: Tasks & Concurrency (2nd Part)
youtube.comIn this week’s lecture of Parallel C++ for Scientific Applications, Dr. Hartmut Kaiser continues the discussion on task-based parallelism in C++, specifically focusing on the nuances of asynchronous parallelism. The lecture addresses specific scalability issues inherent in fork-join parallelism and presents unique methods to mitigate them effectively.
A core discussion introduces extensions to standard futures implemented in HPX, a C++ Standard Library for Concurrency and Parallelism. Finally, the lecture demonstrates how these advanced tools can extend standard C++ capabilities, offering practical solutions for building more scalable and responsive high-performance applications.
If you want to keep up with more news from the Stellar group and watch the lectures of Parallel C++ for Scientific Applications and these tutorials a week earlier please follow our page on LinkedIn https://www.linkedin.com/company/ste-ar-group/
Also, you can find our GitHub page below:
https://github.com/STEllAR-GROUP/hpx
r/cpp • u/goto-con • Feb 19 '26
Learn C++ by Example • Frances Buontempo & Matt Godbolt
youtu.ber/cpp • u/booker388 • Feb 19 '26
Experimental adaptive sort - matches std::sort on random input, 2-8x faster on structured data
Hi all,
I’ve been developing an adaptive sorting algorithm, tentatively called JesseSort, which aims to exploit partial order in input data while still being competitive with standard library sorts on random input. I’m looking for feedback on design and potential adoption strategies.
What it does
- Detects natural runs in the input (ascending, descending, or random) with a tiny lookahead.
- Maintains two sets of piles for ascending and descending runs, essentially a dual-patience sort.
- Falls back to tiny 8-value bitonic sort networks on detected random regions.
- When this random-input block is run too many times, it falls back to std::sort.
- Currently merges adjacent runs in a naive/bottom-up way.
Current numbers
Median runtime ratios vs std::sort over 100 trials:
| Input Type | 1k Values | 10k | 100k | 1M |
|---|---|---|---|---|
| Random | 0.984 | 1.032 | 1.042 | 1.088 |
| Sorted | 1.022 | 0.679 | 0.583 | 1.448? |
| Reverse | 1.636 | 1.076 | 0.900 | 2.101? |
| Sorted+Noise(5%) | 1.048 | 1.041 | 1.079 | 1.201 |
| Random+Repeats(50%) | 1.037 | 1.032 | 1.031 | 1.089 |
| Jitter | 1.012 | 0.674 | 0.586 | 1.443? |
| Alternating | 0.829 | 1.011 | 0.974 | 1.018 |
| Sawtooth | 1.121 | 0.960 | 0.978 | 1.072 |
| BlockSorted | 1.046 | 0.950 | 0.928 | 1.153 |
| OrganPipe | 0.446 | 0.232 | 0.138 | 0.268 |
| Rotated | 0.596 | 0.522 | 0.396 | 0.716 |
| Signal | 1.402 | 0.828 | 0.659 | 0.582 |
Notes:
- Ratios are
JesseSort/std::sort. Values <1 indicate JesseSort is faster. 0.5 means JesseSort takes half the time (2x faster). 2.0 means JesseSort takes twice as much time (2x slower). - Large input blow-ups (
?) appear to be outliers on my machine, but would be curious to see if others see the same pattern.
Current issues / questions
- Handoff threshold: Detecting random input too early loses semi-structured gains; too late slows random input. How should this balance be tuned?
- Fallback vs. std::sort: Could JesseSort itself (dual patience games) serve as a better fallback than heap sort in standard introsort implementations?
- Merge optimizations: Current merge is bottom-up adjacent. I’ve prototyped a TimSort-style merge that merges smaller runs first. Minor speedups in most cases but I haven't tested it enough.
- Memory layout & cache: Some sensitivity to variable placement and data alignment is noticeable. Any advice for robust layout-sensitive optimizations?
- Real-world adoption: Even if slightly slower on purely random input (~5%), the structured input gains are often >50%. Would such an algorithm be worth promoting or considered niche? If the hit to random input is too significant, maybe this would find a better home as an alternative like
std::structured_sort?
I’m looking for input on:
- Algorithmic improvements, especially for the random vs structured handoff
- Practical concerns for integration into standard libraries
- Benchmark methodology for mixed input distributions
- Real-world test datasets that might showcase advantages
Code and full details are available here: https://github.com/lewj85/jessesort
Thanks