From b1fa386c119c4a26c0a2ee2910eb4571322355d5 Mon Sep 17 00:00:00 2001
From: Sylvie <76458234+x02Sylvie@users.noreply.github.com>
Date: Tue, 4 Apr 2023 21:50:15 +0200
Subject: [PATCH] Update ggml.c

Prefetch data used later in the loop
---
 ggml.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ggml.c b/ggml.c
index 59e84ab45d120..fe65b86056064 100644
--- a/ggml.c
+++ b/ggml.c
@@ -1975,6 +1975,10 @@ static void ggml_vec_dot_q4_0(const int n, float * restrict s, const void * rest
 
         // This loop will be unrolled by the compiler    
         for (int u=0;u<UNROLL_COUNT;u++)  {
+            // Prefetch data used later in the loop
+            // TODO these numbers are device dependent shouldn't be hard coded derive
+            _mm_prefetch ( x[i+u].qs + 32*20, 1);	// to-do: document what 32*20 even is	
+	
             /* Compute combined scale for the block */ 
             const __m256 scale = _mm256_mul_ps( 
                     _mm256_broadcast_ss( &x[i+u].d ),