You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2018/01/17 12:23:11 UTC
[13/43] ignite git commit: IGNITE-7203 Java 8 by default
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
new file mode 100644
index 0000000..6cb2200
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
@@ -0,0 +1,120 @@
+/*
+ * 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.ignite.yardstick.ml.math;
+
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+import org.apache.ignite.yardstick.ml.DataChanger;
+
+/**
+ * Ignite benchmark that performs ML Grid operations of matrix multiplication.
+ */
+abstract class IgniteAbstractMatrixMulBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ private static final int SIZE = 1 << 7;
+
+ /** */
+ private double[][] dataSquare = createAndFill(SIZE, SIZE);
+
+ /** */
+ private double[][] dataRect1 = createAndFill(SIZE / 2, SIZE);
+
+ /** */
+ private double[][] dataRect2 = createAndFill(SIZE, SIZE / 2);
+
+ /** */
+ @SuppressWarnings("unused")
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final double scale = DataChanger.next();
+
+ // Create IgniteThread, we may want to work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ Matrix m1, m2, m3, m4, m5, m6;
+
+ Matrix m7 = times(m1 = createAndFill(dataSquare, scale), m2 = createAndFill(dataSquare, scale));
+ Matrix m8 = times(m3 = createAndFill(dataRect1, scale), m4 = createAndFill(dataRect2, scale));
+ Matrix m9 = times(m5 = createAndFill(dataRect2, scale), m6 = createAndFill(dataRect1, scale));
+
+ m1.destroy();
+ m2.destroy();
+ m3.destroy();
+ m4.destroy();
+ m5.destroy();
+ m6.destroy();
+ m7.destroy();
+ m8.destroy();
+ m9.destroy();
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+
+ /**
+ * Override in subclasses with specific type Matrix. Note that size of result matrix may be smaller than requested.
+ *
+ * @param rowSize Requested row size.
+ * @param colSize Requested column size.
+ * @return Matrix of desired type of size that doesn't exceed requested.
+ */
+ abstract Matrix newMatrix(int rowSize, int colSize);
+
+ /** Override in subclasses if needed. */
+ Matrix times(Matrix m1, Matrix m2) {
+ return m1.times(m2);
+ }
+
+ /** Override in subclasses if needed to account for smaller matrix size. */
+ Matrix createAndFill(double[][] data, double scale) {
+ // IMPL NOTE yardstick 0.8.3 fails to discover benchmark if we try to account for smaller size
+ // matrix by using method with lambda parameter here: assign((row, col) -> data[row][col]).
+ Matrix res = newMatrix(data.length, data[0].length).assign(data);
+
+ for (int i = 0; i < data.length && i < data[0].length; i++)
+ res.set(i, i, data[i][i] * scale);
+
+ return res;
+ }
+
+ /** */
+ private double[][] createAndFill(int rowSize, int colSize) {
+ double[][] data = new double[rowSize][colSize];
+
+ for (int i = 0; i < rowSize; i++)
+ for (int j = 0; j < colSize; j++)
+ data[i][j] = -0.5d + Math.random();
+
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
new file mode 100644
index 0000000..027b515
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteDenseLocalOffHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new DenseLocalOffHeapMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
new file mode 100644
index 0000000..6830130
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteDenseLocalOnHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new DenseLocalOnHeapMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
new file mode 100644
index 0000000..8762620
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteSparseBlockDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new SparseBlockDistributedMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
new file mode 100644
index 0000000..0f9d288
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
@@ -0,0 +1,49 @@
+/*
+ * 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.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+
+/**
+ * Ignite benchmark that performs unoptimized matrix multiplication of {@link SparseDistributedMatrix}.
+ * For optimized benchmark refer {@link IgniteSparseBlockDistributedMatrixMulBenchmark}.
+ */
+@SuppressWarnings("unused")
+public class IgniteSparseDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** This benchmark is unacceptably slow without scaling down, see IGNITE-7097. */
+ private static final int SCALE_DOWN = 2;
+
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new SparseDistributedMatrix(rowSize >> SCALE_DOWN, colSize >> SCALE_DOWN,
+ StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+ }
+
+ /** {@inheritDoc} */
+ @Override Matrix createAndFill(double[][] data, double scale) {
+ Matrix res = newMatrix(data.length, data[0].length);
+
+ for (int row = 0; row < res.rowSize(); row++)
+ for (int col = 0; col < res.columnSize(); col++)
+ res.set(row, col, row == col ? data[row][col] * scale : data[row][col]);
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
new file mode 100644
index 0000000..de2c99b
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/IgniteSparseLocalMatrixMulBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ignite.yardstick.ml.math;
+
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteSparseLocalMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
+ /** {@inheritDoc} */
+ @Override Matrix newMatrix(int rowSize, int colSize) {
+ return new SparseLocalOnHeapMatrix(rowSize, colSize);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java
new file mode 100644
index 0000000..d37e967
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/math/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * ML Grid math benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.math;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java
new file mode 100644
index 0000000..4751f35
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * ML Grid benchmarks.
+ */
+package org.apache.ignite.yardstick.ml;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
new file mode 100644
index 0000000..89b5471
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/IgniteOLSMultipleLinearRegressionBenchmark.java
@@ -0,0 +1,69 @@
+/*
+ * 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.ignite.yardstick.ml.regression;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionModel;
+import org.apache.ignite.ml.regressions.linear.LinearRegressionQRTrainer;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteOLSMultipleLinearRegressionBenchmark extends IgniteAbstractBenchmark {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ runLongly();
+
+ return true;
+ }
+
+ /**
+ * Based on OLSMultipleLinearRegressionTest#testLongly.
+ */
+ private void runLongly() {
+ // Y values are first, then independent vars
+ // Each row is one observation
+ double[][] data = new double[][] {
+ { 60323, 83.0, 234289, 2356, 1590, 107608, 1947 },
+ { 61122, 88.5, 259426, 2325, 1456, 108632, 1948 },
+ { 60171, 88.2, 258054, 3682, 1616, 109773, 1949 },
+ { 61187, 89.5, 284599, 3351, 1650, 110929, 1950 },
+ { 63221, 96.2, 328975, 2099, 3099, 112075, 1951 },
+ { 63639, 98.1, 346999, 1932, 3594, 113270, 1952 },
+ { 64989, 99.0, 365385, 1870, 3547, 115094, 1953 },
+ { 63761, 100.0, 363112, 3578, 3350, 116219, 1954 },
+ { 66019, 101.2, 397469, 2904, 3048, 117388, 1955 },
+ { 67857, 104.6, 419180, 2822, 2857, 118734, 1956 },
+ { 68169, 108.4, 442769, 2936, 2798, 120445, 1957 },
+ { 66513, 110.8, 444546, 4681, 2637, 121950, 1958 },
+ { 68655, 112.6, 482704, 3813, 2552, 123366, 1959 },
+ { 69564, 114.2, 502601, 3931, 2514, 125368, 1960 },
+ { 69331, 115.7, 518173, 4806, 2572, 127852, 1961 },
+ { 70551, 116.9, 554894, 4007, 2827, 130081, 1962 }
+ };
+
+ final int nobs = 16;
+ final int nvars = 6;
+
+ LinearRegressionQRTrainer trainer = new LinearRegressionQRTrainer();
+ LinearRegressionModel model = trainer.train(new DenseLocalOnHeapMatrix(data));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java
new file mode 100644
index 0000000..0a5dc1a
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/regression/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * ML Grid regression benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.regression;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
new file mode 100644
index 0000000..f8a7c08
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeGiniBenchmark.java
@@ -0,0 +1,70 @@
+/*
+ * 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.ignite.yardstick.ml.trees;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
+import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteColumnDecisionTreeGiniBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ // IMPL NOTE originally taken from ColumnDecisionTreeTrainerTest#testCacheMixedGini
+ int totalPts = 1 << 10;
+ int featCnt = 2;
+
+ HashMap<Integer, Integer> catsInfo = new HashMap<>();
+ catsInfo.put(1, 3);
+
+ SplitDataGenerator<DenseLocalOnHeapVector> gen = new SplitDataGenerator<>(
+ featCnt, catsInfo, () -> new DenseLocalOnHeapVector(featCnt + 1)).
+ split(0, 1, new int[] {0, 2}).
+ split(1, 0, -10.0);
+
+ gen.testByGen(totalPts, ContinuousSplitCalculators.GINI.apply(ignite),
+ RegionCalculators.GINI, RegionCalculators.MEAN, ignite);
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
new file mode 100644
index 0000000..f9d417f
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/IgniteColumnDecisionTreeVarianceBenchmark.java
@@ -0,0 +1,71 @@
+/*
+ * 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.ignite.yardstick.ml.trees;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.ContinuousSplitCalculators;
+import org.apache.ignite.ml.trees.trainers.columnbased.regcalcs.RegionCalculators;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.thread.IgniteThread;
+import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
+
+/**
+ * Ignite benchmark that performs ML Grid operations.
+ */
+@SuppressWarnings("unused")
+public class IgniteColumnDecisionTreeVarianceBenchmark extends IgniteAbstractBenchmark {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
+ // because we create ignite cache internally.
+ IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
+ this.getClass().getSimpleName(), new Runnable() {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ // IMPL NOTE originally taken from ColumnDecisionTreeTrainerTest#testCacheMixed
+ int totalPts = 1 << 10;
+ int featCnt = 2;
+
+ HashMap<Integer, Integer> catsInfo = new HashMap<>();
+ catsInfo.put(1, 3);
+
+ SplitDataGenerator<DenseLocalOnHeapVector> gen
+ = new SplitDataGenerator<>(
+ featCnt, catsInfo, () -> new DenseLocalOnHeapVector(featCnt + 1)).
+ split(0, 1, new int[] {0, 2}).
+ split(1, 0, -10.0);
+
+ gen.testByGen(totalPts,
+ ContinuousSplitCalculators.VARIANCE, RegionCalculators.VARIANCE, RegionCalculators.MEAN, ignite);
+ }
+ });
+
+ igniteThread.start();
+
+ igniteThread.join();
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
new file mode 100644
index 0000000..f9117f4
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/SplitDataGenerator.java
@@ -0,0 +1,426 @@
+/*
+ * 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.ignite.yardstick.ml.trees;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.DoubleStream;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.ml.math.StorageConstants;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException;
+import org.apache.ignite.ml.math.functions.IgniteFunction;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
+import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
+import org.apache.ignite.ml.structures.LabeledVectorDouble;
+import org.apache.ignite.ml.trees.ContinuousRegionInfo;
+import org.apache.ignite.ml.trees.ContinuousSplitCalculator;
+import org.apache.ignite.ml.trees.models.DecisionTreeModel;
+import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainer;
+import org.apache.ignite.ml.trees.trainers.columnbased.ColumnDecisionTreeTrainerInput;
+import org.apache.ignite.ml.trees.trainers.columnbased.MatrixColumnDecisionTreeTrainerInput;
+import org.apache.ignite.ml.util.Utils;
+
+/** */
+class SplitDataGenerator<V extends Vector> {
+ /** */
+ private static final Random rnd = new Random(12349L);
+
+ /** */
+ private static final double DELTA = 100.0;
+
+ /** Map of the form of (is categorical -> list of region indexes). */
+ private final Map<Boolean, List<Integer>> di;
+
+ /** List of regions. */
+ private final List<Region> regs;
+
+ /** Data of bounds of regions. */
+ private final Map<Integer, IgniteBiTuple<Double, Double>> boundsData;
+
+ /** */
+ private final Map<Integer, Integer> catFeaturesInfo;
+
+ /** Supplier of vectors. */
+ private final Supplier<V> supplier;
+
+ /** Features count. */
+ private final int featCnt;
+
+ /**
+ * Create SplitDataGenerator.
+ *
+ * @param featCnt Features count.
+ * @param catFeaturesInfo Information about categorical features in form of map (feature index -> categories
+ * count).
+ * @param supplier Supplier of vectors.
+ */
+ SplitDataGenerator(int featCnt, Map<Integer, Integer> catFeaturesInfo, Supplier<V> supplier) {
+ regs = new LinkedList<>();
+ boundsData = new HashMap<>();
+ this.supplier = supplier;
+ this.featCnt = featCnt;
+ this.catFeaturesInfo = catFeaturesInfo;
+
+ // Divide indexes into indexes of categorical coordinates and indexes of continuous coordinates.
+ di = IntStream.range(0, featCnt).
+ boxed().
+ collect(Collectors.partitioningBy(catFeaturesInfo::containsKey));
+
+ // Categorical coordinates info.
+ Map<Integer, CatCoordInfo> catCoords = new HashMap<>();
+ di.get(true).forEach(i -> {
+ BitSet bs = new BitSet();
+ bs.set(0, catFeaturesInfo.get(i));
+ catCoords.put(i, new CatCoordInfo(bs));
+ });
+
+ // Continuous coordinates info.
+ Map<Integer, ContCoordInfo> contCoords = new HashMap<>();
+ di.get(false).forEach(i -> {
+ contCoords.put(i, new ContCoordInfo());
+ boundsData.put(i, new IgniteBiTuple<>(-1.0, 1.0));
+ });
+
+ Region firstReg = new Region(catCoords, contCoords, 0);
+ regs.add(firstReg);
+ }
+
+ /** */
+ <D extends ContinuousRegionInfo> void testByGen(int totalPts,
+ IgniteFunction<ColumnDecisionTreeTrainerInput, ? extends ContinuousSplitCalculator<D>> calc,
+ IgniteFunction<ColumnDecisionTreeTrainerInput, IgniteFunction<DoubleStream, Double>> catImpCalc,
+ IgniteFunction<DoubleStream, Double> regCalc, Ignite ignite) {
+
+ List<IgniteBiTuple<Integer, V>> lst = points(totalPts, (i, rn) -> i).collect(Collectors.toList());
+
+ Collections.shuffle(lst, rnd);
+
+ SparseDistributedMatrix m = new SparseDistributedMatrix(totalPts,
+ featCnt + 1, StorageConstants.COLUMN_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
+
+ Map<Integer, List<LabeledVectorDouble>> byRegion = new HashMap<>();
+
+ int i = 0;
+ for (IgniteBiTuple<Integer, V> bt : lst) {
+ byRegion.putIfAbsent(bt.get1(), new LinkedList<>());
+ byRegion.get(bt.get1()).add(asLabeledVector(bt.get2().getStorage().data()));
+ m.setRow(i, bt.get2().getStorage().data());
+ i++;
+ }
+
+ ColumnDecisionTreeTrainer<D> trainer =
+ new ColumnDecisionTreeTrainer<>(3, calc, catImpCalc, regCalc, ignite);
+
+ DecisionTreeModel mdl = trainer.train(new MatrixColumnDecisionTreeTrainerInput(m, catFeaturesInfo));
+
+ byRegion.keySet().forEach(k -> mdl.apply(byRegion.get(k).get(0).features()));
+ }
+
+ /**
+ * Split region by continuous coordinate using given threshold.
+ *
+ * @param regIdx Region index.
+ * @param coordIdx Coordinate index.
+ * @param threshold Threshold.
+ * @return {@code this}.
+ */
+ SplitDataGenerator<V> split(int regIdx, int coordIdx, double threshold) {
+ Region regToSplit = regs.get(regIdx);
+ ContCoordInfo cci = regToSplit.contCoords.get(coordIdx);
+
+ double left = cci.left;
+ double right = cci.right;
+
+ if (threshold < left || threshold > right)
+ throw new MathIllegalArgumentException("Threshold is out of region bounds.");
+
+ regToSplit.incTwoPow();
+
+ Region newReg = Utils.copy(regToSplit);
+ newReg.contCoords.get(coordIdx).left = threshold;
+
+ regs.add(regIdx + 1, newReg);
+ cci.right = threshold;
+
+ IgniteBiTuple<Double, Double> bounds = boundsData.get(coordIdx);
+ double min = bounds.get1();
+ double max = bounds.get2();
+ boundsData.put(coordIdx, new IgniteBiTuple<>(Math.min(threshold, min), Math.max(max, threshold)));
+
+ return this;
+ }
+
+ /**
+ * Split region by categorical coordinate.
+ *
+ * @param regIdx Region index.
+ * @param coordIdx Coordinate index.
+ * @param cats Categories allowed for the left sub region.
+ * @return {@code this}.
+ */
+ SplitDataGenerator<V> split(int regIdx, int coordIdx, int[] cats) {
+ BitSet subset = new BitSet();
+ Arrays.stream(cats).forEach(subset::set);
+ Region regToSplit = regs.get(regIdx);
+ CatCoordInfo cci = regToSplit.catCoords.get(coordIdx);
+
+ BitSet ssc = (BitSet)subset.clone();
+ BitSet set = cci.bs;
+ ssc.and(set);
+ if (ssc.length() != subset.length())
+ throw new MathIllegalArgumentException("Splitter set is not a subset of a parent subset.");
+
+ ssc.xor(set);
+ set.and(subset);
+
+ regToSplit.incTwoPow();
+ Region newReg = Utils.copy(regToSplit);
+ newReg.catCoords.put(coordIdx, new CatCoordInfo(ssc));
+
+ regs.add(regIdx + 1, newReg);
+
+ return this;
+ }
+
+ /**
+ * Get stream of points generated by this generator.
+ *
+ * @param ptsCnt Points count.
+ */
+ private Stream<IgniteBiTuple<Integer, V>> points(int ptsCnt, BiFunction<Double, Random, Double> f) {
+ return IntStream.range(0, regs.size()).
+ boxed().
+ map(i -> regs.get(i).generatePoints(ptsCnt, f.apply((double)i, rnd), boundsData, di, supplier, rnd)
+ .map(v -> new IgniteBiTuple<>(i, v))).flatMap(Function.identity());
+ }
+
+ /**
+ * Convert double array to {@link LabeledVectorDouble}
+ *
+ * @param arr Array for conversion.
+ * @return LabeledVectorDouble.
+ */
+ private static LabeledVectorDouble<DenseLocalOnHeapVector> asLabeledVector(double arr[]) {
+ return new LabeledVectorDouble<>(new DenseLocalOnHeapVector(
+ Arrays.copyOf(arr, arr.length - 1)), arr[arr.length - 1]);
+ }
+
+ /**
+ * Categorical coordinate info.
+ */
+ private static class CatCoordInfo implements Serializable {
+ /**
+ * Defines categories which are included in this region
+ */
+ private final BitSet bs;
+
+ /**
+ * Construct CatCoordInfo.
+ *
+ * @param bs Bitset.
+ */
+ CatCoordInfo(BitSet bs) {
+ this.bs = bs;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "CatCoordInfo [" +
+ "bs=" + bs +
+ ']';
+ }
+ }
+
+ /**
+ * Continuous coordinate info.
+ */
+ private static class ContCoordInfo implements Serializable {
+ /**
+ * Left (min) bound of region.
+ */
+ private double left;
+
+ /**
+ * Right (max) bound of region.
+ */
+ private double right;
+
+ /**
+ * Construct ContCoordInfo.
+ */
+ ContCoordInfo() {
+ left = Double.NEGATIVE_INFINITY;
+ right = Double.POSITIVE_INFINITY;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "ContCoordInfo [" +
+ "left=" + left +
+ ", right=" + right +
+ ']';
+ }
+ }
+
+ /**
+ * Class representing information about region.
+ */
+ private static class Region implements Serializable {
+ /**
+ * Information about categorical coordinates restrictions of this region in form of
+ * (coordinate index -> restriction)
+ */
+ private final Map<Integer, CatCoordInfo> catCoords;
+
+ /**
+ * Information about continuous coordinates restrictions of this region in form of
+ * (coordinate index -> restriction)
+ */
+ private final Map<Integer, ContCoordInfo> contCoords;
+
+ /**
+ * Region should contain {@code 1/2^twoPow * totalPoints} points.
+ */
+ private int twoPow;
+
+ /**
+ * Construct region by information about restrictions on coordinates (features) values.
+ *
+ * @param catCoords Restrictions on categorical coordinates.
+ * @param contCoords Restrictions on continuous coordinates
+ * @param twoPow Region should contain {@code 1/2^twoPow * totalPoints} points.
+ */
+ Region(Map<Integer, CatCoordInfo> catCoords, Map<Integer, ContCoordInfo> contCoords, int twoPow) {
+ this.catCoords = catCoords;
+ this.contCoords = contCoords;
+ this.twoPow = twoPow;
+ }
+
+ /** */
+ int divideBy() {
+ return 1 << twoPow;
+ }
+
+ /** */
+ void incTwoPow() {
+ twoPow++;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Region [" +
+ "catCoords=" + catCoords +
+ ", contCoords=" + contCoords +
+ ", twoPow=" + twoPow +
+ ']';
+ }
+
+ /**
+ * Generate continuous coordinate for this region.
+ *
+ * @param coordIdx Coordinate index.
+ * @param boundsData Data with bounds
+ * @param rnd Random numbers generator.
+ * @return Categorical coordinate value.
+ */
+ double generateContCoord(int coordIdx, Map<Integer, IgniteBiTuple<Double, Double>> boundsData,
+ Random rnd) {
+ ContCoordInfo cci = contCoords.get(coordIdx);
+ double left = cci.left;
+ double right = cci.right;
+
+ if (left == Double.NEGATIVE_INFINITY)
+ left = boundsData.get(coordIdx).get1() - DELTA;
+
+ if (right == Double.POSITIVE_INFINITY)
+ right = boundsData.get(coordIdx).get2() + DELTA;
+
+ double size = right - left;
+
+ return left + rnd.nextDouble() * size;
+ }
+
+ /**
+ * Generate categorical coordinate value for this region.
+ *
+ * @param coordIdx Coordinate index.
+ * @param rnd Random numbers generator.
+ * @return Categorical coordinate value.
+ */
+ double generateCatCoord(int coordIdx, Random rnd) {
+ // Pick random bit.
+ BitSet bs = catCoords.get(coordIdx).bs;
+ int j = rnd.nextInt(bs.length());
+
+ int i = 0;
+ int bn = 0;
+ int bnp = 0;
+
+ while ((bn = bs.nextSetBit(bn)) != -1 && i <= j) {
+ i++;
+ bnp = bn;
+ bn++;
+ }
+
+ return bnp;
+ }
+
+ /**
+ * Generate points for this region.
+ *
+ * @param ptsCnt Count of points to generate.
+ * @param val Label for all points in this region.
+ * @param boundsData Data about bounds of continuous coordinates.
+ * @param catCont Data about which categories can be in this region in the form (coordinate index -> list of
+ * categories indexes).
+ * @param s Vectors supplier.
+ * @param rnd Random numbers generator.
+ * @param <V> Type of vectors.
+ * @return Stream of generated points for this region.
+ */
+ <V extends Vector> Stream<V> generatePoints(int ptsCnt, double val,
+ Map<Integer, IgniteBiTuple<Double, Double>> boundsData, Map<Boolean, List<Integer>> catCont,
+ Supplier<V> s,
+ Random rnd) {
+ return IntStream.range(0, ptsCnt / divideBy()).mapToObj(i -> {
+ V v = s.get();
+ int coordsCnt = v.size();
+ catCont.get(false).forEach(ci -> v.setX(ci, generateContCoord(ci, boundsData, rnd)));
+ catCont.get(true).forEach(ci -> v.setX(ci, generateCatCoord(ci, rnd)));
+
+ v.setX(coordsCnt - 1, val);
+ return v;
+ });
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java
new file mode 100644
index 0000000..fc379a6
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/ml/trees/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * ML Grid decision tree benchmarks.
+ */
+package org.apache.ignite.yardstick.ml.trees;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java
deleted file mode 100644
index 600113b..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/DataChanger.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.ignite.yardstick.ml;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-
-/**
- * Helps to ensure use of meaningfully different data in repeated invocations of benchmarked code in
- * {@link IgniteAbstractBenchmark#test(Map)} method.
- */
-public class DataChanger {
- /** */
- private static final AtomicInteger changer = new AtomicInteger(0);
-
- /**
- * @return Positive "seed" to mutate data.
- */
- public static double next() {
- return (changer.incrementAndGet() % 17) + 1;
- }
-
- /** */
- public static class Scale {
- /** */
- private final double scale;
-
- /** */
- public Scale() {
- this.scale = DataChanger.next();
- }
-
- /** */
- public double[][] mutate(double[][] orig) {
- for (int i = 0; i < orig.length; i++)
- orig[i] = mutate(orig[i]);
-
- return orig;
- }
-
- /** */
- public double[] mutate(double[] orig) {
- for (int i = 0; i < orig.length; i++)
- orig[i] *= scale;
-
- return orig;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
deleted file mode 100644
index de928e8..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansDistributedClustererBenchmark.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.clustering;
-
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.ml.clustering.KMeansDistributedClusterer;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.thread.IgniteThread;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteKMeansDistributedClustererBenchmark extends IgniteAbstractBenchmark {
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- // Create IgniteThread, we must work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- this.getClass().getSimpleName(), new Runnable() {
- /** {@inheritDoc} */
- @Override public void run() {
- // IMPL NOTE originally taken from KMeansDistributedClustererTest
- KMeansDistributedClusterer clusterer = new KMeansDistributedClusterer(
- new EuclideanDistance(), 1, 1, 1L);
-
- double[] v1 = scale.mutate(new double[] {1959, 325100});
- double[] v2 = scale.mutate(new double[] {1960, 373200});
-
- SparseDistributedMatrix points = new SparseDistributedMatrix(
- 2, 2, StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
-
- points.setRow(0, v1);
- points.setRow(1, v2);
-
- clusterer.cluster(points, 1);
-
- points.destroy();
- }
- });
-
- igniteThread.start();
-
- igniteThread.join();
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
deleted file mode 100644
index d68fc6d..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/IgniteKMeansLocalClustererBenchmark.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.clustering;
-
-import java.util.Map;
-import org.apache.ignite.ml.clustering.KMeansLocalClusterer;
-import org.apache.ignite.ml.math.distances.EuclideanDistance;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteKMeansLocalClustererBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- // IMPL NOTE originally taken from KMeansLocalClustererTest
- KMeansLocalClusterer clusterer = new KMeansLocalClusterer(new EuclideanDistance(), 1, 1L);
-
- double[] v1 = scale.mutate(new double[] {1959, 325100});
- double[] v2 = scale.mutate(new double[] {1960, 373200});
-
- DenseLocalOnHeapMatrix points = new DenseLocalOnHeapMatrix(new double[][] {
- v1,
- v2});
-
- clusterer.cluster(points, 1);
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java
deleted file mode 100644
index af217d2..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/clustering/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 description. -->
- * ML Grid clustering benchmarks.
- */
-package org.apache.ignite.yardstick.ml.clustering;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
deleted file mode 100644
index 6997180..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteCholeskyDecompositionBenchmark.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.decompositions.CholeskyDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteCholeskyDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runCholeskyDecomposition();
-
- return true;
- }
-
- /**
- * Based on CholeskyDecompositionTest.
- */
- private void runCholeskyDecomposition() {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- Matrix m = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] {
- {2.0d, -1.0d, 0.0d},
- {-1.0d, 2.0d, -1.0d},
- {0.0d, -1.0d, 2.0d}
- }));
-
- CholeskyDecomposition dec = new CholeskyDecomposition(m);
-
- dec.getL();
- dec.getLT();
-
- Matrix bs = new DenseLocalOnHeapMatrix(scale.mutate(new double[][] {
- {4.0, -6.0, 7.0},
- {1.0, 1.0, 1.0}
- })).transpose();
- dec.solve(bs);
-
- Vector b = new DenseLocalOnHeapVector(scale.mutate(new double[] {4.0, -6.0, 7.0}));
- dec.solve(b);
-
- dec.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
deleted file mode 100644
index e61c40c..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteEigenDecompositionBenchmark.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.decompositions.EigenDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteEigenDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runEigenDecomposition();
-
- return true;
- }
-
- /**
- * Based on EigenDecompositionTest.
- */
- private void runEigenDecomposition() {
- final DataChanger.Scale scale = new DataChanger.Scale();
-
- EigenDecomposition decomposition1 = new EigenDecomposition(new DenseLocalOnHeapMatrix(
- scale.mutate(new double[][] {
- {1.0d, 0.0d, 0.0d, 1.0d},
- {0.0d, 1.0d, 0.0d, 1.0d},
- {0.0d, 0.0d, 2.0d, 0.0d},
- {1.0d, 1.0d, 0.0d, 2.0d}})));
-
- decomposition1.getD();
- decomposition1.getV();
-
- decomposition1.destroy();
-
- EigenDecomposition decomposition2 = new EigenDecomposition(new DenseLocalOnHeapMatrix(
- scale.mutate(new double[][] {
- {1.0d, 0.0d, 0.0d},
- {0.0d, 1.0d, 0.0d},
- {0.0d, 0.0d, 2.0d},
- {1.0d, 1.0d, 0.0d}})));
- // TODO: IGNITE-5828, find out why decomposition of 3X4 matrix throws row index exception
-
- decomposition2.getD();
- decomposition2.getV();
-
- decomposition2.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
deleted file mode 100644
index 1368ef9..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteLUDecompositionBenchmark.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.decompositions.LUDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
-import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteLUDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runLUDecomposition();
-
- return true;
- }
-
- /**
- * Based on LUDecompositionTest.
- */
- private void runLUDecomposition() {
- Matrix testMatrix = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(new double[][] {
- {2.0d, 1.0d, 1.0d, 0.0d},
- {4.0d, 3.0d, 3.0d, 1.0d},
- {8.0d, 7.0d, 9.0d, 5.0d},
- {6.0d, 7.0d, 9.0d, 8.0d}}));
-
- LUDecomposition dec1 = new LUDecomposition(new PivotedMatrixView(testMatrix));
-
- dec1.solve(new DenseLocalOnHeapVector(testMatrix.rowSize()));
-
- dec1.destroy();
-
- LUDecomposition dec2 = new LUDecomposition(new PivotedMatrixView(testMatrix));
-
- dec2.solve(new DenseLocalOnHeapMatrix(testMatrix.rowSize(), testMatrix.rowSize()));
-
- dec2.destroy();
-
- LUDecomposition dec3 = new LUDecomposition(testMatrix);
-
- dec3.getL();
-
- dec3.getU();
-
- dec3.getP();
-
- dec3.getPivot();
-
- dec3.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
deleted file mode 100644
index 9f02852..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/IgniteSingularValueDecompositionBenchmark.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.decomposition;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.decompositions.SingularValueDecomposition;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteSingularValueDecompositionBenchmark extends IgniteAbstractBenchmark {
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- runSingularValueDecomposition();
-
- return true;
- }
-
- /**
- * Based on SingularValueDecompositionTest#basicTest.
- */
- private void runSingularValueDecomposition() {
- Matrix m = new DenseLocalOnHeapMatrix(new DataChanger.Scale().mutate(new double[][] {
- {2.0d, -1.0d, 0.0d},
- {-1.0d, 2.0d, -1.0d},
- {0.0d, -1.0d, 2.0d}
- }));
-
- SingularValueDecomposition dec = new SingularValueDecomposition(m);
-
- Matrix s = dec.getS();
- Matrix u = dec.getU();
- Matrix v = dec.getV();
-
- u.times(s).times(v.transpose());
-
- dec.destroy();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java
deleted file mode 100644
index 4aaece3..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/decomposition/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 description. -->
- * ML Grid decomposition benchmarks.
- */
-package org.apache.ignite.yardstick.ml.decomposition;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
deleted file mode 100644
index 6cb2200..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteAbstractMatrixMulBenchmark.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.math;
-
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.thread.IgniteThread;
-import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.ml.DataChanger;
-
-/**
- * Ignite benchmark that performs ML Grid operations of matrix multiplication.
- */
-abstract class IgniteAbstractMatrixMulBenchmark extends IgniteAbstractBenchmark {
- /** */
- private static final int SIZE = 1 << 7;
-
- /** */
- private double[][] dataSquare = createAndFill(SIZE, SIZE);
-
- /** */
- private double[][] dataRect1 = createAndFill(SIZE / 2, SIZE);
-
- /** */
- private double[][] dataRect2 = createAndFill(SIZE, SIZE / 2);
-
- /** */
- @SuppressWarnings("unused")
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public boolean test(Map<Object, Object> ctx) throws Exception {
- final double scale = DataChanger.next();
-
- // Create IgniteThread, we may want to work with SparseDistributedMatrix inside IgniteThread
- // because we create ignite cache internally.
- IgniteThread igniteThread = new IgniteThread(ignite.configuration().getIgniteInstanceName(),
- this.getClass().getSimpleName(), new Runnable() {
- /** {@inheritDoc} */
- @Override public void run() {
- Matrix m1, m2, m3, m4, m5, m6;
-
- Matrix m7 = times(m1 = createAndFill(dataSquare, scale), m2 = createAndFill(dataSquare, scale));
- Matrix m8 = times(m3 = createAndFill(dataRect1, scale), m4 = createAndFill(dataRect2, scale));
- Matrix m9 = times(m5 = createAndFill(dataRect2, scale), m6 = createAndFill(dataRect1, scale));
-
- m1.destroy();
- m2.destroy();
- m3.destroy();
- m4.destroy();
- m5.destroy();
- m6.destroy();
- m7.destroy();
- m8.destroy();
- m9.destroy();
- }
- });
-
- igniteThread.start();
-
- igniteThread.join();
-
- return true;
- }
-
- /**
- * Override in subclasses with specific type Matrix. Note that size of result matrix may be smaller than requested.
- *
- * @param rowSize Requested row size.
- * @param colSize Requested column size.
- * @return Matrix of desired type of size that doesn't exceed requested.
- */
- abstract Matrix newMatrix(int rowSize, int colSize);
-
- /** Override in subclasses if needed. */
- Matrix times(Matrix m1, Matrix m2) {
- return m1.times(m2);
- }
-
- /** Override in subclasses if needed to account for smaller matrix size. */
- Matrix createAndFill(double[][] data, double scale) {
- // IMPL NOTE yardstick 0.8.3 fails to discover benchmark if we try to account for smaller size
- // matrix by using method with lambda parameter here: assign((row, col) -> data[row][col]).
- Matrix res = newMatrix(data.length, data[0].length).assign(data);
-
- for (int i = 0; i < data.length && i < data[0].length; i++)
- res.set(i, i, data[i][i] * scale);
-
- return res;
- }
-
- /** */
- private double[][] createAndFill(int rowSize, int colSize) {
- double[][] data = new double[rowSize][colSize];
-
- for (int i = 0; i < rowSize; i++)
- for (int j = 0; j < colSize; j++)
- data[i][j] = -0.5d + Math.random();
-
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
deleted file mode 100644
index 027b515..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOffHeapMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOffHeapMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteDenseLocalOffHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new DenseLocalOffHeapMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
deleted file mode 100644
index 6830130..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteDenseLocalOnHeapMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteDenseLocalOnHeapMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new DenseLocalOnHeapMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
deleted file mode 100644
index 8762620..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseBlockDistributedMatrixMulBenchmark.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix;
-
-/**
- * Ignite benchmark that performs ML Grid operations.
- */
-@SuppressWarnings("unused")
-public class IgniteSparseBlockDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new SparseBlockDistributedMatrix(rowSize, colSize);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43a62cdb/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java b/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
deleted file mode 100644
index 0f9d288..0000000
--- a/modules/yardstick/src/main/ml/org/apache/ignite/yardstick/ml/math/IgniteSparseDistributedMatrixMulBenchmark.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.ignite.yardstick.ml.math;
-
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.StorageConstants;
-import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
-
-/**
- * Ignite benchmark that performs unoptimized matrix multiplication of {@link SparseDistributedMatrix}.
- * For optimized benchmark refer {@link IgniteSparseBlockDistributedMatrixMulBenchmark}.
- */
-@SuppressWarnings("unused")
-public class IgniteSparseDistributedMatrixMulBenchmark extends IgniteAbstractMatrixMulBenchmark {
- /** This benchmark is unacceptably slow without scaling down, see IGNITE-7097. */
- private static final int SCALE_DOWN = 2;
-
- /** {@inheritDoc} */
- @Override Matrix newMatrix(int rowSize, int colSize) {
- return new SparseDistributedMatrix(rowSize >> SCALE_DOWN, colSize >> SCALE_DOWN,
- StorageConstants.ROW_STORAGE_MODE, StorageConstants.RANDOM_ACCESS_MODE);
- }
-
- /** {@inheritDoc} */
- @Override Matrix createAndFill(double[][] data, double scale) {
- Matrix res = newMatrix(data.length, data[0].length);
-
- for (int row = 0; row < res.rowSize(); row++)
- for (int col = 0; col < res.columnSize(); col++)
- res.set(row, col, row == col ? data[row][col] * scale : data[row][col]);
-
- return res;
- }
-}