performance - How can I get my CPU's branch target buffer(BTB) size? -
it's useful when execute routine when loops > btb_size, eg,
from
int n = 0; (int = 0; < loops; i++) n++;
to
int n = 0; int loops = loops / 2; for(int = 0; < loops; i+=2) n += 2;
can reduce branch misses.
btb ref:http://www-ee.eng.hawaii.edu/~tep/ee461/notes/ilp/buffer.html doesn't tell how btb size.
any modern compiler worth salt should optimise code int n = loops;
, in more complex example, compiler take care of such optimisation; see llvm's auto-vectorisation, instance, handles many kinds of loop unrolling. rather trying optimise code, find appropriate compiler flags compiler hard work.
Comments
Post a Comment