Flushing the cache is easy: just read 4MB (or whatever your L3 cache size is) of some dummy data and pretty much everything you had cached before would be kicked out.
At the same time, resetting the branch predictor AFAIK can only be done by powering the CPU off and on again.