Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define BIT_MASK(a, b) (size_t)(((size_t) -1 >> ((sizeof(size_t)*8) \
- - (b))) & ~((1U << (a)) - 1))
- unsigned address_to_set(size_t address) {
- return ((address & BIT_MASK(6, 12)) >> 6);
- }
- typedef struct item_t {
- double a1;
- double b2;
- double c3;
- double d4;
- double e5;
- double f6;
- double g7;
- double h8;
- int dummy; // padding
- };
- void mul()
- {
- struct item_t item[1024];
- /*
- * 64 will make it jump to the next cache line in same
- * set when the dummy variable is not present
- *
- * */
- int i;
- for (i=0; i<1024; i+=64) {
- item[i].b2 = 23;
- #ifdef DEBUG
- printf("%p\t%d\n", &(item[i]), address_to_set(&item[i]));
- #endif
- }
- ;
- for (i=0; i<1024; i+=64) {
- item[i].h8 = 23;
- #ifdef DEBUG
- printf("%p\t%d\n", &(item[i]), address_to_set(&item[i]));
- #endif
- }
- }
- int main(void)
- {
- mul();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement