forked from MeghanaGudaram/HighPerformanceComputing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlops.cpp
More file actions
39 lines (31 loc) · 914 Bytes
/
Flops.cpp
File metadata and controls
39 lines (31 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <omp.h>
#include <immintrin.h>
#include <iostream>
#include<chrono>
#include<ctime>
__m256 fma()
{
__m256 x = _mm256_setr_ps (1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 8.2);
__m256 y = _mm256_setr_ps (10.1, 20.1, 30.1, 40.1, 50.1, 60.1, 70.1, 80.1);
__m256 z = _mm256_setr_ps (1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1);
for (long long i=0; i< 10000000; ++i)
{
z= _mm256_fmadd_ps(x, y, z);
}
return z;
}
int main ()
{
using namespace std::chrono;
#pragma omp parallel
{
high_resolution_clock::time_point t1 = high_resolution_clock::now();
__m256 a=fma();
high_resolution_clock::time_point t2 = high_resolution_clock::now();
duration<double> time_span = duration_cast<duration<double>> (t2 - t1);
std::cout << "Time taken for 10^7 flops : " << time_span.count()*1000000 << " useconds.";
std::cout<<std::endl;
}
return 0;
}