Reputation: 9095
In HTSlib, Bonfield memory aligns a series of methods to 32. Why did he do this and what does it achieve?
So, for example here there's this code:
if (type == 'c') {
if (!(q = sam_parse_Bc_vals(b, q, &nused, &nalloc, &overflow)))
return -1;
} else if (type == 'C') {
if (!(q = sam_parse_BC_vals(b, q, &nused, &nalloc, &overflow)))
return -1;
} else if (type == 's') {
if (!(q = sam_parse_Bs_vals(b, q, &nused, &nalloc, &overflow)))
return -1;
} else if (type == 'S') {
//... etc.
}
And if you look at the function definitions, you see this:
HTS_ALIGN32
static char *sam_parse_Bc_vals(bam1_t *b, char *q, uint32_t *nused,
uint32_t *nalloc, int *overflow) {
while (*q == ',') {
if ((*nused)++ >= (*nalloc)) {
if (grow_B_array(b, nalloc, 1) < 0)
return NULL;
}
*(b->data + b->l_data) = hts_str2int(q + 1, &q, 8, overflow);
b->l_data++;
}
return q;
}
That HTS_ALIGN32
is a macro for #define HTS_ALIGN32 __attribute__((aligned(32)))
What performance limitation does this overcome? (Or is there another reason that he did this?)
Upvotes: 2
Views: 112