Avatar ·

How to achieve the theoretical maximum of 4 FLOP/cycle on modern x86-64 processors?

Hello everyone! I'm a beginner C++ developer and recently came across an article about the theoretical performance limit of floating-point computations. It said that modern processors (e.g., Intel Core i7 or AMD Ryzen) are capable of performing up to 4 floating-point operations (FLOP) per cycle. But I can't seem to get anywhere near this figure. Here's my simple test: I'm summing two large arrays of double numbers (10 million elements each) in a loop. The code looks like this: ```cpp #include #include #include int main() { const size_t N = 10'000'000; std::vector a(N, 1.0); std::vector b(N, 2.0); std::vector c(N, 0.0); auto start = std::chrono::high_resolution_clock::now(); for (size_t i = 0; i < N;