Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- #include <stdlib.h>
- using namespace std;
- double coeficientes[] = { 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25,
- 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25,0.25,0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25 };
- void funcion1()
- {
- double mag = 10.0;
- for (int i = 0; i < 320000; i++)
- {
- for (int i = 0; i < 80; i++) {
- coeficientes[i] = coeficientes[i] / mag;
- }
- }
- }
- void funcion2()
- {
- double mag = 10.0;
- for (int i = 0; i < 320000; i++)
- {
- #pragma omp simd
- for (int i = 0; i < 80; i++) {
- coeficientes[i] = coeficientes[i] / mag;
- }
- }
- }
- int main()
- {
- auto start = std::chrono::system_clock::now();
- funcion1();
- funcion2();
- auto end = std::chrono::system_clock::now();
- std::chrono::duration<double> elapsed = end - start;
- std::cout << "Elapsed timeA: " << elapsed.count() << "s" << endl;
- start = std::chrono::system_clock::now();
- thread t1(funcion1);
- thread t2(funcion2);
- t1.join();
- t2.join();
- end = std::chrono::system_clock::now();
- elapsed = end - start;
- std::cout << "Elapsed timeB: " << elapsed.count() << "s \n\n";
- cout << "Main es el hilo principal" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement