summaryrefslogtreecommitdiffstats
path: root/src/config.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-14 10:35:24 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-14 16:00:32 -0400
commit29719ace5192ff5c2d81c29d1947e32d7889f62b (patch)
tree19e211d4f0428c49b0d6973326f9d769d91574db /src/config.h
parent83150980687d644bb0c4faad1c297d1b5b9018b6 (diff)
downloadbfs-29719ace5192ff5c2d81c29d1947e32d7889f62b.tar.xz
config: Add macros for false/true sharing sizes
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index dbe3c74..73348ac 100644
--- a/src/config.h
+++ b/src/config.h
@@ -191,6 +191,29 @@ static inline size_t flex_sizeof_impl(size_t align, size_t min, size_t offset, s
return ret;
}
+/**
+ * False sharing/destructive interference/largest cache line size.
+ */
+#ifdef __GCC_DESTRUCTIVE_SIZE
+# define FALSE_SHARING_SIZE __GCC_DESTRUCTIVE_SIZE
+#else
+# define FALSE_SHARING_SIZE 64
+#endif
+
+/**
+ * True sharing/constructive interference/smallest cache line size.
+ */
+#ifdef __GCC_CONSTRUCTIVE_SIZE
+# define TRUE_SHARING_SIZE __GCC_CONSTRUCTIVE_SIZE
+#else
+# define TRUE_SHARING_SIZE 64
+#endif
+
+/**
+ * Alignment specifier that avoids false sharing.
+ */
+#define cache_align alignas(FALSE_SHARING_SIZE)
+
// Wrappers for attributes
/**