Determine max across a warp;

I want to determine max value-vertex pair across a warp.

  1. if value is greater the then the pair is greater

  2. if two pair has same value then pair with greater vertex is greater

Is anything wrong with the code ? Please point it out if you see it.

// Use __shfl_xor to perform butterfly reduction
    int vertex= random integer;
    float value= random floating point number;
    for (int i = 16; i >= 1; i /= 2) {

        float rec_value = __shfl_xor(value, i, 32); //float

        int rec_vertex = __shfl_xor(vertex, i, 32); // integer

        if (rec_value > value) {
            value = rec_value;
            vertex = rec_vertex;
        } else if (rec_value == value) { // give priority to higher indexed vertex

            if (rec_vertex > vertex) {

                vertex = rec_vertex;
                value = rec_value;
            }

        }
    }