Skip to content

Commit eed3fd4

Browse files
committed
parallel : count cache misses
1 parent 8a9aca3 commit eed3fd4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

examples/parallel/parallel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ int main(int argc, char ** argv) {
135135

136136
int32_t n_total_prompt = 0;
137137
int32_t n_total_gen = 0;
138+
int32_t n_cache_miss = 0;
138139

139140
const auto t_main_start = ggml_time_us();
140141

@@ -272,6 +273,8 @@ int main(int argc, char ** argv) {
272273

273274
LOG("%s : failed to decode batch, retrying with n_batch = %d\n", __func__, n_batch / 2);
274275

276+
n_cache_miss += 1;
277+
275278
// retry with half the batch size to try to find a free slot in the KV cache
276279
n_batch /= 2;
277280
i -= n_batch;
@@ -349,6 +352,7 @@ int main(int argc, char ** argv) {
349352
LOG_TEE("Total prompt tokens: %6d, speed: %5.2f t/s\n", n_total_prompt, (double) (n_total_prompt ) / (t_main_end - t_main_start) * 1e6);
350353
LOG_TEE("Total gen tokens: %6d, speed: %5.2f t/s\n", n_total_gen, (double) (n_total_gen ) / (t_main_end - t_main_start) * 1e6);
351354
LOG_TEE("Total speed (AVG): %6s speed: %5.2f t/s\n", "", (double) (n_total_prompt + n_total_gen) / (t_main_end - t_main_start) * 1e6);
355+
LOG_TEE("Cache misses: %6d\n", n_cache_miss);
352356

353357
LOG_TEE("\n\n");
354358

0 commit comments

Comments
 (0)