Repository: ggerganov/llama.cpp
File: ggml/src/ggml-cuda/solve_tri.cu (CUDA)

Code before:

        if (lane == row) {
            float diag = sA[row * n + row];
            float idiv = 1.0f / diag;
            x_low = fmaf(sum, -idiv, x_low * idiv);
        }
    }

#pragma unroll
    for (int row = half; row < n; ++row) {
        float sum = fmaf(sA[row * n + lane], x_low, 0.0f);
        int j = half + lane;
        if (j < row) {
            sum = fmaf(sA[row * n + j], x_high, sum);
        }
        sum = warp_reduce_sum(sum);

        int updater = row - half;
        if (lane == updater) {
            float diag = sA[row * n + row];
            float idiv = 1.0f / diag;
            x_high = fmaf(sum, -idiv, x_high * idiv);
        }
    }

#pragma unroll 2
    for (int rr = 0; rr < 2; ++rr) {
        int row = rr * WARP_SIZE + lane;
        if (row < n) {
            float val = (row < half) ? x_low : x_high;
            X_batch[row * k + col_idx] = val;
        }
    }
}
#ifdef __clang__
#    pragma clang diagnostic pop
#endif  // __clang__

static void solve_tri_f32_cuda(const float * A,
                               const float * B,
                               float *       X,
                               int           n,
                               int           k,
                               int64_t       ne02,
                               int64_t       ne03,
                               size_t        nb02,
                               size_t        nb03,
                               size_t        nb12,
                               size_t        nb13,
                               size_t        nb2,
                               size_t        nb3,

Review comment (suggestion):
```suggestion
#pragma unroll
```

This is not a correct use of the directive.

Code after:

        if (lane == row) {
            x_low = (x_low - sum) / sA[row * n + row];
        }
    }

#pragma unroll
    for (int row = half; row < n; ++row) {
        float sum = sA[row * n + lane] * x_low;
        const int j = half + lane;
        if (j < row) {
            sum += sA[row * n + j] * x_high;
        }
        sum = warp_reduce_sum(sum);

        if (lane == row - half) {
            x_high = (x_high - sum) / sA[row * n + row];
        }
    }

#pragma unroll
    for (int rr = 0; rr < 2; ++rr) {
        const int row = rr * WARP_SIZE + lane;
        if (row < n) {
            const float val = (row < half) ? x_low : x_high;
            X_batch[row * k + col_idx] = val;
        }
    }
}
#ifdef __clang__
#    pragma clang diagnostic pop
#endif  // __clang__

static void solve_tri_f32_cuda(const float * A,
                               const float * B,
                               float *       X,
                               int           n,
                               int           k,
                               int64_t       ne02,
                               int64_t       ne03,
                               size_t        nb02,
                               size_t        nb03,
                               size_t        nb12,
                               size_t        nb13,
                               size_t        nb2,
                               size_t        nb3,
                               cudaStream_t  stream) {
    const uint3 ne02_fd = init_fastdiv_values((uint32_t) ne02);
    dim3        threads(WARP_SIZE, k);
    dim3        grid(ne02 * ne03);
    if (n == 64) {