std::hardware_destructive_interference_size, std::hardware_constructive_interference_size
提供: cppreference.com
ヘッダ <new> で定義
|
||
inline constexpr std::size_t hardware_destructive_interference_size = /*implementation-defined*/; |
(1) | (C++17以上) |
inline constexpr std::size_t hardware_constructive_interference_size = /*implementation-defined*/; |
(2) | (C++17以上) |
1) 2つのオブジェクトが false sharing を回避するための最小オフセット。 少なくとも alignof(std::max_align_t) 以上であることが保証されます
struct keep_apart { alignas(std::hardware_destructive_interference_size) std::atomic<int> cat; alignas(std::hardware_destructive_interference_size) std::atomic<int> dog; };
2) 隣接したメモリが true sharing を促進する最大サイズ。 少なくとも alignof(std::max_align_t) 以上であることが保証されます
struct together { std::atomic<int> dog; int puppy; }; struct kennel { // Other data members... alignas(sizeof(together)) together pack; // Other data members... }; static_assert(sizeof(together) <= std::hardware_constructive_interference_size);
[編集] ノート
これらの定数は L1 データキャッシュラインサイズにアクセスする移植性のある方法を提供します。
[編集] 例
This section is incomplete Reason: no example |
[編集] 関連項目
処理系がサポートしている���行スレッド数を返します ( std::thread のパブリック静的メンバ関数)
| |
処理系がサポートしている並行スレッド数を返します ( std::jthread のパブリック静的メンバ関数)
|