Skip to content

Instantly share code, notes, and snippets.

@kelindar
Last active August 29, 2015 14:17
Show Gist options
  • Save kelindar/68b678576ff9f18763cf to your computer and use it in GitHub Desktop.
Save kelindar/68b678576ff9f18763cf to your computer and use it in GitHub Desktop.
Data Locality: Reputation Example
// 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;
}
}
// 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