Changes

Jump to: navigation, search

DPS921/Group 8

176 bytes added, 03:04, 28 November 2018
Padding
#include <omp.h>
#include "pch.h"
 
using namespace std::chrono;
struct MyStruct
{ float int value; int padding[2415]; };
int main(int argc, char** argv){
MyStruct testArr[4];
int threads_usedvalue[4] = {};  omp_set_num_threads(14);
double start_time = omp_get_wtime();
#pragma omp parallel for
for (int i = 0; i < 4; i++) {
 
testArr[i].value = 0;
#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 + 21;
}
}
 
std::cout << "testArr value 1: " << testArr[0].value << std::endl;
std::cout << "testArr value 2: " << testArr[1].value << std::endl;
std::cout << "testArr value 3: " << testArr[2].value << std::endl;
std::cout << "testArr value 4: " << testArr[3].value << std::endl;
 
double time = omp_get_wtime() - start_time;
return 0;
}
 
</nowiki>
____________________________________________________________________________________________________________________________________________________________
[[File:1threads_paddingpadding.jpg|1000px]]  [[File:2threads_padding.jpg|1000px]]  [[File:3threads_padding.jpg|1000px]]  [[File:4threads_padding.jpgpng|1000px]]
== '''Critical construct''' ==
42
edits

Navigation menu