diff --git a/.gitignore b/.gitignore index 995238a..2f7144e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *~ debug* release* +*.csv *.out *.err *.log diff --git a/inc/core/benchmark_data.hpp b/inc/core/benchmark_data.hpp index 54f7c19..0799080 100644 --- a/inc/core/benchmark_data.hpp +++ b/inc/core/benchmark_data.hpp @@ -14,12 +14,47 @@ #include #pragma GCC diagnostic pop +#include +#include #include #include -#include namespace gearshifft { + template + struct BenchmarkDataGenerator { + BenchmarkDataGenerator(const std::size_t) {} + + RealType operator()() { + return 0.125 * (i_++ & 7); + } + + private: + std::size_t i_ = 0; + }; + + // To avoid overflows float16 data non-zero points are limited (y[0] of FFT(x) + // is sum of input values). Overflow leads to nan or inf values and iFFT(FFT()) + // cannot be validated. This method still leads to nan's when size_ >= (1<<20). + template <> + struct BenchmarkDataGenerator { + BenchmarkDataGenerator(const std::size_t size) + : sparse_values_(size > LIMIT16), quotient_(size / LIMIT16) {} + + float16 operator()() { + if (sparse_values_) { + return static_cast((i_++ % quotient_ == 0) ? 0.1 : 0.0); + } + return static_cast(0.125 * (i_++ & 7)); + } + + private: + std::size_t i_ = 0; + const bool sparse_values_; + const std::size_t quotient_; + static constexpr std::size_t LIMIT16 = 1 << 15; + }; + /** * Singleton test data helper and container. * Creates real and complex data on first access or when dimensions have changed. @@ -39,6 +74,7 @@ namespace gearshifft { using ComplexVector = std::vector >; + using Generator = BenchmarkDataGenerator; static const BenchmarkDataT& data(const Extent& extents) { @@ -102,26 +138,7 @@ namespace gearshifft { // allocate variables for all test cases data_linear_.resize(size_); - const size_t limit16 = 1<<15; - if(std::is_same::value && size_ > limit16) { - // To avoid overflows float16 data non-zero points are limited - // (y[0] of FFT(x) is sum of input values) - // Overflow leads to nan or inf values and iFFT(FFT()) cannot be validated - // This method still leads to nan's when size_ >= (1<<20) - for( size_t i=0; i; using Precisions = gearshifft::DefaultPrecisionsWithoutHalfPrecision; using FFT_Is_Normalized = std::false_type; + #elif defined(ROCFFT_ENABLED) #include "libraries/rocfft/rocfft.hpp"