Last active
August 29, 2015 14:17
-
-
Save kelindar/68b678576ff9f18763cf to your computer and use it in GitHub Desktop.
Data Locality: Reputation Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Program A: some account with associated reputation | |
| struct Account { | |
| long id; | |
| char[64] name; | |
| char[300] address; | |
| float reputation; | |
| } | |
| // we want to update and add some reputation every day | |
| void increaseReputation(){ | |
| parallel for (int i=0; i<count; i++){ | |
| account->reputation += 2.5; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Program B: we have a split account | |
| struct Account { | |
| long id; | |
| AccountInfo *info; | |
| float reputation; | |
| } | |
| struct AccountInfo { | |
| char[64] name; | |
| char[300] address; | |
| } | |
| // we want to update and add some reputation every day | |
| void increaseReputation(){ | |
| parallel for (int i=0; i<count; i++){ | |
| account->reputation += 2.5; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment