Skip to content

Commit

Permalink
--avx2-only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dancazarin committed Feb 26, 2024
1 parent 1b42cb4 commit 08afae3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ Requires:
* matplotlib module
* numpy module

## Options

| Option | Description |
|--------------------|-----------------------------------------------------------------|
| `SIZE` | 1D FFT |
| `SIZExSIZE` | 2D FFT. Example: `64x32` |
| `SIZExSIZExSIZE` | 3D FFT. Example: `64x32x16` |
| `--complex flags` | `y` (complex tests), `yn` (all tests), `n` (real tests) |
| `--inverse flags` | `y` (IDFT tests), `ny` (DFT/IDFT tests), `n` (DFT tests) |
| `--inplace flags` | `y` (inplace tests), `ny` (all tests), `n` (out-of-place tests) |
| `--save data.json` | Save results in JSON |
| `--save -` | Print resulting JSON to stdout |
| `--avx2-only` | Enable only AVX2 (supported in KFR, IPP, MKL) |
| `--no-progress` | Disable verbose progress output |
| `--no-banner` | Disable banner |

## Benchmark code license

MIT
13 changes: 9 additions & 4 deletions fftlibs/ipp/ipp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ std::string fft_name()
{
ippInit();
#if defined(__x86_64__) || defined(_M_X64)
ippSetCpuFeatures(ippCPUID_MMX | ippCPUID_SSE | ippCPUID_SSE2 | ippCPUID_SSE3 | ippCPUID_SSSE3 |
ippCPUID_MOVBE | ippCPUID_SSE41 | ippCPUID_SSE42 | ippCPUID_AES | ippCPUID_CLMUL |
ippCPUID_SHA | ippCPUID_AVX | ippAVX_ENABLEDBYOS | ippCPUID_RDRAND | ippCPUID_F16C |
ippCPUID_AVX2 | ippCPUID_MOVBE | ippCPUID_ADCOX | ippCPUID_RDSEED | ippCPUID_PREFETCHW);
if (avx2only)
{
fprintf(stderr, "IPP: enabling AVX2\n");
ippSetCpuFeatures(ippCPUID_MMX | ippCPUID_SSE | ippCPUID_SSE2 | ippCPUID_SSE3 | ippCPUID_SSSE3 |
ippCPUID_MOVBE | ippCPUID_SSE41 | ippCPUID_SSE42 | ippCPUID_AES | ippCPUID_CLMUL |
ippCPUID_SHA | ippCPUID_AVX | ippAVX_ENABLEDBYOS | ippCPUID_RDRAND | ippCPUID_F16C |
ippCPUID_AVX2 | ippCPUID_MOVBE | ippCPUID_ADCOX | ippCPUID_RDSEED |
ippCPUID_PREFETCHW);
}
#endif

const IppLibraryVersion* ver = ippsGetLibVersion();
Expand Down
6 changes: 5 additions & 1 deletion fftlibs/kfr/kfr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const char* library_version_dft();
std::string fft_name()
{
#if defined(__x86_64__) || defined(_M_X64)
kfr::override_cpu(kfr::cpu_t::avx2);
if (avx2only)
{
fprintf(stderr, "KFR: enabling AVX2\n");
kfr::override_cpu(kfr::cpu_t::avx2);
}
#endif
return std::string(kfr::library_version_dft());
}
Expand Down
5 changes: 4 additions & 1 deletion fftlibs/mkl/mkl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
std::string fft_name()
{
#if defined(__x86_64__) || defined(_M_X64)
MKL_Enable_Instructions(MKL_ENABLE_AVX2);
if (avx2only) {
fprintf(stderr, "MKL: enabling AVX2\n");
MKL_Enable_Instructions(MKL_ENABLE_AVX2);
}
#endif
char buf[1024];
MKL_Get_Version_String(buf, sizeof(buf));
Expand Down
4 changes: 3 additions & 1 deletion src/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,6 @@ extern template fft_impl_ptr<float> fft_create<float>(const std::vector<size_t>&
extern template fft_impl_ptr<double> fft_create<double>(const std::vector<size_t>& size, bool is_complex,
bool inverse, bool inplace);

std::string fft_name();
std::string fft_name();

extern bool avx2only;
8 changes: 7 additions & 1 deletion src/fft_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ std::string execfile(std::string command)
static std::string outname;
static bool progress = true;
static bool banner = true;
bool avx2only = false;
static std::vector<std::vector<size_t>> sizes;
static std::vector<bool> is_complex_list{ true, false };
static std::vector<bool> inverse_list{ false, true };
Expand Down Expand Up @@ -282,6 +283,10 @@ int main(int argc, char** argv)
{
banner = true;
}
else if (argv[i] == "--avx2-only"sv)
{
avx2only = true;
}
else if (argv[i] == "--"sv)
{
}
Expand All @@ -304,7 +309,8 @@ int main(int argc, char** argv)
{
printf("FFT/DFT benchmarking tool. Copyright (C) 2016-2024 Dan Cazarin https://www.kfrlib.com\n");
printf("Benchmark source code is MIT-licensed\n");
printf("DFT/FFT libraries have their own licenses. Please refer to the respective source code for details.\n");
printf("DFT/FFT libraries have their own licenses. Please refer to the respective source code for "
"details.\n");

if (sizes.empty())
{
Expand Down

0 comments on commit 08afae3

Please sign in to comment.