-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix downstream issues with cmake and minor folder renames
Signed-off-by: Ian <[email protected]>
- Loading branch information
Showing
66 changed files
with
4,897 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
|
||
cmake_minimum_required(VERSION 3.18 FATAL_ERROR) | ||
|
||
project(ccmath-benchmark) | ||
|
||
option(CCM_BENCH_BASIC "Enable basic benchmarks" OFF) | ||
option(CCM_BENCH_COMPARE "Enable comparison benchmarks" OFF) | ||
option(CCM_BENCH_POWER "Enable power benchmarks" OFF) | ||
option(CCM_BENCH_NEAREST "Enable nearest benchmarks" ON) | ||
|
||
option(CCM_BENCH_ALL "Enable all benchmarks" OFF) | ||
|
||
# Force cmake to use Release if debug is detected | ||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(CMAKE_BUILD_TYPE "Release" ON CACHE STRING "Build type" FORCE) | ||
endif () | ||
|
||
if (NOT TARGET ccmath) | ||
find_package(ccmath CONFIG REQUIRED) | ||
endif () | ||
|
||
function(add_benchmark function_name source_files) | ||
add_executable(ccm_benchmark_${function_name} helpers/randomizers.hpp ${source_files}) | ||
target_link_libraries(ccm_benchmark_${function_name} PRIVATE ccmath::ccmath benchmark::benchmark) | ||
target_compile_features(ccm_benchmark_${function_name} PRIVATE cxx_std_17) | ||
endfunction() | ||
|
||
|
||
if (CCM_BENCH_BASIC) | ||
add_benchmark(abs benchmarks/basic/abs.bench.cpp benchmarks/basic/abs.bench.hpp) | ||
add_benchmark(fdim benchmarks/basic/fdim.bench.cpp benchmarks/basic/fdim.bench.hpp) | ||
add_benchmark(fma benchmarks/basic/fma.bench.cpp benchmarks/basic/fma.bench.hpp) | ||
endif () | ||
|
||
if (CCM_BENCH_POWER) | ||
add_benchmark(sqrt benchmarks/power/sqrt.bench.cpp benchmarks/power/sqrt.bench.hpp) | ||
endif () | ||
|
||
if (CCM_BENCH_NEAREST) | ||
#add_benchmark(trunc benchmarks/nearest/trunc.bench.cpp benchmarks/nearest/trunc.bench.hpp) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2024-Present Ian Pike | ||
* Copyright (c) 2024-Present ccmath contributors | ||
* | ||
* This library is provided under the MIT License. | ||
* See LICENSE for more information. | ||
*/ | ||
|
||
#include "abs.bench.hpp" | ||
|
||
// NOLINTBEGIN | ||
|
||
|
||
BENCHMARK(BM_basic_abs_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_abs_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_abs_rand_int_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_abs_rand_int_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_abs_rand_double_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_abs_rand_double_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK_MAIN(); | ||
|
||
// NOLINTEND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) 2024-Present Ian Pike | ||
* Copyright (c) 2024-Present ccmath contributors | ||
* | ||
* This library is provided under the MIT License. | ||
* See LICENSE for more information. | ||
*/ | ||
|
||
#include "../../helpers/randomizers.hpp" | ||
#include <benchmark/benchmark.h> | ||
#include <ccmath/ccmath.hpp> | ||
#include <cmath> | ||
|
||
namespace bm = benchmark; | ||
|
||
// NOLINTBEGIN | ||
|
||
|
||
static void BM_basic_abs_std(benchmark::State& state) { | ||
for ([[maybe_unused]] auto _ : state) { | ||
benchmark::DoNotOptimize(std::abs(state.range(0))); | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_abs_ccmath(benchmark::State& state) { | ||
for ([[maybe_unused]] auto _ : state) { | ||
benchmark::DoNotOptimize(ccm::abs(state.range(0))); | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_abs_rand_int_std(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomIntegers = ran.generateRandomIntegers(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (auto x : randomIntegers) { | ||
benchmark::DoNotOptimize(std::abs(x)); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_abs_rand_int_ccmath(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomIntegers = ran.generateRandomIntegers(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (auto x : randomIntegers) { | ||
benchmark::DoNotOptimize(ccm::abs(x)); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_abs_rand_double_std(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomDoubles = ran.generateRandomDoubles(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (auto x : randomDoubles) { | ||
benchmark::DoNotOptimize(std::abs(x)); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_abs_rand_double_ccmath(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomDoubles = ran.generateRandomDoubles(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (auto x : randomDoubles) { | ||
benchmark::DoNotOptimize(ccm::abs(x)); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
|
||
// NOLINTEND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024-Present Ian Pike | ||
* Copyright (c) 2024-Present ccmath contributors | ||
* | ||
* This library is provided under the MIT License. | ||
* See LICENSE for more information. | ||
*/ | ||
|
||
#include "fdim.bench.hpp" | ||
|
||
// NOLINTBEGIN | ||
|
||
BENCHMARK(BM_basic_fdim_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fdim_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fdim_rand_int_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fdim_rand_int_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fdim_rand_double_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fdim_rand_double_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK_MAIN(); | ||
|
||
// NOLINTEND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2024-Present Ian Pike | ||
* Copyright (c) 2024-Present ccmath contributors | ||
* | ||
* This library is provided under the MIT License. | ||
* See LICENSE for more information. | ||
*/ | ||
|
||
#include "../../helpers/randomizers.hpp" | ||
#include <benchmark/benchmark.h> | ||
#include <ccmath/ccmath.hpp> | ||
#include <cmath> | ||
|
||
namespace bm = benchmark; | ||
|
||
// NOLINTBEGIN | ||
|
||
static void BM_basic_fdim_std(benchmark::State& state) { | ||
for ([[maybe_unused]] auto _ : state) { | ||
benchmark::DoNotOptimize(std::fdim(state.range(0), state.range(1))); | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fdim_ccmath(benchmark::State& state) { | ||
for ([[maybe_unused]] auto _ : state) { | ||
benchmark::DoNotOptimize(ccm::fdim(state.range(0), state.range(1))); | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fdim_rand_int_std(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomIntegers = ran.generateRandomIntegers(state.range(0)); | ||
auto randomIntegers2 = ran.generateRandomIntegers(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomIntegers.size(); ++i) { | ||
benchmark::DoNotOptimize(std::fdim(randomIntegers[i], randomIntegers2[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fdim_rand_int_ccmath(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomIntegers = ran.generateRandomIntegers(state.range(0)); | ||
auto randomIntegers2 = ran.generateRandomIntegers(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomIntegers.size(); ++i) { | ||
benchmark::DoNotOptimize(ccm::fdim(randomIntegers[i], randomIntegers2[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fdim_rand_double_std(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomDoubles = ran.generateRandomDoubles(state.range(0)); | ||
auto randomDoubles2 = ran.generateRandomDoubles(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomDoubles.size(); ++i) { | ||
benchmark::DoNotOptimize(std::fdim(randomDoubles[i], randomDoubles2[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fdim_rand_double_ccmath(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomDoubles = ran.generateRandomDoubles(state.range(0)); | ||
auto randomDoubles2 = ran.generateRandomDoubles(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomDoubles.size(); ++i) { | ||
benchmark::DoNotOptimize(ccm::fdim(randomDoubles[i], randomDoubles2[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
// NOLINTEND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024-Present Ian Pike | ||
* Copyright (c) 2024-Present ccmath contributors | ||
* | ||
* This library is provided under the MIT License. | ||
* See LICENSE for more information. | ||
*/ | ||
|
||
#include "fma.bench.hpp" | ||
|
||
// NOLINTBEGIN | ||
|
||
BENCHMARK(BM_basic_fma_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fma_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fma_rand_int_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fma_rand_int_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fma_rand_double_std)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK(BM_basic_fma_rand_double_ccmath)->RangeMultiplier(2)->Range(8, 8<<10)->Complexity(); | ||
|
||
BENCHMARK_MAIN(); | ||
|
||
// NOLINTEND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2024-Present Ian Pike | ||
* Copyright (c) 2024-Present ccmath contributors | ||
* | ||
* This library is provided under the MIT License. | ||
* See LICENSE for more information. | ||
*/ | ||
|
||
#include "../../helpers/randomizers.hpp" | ||
#include <benchmark/benchmark.h> | ||
#include <ccmath/ccmath.hpp> | ||
#include <cmath> | ||
|
||
namespace bm = benchmark; | ||
|
||
// NOLINTBEGIN | ||
|
||
static void BM_basic_fma_std(benchmark::State& state) { | ||
for ([[maybe_unused]] auto _ : state) { | ||
benchmark::DoNotOptimize(std::fma(state.range(0), state.range(1), state.range(2))); | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fma_ccmath(benchmark::State& state) { | ||
for ([[maybe_unused]] auto _ : state) { | ||
benchmark::DoNotOptimize(ccm::fma(state.range(0), state.range(1), state.range(2))); | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fma_rand_int_std(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomIntegers = ran.generateRandomIntegers(state.range(0)); | ||
auto randomIntegers2 = ran.generateRandomIntegers(state.range(0)); | ||
auto randomIntegers3 = ran.generateRandomIntegers(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomIntegers.size(); ++i) { | ||
benchmark::DoNotOptimize(std::fma(randomIntegers[i], randomIntegers2[i], randomIntegers3[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fma_rand_int_ccmath(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomIntegers = ran.generateRandomIntegers(state.range(0)); | ||
auto randomIntegers2 = ran.generateRandomIntegers(state.range(0)); | ||
auto randomIntegers3 = ran.generateRandomIntegers(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomIntegers.size(); ++i) { | ||
benchmark::DoNotOptimize(ccm::fma(randomIntegers[i], randomIntegers2[i], randomIntegers3[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fma_rand_double_std(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomDoubles = ran.generateRandomDoubles(state.range(0)); | ||
auto randomDoubles2 = ran.generateRandomDoubles(state.range(0)); | ||
auto randomDoubles3 = ran.generateRandomDoubles(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomDoubles.size(); ++i) { | ||
benchmark::DoNotOptimize(std::fma(randomDoubles[i], randomDoubles2[i], randomDoubles3[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
static void BM_basic_fma_rand_double_ccmath(benchmark::State& state) { | ||
ccm::bench::Randomizer ran; | ||
auto randomDoubles = ran.generateRandomDoubles(state.range(0)); | ||
auto randomDoubles2 = ran.generateRandomDoubles(state.range(0)); | ||
auto randomDoubles3 = ran.generateRandomDoubles(state.range(0)); | ||
while (state.KeepRunning()) { | ||
for (size_t i = 0; i < randomDoubles.size(); ++i) { | ||
benchmark::DoNotOptimize(ccm::fma(randomDoubles[i], randomDoubles2[i], randomDoubles3[i])); | ||
} | ||
} | ||
state.SetComplexityN(state.range(0)); | ||
} | ||
|
||
// NOLINTEND |
Empty file.
Empty file.
Oops, something went wrong.