Skip to content

Commit 810f621

Browse files
authored
Merge pull request #334 from cjappl/ReduceWarningsOSXBenchmarks
Get rid of warnings when compiling benchmarks
2 parents 4c826ce + e09967f commit 810f621

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

benchmarks/benchmarks.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
#include "lockbasedqueue.h"
2727
#include "simplelockfree.h"
2828
#include "boostqueue.h"
29+
30+
#pragma clang diagnostic push
31+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
32+
// this uses an old version of OS memory fences on OSX
2933
#include "tbbqueue.h"
34+
#pragma clang diagnostic pop
35+
3036
#include "stdqueue.h"
3137
#include "dlibqueue.h"
3238
#include "../tests/common/simplethread.h"
@@ -966,7 +972,6 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
966972

967973
case bench_only_enqueue_bulk: {
968974
TQueue q;
969-
item_t item = 1;
970975
item_t item_rec;
971976
std::vector<counter_t> data;
972977
for (counter_t i = 0; i != BULK_BATCH_SIZE; ++i) {
@@ -1027,7 +1032,6 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
10271032
case bench_mostly_enqueue_bulk: {
10281033
// Measures the average speed of enqueueing in bulk under light contention
10291034
TQueue q;
1030-
item_t item = 1;
10311035
item_t item_rec;
10321036
std::vector<counter_t> data;
10331037
for (counter_t i = 0; i != BULK_BATCH_SIZE; ++i) {
@@ -1103,7 +1107,6 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
11031107
case bench_only_dequeue_bulk: {
11041108
// Measures the average speed of dequeueing in bulk when all threads are consumers
11051109
TQueue q;
1106-
item_t item = 1;
11071110
item_t item_rec;
11081111
{
11091112
// Fill up the queue first
@@ -1194,7 +1197,6 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
11941197
case bench_mostly_dequeue_bulk: {
11951198
// Measures the average speed of dequeueing in bulk under light contention
11961199
TQueue q;
1197-
item_t item = 1;
11981200
item_t item_rec;
11991201
auto enqueueThreads = std::max(1, nthreads / 4);
12001202
out_opCount = maxOps * BULK_BATCH_SIZE * enqueueThreads;
@@ -1505,11 +1507,10 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
15051507
// (that eight separate threads had at one point enqueued to)
15061508
out_opCount = maxOps * 2 * nthreads;
15071509
TQueue q;
1508-
item_t item = 1;
15091510
item_t item_rec;
15101511
if (nthreads == 1) {
15111512
// No contention -- measures speed of immediately dequeueing the item that was just enqueued
1512-
int item;
1513+
int item = 0;
15131514
auto start = getSystemTime();
15141515
if (useTokens) {
15151516
typename TQueue::producer_token_t prodTok(q);
@@ -1538,7 +1539,7 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
15381539
while (ready.load(std::memory_order_relaxed) != nthreads)
15391540
continue;
15401541

1541-
int item;
1542+
int item = 0;
15421543
auto start = getSystemTime();
15431544
if (useTokens) {
15441545
typename TQueue::producer_token_t prodTok(q);
@@ -1585,7 +1586,7 @@ double runBenchmark(benchmark_type_t benchmark, int nthreads, bool useTokens, un
15851586
auto start = getSystemTime();
15861587
if (id < 2) {
15871588
// Alternate
1588-
int item;
1589+
int item = 0;
15891590
if (useTokens) {
15901591
typename TQueue::consumer_token_t consTok(q);
15911592
typename TQueue::producer_token_t prodTok(q);
@@ -2020,7 +2021,7 @@ int main(int argc, char** argv)
20202021
int maxThreads = QUEUE_MAX_THREADS[queue];
20212022
std::vector<BenchmarkResult> results(ITERATIONS);
20222023
for (int i = 0; i < ITERATIONS; ++i) {
2023-
double elapsed;
2024+
double elapsed = 0.0;
20242025
counter_t ops = 0;
20252026

20262027
switch ((queue_id_t)queue) {

0 commit comments

Comments
 (0)