Improves some sync barrier placements

This commit is contained in:
aendk
2026-05-15 17:53:43 +02:00
parent 378e8e7aae
commit 568376390d
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -73,10 +73,10 @@ static __global__ void k_bin_bcast(const src0_t * src0,
const size_t i_src1 = i13*s13 + i12*s12 + i11*s11;
const size_t i_dst = i3*s3 + i2*s2 + i1*s1;
ggml_cuda_pdl_sync();
const src0_t * src0_row = src0 ? (src0 + i_src0) : nullptr;
dst_t * dst_row = dst + i_dst;
ggml_cuda_pdl_sync();
for (int i0 = i0s; i0 < ne0; i0 += blockDim.x * gridDim.x) {
const uint32_t i10 = fastmodulo(i0, ne10);
@@ -141,12 +141,12 @@ static __global__ void k_bin_bcast_unravel(const src0_t * src0,
const size_t i_src1 = i13*s13 + i12*s12 + i11*s11;
const size_t i_dst = i3*s3 + i2*s2 + i1*s1;
ggml_cuda_pdl_sync();
const src0_t * src0_row = src0 ? (src0 + i_src0) : nullptr;
dst_t * dst_row = dst + i_dst;
const int i10 = fastmodulo(i0, ne10);
ggml_cuda_pdl_sync();
float result = src0_row ? (float) src0_row[i0*s00] : 0.0f;
if constexpr (sizeof...(src1_ptrs) > 0) {
result = (..., (result = bin_op(result, (float)src1s[i_src1 + i10*s10])));
+1 -1
View File
@@ -629,7 +629,6 @@ static __global__ void flash_attn_mask_to_KV_max(
const int tid = threadIdx.x;
const int sequence = blockIdx.y;
const int jt = blockIdx.x;
ggml_cuda_pdl_sync();
mask += sequence*s33 + jt*ncols1*s31;
@@ -637,6 +636,7 @@ static __global__ void flash_attn_mask_to_KV_max(
if (tid < WARP_SIZE) {
buf_iw[tid] = 1;
}
ggml_cuda_pdl_sync();
__syncthreads();
int KV_max_sj = (ne30 - 1) * FATTN_KQ_STRIDE;
+2 -2
View File
@@ -13,12 +13,12 @@ static __global__ void norm_f32(
const int sample = blockIdx.z;
const int tid = threadIdx.x;
ggml_cuda_pdl_sync();
x += sample*stride_sample + channel*stride_channel + row*stride_row;
dst += ((sample*nchannels + channel)*nrows + row)*ncols;
float2 mean_var = make_float2(0.0f, 0.0f);
ggml_cuda_pdl_sync();
for (int col = tid; col < ncols; col += block_size) {
const float xi = x[col];
mean_var.x += xi;
@@ -160,7 +160,6 @@ static __global__ void rms_norm_back_f32(
const int row = blockIdx.x*blockDim.y + threadIdx.y;
const int tid = threadIdx.x;
ggml_cuda_pdl_sync();
grad += int64_t(row)*ncols;
xf += int64_t(row)*ncols;
dst += int64_t(row)*ncols;
@@ -168,6 +167,7 @@ static __global__ void rms_norm_back_f32(
float sum_xx = 0.0f; // sum for squares of x, equivalent to forward pass
float sum_xg = 0.0f; // sum for x * gradient, needed because RMS norm mixes inputs
ggml_cuda_pdl_sync();
for (int col = tid; col < ncols; col += block_size) {
const float xfi = xf[col];
sum_xx += xfi * xfi;