Skip to content

Commit

Permalink
Added Intel TBB concurrent_queue to benchmarks
Browse files Browse the repository at this point in the history
cameron314 committed Nov 8, 2014
1 parent a7ae577 commit 51974e2
Showing 199 changed files with 64,406 additions and 7 deletions.
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This license applies to everything in this repository except that which
is explicitly annotated as being written by other authors, i.e. the Boost
queue (included in the benchmarks for comparison), the CDSChecker tool,
and the Relacy model checker.
queue (included in the benchmarks for comparison), Intel's TBB library (ditto),
the CDSChecker tool, and the Relacy model checker.


Simplified BSD License:
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ a unit test for it can be cooked up.) Just open an issue on GitHub.
## License

I'm releasing the source of this repository (with the exception of third-party code, i.e. the Boost queue
(used in the benchmarks for comparison) and CDSChecker, which have their own licenses) under a [simplified BSD license][license].
(used in the benchmarks for comparison), Intel's TBB library (ditto), CDSChecker, and Relacy, which have their own licenses) under a [simplified BSD license][license].

Note that lock-free programming is a patent minefield, and this code may very
well violate a pending patent (I haven't looked), though it does not to my present knowledge.
13 changes: 13 additions & 0 deletions benchmarks/benchmarks.cpp
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
#include "lockbasedqueue.h"
#include "simplelockfree.h"
#include "boostqueue.h"
#include "tbbqueue.h"
#include "stdqueue.h"
#include "../tests/common/simplethread.h"
#include "../tests/common/systemtime.h"
@@ -185,6 +186,7 @@ enum queue_id_t
{
queue_moodycamel_ConcurrentQueue,
queue_boost,
queue_tbb,
queue_simplelockfree,
queue_lockbased,
queue_std,
@@ -195,6 +197,7 @@ enum queue_id_t
const char QUEUE_NAMES[QUEUE_COUNT][64] = {
"moodycamel::ConcurrentQueue",
"boost::lockfree::queue",
"tbb::concurrent_queue",
"SimpleLockFreeQueue",
"LockBasedQueue",
"std::queue",
@@ -205,6 +208,7 @@ const char QUEUE_SUMMARY_NOTES[QUEUE_COUNT][128] = {
"",
"",
"",
"",
"single thread only",
};

@@ -214,13 +218,15 @@ const bool QUEUE_TOKEN_SUPPORT[QUEUE_COUNT] = {
false,
false,
false,
false,
};

const int QUEUE_MAX_THREADS[QUEUE_COUNT] = {
-1, // no limit
-1,
-1,
-1,
-1,
1,
};

@@ -229,6 +235,7 @@ const bool QUEUE_BENCH_SUPPORT[QUEUE_COUNT][BENCHMARK_TYPE_COUNT] = {
{ 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 },
{ 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 },
};

@@ -1952,6 +1959,9 @@ int main(int argc, char** argv)
case queue_boost:
maxOps = determineMaxOpsForBenchmark<BoostQueueWrapper<int>>((benchmark_type_t)benchmark, nthreads, (bool)useTokens, seed);
break;
case queue_tbb:
maxOps = determineMaxOpsForBenchmark<TbbQueueWrapper<int>>((benchmark_type_t)benchmark, nthreads, (bool)useTokens, seed);
break;
case queue_std:
maxOps = determineMaxOpsForBenchmark<StdQueueWrapper<int>>((benchmark_type_t)benchmark, nthreads, (bool)useTokens, seed);
break;
@@ -1979,6 +1989,9 @@ int main(int argc, char** argv)
case queue_boost:
elapsed = runBenchmark<BoostQueueWrapper<int>>((benchmark_type_t)benchmark, nthreads, (bool)useTokens, seed, maxOps, maxThreads, ops);
break;
case queue_tbb:
elapsed = runBenchmark<TbbQueueWrapper<int>>((benchmark_type_t)benchmark, nthreads, (bool)useTokens, seed, maxOps, maxThreads, ops);
break;
case queue_std:
elapsed = runBenchmark<StdQueueWrapper<int>>((benchmark_type_t)benchmark, nthreads, (bool)useTokens, seed, maxOps, maxThreads, ops);
break;
5 changes: 3 additions & 2 deletions benchmarks/extract_graph_data.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@


def extract(bench, log, data):
# data = { thread_count: [ locked, boost, moodycamel, moodycamel_tok, moodycamel_bulk ], ... }
# data = { thread_count: [ locked, boost, tbb, moodycamel, moodycamel_tok, moodycamel_bulk ], ... }

def do_extract(bench, queue_header):
block = re.search(r'^' + bench + r':.*?' + queue_header + r'\s*(.*?)\s*^\s*Operations per second', log, re.S | re.M | re.I).group(1)
@@ -28,14 +28,15 @@ def do_extract(bench, queue_header):

do_extract(bench, 'LockBasedQueue')
do_extract(bench, 'boost::lockfree::queue')
do_extract(bench, 'tbb::concurrent_queue')
do_extract(bench, 'Without tokens')
do_extract(bench, 'With tokens')
do_extract(bench + ' bulk', 'With tokens')


def write_csv(data, path):
with open(path, 'w') as f:
f.write('threads,"std::queue + std::mutex","boost::lockfree::queue","moodycamel::ConcurrentQueue (no tokens)","moodycamel::ConcurrentQueue","moodycamel::ConcurrentQueue (bulk)"\n')
f.write('threads,"std::queue + std::mutex","boost::lockfree::queue","tbb::concurrent_queue","moodycamel::ConcurrentQueue (no tokens)","moodycamel::ConcurrentQueue","moodycamel::ConcurrentQueue (bulk)"\n')
for threads in sorted(data.keys()):
f.write(str(threads))
for opsst in data[threads]:
Loading
Oops, something went wrong.

0 comments on commit 51974e2

Please sign in to comment.