Skip to content

LLM inference in C/C++

C++ ggml

sycl: coalesce the ssm_conv window loads (#26612)

Titaniumtownf8e30266d23f
diff --git a/ggml/src/ggml-sycl/ssm_conv.cpp b/ggml/src/ggml-sycl/ssm_conv.cpp
index e55223586a..3eafa1a680 100644
--- a/ggml/src/ggml-sycl/ssm_conv.cpp
+++ b/ggml/src/ggml-sycl/ssm_conv.cpp
@@ -36,9 +36,13 @@ static void kernel_ssm_conv(
return;
}
- const int channel = static_cast<int>(idx % d_inner);
- const int token = static_cast<int>((idx / d_inner) % n_t);
- const int seq = static_cast<int>(idx / (static_cast<size_t>(d_inner) * static_cast<size_t>(n_t)));
+ // src has the tokens of one channel contiguous, dst has the channels of one
+ // token contiguous, so either the loads or the store must be strided. Indexing
+ // token-fastest coalesces the d_conv loads, which measured faster except for
+ // short, cache-resident rows.
+ const int token = static_cast<int>(idx % n_t);
+ const int channel = static_cast<int>((idx / n_t) % d_inner);
+ const int seq = static_cast<int>(idx / (static_cast<size_t>(n_t) * static_cast<size_t>(d_inner)));
const float *s = src_data
+ static_cast<size_t>(seq) * static_cast<size_t>(src_stride_seq)