TGViewer
Channel Public Channel
C++ - Reddit

C++ - Reddit

@r_cpp

Stay up-to-date with everything C++!
Content directly fetched from the subreddit just for you.

Join our group for discussions : @programminginc

Powered by : @r_channels
Subscribers
230
Photos
48
Videos
8
Links
25.4K

Showing posts older than #25102 · Back to latest

Older Posts 20 shown
Post #25099 16
Sub-microsecond timing on EC2 is way messier than I expected

Been doing sub-microsecond profiling on EC2 and kept getting wildly inconsistent cycle counts.

One mistake was using cpuid as the serialization barrier before rdtsc. On a VM that can be a mess, since cpuid often traps so the hypervisor can fake feature flags. So now the "measurement overhead" includes a VM exit, which is thousands of cycles on some runs.

Switching to lfence + rdtsc made the numbers a lot more stable.

Then I hit the calibration problem. Measuring TSC frequency with a short sleep() looked simple, but the results were all over the place. Scheduler delay, timer granularity, and probably vCPU steal time were enough to make the calibration useless at this scale. A busy-wait loop with pause gave me a much saner number.

Also forgot to pin the thread at first. rdtscp at least tells you when you migrated, but those samples are basically trash. Same with the first few iterations before icache/branch predictor warm up.

Curious what people here actually use for sub-microsecond timing. Do you just trust nanobench / Google Benchmark, or do you still end up writing your own rdtsc wrappers once VMs get involved?

https://redd.it/1t0o16n
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
Post #25098 18
Syntactic sugar of member function binding?

Instead of

std::bind_front(&Very::Long::Namespace::VeryLongClassName::method, pobject)


I'm currently using

#define BIND_FRONT(method, pobject) std::bind_front(&std::remove_cvref_t<decltype(*(pobject))>::method, (pobject))

BIND_FRONT(method, pobject)


I wonder if we can make

(pobject->method)


or

((*pobject).method)


or

((*pobject)::method)


a syntactic sugar of

BIND_FRONT(method, pobject) // a.k.a `std::bind_front(&std::remove_cvref_t<decltype(*(pobject))>::method, (pobject))`


Possible? Any drawbacks?

https://redd.it/1t0gryo
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
Post #25097 20
I made a super fast CNN library for C++20 from scratch.

I was exploring Convolutional Neural Networks (CNNs) in more depth and I had an interesting idea of making a dependency free, header only cnn library for C++20.

I did some research and found out about tiny-dnn which is a cnn library for c++14, super fast but the developers stopped updating it back in 2016, so I decided to take on a challenge to make my own CNN library from scratch for c+ +20 with extreme performance tuning for CPU, and I did achieve close to what I was expecting.

I benchmarked with "pytorch" and the results were good enough to post, I have documented about the library here along with the benchmark results. At some instances it outperformed pytorch and I was shocked too.

Documentation- "https://Inkd.in/gNFF74JJ"

To get a rough idea on how fast is my engine it goes 97.51% accuracy on mnist dataset in just 25 seconds of training with a throughput of 2k+ images / second.

processor - Ryzen 7 5800H mobile

For overview -

My engine uses DAG layout

It has Zero Allocation

Multithreading Support

L1/L2 Cache Optimization

and a lot of internal stuffs going on, here is the repository link-

"https://github.com/KunwarPrabhat/CustomCNN"

My engine is still in its early stage so there are alot of things that can be fixed I need more devlopers to contribute if they're interested in it :))





https://redd.it/1t080e4
@r_cpp
Post #25095 20
Is anyone still using the CTRE library in 2026?

Back in 2019 an engineer/committee member made a splash by introducing CTRE, Compile Time Regular Expressions.

It was implemented using type aliases instead of constexpr function calls meaning it was easy to implement in C++11. Very impressive stuff.

It also gave you a nicer callsite spelling in C++20 leveraging generalized non-type template parameter passing.

I'm curious if anyone is still using it. If no, why not? I'd love to hear!

https://redd.it/1t05xxt
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
Post #25093 23
Post #25092 22
Working on a new language (vibe-compiler) – Looking for feedback on my C++23 Lexer/Parser

Hey everyone,

I've been working on a custom programming language called vibe-compiler. It's a low-level project built with C++23.


I want to learn more about how can I built a OOP in my custom language. I'm following the www.craftinginterpreters.com . I'd love some feedback on my approach to naming convention and how can i improve the project. Also, if anyone is interested in contributing or just chatting about compiler design, I'd love to connect!

This is the GitHub repo: https://github.com/gemrey13/vibe-compiler

https://redd.it/1szwqdg
@r_cpp
GitHub GitHub - gemrey13/vibe-compiler Contribute to gemrey13/vibe-compiler development by creating an account on GitHub.
Post #25087 16
Post #25086 17
ACAV v1.0.0: an open-source GUI tool for exploring Clang ASTs in C/C++ projects

I am the author of ACAV, the Aurora Clang AST Viewer, and I have just made the first public release, v1.0.0.

ACAV is an open-source Qt desktop application for exploring Clang ASTs in C, C++, Objective-C, and Objective-C++ projects that provide a `compile_commands.json` compilation database.

It supports source-to-AST navigation, AST-node search, source-code search, declaration-context views, selected-subtree JSON export, and background AST generation/caching.



Links:

\- GitHub: https://github.com/uvic-aurora/acav

\- Release: https://github.com/uvic-aurora/acav/releases/tag/v1.0.0

\- Manual: https://uvic-aurora.github.io/acav-manual/index.html

\- Demo video: https://youtu.be/0M7dYAlnrTI

There are also prebuilt Docker/Podman demo images for LLVM 20, 21, and 22.

https://github.com/uvic-aurora/acav/pkgs/container/acav


I would appreciate feedback from C++ users, especially anyone who works with Clang tooling or wants a more visual way to inspect ASTs.





https://redd.it/1sz6w3w
@r_cpp
GitHub GitHub - uvic-aurora/acav: Aurora Clang AST Viewer Aurora Clang AST Viewer. Contribute to uvic-aurora/acav development by creating an account on GitHub.
Post #25085 18
Post #25083 18
Build a simple and yet powerful TUI file-organizer (forg?)

And Yes, i know, organizing can quit your searching. But I'm constantly nerved down to my bones (don't know how to bring this in proper english) when I'm looking at my /Downloads, /Documents, /Active_Projects, /AnythingAtAll and still find a lot of stuff in it after some days of intensive work at my lap.... Aaargh...I think often by myself.

So here it is. Simple OSX/Linux Tool with TUI ...everything lined up in your /Organized.... (configurable of 'cause)

May it be useful. For you as it is already for me.

FREE at all. clone...compile...have fun.... cheers...

github: https://github.com/SaschaKohler/file-organizer

https://redd.it/1sywf3f
@r_cpp
GitHub GitHub - SaschaKohler/file-organizer: just another file management tool written in C++20 just another file management tool written in C++20 - SaschaKohler/file-organizer
Older posts →
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →