-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended current benchmark tool with support to benchmark of libm functions. Libm benchmark is enabled in all functions listed in benchlibm.cpp. It interfaces with the rest of the existing tool through benchmark_callers_libm.hpp (defines macros which simplify how the list of functions to benchmark looks like as it groups functions by precision/accuracy/variant). The tool is integrated with SLEEF via CMake, meaning it can be built automatically when SLEEF is built. To enable that, pass CMake argument -DSLEEF_BUILD_BENCH=ON and -DSLEEF_BUILD_BENCH_REF=ON. Note this option is only enabled on Linux OS.
- Loading branch information
1 parent
b56eab1
commit 0633394
Showing
9 changed files
with
182 additions
and
10 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
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
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
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
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,69 @@ | ||
// Copyright Naoki Shibata and contributors 2024. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include "benchmark_callers_libm.hpp" | ||
#include <math.h> | ||
|
||
// ======================TRIG========================== | ||
// sin on different intervals | ||
BENCH_SCALAR(sin, 0, 6.28); | ||
BENCH_SCALAR(sin, 0, 1e+6); | ||
BENCH_SINGLE_SCALAR(sin, 0, 1e20); | ||
BENCH_DOUBLE_SCALAR(sin, 0, 1e+100); | ||
|
||
// cos on different intervals | ||
BENCH_SCALAR(cos, 0, 6.28); | ||
BENCH_SCALAR(cos, 0, 1e+6); | ||
BENCH_SINGLE_SCALAR(cos, 0, 1e20); | ||
BENCH_DOUBLE_SCALAR(cos, 0, 1e+100); | ||
|
||
// tan on different intervals | ||
BENCH_SCALAR(tan, 0, 6.28); | ||
BENCH_SCALAR(tan, 0, 1e+6); | ||
BENCH_SINGLE_SCALAR(tan, 0, 1e20); | ||
BENCH_DOUBLE_SCALAR(tan, 0, 1e+100); | ||
|
||
BENCH_SCALAR_VOID_3ARGS(sincos, 0, 6.28); | ||
BENCH_SCALAR_VOID_3ARGS(sincos, 0, 1e+6); | ||
BENCH_SINGLE_SCALAR_VOID_3ARGS(sincos, 0, 1e20); | ||
BENCH_DOUBLE_SCALAR_VOID_3ARGS(sincos, 0, 1e+100); | ||
|
||
// inverse trig | ||
BENCH_SCALAR(asin, -1.0, 1.0); | ||
BENCH_SCALAR(acos, -1.0, 1.0); | ||
BENCH_SCALAR(atan, -10, 10); | ||
BENCH_SCALAR_2ARGS(atan2, -10, 10) | ||
|
||
// ======================NON TRIG========================== | ||
// log | ||
BENCH_SINGLE_SCALAR(log, 0, 1e+38); | ||
BENCH_DOUBLE_SCALAR(log, 0, 1e+100); | ||
|
||
BENCH_SINGLE_SCALAR(log2, 0, 1e+38); | ||
BENCH_DOUBLE_SCALAR(log2, 0, 1e+100); | ||
|
||
BENCH_SINGLE_SCALAR(log10, 0, 1e+38); | ||
BENCH_DOUBLE_SCALAR(log10, 0, 1e+100); | ||
|
||
BENCH_SINGLE_SCALAR(log1p, 0, 1e+38); | ||
BENCH_DOUBLE_SCALAR(log1p, 0, 1e+100); | ||
|
||
// exp | ||
BENCH_SINGLE_SCALAR(exp, -700, 700); | ||
BENCH_DOUBLE_SCALAR(exp, -700, 700); | ||
|
||
BENCH_SINGLE_SCALAR(exp2, -100, 100); | ||
BENCH_DOUBLE_SCALAR(exp2, -700, 700); | ||
|
||
BENCH_SINGLE_SCALAR(exp10, -100, 100); | ||
BENCH_DOUBLE_SCALAR(exp10, -700, 700); | ||
|
||
BENCH_SINGLE_SCALAR(expm1, -100, 100); | ||
BENCH_DOUBLE_SCALAR(expm1, -700, 700); | ||
|
||
// pow | ||
BENCH_SCALAR_2ARGS(pow, -30, 30); | ||
|
||
BENCHMARK_MAIN(); |
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,46 @@ | ||
// Copyright Naoki Shibata and contributors 2024. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#pragma once | ||
#include "benchmark_templates.hpp" | ||
|
||
// Callers for libm - no separate file as its much simpler | ||
// only interested in scalar (i think?) | ||
#define BENCH(funname, funtype, namefilter, min, max) \ | ||
BENCHMARK_CAPTURE(BM_Sleef_templated_function, #funname, funtype funname, min, max) \ | ||
->Name("MB_libm_" #funname "_" #namefilter "_" #min "_" #max); | ||
|
||
#define BENCH_SINGLE_SCALAR(fun, min, max) \ | ||
BENCH(fun, (float (*) (float)), u10_scalarf, min, max); | ||
#define BENCH_DOUBLE_SCALAR(fun, min, max) \ | ||
BENCH(fun, (double (*) (double)), u10_scalard, min, max); | ||
|
||
#define BENCH_SCALAR(fun, min, max) \ | ||
BENCH_SINGLE_SCALAR(fun, min, max); \ | ||
BENCH_DOUBLE_SCALAR(fun, min, max); | ||
|
||
// special case for pow and atan2 | ||
#define BENCH_SINGLE_SCALAR_2ARGS(fun, min, max) \ | ||
BENCH(fun, (float (*) (float, float)), u10_scalarf, min, max); | ||
#define BENCH_DOUBLE_SCALAR_2ARGS(fun, min, max) \ | ||
BENCH(fun, (double (*) (double, double)), u10_scalard, min, max); | ||
|
||
#define BENCH_SCALAR_2ARGS(fun, min, max) \ | ||
BENCH_SINGLE_SCALAR_2ARGS(fun, min, max); \ | ||
BENCH_DOUBLE_SCALAR_2ARGS(fun, min, max); | ||
|
||
|
||
// special case for sincos | ||
#define BENCH_SINGLE_SCALAR_VOID_3ARGS(fun, min, max) \ | ||
BENCH(fun, (void (*)(float, float*, float*)), u10_scalarf, min, max); | ||
#define BENCH_DOUBLE_SCALAR_VOID_3ARGS(fun, min, max) \ | ||
BENCH(fun, (void (*)(double, double*, double*)), u10_scalard, min, max); | ||
|
||
#define BENCH_SCALAR_VOID_3ARGS(fun, min, max) \ | ||
BENCH_SINGLE_SCALAR_VOID_3ARGS(fun, min, max); \ | ||
BENCH_DOUBLE_SCALAR_VOID_3ARGS(fun, min, max); | ||
|
||
|
||
|
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
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
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