def round_up(n, size):
    """
    Round an integer to next power of size. Size must be power of 2.
    """
    assert size & (size - 1) == 0, "size is not power of 2"
    return ((n - 1) | (size - 1)) + 1