You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by ba...@apache.org on 2021/09/07 14:21:16 UTC

[systemds] branch master updated: [MINOR] Move right indexing out of inner loop mLogReg

This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/master by this push:
     new b54a945  [MINOR] Move right indexing out of inner loop mLogReg
b54a945 is described below

commit b54a945ae222c8f0d30e630710ebe65ef9543b49
Author: baunsgaard <ba...@tugraz.at>
AuthorDate: Tue Sep 7 16:16:28 2021 +0200

    [MINOR] Move right indexing out of inner loop mLogReg
    
    Manually moving right indexing out of inner loop in mLogReg.
    Our compiler did not detect that the double inner loop contained a
    right indexing, that could be moved outside the loop.
    this in my small case reduce execution time by a second in small
    cases but 50 sec in 16x and 200 sec in 128x census_enc dataset.
    The relative effect is largest on compressed data, but is also
    showing up in uncompressed execution.
---
 scripts/builtin/multiLogReg.dml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/builtin/multiLogReg.dml b/scripts/builtin/multiLogReg.dml
index e30bfb3..a4fdf6a 100644
--- a/scripts/builtin/multiLogReg.dml
+++ b/scripts/builtin/multiLogReg.dml
@@ -155,6 +155,7 @@ m_multiLogReg = function(Matrix[Double] X, Matrix[Double] Y, Int icpt = 2,
     innerconverge = (sqrt (norm_R2) <= psi * norm_Grad);
     is_trust_boundary_reached = 0;
 
+    P_1K = P [, 1:K]
     while (! innerconverge)
     {
       if (icpt == 2) {
@@ -164,8 +165,8 @@ m_multiLogReg = function(Matrix[Double] X, Matrix[Double] Y, Int icpt = 2,
       else 
         ssX_V = V;
 
-      Q = P [, 1:K] * (X %*% ssX_V);
-      HV = t(X) %*% (Q - P [, 1:K] * (rowSums (Q) %*% matrix (1, 1, K)));
+      Q = P_1K * (X %*% ssX_V);
+      HV = t(X) %*% (Q - P_1K * (rowSums (Q) %*% matrix (1, 1, K)));
 
       if (icpt == 2)
         HV = diag (scale_X) %*% HV + shift_X %*% HV [D, ];