I was taking a look at the barrier implementation for OpenMPI and see that they are using a sort of logN tree-based algorithm, but I'm having some trouble grokking the implementation.
Seems like a bitmask and the highest set bit for the current rank is used to determine "peers" but I'm not sure how exactly that translates to a tree barrier, e.g. as described here.