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

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


The following commit(s) were added to refs/heads/main by this push:
     new 3fb3bf5  [SYSTEMDS-3287] Fix eval lazy loading of builtin function 
hierarchies
3fb3bf5 is described below

commit 3fb3bf5fc50983b9332519c49beb4be5472acd15
Author: Matthias Boehm <[email protected]>
AuthorDate: Thu Mar 3 23:14:50 2022 +0100

    [SYSTEMDS-3287] Fix eval lazy loading of builtin function hierarchies
    
    This patch fixes conflicts on eval("foo") lazy function compilation
    where builtin functions composed of other builtins are loaded and only
    partially add the missing functions. We already supported this
    functionality for a while but when adding the necessary parfor support
    (with different functions for different threads), the default thread
    handling was partially corrupted.
    
    Thanks to Shafaq for catching this issue and the consice test case.
---
 .../instructions/cp/EvalNaryCPInstruction.java     |  4 +++-
 .../test/functions/misc/FunctionPotpourriTest.java |  6 +++++
 .../functions/misc/FunPotpourriEvalNamespace3.dml  | 26 ++++++++++++++++++++++
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/EvalNaryCPInstruction.java
 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/EvalNaryCPInstruction.java
index 0bbb242..82a13bb 100644
--- 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/EvalNaryCPInstruction.java
+++ 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/EvalNaryCPInstruction.java
@@ -59,7 +59,9 @@ import org.apache.sysds.runtime.util.ProgramConverter;
  */
 public class EvalNaryCPInstruction extends BuiltinNaryCPInstruction {
 
-       private int _threadID = -1;
+       // default: not in parfor context; otherwise updated via 
+       // updateInstructionThreadID during parfor worker setup and/or 
recompilation
+       private int _threadID = 0;
        
        public EvalNaryCPInstruction(Operator op, String opcode, String istr, 
CPOperand output, CPOperand... inputs) {
                super(op, opcode, istr, output, inputs);
diff --git 
a/src/test/java/org/apache/sysds/test/functions/misc/FunctionPotpourriTest.java 
b/src/test/java/org/apache/sysds/test/functions/misc/FunctionPotpourriTest.java
index 53f615b..3ade279 100644
--- 
a/src/test/java/org/apache/sysds/test/functions/misc/FunctionPotpourriTest.java
+++ 
b/src/test/java/org/apache/sysds/test/functions/misc/FunctionPotpourriTest.java
@@ -61,6 +61,7 @@ public class FunctionPotpourriTest extends AutomatedTestBase
                "FunPotpourriEvalNamespace2",
                "FunPotpourriBuiltinPrecedence",
                "FunPotpourriParforEvalBuiltin",
+               "FunPotpourriEvalNamespace3",
        };
        
        private final static String TEST_DIR = "functions/misc/";
@@ -265,6 +266,11 @@ public class FunctionPotpourriTest extends 
AutomatedTestBase
                runFunctionTest( TEST_NAMES[27], null, true );
        }
        
+       @Test
+       public void testFunctionEvalNamespace3() {
+               runFunctionTest( TEST_NAMES[28], null, false );
+       }
+       
        private void runFunctionTest(String testName, Class<?> error) {
                runFunctionTest(testName, error, false);
        }
diff --git a/src/test/scripts/functions/misc/FunPotpourriEvalNamespace3.dml 
b/src/test/scripts/functions/misc/FunPotpourriEvalNamespace3.dml
new file mode 100644
index 0000000..700f220
--- /dev/null
+++ b/src/test/scripts/functions/misc/FunPotpourriEvalNamespace3.dml
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+X = rand(rows=1000, cols=100, min=1, max=10)
+print(toString(X, rows=2))
+scaledData = eval("scale", list(X, TRUE, FALSE))
+dimRed = eval("pca", list(scaledData, 4, FALSE, FALSE))
+print("processed data: \n"+toString(dimRed, rows=2))

Reply via email to