Changes

Jump to: navigation, search

DPS921/Group 8

984 bytes added, 09:36, 26 November 2018
Padding
[[File:Cacheline2.jpeg]]
 
____________________________________________________________________________________________________________________________________________________________
//Test.cpp Test padding excution time
 
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <chrono>
#include <algorithm>
#include <omp.h>
#include "pch.h"
using namespace std::chrono;
 
struct MyStruct
{
float value;
int padding[24];
};
 
int main(int argc, char** argv)
{
MyStruct testArr[4];
 
omp_set_num_threads(3);
double start_time = omp_get_wtime();
 
#pragma omp parallel for
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10000; j++) {
//#pragma omp critical
testArr[i].value = testArr[i].value + 2;
}
 
}
 
double time = omp_get_wtime() - start_time;
std::cout << "Execution Time: " << time << std::endl;
 
return 0;
}
 
____________________________________________________________________________________________________________________________________________________________
== Synchronization ==
42
edits

Navigation menu