C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::cache_isolated

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Wed, 1 Apr 2026 14:00:04 +0200
Do you expect a certain guaranteed behavior, e.g. that the cache line is never loaded, if the object is not accessed, etc.? Or certain behavior for multiple cores?   Or is it just a performance hint? And could be ignored and be still a correct program?   -----Ursprüngliche Nachricht----- Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Mi 01.04.2026 13:49 Betreff:[std-proposals] std::cache_isolated An:std-proposals <std-proposals_at_[hidden]>; CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;  I wasn't sure if this would be something for Boost, but then I was thinking that the compiler writers would know more about the target architecture. So maybe it belongs in the C++ standard library rather than Boost. If we had a wrapper class to force at most one object to a cache line, the most naive implementation could be something like: template<typename T> class alignas(std::hardware_destructive_interference_size) cache_isolated : public T {   static constexpr std::size_t len = std::hardware_destructive_interference_size;   std::array<char unsigned, (len - (sizeof(T) % len)) % len> cache_line_padding; public:   template<typename... Params>   cache_isolated(Params&&... args) : T{ std::forward<Params>(args)... } {} };  Of course if 'T' is a class marked 'final' then inheritance wouldn't work here, and it would need to be a sub-object instead. And then individual compilers could provide more specific optimised implementations. -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-04-01 12:01:03