40 #define USE_SCALAR_SINCOS
49 static const float upper = 40000.f;
57 #ifdef USE_SCALAR_SINCOS
69 #ifdef USE_SCALAR_SINCOS
92 <<
"------------------------------------------------------------\n"
93 << std::setw(15) <<
"fu(x_i)"
94 << std::setw(15) <<
"FD fu'(x_i)"
95 << std::setw(15) <<
"SYM fu'(x)"
96 << std::setw(15) <<
"error %\n";
99 << std::setw(15) << y_points[i]
101 << std::setw(15) <<
dfu(x_points[i])
106 << std::setw(15) << y_points[N - 1]
108 << std::setw(15) <<
dfu(x_points[N - 1])
130 const float oneOver2h = 0.5f /
h;
133 dy_points[0] = (y_points[1] - y_points[0]) /
h;
136 for (
int i = 1; i <
N - 1; ++i) {
137 dy_points[i] = (y_points[i + 1] - y_points[i - 1]) * oneOver2h;
139 dy_points[N - 1] = (y_points[N - 1] - y_points[N - 2]) /
h;
143 std::cout <<
"\n" << std::setw(60) <<
"Classical finite difference method" << std::endl;
146 const float oneOver2h = 0.5f /
h;
149 dy_points[0] = (y_points[1] - y_points[0]) /
h;
152 for (
int i = 1; i <
N - 1; ++i) {
153 dy_points[i] = (y_points[i + 1] - y_points[i - 1]) * oneOver2h;
155 dy_points[N - 1] = (y_points[N - 1] - y_points[N - 2]) /
h;
159 std::cout <<
"cycle count: " << timer.
Cycles()
160 <<
" | " <<
static_cast<double>(N * 2) / timer.
Cycles() <<
" FLOP/cycle"
161 <<
" | " <<
static_cast<double>(N * 2 *
sizeof(float)) / timer.
Cycles() <<
" Byte/cycle"
167 std::cout << std::setw(60) <<
"Vectorized finite difference method" << std::endl;
176 dy_points[0] = (y_points[1] - y_points[0]) /
h;
239 std::cout <<
"cycle count: " << timer.
Cycles()
240 <<
" | " <<
static_cast<double>(
N * 2) / timer.
Cycles() <<
" FLOP/cycle"
241 <<
" | " <<
static_cast<double>(
N * 2 *
sizeof(float)) / timer.
Cycles() <<
" Byte/cycle"
244 speedup /= timer.
Cycles();
245 std::cout <<
"Speedup: " << speedup <<
"\n";
_VC_CONSTEXPR size_t vectorsCount() const
Vc::Memory< float_v, N > y_points
static const float epsilon
_VC_CONSTEXPR size_t entriesCount() const
Vc::Memory< float_v, N > x_points
unsigned long long Cycles() const
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
Vc_ALWAYS_INLINE void prefetchForOneRead(const void *addr)
Prefetch the cacheline containing addr for a single read access.
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlag > vector(size_t i)
float *VC_RESTRICT dy_points
A helper class for fixed-size two-dimensional arrays.
int main(int argc, char **argv)
Main program.
VECTOR_NAMESPACE::float_v float_v
static float dfu(float x)
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlag > lastVector()