Changes

Jump to: navigation, search

GPU621/Analyzing False Sharing

166 bytes added, 15:29, 24 November 2022
no edit summary
cout << "number.num2:" << number.num2 << endl;
}
 
int main() {
Number number = { 0, 0 };
In this program code, we can easily see that the Number struct has two member variables (num1 and num2). They are for loop in two different threads to execute the increment operator 1000000 times. This time we use Linux with multiple cores to compile (note that here we are not using any optimization)
 
g++ -std=c++11 -pthread false_sharing.cpp
 
This is the result after running:
[[File:LinuxOutput.jpg|400px]]<br />
[[File:LinuxOutput3.jpg|400px]]<br />
We can see from this result that the runtime is actually unstable and takes a long time.
118
edits

Navigation menu