typedef struct Type {
uint32_t v[2];
} Type;
memcpy1(){
...
for(...) {
b[i].v[0] = a[i].v[0];
b[i].v[1] = a[i].v[1];
b[i+1].v[0] = a[i+1].v[0];
b[i+1].v[1] = a[i+1].v[1];
}
...
}
memcpy2() {
...
for(...) {
uint32_t v1 = a[i].v[0];
uint32_t v2 = a[i].v[1];
uint32_t v3 = a[i+1].v[0];
uint32_t v4 = a[i+1].v[1];
b[i].v[0] = v1;
b[i].v[1] = v2;
b[i+1].v[0] = v3;
b[i+1].v[1] = v4;
}
...
}
Instrumentsを使った計測での比較
TIME | time | L2_RQSTS.ALL_DEMAND_MISS | MEM_LOAD_RETIRED.L1_MISS | MEM_LOAD_RETIRED.L2_MISS |
---|---|---|---|---|
memcpy1 | 5365ms | 13,478,515 | 218,870 | 572,849,861 |
memcpy2 | 3604ms | 1,730,475 | 80,561 | 3,698,854 |