aboutsummaryrefslogtreecommitdiff
path: root/miner.h
diff options
context:
space:
mode:
authorckolivas <kernel@kolivas.org>2011-06-09 11:45:06 +1000
committerckolivas <kernel@kolivas.org>2011-06-09 11:45:06 +1000
commit8a832eeab524bbad160adb7c27acb370d6adedff (patch)
tree75b8e08a61d4e488824b1c0fa2de4bc05459cc03 /miner.h
parentf2e4ff0e509f69404aa11f5232d8f63110383f03 (diff)
Linux + x86_64 optimisations.
Add likely() macro. Optimise a few obvious code paths with likely/unlikely. Change algo to sse2_amd64 by default. Move priority change to worker threads only. Detect number of CPUs and set default number of threads == CPUs. Add scheduling policy change to worker threads to SCHED_IDLE first and fallback to SCHED_BATCH on linux. Don't error when failing to set priority. Add CPU affinity and bind worker threads to CPUs when number of threads is a multiple of number of CPUs. Update NEWS with changes.
Diffstat (limited to 'miner.h')
-rw-r--r--miner.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/miner.h b/miner.h
index 0781ce7..e72404f 100644
--- a/miner.h
+++ b/miner.h
@@ -87,12 +87,14 @@ enum {
};
#endif
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#undef unlikely
-#define unlikely(expr) (__builtin_expect((expr), 0))
+#undef likely
+#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+#define unlikely(expr) (__builtin_expect(!!(expr), 0))
+#define likely(expr) (__builtin_expect(!!(expr), 1))
#else
-#undef unlikely
#define unlikely(expr) (expr)
+#define likely(expr) (expr)
#endif
#if defined(__i386__)