You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2016/11/21 17:32:27 UTC
[01/14] incubator-mnemonic git commit: MNEMONIC-159: add a selective
mode parameter to the perform() of DNCS
Repository: incubator-mnemonic
Updated Branches:
refs/heads/master 3b000612c -> becaead0e
MNEMONIC-159: add a selective mode parameter to the perform() of DNCS
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/e2eb6b01
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/e2eb6b01
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/e2eb6b01
Branch: refs/heads/master
Commit: e2eb6b01ec904fd1240507c73195fcc5c17b97bd
Parents: 3b00061
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Mon Nov 14 10:50:34 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:47:52 2016 -0800
----------------------------------------------------------------------
.../service/computingservice/internal/PrintServiceImpl.java | 2 +-
.../service/computingservice/internal/SortServiceImpl.java | 8 +++++---
.../computingservice/DurableSinglyLinkedListNGPrintTest.java | 4 ++--
.../computingservice/DurableSinglyLinkedListNGSortTest.java | 4 ++--
.../service/computingservice/GeneralComputingService.java | 5 ++++-
5 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e2eb6b01/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/PrintServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/PrintServiceImpl.java b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/PrintServiceImpl.java
index 469b813..ef82755 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/PrintServiceImpl.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/PrintServiceImpl.java
@@ -42,7 +42,7 @@ public class PrintServiceImpl implements GeneralComputingService {
* {@inheritDoc}
*/
@Override
- public long[] perform(ValueInfo[] valinfos) {
+ public long[] perform(String mode, ValueInfo[] valinfos) {
long[] ret = null;
if (null != valinfos) {
ret = nperformPrint(valinfos);
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e2eb6b01/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
index ace277c..ffa99d1 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
@@ -42,10 +42,12 @@ public class SortServiceImpl implements GeneralComputingService {
* {@inheritDoc}
*/
@Override
- public long[] perform(ValueInfo[] valinfos) {
+ public long[] perform(String mode, ValueInfo[] valinfos) {
long[] ret = null;
- if (null != valinfos) {
- ret = nperformBubbleSort(valinfos);
+ if (null != mode && null != valinfos) {
+ if ("tensor_bubble".equals(mode)) {
+ ret = nperformBubbleSort(valinfos);
+ }
}
return ret;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e2eb6b01/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGPrintTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGPrintTest.java b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGPrintTest.java
index e387fff..7a4038e 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGPrintTest.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGPrintTest.java
@@ -137,7 +137,7 @@ public class DurableSinglyLinkedListNGPrintTest {
vinfo.dtype = DurableType.SHORT;
vinfo.frames = Utils.genNativeParamForm(objstack, fidinfostack);
ValueInfo[] vinfos = {vinfo};
- gcsvr.perform(vinfos);
+ gcsvr.perform(null, vinfos);
}
@@ -231,7 +231,7 @@ public class DurableSinglyLinkedListNGPrintTest {
vinfo.dtype = DurableType.DOUBLE;
vinfo.frames = Utils.genNativeParamForm(objstack, fidinfostack);
ValueInfo[] vinfos = {vinfo};
- gcsvr.perform(vinfos);
+ gcsvr.perform(null, vinfos);
// Assert.assert, expected);(plist, plist2);
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e2eb6b01/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
index 1c939d3..1697341 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/test/java/org/apache/mnemonic/service/computingservice/DurableSinglyLinkedListNGSortTest.java
@@ -141,7 +141,7 @@ public class DurableSinglyLinkedListNGSortTest {
vinfo.dtype = DurableType.SHORT;
vinfo.frames = Utils.genNativeParamForm(objstack, fidinfostack);
ValueInfo[] vinfos = {vinfo};
- long[] ret = gcsvr.perform(vinfos);
+ long[] ret = gcsvr.perform("tensor_bubble", vinfos);
Assert.assertEquals(1, ret.length);
long handler2 = ret[0];
@@ -262,7 +262,7 @@ public class DurableSinglyLinkedListNGSortTest {
vinfo.dtype = DurableType.DOUBLE;
vinfo.frames = Utils.genNativeParamForm(objstack, fidinfostack);
ValueInfo[] vinfos = {vinfo};
- gcsvr.perform(vinfos);
+ gcsvr.perform("tensor_bubble", vinfos);
// Assert.assert, expected);(plist, plist2);
DurableSinglyLinkedList<DurableSinglyLinkedList<Double>> linkedvals3 = DurableSinglyLinkedListFactory.restore(m_act,
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e2eb6b01/mnemonic-core/src/main/java/org/apache/mnemonic/service/computingservice/GeneralComputingService.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/service/computingservice/GeneralComputingService.java b/mnemonic-core/src/main/java/org/apache/mnemonic/service/computingservice/GeneralComputingService.java
index e05fec6..1608e96 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/service/computingservice/GeneralComputingService.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/service/computingservice/GeneralComputingService.java
@@ -38,11 +38,14 @@ public interface GeneralComputingService {
/**
* perform native functionalities according to prepared computing parameters
*
+ * @param mode
+ * a selection mode of run instance
+ *
* @param valinfos
* an array of value info
*
* @return the array of handler about updated object graphs if any
*/
- long[] perform(ValueInfo[] valinfos);
+ long[] perform(String mode, ValueInfo[] valinfos);
}
[06/14] incubator-mnemonic git commit: MNEMONIC-162: Add a bench
workload for sorting
Posted by ga...@apache.org.
MNEMONIC-162: Add a bench workload for sorting
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/07aace85
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/07aace85
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/07aace85
Branch: refs/heads/master
Commit: 07aace852d32bd127cc7141966e5d9fdb23abb43
Parents: f2490df
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Tue Nov 8 12:21:31 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:50:10 2016 -0800
----------------------------------------------------------------------
mnemonic-benches/mnemonic-sort-bench/pom.xml | 151 +++++++++++++++++++
.../java/org/apache/mnemonic/bench/Sort.java | 42 ++++++
.../src/main/resources/log4j.properties | 33 ++++
mnemonic-benches/pom.xml | 97 ++++++++++++
pom.xml | 1 +
5 files changed, 324 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/07aace85/mnemonic-benches/mnemonic-sort-bench/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/pom.xml b/mnemonic-benches/mnemonic-sort-bench/pom.xml
new file mode 100644
index 0000000..06bc239
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/pom.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.mnemonic</groupId>
+ <artifactId>mnemonic-benches</artifactId>
+ <version>0.3.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mnemonic-sort-bench</artifactId>
+ <name>mnemonic-sort-bench</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>${project.groupId}.bench.Sort</mainClass>
+ </transformer>
+ </transformers>
+ <minimizeJar>true</minimizeJar>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.10</version>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mnemonic-nvml-vmem-service</artifactId>
+ <version>${project.version}</version>
+ <classifier>${os.detected.classifier}</classifier>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mnemonic-pmalloc-service</artifactId>
+ <version>${project.version}</version>
+ <classifier>${os.detected.classifier}</classifier>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mnemonic-utilities-service</artifactId>
+ <version>${project.version}</version>
+ <classifier>${os.detected.classifier}</classifier>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/service-dist</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>bench</id>
+ <activation>
+ <property>
+ <name>bench</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>java</executable>
+ <arguments>
+ <argument>-Djava.ext.dirs=${project.build.directory}/service-dist</argument>
+ <argument>-ea</argument>
+ <argument>-classpath</argument>
+ <classpath />
+ <argument>${project.groupId}.bench.Sort</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/07aace85/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
new file mode 100644
index 0000000..9e44c4e
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
@@ -0,0 +1,42 @@
+/*
+ * 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.mnemonic.bench;
+
+import java.util.Random;
+
+
+/**
+ * Main is the class of example.
+ *
+ */
+@SuppressWarnings("restriction")
+public class Sort {
+
+ /**
+ * Run a example code to demonstrate some basic functionalities.
+ *
+ * @param argv
+ * array of commandline parameters
+ */
+ public static void main(String[] argv) throws Exception {
+ Random randomGenerator = new Random();
+
+ System.out.println("-------------------");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/07aace85/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
new file mode 100644
index 0000000..24b0e3c
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+# Root logger option
+log4j.rootLogger=INFO, file, stdout
+
+#to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
+
+#to log.log file
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=log.log
+log4j.appender.file.MaxFileSize=10MB
+log4j.appender.file.MaxBackupIndex=10
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/07aace85/mnemonic-benches/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/pom.xml b/mnemonic-benches/pom.xml
new file mode 100644
index 0000000..899bb2a
--- /dev/null
+++ b/mnemonic-benches/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.mnemonic</groupId>
+ <artifactId>mnemonic-parent</artifactId>
+ <version>0.3.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>mnemonic-benches</artifactId>
+ <name>mnemonic-benches</name>
+ <packaging>pom</packaging>
+ <url>http://mnemonic.incubator.apache.org</url>
+
+ <properties>
+ <service.basedir>${project.parent.basedir}</service.basedir>
+ </properties>
+
+ <modules>
+ <module>mnemonic-sort-bench</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.mnemonic</groupId>
+ <artifactId>mnemonic-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- logging dependencies -->
+ <!-- assume all APIs will be used -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.4.0.Final</version>
+ </extension>
+ </extensions>
+ <plugins>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.10</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
+
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/07aace85/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 111689f..33e946a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,6 +92,7 @@
<module>mnemonic-examples</module>
<module>mnemonic-memory-services</module>
<module>mnemonic-computing-services</module>
+ <module>mnemonic-benches</module>
</modules>
<properties>
[09/14] incubator-mnemonic git commit: MNEMONIC-158: Add durable
native computing sorting workload for bench workload
Posted by ga...@apache.org.
MNEMONIC-158: Add durable native computing sorting workload for bench workload
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/53bf3b67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/53bf3b67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/53bf3b67
Branch: refs/heads/master
Commit: 53bf3b67df91a8b12097465fe74109dba90334b4
Parents: 052f713
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Fri Nov 11 16:04:36 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:51:14 2016 -0800
----------------------------------------------------------------------
mnemonic-benches/mnemonic-sort-bench/pom.xml | 14 ++++
.../apache/mnemonic/bench/DNCSTextFileSort.java | 80 +++++++++++++++++++-
.../mnemonic/bench/RegularTestFileSort.java | 30 +++++++-
.../java/org/apache/mnemonic/bench/Sort.java | 16 +++-
.../org/apache/mnemonic/bench/TextFileSort.java | 8 +-
mnemonic-benches/pom.xml | 5 ++
.../src/main/native/common.c | 8 +-
7 files changed, 143 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-benches/mnemonic-sort-bench/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/pom.xml b/mnemonic-benches/mnemonic-sort-bench/pom.xml
index b4aed55..32aed1e 100644
--- a/mnemonic-benches/mnemonic-sort-bench/pom.xml
+++ b/mnemonic-benches/mnemonic-sort-bench/pom.xml
@@ -93,6 +93,20 @@
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
+ <artifactId>mnemonic-sys-vmem-service</artifactId>
+ <version>${project.version}</version>
+ <classifier>${os.detected.classifier}</classifier>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mnemonic-nvml-pmem-service</artifactId>
+ <version>${project.version}</version>
+ <classifier>${os.detected.classifier}</classifier>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
<artifactId>mnemonic-pmalloc-service</artifactId>
<version>${project.version}</version>
<classifier>${os.detected.classifier}</classifier>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
index 9f15f84..e2fe132 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
@@ -20,22 +20,94 @@ package org.apache.mnemonic.bench;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.mnemonic.VolatileMemAllocator;
+import org.apache.mnemonic.EntityFactoryProxy;
+import org.apache.mnemonic.Utils;
+import org.apache.mnemonic.DurableType;
+import org.apache.mnemonic.collections.DurableSinglyLinkedList;
+import org.apache.mnemonic.collections.DurableSinglyLinkedListFactory;
+import org.apache.mnemonic.service.computingservice.GeneralComputingService;
+import org.apache.mnemonic.service.computingservice.ValueInfo;
public class DNCSTextFileSort implements TextFileSort {
+ private String uri = "";
+ private VolatileMemAllocator m_act = null;
+ private DurableType[] elem_gftypes = {DurableType.LONG};
+ private EntityFactoryProxy[] elem_efproxies = null;
+ private Long head;
+ private long[] sortinfo = new long[3];
+ private long[][] ostack;
- @Override
- public void build(BufferedReader reader) throws NumberFormatException, IOException {
+ public DNCSTextFileSort() {
+ }
+ @Override
+ public void load(BufferedReader reader) throws NumberFormatException, IOException {
+ if (null != m_act) {
+ clear();
+ }
+ m_act = new VolatileMemAllocator(Utils.getVolatileMemoryAllocatorService("sysvmem"), 1024 * 1024 * 1024 * 5,
+ uri, true);
+ String text = null;
+ DurableSinglyLinkedList<Long> curnode = null, prvnode = null, node = null;
+ Long val;
+ while ((text = reader.readLine()) != null) {
+ val = Long.parseLong(text);
+ curnode = DurableSinglyLinkedListFactory.create(m_act, elem_efproxies, elem_gftypes, false);
+ curnode.setItem(val, false);
+ if (null == prvnode) {
+ this.head = curnode.getHandler();
+ this.ostack = curnode.getNativeFieldInfo();
+ } else {
+ prvnode.setNext(curnode, false);
+ }
+ prvnode = curnode;
+ }
}
@Override
public void doSort() {
-
+ GeneralComputingService gcsvr = Utils.getGeneralComputingService("sort");
+ ValueInfo vinfo = new ValueInfo();
+ List<long[][]> objstack = new ArrayList<long[][]>();
+ objstack.add(this.ostack);
+ long[][] fidinfostack = {{2L, 1L}};
+ vinfo.handler = this.head;
+ vinfo.transtable = m_act.getTranslateTable();
+ vinfo.dtype = DurableType.LONG;
+ vinfo.frames = Utils.genNativeParamForm(objstack, fidinfostack);
+ ValueInfo[] vinfos = {vinfo};
+ long[] ret = gcsvr.perform("1dlong_bubble", vinfos);
+ this.head = ret[0];
+ this.sortinfo[0] = ret[1];
+ this.sortinfo[1] = ret[2];
+ this.sortinfo[2] = ret[3];
}
@Override
- public void save(BufferedWriter writer) throws IOException {
+ public void store(BufferedWriter writer) throws IOException {
+ DurableSinglyLinkedList<Long> linkvals = DurableSinglyLinkedListFactory.restore(m_act,
+ elem_efproxies, elem_gftypes, this.head, false);
+ Iterator<Long> elemiter = linkvals.iterator();
+ Long val;
+ while (elemiter.hasNext()) {
+ val = elemiter.next();
+ writer.write(val.toString());
+ writer.newLine();
+ }
+ }
+ @Override
+ public long[] getSortInfo() {
+ return this.sortinfo;
}
+ @Override
+ public void clear() {
+ m_act.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
index 2fe77de..536e362 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
@@ -24,12 +24,13 @@ import java.io.IOException;
public class RegularTestFileSort implements TextFileSort {
private Node<Long> head;
+ private long[] sortinfo = new long[3];
public RegularTestFileSort() {
}
@Override
- public void build(BufferedReader reader) throws NumberFormatException, IOException {
+ public void load(BufferedReader reader) throws NumberFormatException, IOException {
String text = null;
Node<Long> curnode = null;
Long val;
@@ -44,15 +45,21 @@ public class RegularTestFileSort implements TextFileSort {
}
}
}
+
@Override
public void doSort() {
Node<Long> curnode, tmpnode, prevnode;
+ long cntscan = 0L, cntswap = 0L, cntnoswap = 0L;
boolean changed;
+ if (null == this.head) {
+ return;
+ }
do {
+ ++cntscan;
curnode = this.head;
prevnode = null;
changed = false;
- while (null != curnode) {
+ while (true) {
tmpnode = curnode.getNext();
if (null == tmpnode) {
break;
@@ -67,16 +74,22 @@ public class RegularTestFileSort implements TextFileSort {
}
prevnode = tmpnode;
changed = true;
+ ++cntswap;
} else {
prevnode = curnode;
curnode = tmpnode;
+ ++cntnoswap;
}
}
} while (changed);
+ this.sortinfo[0] = cntscan;
+ this.sortinfo[1] = cntswap;
+ this.sortinfo[2] = cntnoswap;
}
+
@Override
- public void save(BufferedWriter writer) throws IOException {
- Node<Long> curnode = head;
+ public void store(BufferedWriter writer) throws IOException {
+ Node<Long> curnode = this.head;
while (null != curnode) {
writer.write(curnode.getData().toString());
writer.newLine();
@@ -84,4 +97,13 @@ public class RegularTestFileSort implements TextFileSort {
}
}
+ @Override
+ public long[] getSortInfo() {
+ return this.sortinfo;
+ }
+
+ @Override
+ public void clear() {
+ this.head = null;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
index df96058..daca7da 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
@@ -110,14 +110,16 @@ public class Sort {
}
sttime = System.nanoTime();
- tfsorter.build(reader);
- reportElapse("Build Time", sttime, System.nanoTime());
+ tfsorter.load(reader);
+ reportElapse("Load Time", sttime, System.nanoTime());
sttime = System.nanoTime();
tfsorter.doSort();
reportElapse("Sort Time", sttime, System.nanoTime());
sttime = System.nanoTime();
- tfsorter.save(writer);
- reportElapse("Save Time", sttime, System.nanoTime());
+ tfsorter.store(writer);
+ reportElapse("Store Time", sttime, System.nanoTime());
+ reportSortInfo(tfsorter.getSortInfo());
+ tfsorter.clear();
} catch (FileNotFoundException e) {
System.err.println(e.getMessage());
throw e;
@@ -143,4 +145,10 @@ public class Sort {
System.out.println(String.format("%s : %,d ms.", msg,
TimeUnit.NANOSECONDS.toMillis(t2 - t1)));
}
+
+ static void reportSortInfo(long[] sortinfo) {
+ System.out.println(String.format("Scan Count: %,d ", sortinfo[0]));
+ System.out.println(String.format("Swap Count: %,d ", sortinfo[1]));
+ System.out.println(String.format("No Swap Count : %,d ", sortinfo[2]));
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
index b88d893..88cd0de 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
@@ -23,9 +23,13 @@ import java.io.IOException;
public interface TextFileSort {
- void build(BufferedReader reader) throws NumberFormatException, IOException;
+ void load(BufferedReader reader) throws NumberFormatException, IOException;
void doSort();
- void save(BufferedWriter writer) throws IOException;
+ void store(BufferedWriter writer) throws IOException;
+
+ long[] getSortInfo();
+
+ void clear();
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-benches/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/pom.xml b/mnemonic-benches/pom.xml
index 9c5a664..377f1c0 100644
--- a/mnemonic-benches/pom.xml
+++ b/mnemonic-benches/pom.xml
@@ -49,6 +49,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.mnemonic</groupId>
+ <artifactId>mnemonic-collections</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/53bf3b67/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
index 7f7a35c..1bf50d1 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
@@ -276,7 +276,7 @@ jlongArray constructJLongArray(JNIEnv* env, long arr[], size_t sz) {
inline void *to_e(JNIEnv* env, struct NValueInfo *nvinfo, long p) {
size_t i;
struct transitem * ti;
- if (NULL != nvinfo || NULL != nvinfo->transtable) {
+ if (NULL != nvinfo && NULL != nvinfo->transtable) {
for (i = 0; i < nvinfo->transtablesz; ++i) {
ti = nvinfo->transtable + i;
if (p >= ti->hdlbase && p < ti->size) {
@@ -285,7 +285,7 @@ inline void *to_e(JNIEnv* env, struct NValueInfo *nvinfo, long p) {
}
throw(env, "No item found in Translate Table.");
} else {
- return p;
+ return addr_from_java(p);
}
return NULL;
}
@@ -293,7 +293,7 @@ inline void *to_e(JNIEnv* env, struct NValueInfo *nvinfo, long p) {
inline long to_p(JNIEnv* env, struct NValueInfo *nvinfo, void *e) {
size_t i;
struct transitem * ti;
- if (NULL != nvinfo || NULL != nvinfo->transtable) {
+ if (NULL != nvinfo && NULL != nvinfo->transtable) {
for (i = 0; i < nvinfo->transtablesz; ++i) {
ti = nvinfo->transtable + i;
if (e >= ti->base && e < ti->base + ti->size) {
@@ -302,7 +302,7 @@ inline long to_p(JNIEnv* env, struct NValueInfo *nvinfo, void *e) {
}
throw(env, "No item found in Translate Table.");
} else {
- return e;
+ return addr_to_java(e);
}
return -1L;
}
[04/14] incubator-mnemonic git commit: MNEMONIC-151: Accept null
transtable for volatile memory service
Posted by ga...@apache.org.
MNEMONIC-151: Accept null transtable for volatile memory service
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/51107ce6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/51107ce6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/51107ce6
Branch: refs/heads/master
Commit: 51107ce64d6f58f542a1ce949b821f25b17fa508
Parents: f600bd2
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Sat Nov 12 12:26:21 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:49:30 2016 -0800
----------------------------------------------------------------------
.../mnemonic-utilities-service/src/main/native/common.c | 12 ++++++++----
.../java/org/apache/mnemonic/VolatileMemAllocator.java | 6 ++++++
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/51107ce6/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
index 998334b..7f7a35c 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/common.c
@@ -106,8 +106,12 @@ struct NValueInfo *constructNValInfo(JNIEnv* env, jobject vinfoobj) {
ret->dtype = (*env)->CallIntMethod(env, dutobj, getval_mtd);
jobjectArray tbarr = (*env)->GetObjectField(env, vinfoobj, transtable_fid);
- jsize tbarrlen = (*env)->GetArrayLength(env, tbarr);
- if (NULL != tbarr && tbarrlen > 0){
+ jsize tbarrlen = 0;
+ ret->transtablesz = 0;
+ if (NULL != tbarr) {
+ tbarrlen = (*env)->GetArrayLength(env, tbarr);
+ }
+ if (tbarrlen > 0){
ret->transtable = (struct transitem *)calloc(
tbarrlen, sizeof(struct transitem));
if (NULL != ret->transtable) {
@@ -281,7 +285,7 @@ inline void *to_e(JNIEnv* env, struct NValueInfo *nvinfo, long p) {
}
throw(env, "No item found in Translate Table.");
} else {
- throw(env, "NValueInfo or Translate Table is NULL.");
+ return p;
}
return NULL;
}
@@ -298,7 +302,7 @@ inline long to_p(JNIEnv* env, struct NValueInfo *nvinfo, void *e) {
}
throw(env, "No item found in Translate Table.");
} else {
- throw(env, "NValueInfo or Translate Table is NULL.");
+ return e;
}
return -1L;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/51107ce6/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java b/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
index 453129b..4f4fdbc 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
@@ -480,6 +480,9 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
@Override
public long getPortableAddress(long addr) {
int i;
+ if (null == m_ttable) {
+ return addr;
+ }
for (i = 0; i < m_ttable.length; ++i) {
if (addr >= m_ttable[i][2] && addr < m_ttable[i][1] + m_ttable[i][2]) {
return addr - m_ttable[i][2];
@@ -499,6 +502,9 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
@Override
public long getEffectiveAddress(long addr) {
int i;
+ if (null == m_ttable) {
+ return addr;
+ }
for (i = 0; i < m_ttable.length; ++i) {
if (addr >= m_ttable[i][0] && addr < m_ttable[i][1]) {
return addr + m_ttable[i][2];
[14/14] incubator-mnemonic git commit: MNEMONIC-166 - Add run sort
bench section to README
Posted by ga...@apache.org.
MNEMONIC-166 - Add run sort bench section to README
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/becaead0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/becaead0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/becaead0
Branch: refs/heads/master
Commit: becaead0e6163e2d0f718800eb7ae99681c0bf20
Parents: 9560658
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Sat Nov 19 10:16:55 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Sat Nov 19 10:22:52 2016 -0800
----------------------------------------------------------------------
README.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/becaead0/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 990df94..cd4da44 100644
--- a/README.md
+++ b/README.md
@@ -287,6 +287,20 @@ To run several test cases:
$ mvn -Dtest=DurableSinglyLinkedListNGSortTest test -pl mnemonic-computing-services/mnemonic-utilities-service -DskipTests=false
```
+
+### How to benchmark ?
+To run sort bench workloads.
+```bash
+ $ # generate some input data files with a count parameter that indicates how many random numbers to be generated
+ $ mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py 20000
+ $ # create a configure file that contains all the absolute paths of generated input data files to work on in a batch
+ $ # call the run.py to run the bench workloads with the configure file
+ $ mnemonic-benches/mnemonic-sort-bench/bin/run.py ./sort-files.conf
+ $ # after finished, you can find the result data from the sort_bench_result.log
+ $ less mnemonic-benches/mnemonic-sort-bench/sort_bench_result.log
+```
+
+
### Where is the document ?
* Source code comments
* [API Documentation](http://nonvolatilecomputing.github.io/Mnemonic/apidocs/index.html)
[13/14] incubator-mnemonic git commit: MNEMONIC-165 - Add sys-vmem
service to Durable Memory Service Comparison Table in README
Posted by ga...@apache.org.
MNEMONIC-165 - Add sys-vmem service to Durable Memory Service Comparison Table in README
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/95606582
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/95606582
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/95606582
Branch: refs/heads/master
Commit: 956065829557f7e195ed09a525cfd3240e79c7e4
Parents: 17d7648
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Sat Nov 19 09:59:45 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Sat Nov 19 10:01:36 2016 -0800
----------------------------------------------------------------------
README.md | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/95606582/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 9f5a776..990df94 100644
--- a/README.md
+++ b/README.md
@@ -202,6 +202,7 @@ Please see the file LICENSE for information on how this library is licensed.
* **mnemonic-memory-services/mnemonic-pmalloc-service** -- the submodule project for pmalloc memory service
* **mnemonic-memory-services/mnemonic-nvml-vmem-service** -- the submodule project for vmem memory service
* **mnemonic-memory-services/mnemonic-nvml-pmem-service** -- the submodule project for pmem memory service
+* **mnemonic-memory-services/mnemonic-sys-vmem-service** -- the submodule project for system vmem memory service
* **mnemonic-memory-services/service-dist** -- the location of extensive memory services (auto-generated)
* **mnemonic-computing-services/mnemonic-utilities-service** -- the submodule project for utilities computing service
* **mnemonic-computing-services/service-dist** -- the location of extensive computing services (auto-generated)
@@ -210,18 +211,18 @@ Please see the file LICENSE for information on how this library is licensed.
#### Durable Memory Service Comparison Table
-| Features | NVML-VMEM | PMALLOC | NVML-PMEM |
-|---------------------------------|:---------------:|:-------------:|:---------------:|
-| Fixed Durable K-V Store | NA | O | O |
-| Support DOM | O | O | O |
-| Support DNCM | O | O | O |
-| Support OS X | NA | O | NA |
-| Memory Map Sync. | NA | O | O |
-| PM Flush | NA | NA | O |
-| PM Drain | NA | NA | O |
-| PM Persist | NA | NA | O |
-| PM Atomic Ops. | NA | NA | O |
-| Performance | High | High | Low |
+| Features | NVML-VMEM | PMALLOC | NVML-PMEM | SYS-VMEM |
+|---------------------------------|:---------------:|:-------------:|:---------------:|:---------------:|
+| Fixed Durable K-V Store | NA | O | O | NA |
+| Support DOM | O | O | O | O |
+| Support DNCM | O | O | O | O |
+| Support OS X | NA | O | NA | O |
+| Memory Map Sync. | NA | O | O | NA |
+| PM Flush | NA | NA | O | NA |
+| PM Drain | NA | NA | O | NA |
+| PM Persist | NA | NA | O | NA |
+| PM Atomic Ops. | NA | NA | O | NA |
+| Expected Performance | Average | Average | Slow(on Disk) | Fast |
To build this library, you may need to install some required packages on the build system:
[11/14] incubator-mnemonic git commit: MNEMONIC-163 - Collect outputs
of sort-bench to a log file
Posted by ga...@apache.org.
MNEMONIC-163 - Collect outputs of sort-bench to a log file
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/b5fbd946
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/b5fbd946
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/b5fbd946
Branch: refs/heads/master
Commit: b5fbd94612af594d4c97771fcce1d738ff3d10b1
Parents: e30ac72
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Thu Nov 17 13:10:31 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 14:44:58 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/mnemonic/bench/Sort.java | 27 ++++++-----
.../src/main/resources/log4j.properties | 33 -------------
.../src/main/resources/logback.xml | 49 ++++++++++++++++++++
mnemonic-benches/pom.xml | 16 -------
4 files changed, 65 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
index daca7da..96972ce 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
@@ -24,7 +24,10 @@ import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
-import java.util.Random;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
import java.util.concurrent.TimeUnit;
import java.io.File;
import java.io.BufferedReader;
@@ -39,15 +42,16 @@ import java.io.FileNotFoundException;
*
*/
public class Sort {
-
/**
* Run workloads to bench performance.
*
* @param args
* array of commandline parameters
*/
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Sort.class);
+
public static void main(String[] args) throws Exception {
- Random randomGenerator = new Random();
Options options = new Options();
@@ -83,10 +87,11 @@ public class Sort {
System.exit(1);
return;
}
+ MDC.put("mode", String.format("Mode-%s", runMode));
- System.out.println(String.format("Run Mode is %s", runMode));
- System.out.println(String.format("Input file is %s", inputFilePath));
- System.out.println(String.format("Output file is %s", outputFilePath));
+ LOGGER.info("Run Mode : {}", runMode);
+ LOGGER.info("Input file : {}", inputFilePath);
+ LOGGER.info("Output file : {}", outputFilePath);
File inputFile = new File(inputFilePath);
File outputFile = new File(outputFilePath);
@@ -142,13 +147,13 @@ public class Sort {
}
static void reportElapse(String msg, long t1, long t2) {
- System.out.println(String.format("%s : %,d ms.", msg,
- TimeUnit.NANOSECONDS.toMillis(t2 - t1)));
+ LOGGER.info("{} : {} ms.", msg,
+ TimeUnit.NANOSECONDS.toMillis(t2 - t1));
}
static void reportSortInfo(long[] sortinfo) {
- System.out.println(String.format("Scan Count: %,d ", sortinfo[0]));
- System.out.println(String.format("Swap Count: %,d ", sortinfo[1]));
- System.out.println(String.format("No Swap Count : %,d ", sortinfo[2]));
+ LOGGER.info("Scan Count : {} ", sortinfo[0]);
+ LOGGER.info("Swap Count : {} ", sortinfo[1]);
+ LOGGER.info("No Swap Count : {} ", sortinfo[2]);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
deleted file mode 100644
index 24b0e3c..0000000
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,33 +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.
-#
-
-# Root logger option
-log4j.rootLogger=INFO, file, stdout
-
-#to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
-
-#to log.log file
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=log.log
-log4j.appender.file.MaxFileSize=10MB
-log4j.appender.file.MaxBackupIndex=10
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml
new file mode 100644
index 0000000..367c140
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/resources/logback.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="RESULT_FILE" class="ch.qos.logback.core.FileAppender">
+ <file>sort_bench_result.log</file>
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <Pattern>%d [%thread] %-5level %X{mode} %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.apache.mnemonic.bench" level="INFO" additivity="false">
+ <appender-ref ref="RESULT_FILE" />
+ </logger>
+
+ <!-- Strictly speaking, the level attribute is not necessary since -->
+ <!-- the level of the root level is set to DEBUG by default. -->
+ <root level="DEBUG">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/b5fbd946/mnemonic-benches/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/pom.xml b/mnemonic-benches/pom.xml
index bf8a3c1..56ef788 100644
--- a/mnemonic-benches/pom.xml
+++ b/mnemonic-benches/pom.xml
@@ -64,22 +64,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
[10/14] incubator-mnemonic git commit: MNEMONIC-161: add classic
logback logger dependency
Posted by ga...@apache.org.
MNEMONIC-161: add classic logback logger dependency
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/e30ac725
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/e30ac725
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/e30ac725
Branch: refs/heads/master
Commit: e30ac7250526f5d4e5480de1653d005069c91ccf
Parents: 53bf3b6
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Thu Nov 17 12:18:08 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:51:33 2016 -0800
----------------------------------------------------------------------
mnemonic-benches/pom.xml | 8 ++++++++
pom.xml | 11 +++++++++++
2 files changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e30ac725/mnemonic-benches/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/pom.xml b/mnemonic-benches/pom.xml
index 377f1c0..bf8a3c1 100644
--- a/mnemonic-benches/pom.xml
+++ b/mnemonic-benches/pom.xml
@@ -79,6 +79,14 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e30ac725/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 04df5c5..7e10bf0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,7 @@
<gpg.keyname>apache.org</gpg.keyname>
<slf4j.version>1.7.21</slf4j.version>
<log4j.version>1.2.17</log4j.version>
+ <logback.version>1.1.7</logback.version>
</properties>
<repositories>
@@ -172,6 +173,16 @@
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
[08/14] incubator-mnemonic git commit: MNEMONIC-157: Add regular
sorting workload for bench workload
Posted by ga...@apache.org.
MNEMONIC-157: Add regular sorting workload for bench workload
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/052f7134
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/052f7134
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/052f7134
Branch: refs/heads/master
Commit: 052f7134fec619dc83c0b3197cf736589ccf12a0
Parents: 4e02a15
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Thu Nov 10 10:01:07 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:50:50 2016 -0800
----------------------------------------------------------------------
.../apache/mnemonic/bench/DNCSTextFileSort.java | 41 +++++++++
.../java/org/apache/mnemonic/bench/Node.java | 46 +++++++++++
.../mnemonic/bench/RegularTestFileSort.java | 87 ++++++++++++++++++++
.../java/org/apache/mnemonic/bench/Sort.java | 32 ++++---
.../org/apache/mnemonic/bench/TextFileSort.java | 31 +++++++
5 files changed, 227 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/052f7134/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
new file mode 100644
index 0000000..9f15f84
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/DNCSTextFileSort.java
@@ -0,0 +1,41 @@
+/*
+ * 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.mnemonic.bench;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+
+public class DNCSTextFileSort implements TextFileSort {
+
+ @Override
+ public void build(BufferedReader reader) throws NumberFormatException, IOException {
+
+ }
+
+ @Override
+ public void doSort() {
+
+ }
+
+ @Override
+ public void save(BufferedWriter writer) throws IOException {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/052f7134/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Node.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Node.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Node.java
new file mode 100644
index 0000000..f653853
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Node.java
@@ -0,0 +1,46 @@
+/*
+ * 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.mnemonic.bench;
+
+public class Node<T> {
+
+ T data;
+ Node<T> nextNode;
+
+ public Node(T data) {
+ this.data = data;
+ this.nextNode = null;
+ }
+
+ public Node(T data, Node<T> node) {
+ this.data = data;
+ this.nextNode = node;
+ }
+
+ public T getData() {
+ return this.data;
+ }
+
+ public void setNext(Node<T> node) {
+ this.nextNode = node;
+ }
+
+ public Node<T> getNext() {
+ return this.nextNode;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/052f7134/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
new file mode 100644
index 0000000..2fe77de
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/RegularTestFileSort.java
@@ -0,0 +1,87 @@
+/*
+ * 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.mnemonic.bench;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+
+public class RegularTestFileSort implements TextFileSort {
+
+ private Node<Long> head;
+
+ public RegularTestFileSort() {
+ }
+
+ @Override
+ public void build(BufferedReader reader) throws NumberFormatException, IOException {
+ String text = null;
+ Node<Long> curnode = null;
+ Long val;
+ while ((text = reader.readLine()) != null) {
+ val = Long.parseLong(text);
+ if (null == curnode) {
+ curnode = new Node<Long>(val);
+ this.head = curnode;
+ } else {
+ curnode.setNext(new Node<Long>(val));
+ curnode = curnode.getNext();
+ }
+ }
+ }
+ @Override
+ public void doSort() {
+ Node<Long> curnode, tmpnode, prevnode;
+ boolean changed;
+ do {
+ curnode = this.head;
+ prevnode = null;
+ changed = false;
+ while (null != curnode) {
+ tmpnode = curnode.getNext();
+ if (null == tmpnode) {
+ break;
+ }
+ if (curnode.getData().compareTo(tmpnode.getData()) > 0) {
+ curnode.setNext(tmpnode.getNext());
+ tmpnode.setNext(curnode);
+ if (null == prevnode) {
+ this.head = tmpnode;
+ } else {
+ prevnode.setNext(tmpnode);
+ }
+ prevnode = tmpnode;
+ changed = true;
+ } else {
+ prevnode = curnode;
+ curnode = tmpnode;
+ }
+ }
+ } while (changed);
+ }
+ @Override
+ public void save(BufferedWriter writer) throws IOException {
+ Node<Long> curnode = head;
+ while (null != curnode) {
+ writer.write(curnode.getData().toString());
+ writer.newLine();
+ curnode = curnode.getNext();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/052f7134/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
index 8f6e4ef..df96058 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
@@ -25,6 +25,7 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import java.io.File;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -34,10 +35,9 @@ import java.io.IOException;
import java.io.FileNotFoundException;
/**
- * Main is the class of example.
+ * Sort is the class of sort-bench.
*
*/
-@SuppressWarnings("restriction")
public class Sort {
/**
@@ -94,21 +94,30 @@ public class Sort {
BufferedReader reader = null;
BufferedWriter writer = null;
+ TextFileSort tfsorter = null;
+
+ long sttime;
+
try {
reader = new BufferedReader(new FileReader(inputFile));
writer = new BufferedWriter(new FileWriter(outputFile));
if (runMode.equals("A")) {
/* regular way */
- String text = null;
- while ((text = reader.readLine()) != null) {
- System.out.println(text);
- writer.write(text);
- writer.newLine();
- }
+ tfsorter = new RegularTestFileSort();
} else {
/* mnemonic way */
- System.out.println("mnemonic way");
+ tfsorter = new DNCSTextFileSort();
}
+
+ sttime = System.nanoTime();
+ tfsorter.build(reader);
+ reportElapse("Build Time", sttime, System.nanoTime());
+ sttime = System.nanoTime();
+ tfsorter.doSort();
+ reportElapse("Sort Time", sttime, System.nanoTime());
+ sttime = System.nanoTime();
+ tfsorter.save(writer);
+ reportElapse("Save Time", sttime, System.nanoTime());
} catch (FileNotFoundException e) {
System.err.println(e.getMessage());
throw e;
@@ -128,7 +137,10 @@ public class Sort {
throw e;
}
}
-
}
+ static void reportElapse(String msg, long t1, long t2) {
+ System.out.println(String.format("%s : %,d ms.", msg,
+ TimeUnit.NANOSECONDS.toMillis(t2 - t1)));
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/052f7134/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
new file mode 100644
index 0000000..b88d893
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/TextFileSort.java
@@ -0,0 +1,31 @@
+/*
+ * 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.mnemonic.bench;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+
+public interface TextFileSort {
+
+ void build(BufferedReader reader) throws NumberFormatException, IOException;
+
+ void doSort();
+
+ void save(BufferedWriter writer) throws IOException;
+}
[07/14] incubator-mnemonic git commit: MNEMONIC-155: Support mode,
input and output parameters for sort-bench
Posted by ga...@apache.org.
MNEMONIC-155: Support mode, input and output parameters for sort-bench
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/4e02a15b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/4e02a15b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/4e02a15b
Branch: refs/heads/master
Commit: 4e02a15b11c68b806efb9db5b92f66da4e7f5eed
Parents: 07aace8
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Wed Nov 9 11:02:37 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:50:31 2016 -0800
----------------------------------------------------------------------
mnemonic-benches/mnemonic-sort-bench/pom.xml | 14 ++-
.../java/org/apache/mnemonic/bench/Sort.java | 102 ++++++++++++++++++-
mnemonic-benches/pom.xml | 4 +
pom.xml | 5 +
4 files changed, 119 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/4e02a15b/mnemonic-benches/mnemonic-sort-bench/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/pom.xml b/mnemonic-benches/mnemonic-sort-bench/pom.xml
index 06bc239..b4aed55 100644
--- a/mnemonic-benches/mnemonic-sort-bench/pom.xml
+++ b/mnemonic-benches/mnemonic-sort-bench/pom.xml
@@ -32,6 +32,12 @@
<name>mnemonic-sort-bench</name>
<packaging>jar</packaging>
+ <properties>
+ <mode></mode>
+ <input></input>
+ <output></output>
+ </properties>
+
<dependencies>
</dependencies>
@@ -134,11 +140,17 @@
<configuration>
<executable>java</executable>
<arguments>
- <argument>-Djava.ext.dirs=${project.build.directory}/service-dist</argument>
+ <argument>-Djava.ext.dirs=${project.build.directory}/service-dist</argument>
<argument>-ea</argument>
<argument>-classpath</argument>
<classpath />
<argument>${project.groupId}.bench.Sort</argument>
+ <argument>-m</argument>
+ <argument>${mode}</argument>
+ <argument>-i</argument>
+ <argument>${input}</argument>
+ <argument>-o</argument>
+ <argument>${output}</argument>
</arguments>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/4e02a15b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
index 9e44c4e..8f6e4ef 100644
--- a/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
+++ b/mnemonic-benches/mnemonic-sort-bench/src/main/java/org/apache/mnemonic/bench/Sort.java
@@ -17,8 +17,21 @@
package org.apache.mnemonic.bench;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.ParseException;
import java.util.Random;
-
+import java.io.File;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.FileNotFoundException;
/**
* Main is the class of example.
@@ -28,15 +41,94 @@ import java.util.Random;
public class Sort {
/**
- * Run a example code to demonstrate some basic functionalities.
+ * Run workloads to bench performance.
*
- * @param argv
+ * @param args
* array of commandline parameters
*/
- public static void main(String[] argv) throws Exception {
+ public static void main(String[] args) throws Exception {
Random randomGenerator = new Random();
- System.out.println("-------------------");
+ Options options = new Options();
+
+ Option mode = new Option("m", "mode", true, "run mode [A|B]");
+ mode.setRequired(true);
+ options.addOption(mode);
+
+ Option input = new Option("i", "input", true, "input file path");
+ input.setRequired(true);
+ options.addOption(input);
+
+ Option output = new Option("o", "output", true, "output file");
+ output.setRequired(true);
+ options.addOption(output);
+
+ CommandLineParser parser = new DefaultParser();
+ HelpFormatter formatter = new HelpFormatter();
+ CommandLine cmd;
+
+ String runMode, inputFilePath, outputFilePath;
+
+ try {
+ cmd = parser.parse(options, args);
+ runMode = cmd.getOptionValue("mode");
+ inputFilePath = cmd.getOptionValue("input");
+ outputFilePath = cmd.getOptionValue("output");
+ if (!runMode.equals("A") && !runMode.equals("B")) {
+ throw new ParseException("Run mode is not specified correctly, Please use A or B as run mode.");
+ }
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ formatter.printHelp("Sort-bench", options);
+ System.exit(1);
+ return;
+ }
+
+ System.out.println(String.format("Run Mode is %s", runMode));
+ System.out.println(String.format("Input file is %s", inputFilePath));
+ System.out.println(String.format("Output file is %s", outputFilePath));
+
+ File inputFile = new File(inputFilePath);
+ File outputFile = new File(outputFilePath);
+
+ BufferedReader reader = null;
+ BufferedWriter writer = null;
+
+ try {
+ reader = new BufferedReader(new FileReader(inputFile));
+ writer = new BufferedWriter(new FileWriter(outputFile));
+ if (runMode.equals("A")) {
+ /* regular way */
+ String text = null;
+ while ((text = reader.readLine()) != null) {
+ System.out.println(text);
+ writer.write(text);
+ writer.newLine();
+ }
+ } else {
+ /* mnemonic way */
+ System.out.println("mnemonic way");
+ }
+ } catch (FileNotFoundException e) {
+ System.err.println(e.getMessage());
+ throw e;
+ } catch (IOException e) {
+ System.err.println(e.getMessage());
+ throw e;
+ } finally {
+ try {
+ if (null != reader) {
+ reader.close();
+ }
+ if (null != writer) {
+ writer.close();
+ }
+ } catch (IOException e) {
+ System.err.println(e.getMessage());
+ throw e;
+ }
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/4e02a15b/mnemonic-benches/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-benches/pom.xml b/mnemonic-benches/pom.xml
index 899bb2a..9c5a664 100644
--- a/mnemonic-benches/pom.xml
+++ b/mnemonic-benches/pom.xml
@@ -48,6 +48,10 @@
<artifactId>mnemonic-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </dependency>
<!-- logging dependencies -->
<!-- assume all APIs will be used -->
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/4e02a15b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 33e946a..04df5c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -137,6 +137,11 @@
<version>0.6.1</version>
</dependency>
<dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+ <dependency>
<groupId>com.squareup</groupId>
<artifactId>javapoet</artifactId>
<version>1.6.1</version>
[03/14] incubator-mnemonic git commit: MNEMONIC-153: add a sys-vmem
service MNEMONIC-152: no return for size() in common.c
Posted by ga...@apache.org.
MNEMONIC-153: add a sys-vmem service
MNEMONIC-152: no return for size() in common.c
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/f600bd2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/f600bd2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/f600bd2b
Branch: refs/heads/master
Commit: f600bd2b87e2bfccf27f29396c806d3c9cce1f11
Parents: 0c0a20d
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Mon Nov 14 22:28:47 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:49:00 2016 -0800
----------------------------------------------------------------------
.../src/main/native/common.c | 1 +
.../src/main/native/common.c | 1 +
.../mnemonic-sys-vmem-service/pom.xml | 168 +++++++++++++
.../internal/SysVMemServiceImpl.java | 166 +++++++++++++
.../src/main/native/CMakeLists.txt | 49 ++++
.../src/main/native/LICENSE | 202 ++++++++++++++++
.../src/main/native/common.c | 89 +++++++
.../src/main/native/common.h | 65 +++++
.../src/main/native/config.h.in | 24 ++
..._memoryservice_internal_SysVMemServiceImpl.c | 238 +++++++++++++++++++
..._memoryservice_internal_SysVMemServiceImpl.h | 48 ++++
...memoryservice.VolatileMemoryAllocatorService | 1 +
.../src/main/resources/log4j.properties | 33 +++
mnemonic-memory-services/pom.xml | 1 +
14 files changed, 1086 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
index 2fa660a..91400b3 100644
--- a/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
+++ b/mnemonic-memory-services/mnemonic-nvml-vmem-service/src/main/native/common.c
@@ -85,4 +85,5 @@ vsize(VMPool *pool, void *p) {
nativebuf = p - PMBHSZ;
ret = ((PMBHeader *) nativebuf)->size - PMBHSZ;
}
+ return ret;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
index b5e5a9a..0793e3b 100644
--- a/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
+++ b/mnemonic-memory-services/mnemonic-pmalloc-service/src/main/native/common.c
@@ -85,4 +85,5 @@ pmalsize(PMALPool *pool, void *p) {
nativebuf = p - PMBHSZ;
ret = ((PMBHeader *) nativebuf)->size - PMBHSZ;
}
+ return ret;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/pom.xml b/mnemonic-memory-services/mnemonic-sys-vmem-service/pom.xml
new file mode 100644
index 0000000..0e8244d
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/pom.xml
@@ -0,0 +1,168 @@
+<?xml version="1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.mnemonic</groupId>
+ <artifactId>mnemonic-memory-services</artifactId>
+ <version>0.3.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mnemonic-sys-vmem-service</artifactId>
+ <name>mnemonic-sys-vmem-service</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/native/dist</directory>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-native</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <echo>Java Home: ${java.home}</echo>
+ <mkdir dir="src/main/native/build" />
+ <exec dir="src/main/native/build" executable="cmake" failonerror="true">
+ <arg value=".." />
+ </exec>
+ <exec dir="src/main/native/build" executable="make" failonerror="true">
+ <env key="JAVA_HOME" value="${java.home}/.." />
+ </exec>
+ </target>
+ </configuration>
+ </execution>
+ <execution>
+ <id>clean-native</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <delete dir="src/main/native/build" />
+ <delete dir="src/main/native/dist" />
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-scm-publish-plugin</artifactId>
+ <configuration>
+ <checkoutDirectory>${project.build.directory}/scmpublish</checkoutDirectory>
+ <checkinComment>Publishing javadoc for ${project.artifactId}:${project.version}</checkinComment>
+ <content>${project.reporting.outputDirectory}/apidocs</content>
+ <skipDeletedFiles>true</skipDeletedFiles>
+ <pubScmUrl>scm:git:https://github.com/bigdata-memory/mnenomic-project.git</pubScmUrl>
+ <scmBranch>gh-pages</scmBranch> <!-- branch with static site -->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>doc</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ <show>public</show>
+ <nohelp>true</nohelp>
+ <header>Mnenomic-SysVMemAllocator, ${project.version}</header>
+ <footer>Mnenomic-SysVMemAllocator, ${project.version}</footer>
+ <doctitle>Mnenomic, ${project.version}</doctitle>
+ <links>
+ <link>http://static.springsource.org/spring/docs/3.0.x/javadoc-api/</link>
+ <additionalparam>-Xdoclint:all -Xdoclint:-missing</additionalparam>
+ </links>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>test</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Xmx2g -XX:MaxPermSize=1g</argLine>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memoryservice/internal/SysVMemServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memoryservice/internal/SysVMemServiceImpl.java b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memoryservice/internal/SysVMemServiceImpl.java
new file mode 100644
index 0000000..ac4fe6c
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/java/org/apache/mnemonic/service/memoryservice/internal/SysVMemServiceImpl.java
@@ -0,0 +1,166 @@
+/*
+ * 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.mnemonic.service.memoryservice.internal;
+
+import org.apache.mnemonic.service.memoryservice.VolatileMemoryAllocatorService;
+import org.flowcomputing.commons.primitives.NativeLibraryLoader;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SysVMemServiceImpl implements VolatileMemoryAllocatorService {
+ static {
+ try {
+ NativeLibraryLoader.loadFromJar("sysvmemallocator");
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ }
+
+ protected Map<Long, Long> m_info = Collections.synchronizedMap(new HashMap<Long, Long>());
+
+ @Override
+ public String getServiceId() {
+ return "sysvmem";
+ }
+
+ @Override
+ public long init(long capacity, String uri, boolean isnew) {
+ long ret = ninit(capacity, uri, isnew);
+ m_info.put(ret, capacity);
+ return ret;
+ }
+
+ @Override
+ public void close(long id) {
+ nclose(id);
+ }
+
+ @Override
+ public void sync(long id, long addr, long length, boolean autodetect) {
+ nsync(id, addr, length, autodetect);
+ }
+
+ @Override
+ public long capacity(long id) {
+ return m_info.get(id);
+ }
+
+ @Override
+ public long allocate(long id, long size, boolean initzero) {
+ return nallocate(id, size, initzero);
+ }
+
+ @Override
+ public long reallocate(long id, long addr, long size, boolean initzero) {
+ return nreallocate(id, addr, size, initzero);
+ }
+
+ @Override
+ public void free(long id, long addr) {
+ nfree(id, addr);
+ }
+
+ @Override
+ public ByteBuffer createByteBuffer(long id, long size) {
+ return ncreateByteBuffer(id, size);
+ }
+
+ @Override
+ public ByteBuffer resizeByteBuffer(long id, ByteBuffer bytebuf, long size) {
+ return nresizeByteBuffer(id, bytebuf, size);
+ }
+
+ @Override
+ public void destroyByteBuffer(long id, ByteBuffer bytebuf) {
+ ndestroyByteBuffer(id, bytebuf);
+ }
+
+ @Override
+ public ByteBuffer retrieveByteBuffer(long id, long handler) {
+ return nretrieveByteBuffer(id, handler);
+ }
+
+ @Override
+ public long retrieveSize(long id, long handler) {
+ return nretrieveSize(id, handler);
+ }
+
+ @Override
+ public long getByteBufferHandler(long id, ByteBuffer buf) {
+ return ngetByteBufferHandler(id, buf);
+ }
+
+ @Override
+ public void setHandler(long id, long key, long handler) {
+ nsetHandler(id, key, handler);
+ }
+
+ @Override
+ public long getHandler(long id, long key) {
+ return ngetHandler(id, key);
+ }
+
+ @Override
+ public long handlerCapacity(long id) {
+ return nhandlerCapacity(id);
+ }
+
+ @Override
+ public long getBaseAddress(long id) {
+ return 0L;
+ //return ngetBaseAddress(id);
+ }
+
+ protected native long ninit(long capacity, String uri, boolean isnew);
+
+ protected native void nclose(long id);
+
+ protected native void nsync(long id, long addr, long length, boolean autodetect);
+
+ protected native long ncapacity(long id);
+
+ protected native long nallocate(long id, long size, boolean initzero);
+
+ protected native long nreallocate(long id, long addr, long size, boolean initzero);
+
+ protected native void nfree(long id, long addr);
+
+ protected native ByteBuffer ncreateByteBuffer(long id, long size);
+
+ protected native ByteBuffer nresizeByteBuffer(long id, ByteBuffer bytebuf, long size);
+
+ protected native void ndestroyByteBuffer(long id, ByteBuffer bytebuf);
+
+ protected native ByteBuffer nretrieveByteBuffer(long id, long handler);
+
+ protected native long nretrieveSize(long id, long handler);
+
+ protected native long ngetByteBufferHandler(long id, ByteBuffer buf);
+
+ protected native void nsetHandler(long id, long key, long handler);
+
+ protected native long ngetHandler(long id, long key);
+
+ protected native long nhandlerCapacity(long id);
+
+ protected native long ngetBaseAddress(long id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/CMakeLists.txt b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/CMakeLists.txt
new file mode 100644
index 0000000..0e6de72
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/CMakeLists.txt
@@ -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.
+#
+
+cmake_minimum_required(VERSION 2.8.11)
+project(sysvmemallocator)
+
+configure_file (
+ "${PROJECT_SOURCE_DIR}/config.h.in"
+ "${PROJECT_BINARY_DIR}/config.h"
+ )
+include_directories(${PROJECT_BINARY_DIR})
+
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../dist/native")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
+set(sysvmemallocator_VERSION_MAJOR 0)
+set(sysvmemallocator_VERSION_MINOR 0)
+set(CMAKE_BUILD_TYPE "Release")
+set(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -O0 -Wall -rdynamic -g -ggdb")
+set(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -O3 -Wall")
+
+find_package(JNI REQUIRED)
+include_directories(${JNI_INCLUDE_DIRS})
+
+find_package(Threads REQUIRED)
+include_directories(${CMAKE_THREAD_LIBS_INIT})
+
+add_library(sysvmemallocator SHARED common.c org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.c)
+target_include_directories(sysvmemallocator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+
+include (InstallRequiredSystemLibraries)
+set (CPACK_RESOURCE_FILE_LICENSE
+ "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+set (CPACK_PACKAGE_VERSION_MAJOR "${sysvmemallocator_VERSION_MAJOR}")
+set (CPACK_PACKAGE_VERSION_MINOR "${sysvmemallocator_VERSION_MINOR}")
+include (CPack)
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/LICENSE
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/LICENSE b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/LICENSE
new file mode 100644
index 0000000..8f71f43
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/LICENSE
@@ -0,0 +1,202 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed 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.
+
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.c b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.c
new file mode 100644
index 0000000..0f10963
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.c
@@ -0,0 +1,89 @@
+/**
+ * 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.
+ */
+
+#include <common.h>
+
+/******************************************************************************
+ ** Generally-useful functions for JNI programming.
+ *****************************************************************************/
+
+/**
+ * Throws a RuntimeException, with either an explicit message or the message
+ * corresponding to the current system error value.
+ */
+inline void
+throw(JNIEnv* env, const char* msg) {
+ if (msg == NULL)
+ msg = sys_errlist[errno];
+
+ jclass xklass = (*env)->FindClass(env, "java/lang/RuntimeException");
+ (*env)->ThrowNew(env, xklass, msg);
+}
+
+inline void*
+addr_from_java(jlong addr) {
+ // This assert fails in a variety of ways on 32-bit systems.
+ // It is impossible to predict whether native code that converts
+ // pointers to longs will sign-extend or zero-extend the addresses.
+ //assert(addr == (uintptr_t)addr, "must not be odd high bits");
+ return (void*) (uintptr_t) addr;
+}
+
+inline jlong
+addr_to_java(void* p) {
+ assert(p == (void*) (uintptr_t) p);
+ return (long) (uintptr_t) p;
+}
+
+inline void *
+sysvrealloc(SysVMPool *pool, void *p, size_t size, int initzero) {
+ void *ret = NULL;
+ void *nativebuf = NULL;
+ if (NULL == p) {
+ if (initzero) {
+ nativebuf = calloc(1, sizeof(uint8_t) * size + PMBHSZ);
+ } else {
+ nativebuf = malloc(sizeof(uint8_t) * size + PMBHSZ);
+ }
+ } else {
+ nativebuf = realloc(p, sizeof(uint8_t) * size + PMBHSZ);
+ }
+ if (NULL != nativebuf) {
+ ((PMBHeader *) nativebuf)->size = size + PMBHSZ;
+ ret = nativebuf + PMBHSZ;
+ }
+ return ret;
+}
+
+inline void
+sysvfree(SysVMPool *pool, void *p) {
+ if (p != NULL) {
+ free(p);
+ }
+}
+
+inline size_t
+sysvsize(SysVMPool *pool, void *p) {
+ size_t ret = 0;
+ void* nativebuf;
+ if (p != NULL) {
+ nativebuf = p - PMBHSZ;
+ ret = ((PMBHeader *) nativebuf)->size - PMBHSZ;
+ }
+ return ret;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.h
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.h b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.h
new file mode 100644
index 0000000..67f38cb
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/common.h
@@ -0,0 +1,65 @@
+/**
+ * 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.
+ */
+
+#ifndef _COMMON_H
+#define _COMMON_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <assert.h>
+#include <pthread.h>
+#include <jni.h>
+
+void throw(JNIEnv* env, const char* msg);
+
+void* addr_from_java(jlong addr);
+
+jlong addr_to_java(void* p);
+
+typedef struct {
+ //size_t size;
+ jlong size;
+} PMBHeader;
+
+#define PMBHSZ (sizeof(PMBHeader))
+
+typedef struct {
+ pthread_mutex_t mutex;
+} SysVMPool;
+
+void *sysvrealloc(SysVMPool *pool, void *p, size_t size, int initzero);
+
+void sysvfree(SysVMPool *pool, void *p);
+
+size_t sysvsize(SysVMPool *pool, void *p);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/config.h.in
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/config.h.in b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/config.h.in
new file mode 100644
index 0000000..9950a43
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/config.h.in
@@ -0,0 +1,24 @@
+/**
+ * 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.
+ */
+
+#ifndef GUARD
+#define GUARD
+
+#cmakedefine _CONFIG_HEADER_H_
+
+#endif //GUARD
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.c
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.c b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.c
new file mode 100644
index 0000000..9a61765
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.c
@@ -0,0 +1,238 @@
+/**
+ * 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.
+ */
+
+#include "org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.h"
+
+static SysVMPool *g_sysvmpool_arr = NULL;
+static size_t g_sysvmpool_count = 0;
+
+static pthread_rwlock_t g_sysvmem_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+
+/******************************************************************************
+ ** JNI implementations
+ *****************************************************************************/
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nallocate(JNIEnv* env,
+ jobject this, jlong id, jlong size, jboolean initzero) {
+ SysVMPool *pool;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ void* nativebuf = sysvrealloc(pool, NULL, size, initzero);
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ return addr_to_java(nativebuf);
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nreallocate(JNIEnv* env,
+ jobject this, jlong id, jlong addr, jlong size, jboolean initzero) {
+ SysVMPool *pool;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ void* p = addr_from_java(addr);
+ void* nativebuf = sysvrealloc(pool, p, size, initzero);
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ return addr_to_java(nativebuf);
+}
+
+JNIEXPORT
+void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nfree(
+ JNIEnv* env,
+ jobject this, jlong id,
+ jlong addr) {
+ SysVMPool *pool;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ void* nativebuf = addr_from_java(addr);
+ sysvfree(pool, nativebuf);
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+}
+
+JNIEXPORT
+void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nsync(
+ JNIEnv* env,
+ jobject this, jlong id, jlong addr, jlong len, jboolean autodetect)
+{
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ncapacity(
+ JNIEnv* env,
+ jobject this, jlong id)
+{
+ SysVMPool *pool;
+ pool = g_sysvmpool_arr + id;
+ return 0L;
+}
+
+JNIEXPORT
+jobject JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ncreateByteBuffer(
+ JNIEnv *env, jobject this, jlong id, jlong size) {
+ SysVMPool *pool;
+ jobject ret = NULL;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ void* nativebuf = sysvrealloc(pool, NULL, size, 0);
+ ret = NULL != nativebuf ? (*env)->NewDirectByteBuffer(env, nativebuf, size) : NULL;
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ return ret;
+}
+
+JNIEXPORT
+jobject JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nretrieveByteBuffer(
+ JNIEnv *env, jobject this, jlong id, jlong addr) {
+ jobject ret = NULL;
+ void* p = addr_from_java(addr);
+ if (NULL != p) {
+ void* nativebuf = p - PMBHSZ;
+ ret = (*env)->NewDirectByteBuffer(env, p, ((PMBHeader *) nativebuf)->size - PMBHSZ);
+ }
+ return ret;
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nretrieveSize(JNIEnv *env,
+ jobject this, jlong id, jlong addr) {
+ SysVMPool *pool;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ void* p = addr_from_java(addr);
+ jlong ret = sysvsize(pool, p);
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ return ret;
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ngetByteBufferHandler(
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf) {
+ jlong ret = 0L;
+ if (NULL != bytebuf) {
+ void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
+ ret = addr_to_java(nativebuf);
+ }
+ return ret;
+}
+
+JNIEXPORT
+jobject JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nresizeByteBuffer(
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf, jlong size) {
+ SysVMPool *pool;
+ jobject ret = NULL;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ if (NULL != bytebuf) {
+ void* nativebuf = (void*) (*env)->GetDirectBufferAddress(env, bytebuf);
+ if (nativebuf != NULL) {
+ nativebuf = sysvrealloc(pool, nativebuf, size, 0);
+ if (NULL != nativebuf) {
+ ret = (*env)->NewDirectByteBuffer(env, nativebuf, size);
+ }
+ }
+ }
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ return ret;
+}
+
+JNIEXPORT
+void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ndestroyByteBuffer(
+ JNIEnv *env, jobject this, jlong id, jobject bytebuf) {
+ SysVMPool *pool;
+ pthread_rwlock_rdlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ if (NULL != bytebuf) {
+ void* nativebuf = (*env)->GetDirectBufferAddress(env, bytebuf);
+ if (nativebuf != NULL) {
+ sysvfree(pool, nativebuf);
+ }
+ }
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+}
+
+
+JNIEXPORT
+void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nsetHandler(
+ JNIEnv *env, jobject this, jlong id, jlong key, jlong value)
+{
+ throw(env, "setkey()/getkey() temporarily not supported");
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ngetHandler(JNIEnv *env,
+ jobject this, jlong id, jlong key) {
+ throw(env, "setkey()/getkey() temporarily not supported");
+ return 0;
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nhandlerCapacity(
+ JNIEnv *env, jobject this) {
+ throw(env, "setkey()/getkey() temporarily not supported");
+ return 0;
+}
+
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ngetBaseAddress(JNIEnv *env,
+ jobject this, jlong id) {
+ return 0L;
+}
+
+JNIEXPORT
+jlong JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_ninit(JNIEnv *env, jclass this,
+ jlong capacity, jstring pathname, jboolean isnew) {
+ pthread_rwlock_wrlock(&g_sysvmem_rwlock);
+ SysVMPool *pool;
+ size_t ret = -1;
+ g_sysvmpool_arr = realloc(g_sysvmpool_arr, (g_sysvmpool_count + 1) * sizeof(SysVMPool));
+ if (NULL != g_sysvmpool_arr) {
+ pool = g_sysvmpool_arr + g_sysvmpool_count;
+ ret = g_sysvmpool_count;
+ g_sysvmpool_count++;
+ } else {
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ throw(env, "Out of memory!");
+ }
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ return ret;
+}
+
+JNIEXPORT
+void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_nclose
+(JNIEnv *env, jobject this, jlong id)
+{
+ SysVMPool *pool;
+ pthread_rwlock_wrlock(&g_sysvmem_rwlock);
+ pool = g_sysvmpool_arr + id;
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+}
+
+__attribute__((destructor)) void fini(void) {
+ int i;
+ SysVMPool *pool;
+ pthread_rwlock_wrlock(&g_sysvmem_rwlock);
+ if (NULL != g_sysvmpool_arr) {
+ for (i = 0; i < g_sysvmpool_count; ++i) {
+ pool = g_sysvmpool_arr + i;
+ }
+ free(g_sysvmpool_arr);
+ g_sysvmpool_arr = NULL;
+ g_sysvmpool_count = 0;
+ }
+ pthread_rwlock_unlock(&g_sysvmem_rwlock);
+ pthread_rwlock_destroy(&g_sysvmem_rwlock);
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.h
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.h b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.h
new file mode 100644
index 0000000..8f84cc3
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/native/org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl.h
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+#include <jni.h>
+/* Header for class org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl */
+
+#include "common.h"
+
+#ifndef _Included_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl
+#define _Included_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl
+ * Method: jniInit
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_jniInit
+(JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl
+ * Method: jniTerm
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_apache_mnemonic_service_memoryservice_internal_SysVMemServiceImpl_jniTerm
+(JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/META-INF/services/org.apache.mnemonic.service.memoryservice.VolatileMemoryAllocatorService
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/META-INF/services/org.apache.mnemonic.service.memoryservice.VolatileMemoryAllocatorService b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/META-INF/services/org.apache.mnemonic.service.memoryservice.VolatileMemoryAllocatorService
new file mode 100644
index 0000000..c9c3c72
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/META-INF/services/org.apache.mnemonic.service.memoryservice.VolatileMemoryAllocatorService
@@ -0,0 +1 @@
+org.apache.mnemonic.service.memoryservice.internal.SysVMemServiceImpl
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/log4j.properties b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/log4j.properties
new file mode 100644
index 0000000..24b0e3c
--- /dev/null
+++ b/mnemonic-memory-services/mnemonic-sys-vmem-service/src/main/resources/log4j.properties
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+# Root logger option
+log4j.rootLogger=INFO, file, stdout
+
+#to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
+
+#to log.log file
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=log.log
+log4j.appender.file.MaxFileSize=10MB
+log4j.appender.file.MaxBackupIndex=10
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f600bd2b/mnemonic-memory-services/pom.xml
----------------------------------------------------------------------
diff --git a/mnemonic-memory-services/pom.xml b/mnemonic-memory-services/pom.xml
index d8431b4..2aa3382 100644
--- a/mnemonic-memory-services/pom.xml
+++ b/mnemonic-memory-services/pom.xml
@@ -42,6 +42,7 @@
<module>mnemonic-nvml-vmem-service</module>
<module>mnemonic-nvml-pmem-service</module>
<module>mnemonic-pmalloc-service</module>
+ <module>mnemonic-sys-vmem-service</module>
</modules>
<dependencies>
[12/14] incubator-mnemonic git commit: MNEMONIC-164: Create a run
script for sort-bench
Posted by ga...@apache.org.
MNEMONIC-164: Create a run script for sort-bench
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/17d76489
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/17d76489
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/17d76489
Branch: refs/heads/master
Commit: 17d764898ae020c1890beb39f53e2e746a1254ce
Parents: b5fbd94
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Thu Nov 17 15:27:38 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 16:01:59 2016 -0800
----------------------------------------------------------------------
mnemonic-benches/mnemonic-sort-bench/bin/run.py | 49 ++++++++++++++++++++
1 file changed, 49 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/17d76489/mnemonic-benches/mnemonic-sort-bench/bin/run.py
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/bin/run.py b/mnemonic-benches/mnemonic-sort-bench/bin/run.py
new file mode 100755
index 0000000..42d93ed
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/bin/run.py
@@ -0,0 +1,49 @@
+#! /usr/bin/env python
+
+#
+# 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.
+#
+
+import argparse
+import sys
+import os.path
+import subprocess
+
+parser = argparse.ArgumentParser()
+parser.add_argument("input", type=str, help="specify an input file that contains a set of absolute paths of data files.")
+args = parser.parse_args()
+
+with open(args.input, "r") as sfinput:
+ fns = sfinput.readlines()
+
+runcmdtmp = "mvn exec:exec -Pbench -pl mnemonic-benches/mnemonic-sort-bench -Dmode={0} -Dinput={1} -Doutput={1}_{0}.out"
+cmpcmdtmp = "diff {1}_{0}.out {3}_{2}.out"
+rstfntmp = "{1}_{0}.out"
+
+for efn in fns:
+ fn = efn.strip().rstrip('\n')
+ if fn:
+ if os.path.isfile(fn):
+ print("Processing {0}, run mode A".format(fn))
+ subprocess.check_call(runcmdtmp.format('A', fn), shell=True);
+ print("Processing {0}, run mode B".format(fn))
+ subprocess.check_call(runcmdtmp.format('B', fn), shell=True);
+ print("Comparing results {0} - {1}".format(rstfntmp.format('A', fn), rstfntmp.format('B', fn)))
+ subprocess.check_call(cmpcmdtmp.format('A', fn, 'B', fn), shell=True);
+ else:
+ print("Input data file {0} does not exist.".format(fn))
+
+print("Finished!")
[05/14] incubator-mnemonic git commit: MNEMONIC-154: Add a data
generator for sorting bench
Posted by ga...@apache.org.
MNEMONIC-154: Add a data generator for sorting bench
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/f2490dff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/f2490dff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/f2490dff
Branch: refs/heads/master
Commit: f2490dff2236c12ff6aacfda8c3b73e2fb38b17c
Parents: 51107ce
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Tue Nov 8 10:59:34 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:49:51 2016 -0800
----------------------------------------------------------------------
.../mnemonic-sort-bench/bin/gen_data.py | 53 ++++++++++++++++++++
1 file changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f2490dff/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py b/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py
new file mode 100755
index 0000000..8112412
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py
@@ -0,0 +1,53 @@
+#! /usr/bin/env python
+
+#
+# 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.
+#
+
+import argparse
+import sys
+import random
+
+parser = argparse.ArgumentParser()
+parser.add_argument("count", type=long, help="specify how many random numbers will be generated")
+parser.add_argument("-s", "--seed", help="specify the random seed")
+args = parser.parse_args()
+
+if args.seed:
+ seed = args.seed
+else:
+ seed = random.randint(0, sys.maxint)
+random.seed(seed)
+
+fn = "sort_data_{0}_{1}.dat".format(args.count, seed)
+afile = open(fn, "w", 512*1024*1024 )
+
+print("The generated data will be written to the file {0} with the seed {1}".format(fn, seed))
+try:
+ for i in xrange(args.count):
+ line = str(random.randint(1, 999999999)) + "\n"
+ afile.write(line)
+ if 0 == i % 1000000:
+ sys.stdout.write('.')
+ sys.stdout.flush()
+except ValueError:
+ pass
+
+afile.close()
+
+print("")
+print("The generated data have been written to the file {0} with the seed {1}\n".format(fn, seed))
+
[02/14] incubator-mnemonic git commit: MNEMONIC-160: add optimized 1d
long bubble sorting
Posted by ga...@apache.org.
MNEMONIC-160: add optimized 1d long bubble sorting
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/0c0a20dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/0c0a20dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/0c0a20dc
Branch: refs/heads/master
Commit: 0c0a20dc4d96931944d09469306f9d38180c8517
Parents: e2eb6b0
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Mon Nov 14 11:48:23 2016 -0800
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Thu Nov 17 12:48:22 2016 -0800
----------------------------------------------------------------------
.../internal/SortServiceImpl.java | 4 +
.../src/main/native/CMakeLists.txt | 2 +-
..._computingservice_internal_SortServiceImpl.c | 112 +++++++++++++++++++
3 files changed, 117 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/0c0a20dc/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
index ffa99d1..b866506 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computingservice/internal/SortServiceImpl.java
@@ -47,6 +47,8 @@ public class SortServiceImpl implements GeneralComputingService {
if (null != mode && null != valinfos) {
if ("tensor_bubble".equals(mode)) {
ret = nperformBubbleSort(valinfos);
+ } else if ("1dlong_bubble".equals(mode)) {
+ ret = nperform1DLongBubbleSort(valinfos);
}
}
return ret;
@@ -59,4 +61,6 @@ public class SortServiceImpl implements GeneralComputingService {
*/
protected native long[] nperformBubbleSort(ValueInfo[] valinfos);
+ protected native long[] nperform1DLongBubbleSort(ValueInfo[] valinfos);
+
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/0c0a20dc/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/CMakeLists.txt b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/CMakeLists.txt
index fc93968..ccb878d 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/CMakeLists.txt
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/CMakeLists.txt
@@ -28,7 +28,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../dist/native")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -O0 -Wall -rdynamic -g -ggdb")
-set(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -O3 -Wall")
+set(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -march=native -O3 -Wall")
find_package(JNI REQUIRED)
include_directories(${JNI_INCLUDE_DIRS})
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/0c0a20dc/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/org_apache_mnemonic_service_computingservice_internal_SortServiceImpl.c
----------------------------------------------------------------------
diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/org_apache_mnemonic_service_computingservice_internal_SortServiceImpl.c b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/org_apache_mnemonic_service_computingservice_internal_SortServiceImpl.c
index 40fda19..6f84c6c 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/org_apache_mnemonic_service_computingservice_internal_SortServiceImpl.c
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/native/org_apache_mnemonic_service_computingservice_internal_SortServiceImpl.c
@@ -135,3 +135,115 @@ jlongArray JNICALL Java_org_apache_mnemonic_service_computingservice_internal_So
destructNValueInfos(nvinfos, visz);
return ret;
}
+
+#define TO_E(nvi, p) addr_from_java(p)
+
+typedef struct {
+ long scan_count;
+ long swap_count;
+ long noswap_count;
+} SortInfo;
+
+long handle1DLongBubbleSort(JNIEnv* env, struct NValueInfo *nvinfo, SortInfo *sortinfo) {
+ if (NULL == nvinfo->frames || 0 >= nvinfo->framessz) {
+ return 0L;
+ }
+ register long *itmaddrs = NULL;
+ register long *nxtfitmaddrs = NULL;
+ register int pendings = 0;
+ register long hdls = 0;
+ hdls = nvinfo->handler;
+ itmaddrs = &nvinfo->handler;
+ register long *iatmp;
+ register long curoff = nvinfo->frames->nextoff;
+ register long curnloff = nvinfo->frames->nlvloff;
+// register long curnlsz = nvinfo->frames->nlvlsz;
+ register void *addr = NULL;
+ assert(-1L != curoff);
+ iatmp = itmaddrs;
+ register long *hptr1 = NULL, *hptr2 = NULL;
+ register void *pvaladdr = NULL;
+ register long *tmpptr = NULL;
+ register long tmpval = 0L;
+ register long cntscan = 0L, cntswap = 0L, cntnoswap = 0L;
+
+ if (0L == hdls) {
+ return 0L;
+ }
+
+ do {
+ ++cntscan;
+ pendings = 0;
+ pvaladdr = NULL;
+
+ addr = TO_E(nvinfo, hdls) + curnloff;
+ nxtfitmaddrs = (long*)(TO_E(nvinfo, hdls) + curoff);
+ pvaladdr = addr;
+ hptr2 = itmaddrs;
+
+ while (1) {
+ itmaddrs = nxtfitmaddrs;
+ hdls = *itmaddrs;
+ if (0L == hdls) {
+ break;
+ }
+ addr = TO_E(nvinfo, hdls) + curnloff;
+ nxtfitmaddrs = (long*)(TO_E(nvinfo, hdls) + curoff);
+
+ hptr1 = hptr2;
+ hptr2 = itmaddrs;
+ if (*(long*)pvaladdr > *(long*)addr) {
+ tmpptr = nxtfitmaddrs;
+ tmpval = *tmpptr;
+ *tmpptr = *hptr1;
+ *hptr1 = *hptr2;
+ *hptr2 = tmpval;
+ nxtfitmaddrs = hptr2;
+ hptr2 = tmpptr;
+ pendings = 1;
+ ++cntswap;
+ } else {
+ pvaladdr = addr;
+ ++cntnoswap;
+ }
+
+ }
+
+ itmaddrs = iatmp;
+ hdls = *iatmp;
+ } while (0 != pendings);
+
+ if (NULL != sortinfo) {
+ sortinfo->scan_count = cntscan;
+ sortinfo->swap_count = cntswap;
+ sortinfo->noswap_count = cntnoswap;
+ }
+ return nvinfo->handler;
+}
+
+JNIEXPORT
+jlongArray JNICALL Java_org_apache_mnemonic_service_computingservice_internal_SortServiceImpl_nperform1DLongBubbleSort(
+ JNIEnv* env, jobject this, jobjectArray vinfos) {
+ jlongArray ret = NULL;
+ jsize retsz = 1;
+ jsize idx;
+ size_t visz;
+ SortInfo sortinfo;
+ struct NValueInfo **nvinfos = constructNValueInfos(env, vinfos, &visz);
+ retsz = visz + 3;
+ jlong nret[retsz];
+ for(idx = 0; idx < retsz; ++idx) {
+ nret[idx] = 0L;
+ }
+ printNValueInfos(nvinfos, visz);
+ assert(1 == visz);
+
+ nret[0] = handle1DLongBubbleSort(env, *nvinfos, &sortinfo);
+ nret[1] = sortinfo.scan_count;
+ nret[2] = sortinfo.swap_count;
+ nret[3] = sortinfo.noswap_count;
+
+ ret = constructJLongArray(env, nret, retsz);
+ destructNValueInfos(nvinfos, visz);
+ return ret;
+}