Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion bench/latency.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ static void pthreadpool_parallelize_1d_tile_1d(benchmark::State& state) {
}
pthreadpool_destroy(threadpool);
}
BENCHMARK(pthreadpool_parallelize_1d_tile_1d)->UseRealTime()->Apply(SetNumberOfThreads);

static void compute_1d_dynamic(void*, size_t, size_t) {}

static void pthreadpool_parallelize_1d_dynamic(benchmark::State& state) {
const uint32_t threads = static_cast<uint32_t>(state.range(0));
pthreadpool_t threadpool = pthreadpool_create(threads);
while (state.KeepRunning()) {
pthreadpool_parallelize_1d_dynamic(threadpool, compute_1d_dynamic,
nullptr /* context */, threads, 1,
0 /* flags */);
}
pthreadpool_destroy(threadpool);
}
BENCHMARK(pthreadpool_parallelize_1d_dynamic)
->UseRealTime()
->Apply(SetNumberOfThreads);

BENCHMARK(pthreadpool_parallelize_1d_tile_1d)
->UseRealTime()
Expand Down Expand Up @@ -79,7 +96,19 @@ static void pthreadpool_parallelize_2d_tile_2d(benchmark::State& state) {
pthreadpool_destroy(threadpool);
}

BENCHMARK(pthreadpool_parallelize_2d_tile_2d)
static void compute_2d_dynamic(void*, size_t, size_t, size_t, size_t) {}

static void pthreadpool_parallelize_2d_dynamic(benchmark::State& state) {
const uint32_t threads = static_cast<uint32_t>(state.range(0));
pthreadpool_t threadpool = pthreadpool_create(threads);
while (state.KeepRunning()) {
pthreadpool_parallelize_2d_dynamic(threadpool, compute_2d_dynamic,
nullptr /* context */, 1, threads, 1, 1,
0 /* flags */);
}
pthreadpool_destroy(threadpool);
}
BENCHMARK(pthreadpool_parallelize_2d_dynamic)
->UseRealTime()
->Apply(SetNumberOfThreads);

Expand Down
97 changes: 93 additions & 4 deletions bench/throughput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,29 @@ BENCHMARK(pthreadpool_parallelize_1d_tile_1d)
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_2d(void*, size_t, size_t) {}
static void compute_1d_dynamic(void*, size_t, size_t) {}

static void pthreadpool_parallelize_1d_dynamic(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
const size_t threads = pthreadpool_get_threads_count(threadpool);
const size_t items = static_cast<size_t>(state.range(0));
while (state.KeepRunning()) {
pthreadpool_parallelize_1d_dynamic(threadpool, compute_1d_dynamic,
nullptr /* context */, items * threads,
1, 0 /* flags */);
}
pthreadpool_destroy(threadpool);

/* Do not normalize by thread */
state.SetItemsProcessed(int64_t(state.iterations()) * items);
}
BENCHMARK(pthreadpool_parallelize_1d_dynamic)
->UseRealTime()
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_2d(void*, size_t, size_t) {
}

static void pthreadpool_parallelize_2d(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
Expand Down Expand Up @@ -95,7 +117,29 @@ BENCHMARK(pthreadpool_parallelize_2d_tile_1d)
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_2d_tile_2d(void*, size_t, size_t, size_t, size_t) {}
static void compute_2d_tile_1d_dynamic(void*, size_t, size_t, size_t) {}

static void pthreadpool_parallelize_2d_tile_1d_dynamic(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
const size_t threads = pthreadpool_get_threads_count(threadpool);
const size_t items = static_cast<size_t>(state.range(0));
while (state.KeepRunning()) {
pthreadpool_parallelize_2d_tile_1d_dynamic(threadpool, compute_2d_tile_1d_dynamic,
nullptr /* context */, threads, items,
1, 0 /* flags */);
}
pthreadpool_destroy(threadpool);

/* Do not normalize by thread */
state.SetItemsProcessed(int64_t(state.iterations()) * items);
}
BENCHMARK(pthreadpool_parallelize_2d_tile_1d_dynamic)
->UseRealTime()
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_2d_tile_2d(void*, size_t, size_t, size_t, size_t) {
}

static void pthreadpool_parallelize_2d_tile_2d(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
Expand All @@ -116,7 +160,29 @@ BENCHMARK(pthreadpool_parallelize_2d_tile_2d)
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_3d(void*, size_t, size_t, size_t) {}
static void compute_2d_dynamic(void*, size_t, size_t, size_t, size_t) {}

static void pthreadpool_parallelize_2d_dynamic(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
const size_t threads = pthreadpool_get_threads_count(threadpool);
const size_t items = static_cast<size_t>(state.range(0));
while (state.KeepRunning()) {
pthreadpool_parallelize_2d_dynamic(threadpool, compute_2d_dynamic,
nullptr /* context */, threads, items, 1,
1, 0 /* flags */);
}
pthreadpool_destroy(threadpool);

/* Do not normalize by thread */
state.SetItemsProcessed(int64_t(state.iterations()) * items);
}
BENCHMARK(pthreadpool_parallelize_2d_dynamic)
->UseRealTime()
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_3d(void*, size_t, size_t, size_t) {
}

static void pthreadpool_parallelize_3d(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
Expand Down Expand Up @@ -178,7 +244,30 @@ BENCHMARK(pthreadpool_parallelize_3d_tile_2d)
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_4d(void*, size_t, size_t, size_t, size_t) {}
static void compute_3d_tile_2d_dynamic(void*, size_t, size_t, size_t, size_t,
size_t) {}

static void pthreadpool_parallelize_3d_tile_2d_dynamic(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
const size_t threads = pthreadpool_get_threads_count(threadpool);
const size_t items = static_cast<size_t>(state.range(0));
while (state.KeepRunning()) {
pthreadpool_parallelize_3d_tile_2d_dynamic(threadpool, compute_3d_tile_2d_dynamic,
nullptr /* context */, 1, threads,
items, 1, 1, 0 /* flags */);
}
pthreadpool_destroy(threadpool);

/* Do not normalize by thread */
state.SetItemsProcessed(int64_t(state.iterations()) * items);
}
BENCHMARK(pthreadpool_parallelize_3d_tile_2d_dynamic)
->UseRealTime()
->RangeMultiplier(10)
->Range(10, 1000000);

static void compute_4d(void*, size_t, size_t, size_t, size_t) {
}

static void pthreadpool_parallelize_4d(benchmark::State& state) {
pthreadpool_t threadpool = pthreadpool_create(2);
Expand Down
Loading