phaniarnab commented on code in PR #2050:
URL: https://github.com/apache/systemds/pull/2050#discussion_r1682486198


##########
src/test/java/org/apache/sysds/test/gpu/multigpu/GPUTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+package org.apache.sysds.test.gpu.multigpu;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.sysds.runtime.controlprogram.ParForProgramBlock;
+import org.apache.sysds.test.AutomatedTestBase;
+import org.apache.sysds.test.TestConfiguration;
+
+public abstract class GPUTest extends AutomatedTestBase {
+    protected static final String TEST_DIR = "gpu/";
+    protected static final String TEST_CLASS_DIR = TEST_DIR + 
MultiGPUTest.class.getSimpleName() + "/";
+    protected static final String SINGLE_GPU_TEST = "SingleGPUTest";
+    protected static final String MULTI_GPUS_TEST = "MultiGPUsTest";
+    protected static final String TEST_NAME = "GPUTest";
+    protected static final String DATA_SET = DATASET_DIR + 
"MNIST/mnist_test.csv";
+    protected static final String SINGLE_TEST_CONFIG = CONFIG_DIR + 
"SystemDS-SingleGPU-config.xml";
+    protected static final String MULTI_TEST_CONFIG = CONFIG_DIR + 
"SystemDS-config.xml";
+
+    @Override
+    public void setUp() {
+        TEST_GPU = true;
+        VERBOSE_STATS = true;
+        addTestConfiguration(SINGLE_GPU_TEST,
+                new TestConfiguration(TEST_CLASS_DIR, SINGLE_GPU_TEST, new 
String[] { "R" }));
+        addTestConfiguration(MULTI_GPUS_TEST,
+                new TestConfiguration(TEST_CLASS_DIR, MULTI_GPUS_TEST, new 
String[] { "R" }));
+    }
+
+    public abstract void gpuTest();
+
+    /**
+     * Run the test with multiple GPUs
+     * 
+     * @param multiGPUs whether to run the test with multiple GPUs
+     */
+    protected void runMultiGPUsTest(boolean multiGPUs) {
+        getAndLoadTestConfiguration(multiGPUs ? MULTI_GPUS_TEST : 
SINGLE_GPU_TEST);
+
+        String HOME = SCRIPT_DIR + TEST_DIR;
+        fullDMLScriptName = HOME + TEST_NAME + ".dml";
+        programArgs = new String[] { "-args", DATA_SET, output("R"), "-config",
+                multiGPUs ? MULTI_TEST_CONFIG : SINGLE_TEST_CONFIG };
+        fullRScriptName = HOME + TEST_NAME + ".R";
+
+        rCmd = null;
+        InMemoryAppender appender = configureLog4j();
+
+        runTest(true, false, null, -1);
+
+        List<String> logs = appender.getLogMessages();
+        for (String log : logs) {
+            if (log.contains("degree of parallelism")) {
+                int extractedNumThreads = extractNumThreads(log);
+                if (multiGPUs) {
+                    assert extractedNumThreads > 1 : "Test failed: _numThreads 
is not greater than 1";
+                } else {
+                    assert extractedNumThreads == 1 : "Test failed: 
_numThreads is not equal to 1";

Review Comment:
   How does this assertion confirms the use of multiple GPUs?



##########
src/test/java/org/apache/sysds/test/gpu/multigpu/GPUTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+package org.apache.sysds.test.gpu.multigpu;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.sysds.runtime.controlprogram.ParForProgramBlock;
+import org.apache.sysds.test.AutomatedTestBase;
+import org.apache.sysds.test.TestConfiguration;
+
+public abstract class GPUTest extends AutomatedTestBase {
+    protected static final String TEST_DIR = "gpu/";
+    protected static final String TEST_CLASS_DIR = TEST_DIR + 
MultiGPUTest.class.getSimpleName() + "/";
+    protected static final String SINGLE_GPU_TEST = "SingleGPUTest";
+    protected static final String MULTI_GPUS_TEST = "MultiGPUsTest";
+    protected static final String TEST_NAME = "GPUTest";
+    protected static final String DATA_SET = DATASET_DIR + 
"MNIST/mnist_test.csv";
+    protected static final String SINGLE_TEST_CONFIG = CONFIG_DIR + 
"SystemDS-SingleGPU-config.xml";
+    protected static final String MULTI_TEST_CONFIG = CONFIG_DIR + 
"SystemDS-config.xml";
+
+    @Override
+    public void setUp() {
+        TEST_GPU = true;
+        VERBOSE_STATS = true;
+        addTestConfiguration(SINGLE_GPU_TEST,
+                new TestConfiguration(TEST_CLASS_DIR, SINGLE_GPU_TEST, new 
String[] { "R" }));
+        addTestConfiguration(MULTI_GPUS_TEST,
+                new TestConfiguration(TEST_CLASS_DIR, MULTI_GPUS_TEST, new 
String[] { "R" }));
+    }
+
+    public abstract void gpuTest();
+
+    /**
+     * Run the test with multiple GPUs
+     * 
+     * @param multiGPUs whether to run the test with multiple GPUs
+     */
+    protected void runMultiGPUsTest(boolean multiGPUs) {
+        getAndLoadTestConfiguration(multiGPUs ? MULTI_GPUS_TEST : 
SINGLE_GPU_TEST);
+
+        String HOME = SCRIPT_DIR + TEST_DIR;
+        fullDMLScriptName = HOME + TEST_NAME + ".dml";
+        programArgs = new String[] { "-args", DATA_SET, output("R"), "-config",
+                multiGPUs ? MULTI_TEST_CONFIG : SINGLE_TEST_CONFIG };
+        fullRScriptName = HOME + TEST_NAME + ".R";
+
+        rCmd = null;
+        InMemoryAppender appender = configureLog4j();
+
+        runTest(true, false, null, -1);
+
+        List<String> logs = appender.getLogMessages();
+        for (String log : logs) {
+            if (log.contains("degree of parallelism")) {
+                int extractedNumThreads = extractNumThreads(log);
+                if (multiGPUs) {
+                    assert extractedNumThreads > 1 : "Test failed: _numThreads 
is not greater than 1";
+                } else {
+                    assert extractedNumThreads == 1 : "Test failed: 
_numThreads is not equal to 1";

Review Comment:
   How does this assertion confirm the use of multiple GPUs?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@systemds.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to