diff options
author | Jan Huwald <jh@sotun.de> | 2013-06-24 09:20:54 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2013-06-24 09:20:54 (GMT) |
commit | 21d9e26dfb72ba6d0fa4f3f40a439e51d943d349 (patch) | |
tree | 9d19dd79427c411cd8ac8f17cd5465158d838f52 /cachepad.hpp | |
parent | aac019848c8813fe9dff3a8e9128c418f1225cda (diff) |
support canceling iterTrans if no work is done anymore
A bool is passed to the worker function to store wether any work has
been done in an iterState round. To prevent cache line bouncing, each
worker thread has its own cache line aligned bool which is ultimately
merged.
Diffstat (limited to 'cachepad.hpp')
-rw-r--r-- | cachepad.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cachepad.hpp b/cachepad.hpp new file mode 100644 index 0000000..beb7528 --- /dev/null +++ b/cachepad.hpp @@ -0,0 +1,15 @@ +#pragma once + +template<typename T> +struct cache_pad { + template<typename ...Arg> + cache_pad(Arg... args) : val(args...) {} + + operator T () { return val; } + T& operator () () { return val; } + + union { + T val; + char pad[(sizeof(T) + 63) / 64 * 64]; + }; +} __attribute__ ((aligned (64))); // TODO: port to C++11 alignas once GCC support is old enough |