public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Reduce cache misses for source_gemm_r
@ 2018-10-19  3:10 Max Bruce
  2018-10-19  8:18 ` Patrick Alken
  0 siblings, 1 reply; 2+ messages in thread
From: Max Bruce @ 2018-10-19  3:10 UTC (permalink / raw)
  To: gsl-discuss

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

Hey guys,

I'm new to contributing to GNU projects, but... I'm guessing I send
commits through here? Would appreciate some sort of note on the
procedure on the website

I noticed that your matrix multiplication code had bad cache
performance due to a misordering of a loop. In a replicated version of
my change, I saw about 20% performance gains on my AMD FX CPU.

Do let me know if this is not the correct contribution procedure.

-Max

[-- Attachment #2: 0001-Reduce-cache-misses-for-source_gemm_r.patch --]
[-- Type: text/x-patch, Size: 1622 bytes --]

From 0345eaf2eb48997fa3d00fae2b37cf416d3713d4 Mon Sep 17 00:00:00 2001
From: JavaProphet <max.bruce12@gmail.com>
Date: Thu, 18 Oct 2018 20:00:47 -0700
Subject: [PATCH] Reduce cache misses for source_gemm_r

---
 cblas/source_gemm_r.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cblas/source_gemm_r.h b/cblas/source_gemm_r.h
index a008d22..7c9848e 100644
--- a/cblas/source_gemm_r.h
+++ b/cblas/source_gemm_r.h
@@ -71,8 +71,8 @@
 
     /* form  C := alpha*A*B + C */
 
-    for (k = 0; k < K; k++) {
-      for (i = 0; i < n1; i++) {
+    for (i = 0; i < n1; i++) {
+      for (k = 0; k < K; k++) {
         const BASE temp = alpha * F[ldf * i + k];
         if (temp != 0.0) {
           for (j = 0; j < n2; j++) {
@@ -86,8 +86,8 @@
 
     /* form  C := alpha*A*B' + C */
 
+  for (j = 0; j < n2; j++) {
     for (i = 0; i < n1; i++) {
-      for (j = 0; j < n2; j++) {
         BASE temp = 0.0;
         for (k = 0; k < K; k++) {
           temp += F[ldf * i + k] * G[ldg * j + k];
@@ -98,8 +98,8 @@
 
   } else if (TransF == CblasTrans && TransG == CblasNoTrans) {
 
+  for (i = 0; i < n1; i++) {
     for (k = 0; k < K; k++) {
-      for (i = 0; i < n1; i++) {
         const BASE temp = alpha * F[ldf * k + i];
         if (temp != 0.0) {
           for (j = 0; j < n2; j++) {
@@ -111,8 +111,8 @@
 
   } else if (TransF == CblasTrans && TransG == CblasTrans) {
 
+  for (j = 0; j < n2; j++) {
     for (i = 0; i < n1; i++) {
-      for (j = 0; j < n2; j++) {
         BASE temp = 0.0;
         for (k = 0; k < K; k++) {
           temp += F[ldf * k + i] * G[ldg * j + k];
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Reduce cache misses for source_gemm_r
  2018-10-19  3:10 Reduce cache misses for source_gemm_r Max Bruce
@ 2018-10-19  8:18 ` Patrick Alken
  0 siblings, 0 replies; 2+ messages in thread
From: Patrick Alken @ 2018-10-19  8:18 UTC (permalink / raw)
  To: gsl-discuss

Thanks Max, this is fine. I will take a look at your patch as soon as I can.

On 10/19/2018 05:10 AM, Max Bruce wrote:
> Hey guys,
>
> I'm new to contributing to GNU projects, but... I'm guessing I send
> commits through here? Would appreciate some sort of note on the
> procedure on the website
>
> I noticed that your matrix multiplication code had bad cache
> performance due to a misordering of a loop. In a replicated version of
> my change, I saw about 20% performance gains on my AMD FX CPU.
>
> Do let me know if this is not the correct contribution procedure.
>
> -Max



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-19  8:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-19  3:10 Reduce cache misses for source_gemm_r Max Bruce
2018-10-19  8:18 ` Patrick Alken

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).