aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Kotsiuba <artem.kotsiuba@linaro.org>2021-08-31 12:44:35 +0100
committerArtem Kotsiuba <artem.kotsiuba@linaro.org>2021-09-29 11:21:07 +0100
commit5ae99b12367cf83279bf110f0bb1d9601059fe0f (patch)
tree6a679b0397801e2412e5cb51078ca7bd260ad831
parent8f72857068e2e58f0e46a0333efc12a7e7dcaae5 (diff)
downloadart-external-benchmarks-5ae99b12367cf83279bf110f0bb1d9601059fe0f.tar.gz
Add script to setup DaCapo benchmark
This change adds a script to install DaCapo benchmark. The change also includes wrapper classes, patches to apply on top of DaCapo benchmarks with fixes and updates. Test: ./setup_dacapo.sh -d /linaro_aosp/ Change-Id: I8a0250d20c0f5cdcc1341dfae696d9130a09e0a6
-rw-r--r--LICENSE-APACHE176
-rw-r--r--README3
-rw-r--r--dacapo/README20
-rw-r--r--dacapo/patches/avrora_conf.patch20
-rw-r--r--dacapo/patches/dacapo_patch.patch340
-rw-r--r--dacapo/patches/h2_conf.patch20
-rw-r--r--dacapo/patches/xalan_conf.patch20
-rwxr-xr-xdacapo/setup_dacapo.sh188
-rw-r--r--dacapo/wrappers/dacapo/avrora/AvroraBench.java31
-rw-r--r--dacapo/wrappers/dacapo/base/BaseBench.java94
-rw-r--r--dacapo/wrappers/dacapo/h2/H2Bench.java31
-rw-r--r--dacapo/wrappers/dacapo/xalan/XalanBench.java31
12 files changed, 974 insertions, 0 deletions
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 0000000..1b5ec8b
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,176 @@
+ 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
diff --git a/README b/README
new file mode 100644
index 0000000..89aa9f9
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+### General info
+This is a repository that hosts external benchmarks that can not
+reside in the same repository with Linaro ART tree.
diff --git a/dacapo/README b/dacapo/README
new file mode 100644
index 0000000..4c68f52
--- /dev/null
+++ b/dacapo/README
@@ -0,0 +1,20 @@
+### General info
+ This implementation integrates three DaCapo benchmarks (Avrora, Xalan
+ and H2) with Linaro ART tree.
+ To learn more about DaCapo benchmarks, please see
+ https://github.com/dacapobench/dacapobench
+
+### Prerequisites
+ Initialize JAVA_HOME environment variable with path to Java 8
+ Install `ant`, `maven` and `cvs`.
+
+### Installation
+ `./setup_dacapo.sh -d /PATH_TO_LINARO_TREE`
+
+### Usage
+ Use it as part of Linaro benchmark framework (see AvroraBench.java,
+ XalanBench.java and H2Bench.java)
+
+ To run DaCapo benchmarks as a standalone application make sure you use
+ the following options
+ `export _JAVA_OPTIONS="-Xms512m -Xmx2048m -XX:MaxPermSize=512m"`\`
diff --git a/dacapo/patches/avrora_conf.patch b/dacapo/patches/avrora_conf.patch
new file mode 100644
index 0000000..b3f1083
--- /dev/null
+++ b/dacapo/patches/avrora_conf.patch
@@ -0,0 +1,20 @@
+--- avrora.cnf 2020-06-01 03:15:20.000000000 +0100
++++ avrora_new.cnf 2021-09-28 11:18:51.799256436 +0100
+#
+#
+# Remove all JARs from the list as any attempt to load them will
+# trigger DaCapo exception (Benchmark.java:599) due to using
+# Classloader.getResource() method which fails if we call
+# it from the JAR. These JAR files are already in the classpath
+# and their classes can be used, so we don't need to explicitly
+# load them in Benchmark.java.
+#
+@@ -1,7 +1,6 @@
+ benchmark avrora
+ class org.dacapo.harness.Avrora
+- thread-model single
+- jars "avrora-cvs-20131011.jar";
++ thread-model single;
+
+ size small args "-seconds=30",
+ "-platform=mica2",
diff --git a/dacapo/patches/dacapo_patch.patch b/dacapo/patches/dacapo_patch.patch
new file mode 100644
index 0000000..b6c29c2
--- /dev/null
+++ b/dacapo/patches/dacapo_patch.patch
@@ -0,0 +1,340 @@
+diff -ruNb dacapobench-master/benchmarks/bms/avrora/harness/src/org/dacapo/harness/Avrora.java dacapobench-master-new/benchmarks/bms/avrora/harness/src/org/dacapo/harness/Avrora.java
+--- dacapobench-master/benchmarks/bms/avrora/harness/src/org/dacapo/harness/Avrora.java 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/bms/avrora/harness/src/org/dacapo/harness/Avrora.java 2021-08-10 13:12:45.648344931 +0100
+#
+#
+# This change adds additional argument to constructor of Avrora benchmark class
+# to make it possible to specify
+# path prefix to resource files.
+#
+@@ -22,8 +22,8 @@
+
+ String[] args;
+
+- public Avrora(Config config, File scratch) throws Exception {
+- super(config, scratch);
++ public Avrora(String path, Config config, File scratch) throws Exception {
++ super(path, config, scratch);
+ Class<?> clazz = Class.forName("avrora.Main", true, loader);
+ this.method = clazz.getMethod("main", String[].class);
+ }
+diff -ruNb dacapobench-master/benchmarks/bms/h2/harness/src/org/dacapo/harness/H2.java dacapobench-master-new/benchmarks/bms/h2/harness/src/org/dacapo/harness/H2.java
+--- dacapobench-master/benchmarks/bms/h2/harness/src/org/dacapo/harness/H2.java 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/bms/h2/harness/src/org/dacapo/harness/H2.java 2021-08-11 10:43:32.725990169 +0100
+#
+#
+# This change adds additional argument to constructor of H2 benchmark class
+# to make it possible to specify path prefix to resource files.
+#
+@@ -35,8 +35,8 @@
+ private Method iterationTPCC;
+ private Method postIterationTPCC;
+
+- public H2(Config config, File scratch) throws Exception {
+- super(config, scratch, false);
++ public H2(String path, Config config, File scratch) throws Exception {
++ super(path, config, scratch, false);
+ }
+
+ @Override
+diff -ruNb dacapobench-master/benchmarks/bms/luindex/build.xml dacapobench-master-new/benchmarks/bms/luindex/build.xml
+--- dacapobench-master/benchmarks/bms/luindex/build.xml 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/bms/luindex/build.xml 2021-08-09 12:19:17.852233037 +0100
+@@ -32,7 +32,7 @@
+
+ <target name="bm-build" depends="lucene">
+ <mkdir dir="${bm-build-dir}"/>
+- <javac srcdir="${bm-src-dir}" source="1.8"
++ <javac srcdir="${bm-src-dir}" source="1.8" target="1.8"
+ classpath="${harness-classpath}:${lucene-jars}/${lucene-core-jar-name}:${lucene-jars}/${lucene-demos-jar-name}"
+ destdir="${bm-build-dir}"
+ includes="org/dacapo/luindex/*" debug="true" debuglevel="lines,vars,source"/>
+diff -ruNb dacapobench-master/benchmarks/bms/xalan/harness/src/org/dacapo/harness/Xalan.java dacapobench-master-new/benchmarks/bms/xalan/harness/src/org/dacapo/harness/Xalan.java
+--- dacapobench-master/benchmarks/bms/xalan/harness/src/org/dacapo/harness/Xalan.java 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/bms/xalan/harness/src/org/dacapo/harness/Xalan.java 2021-08-10 11:53:29.035233056 +0100
+#
+#
+# This change adds additional argument to constructor of Xalan benchmark class
+# to make it possible to specify path prefix to resource files.
+#
+@@ -28,8 +28,8 @@
+ Object benchmark;
+ Method createWorkersMethod;
+
+- public Xalan(Config config, File scratch) throws Exception {
+- super(config, scratch, false);
++ public Xalan(String path, Config config, File scratch) throws Exception {
++ super(path, config, scratch, false);
+ Class<?> clazz = Class.forName("org.dacapo.xalan.XSLTBench", true, loader);
+ this.method = clazz.getMethod("doWork", int.class);
+ createWorkersMethod = clazz.getMethod("createWorkers", int.class);
+diff -ruNb dacapobench-master/benchmarks/bms/xalan/src/org/dacapo/xalan/XSLTBench.java dacapobench-master-new/benchmarks/bms/xalan/src/org/dacapo/xalan/XSLTBench.java
+--- dacapobench-master/benchmarks/bms/xalan/src/org/dacapo/xalan/XSLTBench.java 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/bms/xalan/src/org/dacapo/xalan/XSLTBench.java 2021-08-12 17:17:08.052311883 +0100
+#
+#
+# This change suppresses the exception thrown in Xalan benchmark due to
+# xalan.jar version mismatch (2.7.1 version which is already
+# available in Android environment, and 2.7.2).
+#
+@@ -150,7 +150,7 @@
+ System.err.println("*** unzip " + props.get("java.class.path") + " xalan.jar");
+ System.err.println("*** and override your jvm's boot classpath:");
+ System.err.println("*** java -Xbootclasspath/p:xalan.jar [...] ");
+- throw new Exception("Please fix your bootclasspath and try again.");
++ //throw new Exception("Please fix your bootclasspath and try again.");
+ }
+
+ // Fix the JAXP transformer to be Xalan
+diff -ruNb dacapobench-master/benchmarks/build.xml dacapobench-master-new/benchmarks/build.xml
+--- dacapobench-master/benchmarks/build.xml 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/build.xml 2021-08-19 14:20:22.079839936 +0100
+#
+#
+# This change disables all other benchmarks from the build target, except for
+# three benchmarks we are interested in (avrora, h2 and xalan).
+#
+@@ -286,7 +286,7 @@
+ <!-- =================================
+ target: compile all sources
+ ================================= -->
+- <target name="compile" depends="avrora,batik,h2,eclipse,fop,jython,luindex,lusearch,pmd,sunflow,tradebeans,tradesoap,tomcat,xalan">
++ <target name="compile" depends="avrora,h2,xalan">
+ <antcall target="build.status.fail" />
+ <antcall target="build.status.pass" />
+ </target>
+@@ -398,42 +398,9 @@
+ <target name="avrora" depends="init,harness">
+ <build.bm benchmark="avrora"/>
+ </target>
+- <target name="batik" depends="init,harness">
+- <build.bm benchmark="batik"/>
+- </target>
+ <target name="h2" depends="init,harness">
+ <build.bm benchmark="h2"/>
+ </target>
+- <target name="eclipse" depends="init,harness">
+- <build.bm benchmark="eclipse"/>
+- </target>
+- <target name="fop" depends="init,harness">
+- <build.bm benchmark="fop"/>
+- </target>
+- <target name="jython" depends="init,harness">
+- <build.bm benchmark="jython"/>
+- </target>
+- <target name="luindex" depends="init,harness">
+- <build.bm benchmark="luindex"/>
+- </target>
+- <target name="lusearch" depends="init,harness">
+- <build.bm benchmark="lusearch"/>
+- </target>
+- <target name="pmd" depends="init,harness">
+- <build.bm benchmark="pmd"/>
+- </target>
+- <target name="sunflow" depends="init,harness">
+- <build.bm benchmark="sunflow"/>
+- </target>
+- <target name="tomcat" depends="init,harness">
+- <build.bm benchmark="tomcat"/>
+- </target>
+- <target name="tradebeans" depends="init,harness">
+- <build.bm benchmark="tradebeans"/>
+- </target>
+- <target name="tradesoap" depends="init,harness">
+- <build.bm benchmark="tradesoap"/>
+- </target>
+ <target name="xalan" depends="init,harness">
+ <build.bm benchmark="xalan"/>
+ </target>
+diff -ruNb dacapobench-master/benchmarks/harness/src/org/dacapo/harness/Benchmark.java dacapobench-master-new/benchmarks/harness/src/org/dacapo/harness/Benchmark.java
+--- dacapobench-master/benchmarks/harness/src/org/dacapo/harness/Benchmark.java 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/harness/src/org/dacapo/harness/Benchmark.java 2021-08-10 12:26:42.669206949 +0100
+#
+#
+# This change does two things:
+# 1) Adds a new member to base Benchmark class to store prefix path to resources.
+# 2) Modifies the way resources are loaded: dacapo.jar is normally expected to be
+# used as a standalone application in a non-Android environment.
+# Instead we use it as a dependency to our Android application.
+# This breaks existing approach to resource loading using URL and getResource().
+#
+@@ -115,6 +115,8 @@
+ */
+ protected final Config config;
+
++ protected final String prefixPath;
++
+ /**
+ * Classloader used to run the benchmark
+ */
+@@ -204,15 +206,16 @@
+ *
+ * @param scratch Scratch directory
+ */
+- public Benchmark(Config config, File scratch) throws Exception {
+- this(config, scratch, true);
++ public Benchmark(String prefixPath, Config config, File scratch) throws Exception {
++ this(prefixPath, config, scratch, true);
+ }
+
+- public Benchmark(Config config, File scratch, boolean silent) throws Exception {
++ public Benchmark(String prefixPath, Config config, File scratch, boolean silent) throws Exception {
+ // TODO this is very ugly
+ Benchmark.silent = silent;
+ this.scratch = scratch;
+ this.config = config;
++ this.prefixPath = prefixPath;
+ initialize();
+ }
+
+@@ -258,7 +261,7 @@
+ * <code>data/<i>name</i>.zip</code> into the scratch directory.
+ */
+ protected void prepare() throws Exception {
+- unpackZipFileResource("dat/" + config.name + ".zip", scratch);
++ unpackZipFileResource(prefixPath + "dat/" + config.name + ".zip", scratch);
+ }
+
+ /**
+@@ -579,11 +582,12 @@
+ * @throws IOException
+ */
+ public static void unpackZipFileResource(String name, File destination) throws IOException, FileNotFoundException, DacapoException {
+- URL resource = getURL(name);
+- if (resource == null)
+- throw new DacapoException("No such zip file: \"" + name + "\"");
++ //URL resource = getURL(name);
++ //if (resource == null)
++ // throw new DacapoException("No such zip file: \"" + name + "\"");
+
+- BufferedInputStream inputStream = new BufferedInputStream(resource.openStream());
++ //BufferedInputStream inputStream = new BufferedInputStream(resource.openStream());
++ InputStream inputStream = new FileInputStream(new File(name));
+ unpackZipStream(inputStream, destination);
+ }
+
+@@ -602,7 +606,7 @@
+ * @param destination
+ * @throws IOException
+ */
+- private static void unpackZipStream(BufferedInputStream inputStream, File destination) throws IOException {
++ private static void unpackZipStream(InputStream inputStream, File destination) throws IOException {
+ ZipInputStream input = new ZipInputStream(inputStream);
+ ZipEntry entry;
+ while ((entry = input.getNextEntry()) != null) {
+diff -ruNb dacapobench-master/benchmarks/harness/src/org/dacapo/harness/CommandLineArgs.java dacapobench-master-new/benchmarks/harness/src/org/dacapo/harness/CommandLineArgs.java
+--- dacapobench-master/benchmarks/harness/src/org/dacapo/harness/CommandLineArgs.java 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/harness/src/org/dacapo/harness/CommandLineArgs.java 2021-08-10 15:34:33.592765614 +0100
+#
+#
+# This change does two things:
+# 1) Makes it possible to create instances of CommandLine class outside of its package.
+# 2) Removes code that checks that at least one benchmark is specified in command line arguments.
+# This is no longer needed because we do not use dacapo.jar as a standalone application and using
+# CommandLineArgs to pass workload size
+#
+@@ -134,7 +134,7 @@
+ private Callback callback = null;
+ private List<String> benchmarks = new ArrayList<String>();
+
+- CommandLineArgs(String[] args) throws Exception {
++ public CommandLineArgs(String[] args) throws Exception {
+ try {
+ boolean reportAndExitOk = false;
+ line = parser.parse(options, args);
+@@ -167,47 +167,6 @@
+
+ // configure the callback
+ defineCallback();
+-
+- // check that at least one or more benchmarks are specified or a
+- // config file is specified but not both
+- if (line.getArgList().isEmpty() && !line.hasOption(OPT_CONFIG)) {
+- printUsage();
+- System.exit(EXIT_MISSING_BENCHMARKS);
+- } else if (line.hasOption(OPT_CONFIG) && !line.getArgList().isEmpty()) {
+- System.err.println("You may only specify a cnf or a list of benchmarks, but not both");
+- System.exit(EXIT_BAD_COMMANDLINE);
+- }
+-
+- List<String> benchmarkSet = extractBenchmarkSet();
+-
+- if (!line.getArgList().isEmpty()) {
+- // now get the benchmark names and check against the available benchmarks
+- for (Object bm : line.getArgList()) {
+- if (benchmarkSet.contains(bm))
+- benchmarks.add((String) bm);
+- else {
+- System.err.println("Unknown benchmark: " + bm);
+- System.exit(EXIT_UNKNOWN_BENCHMARK);
+- }
+- }
+- } else {
+- // determine benchmark from the cnf file and add it to the benchmarks
+- File cnfFile = new File(line.getOptionValue(OPT_CONFIG));
+-
+- if (!cnfFile.canRead()) {
+- System.err.println("Unknown config file: " + cnfFile.getAbsolutePath());
+- System.exit(EXIT_UNKNOWN_BENCHMARK);
+- }
+-
+- Config config = Config.parse(cnfFile);
+-
+- if (benchmarkSet.contains(config.name))
+- benchmarks.add(config.name);
+- else {
+- System.err.println("Unknown benchmark specified in cnf file: " + config.name);
+- System.exit(EXIT_UNKNOWN_BENCHMARK);
+- }
+- }
+ }
+
+ /**
+diff -ruNb dacapobench-master/benchmarks/libs/h2/build.xml dacapobench-master-new/benchmarks/libs/h2/build.xml
+--- dacapobench-master/benchmarks/libs/h2/build.xml 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/libs/h2/build.xml 2021-08-05 13:32:34.631246523 +0100
+#
+#
+# This change fixes the URL to Maven repository to use HTTPS instead of HTTP
+# See https://support.sonatype.com/hc/en-us/articles/360041287334
+#
+@@ -12,7 +12,7 @@
+
+ <property name="lib-name" value="h2"/>
+ <property name="lib-version" value="1.4.196"/>
+- <property name="lib-url" value="http://repo2.maven.org/maven2/com/h2database/${lib-name}/${lib-version}"/>
++ <property name="lib-url" value="https://repo1.maven.org/maven2/com/h2database/${lib-name}/${lib-version}"/>
+ <property name="lib-src" value="h2-${lib-version}.jar"/>
+
+ <import file="../common.xml"/>
+diff -ruNb dacapobench-master/benchmarks/libs/junit/build.xml dacapobench-master-new/benchmarks/libs/junit/build.xml
+--- dacapobench-master/benchmarks/libs/junit/build.xml 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/libs/junit/build.xml 2021-08-05 13:30:58.533605200 +0100
+#
+#
+# This change fixes the URL to Maven repository to use HTTPS instead of HTTP
+# See https://support.sonatype.com/hc/en-us/articles/360041287334
+#
+@@ -12,7 +12,7 @@
+
+ <property name="lib-name" value="junit"/>
+ <property name="lib-version" value="4.12"/>
+- <property name="lib-url" value="http://central.maven.org/maven2/junit/junit/${lib-version}"/>
++ <property name="lib-url" value="https://repo1.maven.org/maven2/junit/junit/${lib-version}"/>
+ <property name="lib-src" value="junit-${lib-version}.jar"/>
+
+ <import file="../common.xml"/>
+diff -ruNb dacapobench-master/benchmarks/libs/lucene/build.xml dacapobench-master-new/benchmarks/libs/lucene/build.xml
+--- dacapobench-master/benchmarks/libs/lucene/build.xml 2020-06-01 03:15:20.000000000 +0100
++++ dacapobench-master-new/benchmarks/libs/lucene/build.xml 2021-08-12 11:45:36.631105917 +0100
+@@ -20,7 +20,9 @@
+
+ <property name="lib-build-top" value="${lib-build-dir}/lucene-${lib-version}"/>
+
+- <target name="unpack" depends="untar"/>
++ <target name="unpack" depends="untar">
++ <patch patchfile="${lib-base}/${lib-name}/lucene.patch" dir="${lib-build-dir}" ignorewhitespace="yes" strip="0" failonerror="yes"/>
++ </target>
+
+ <target name="build">
+ <ant antfile="common-build.xml" target="ivy-bootstrap" dir="${lib-build-top}" inheritall="false"/>
diff --git a/dacapo/patches/h2_conf.patch b/dacapo/patches/h2_conf.patch
new file mode 100644
index 0000000..dd667c7
--- /dev/null
+++ b/dacapo/patches/h2_conf.patch
@@ -0,0 +1,20 @@
+--- h2.cnf 2020-06-01 03:15:20.000000000 +0100
++++ h2_new.cnf 2021-09-28 11:13:59.246290724 +0100
+#
+#
+# Remove all JARs from the list as any attempt to load them will
+# trigger DaCapo exception (Benchmark.java:599) due to using
+# Classloader.getResource() method which fails if we call
+# it from the JAR. These JAR files are already in the classpath
+# and their classes can be used, so we don't need to explicitly
+# load them in Benchmark.java.
+#
+@@ -1,7 +1,6 @@
+ benchmark h2
+ class org.dacapo.harness.H2
+- thread-model per_cpu
+- jars "dacapo-h2.jar","derbyTesting.jar","junit-4.12.jar","h2-1.4.196.jar";
++ thread-model per_cpu;
+
+ size small args
+ "--total-transactions", "400",
diff --git a/dacapo/patches/xalan_conf.patch b/dacapo/patches/xalan_conf.patch
new file mode 100644
index 0000000..98ab7bb
--- /dev/null
+++ b/dacapo/patches/xalan_conf.patch
@@ -0,0 +1,20 @@
+--- xalan.cnf 2020-06-01 03:15:20.000000000 +0100
++++ xalan_new.cnf 2021-09-28 11:16:53.469242749 +0100
+#
+#
+# Remove all JARs from the list as any attempt to load them will
+# trigger DaCapo exception (Benchmark.java:599) due to using
+# Classloader.getResource() method which fails if we call
+# it from the JAR. These JAR files are already in the classpath
+# and their classes can be used, so we don't need to explicitly
+# load them in Benchmark.java.
+#
+@@ -1,7 +1,6 @@
+ benchmark xalan
+ class org.dacapo.harness.Xalan
+- thread-model per_cpu
+- jars "dacapo-xalan.jar", "xalan.jar", "xercesImpl.jar", "xml-apis.jar", "serializer.jar";
++ thread-model per_cpu;
+
+ size small args "10"
+ threads 1
diff --git a/dacapo/setup_dacapo.sh b/dacapo/setup_dacapo.sh
new file mode 100755
index 0000000..ac94e60
--- /dev/null
+++ b/dacapo/setup_dacapo.sh
@@ -0,0 +1,188 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Linaro Limited. All rights reserved.
+#
+# 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.
+
+unset DEST_DIR
+
+readonly CRED="\033[0;31m"
+readonly CORANGE="\033[0;33m"
+readonly CGREEN="\033[0;32m"
+readonly CNC="\033[0m"
+
+# Print error message
+# ${1} - error message
+error() {
+ echo -e "${CRED}ERROR: $*${CNC}" >&2
+}
+
+# Print info message
+# ${1} - info message
+info() {
+ echo -e "${CORANGE}INFO: $*${CNC}" >&2
+}
+
+# Print error message and exit from the script
+# ${1} - error message.
+exit_with_error() {
+ error "$1"
+ exit 1
+}
+
+# Check exit code of the previous command; if non-zero, abort.
+# Arguments:
+# ${1} - error message.
+if_error() {
+ # shellcheck disable=SC2181
+ if [[ $? -ne 0 ]]; then
+ exit_with_error "$1"
+ fi
+}
+
+# Execute the arguments; if the exit code is non-zero, abort.
+safe() {
+ "$@"
+ if_error "Failed command: $*"
+}
+
+readonly usage="Usage: $(basename "$0") -d dest_dir
+Setup DaCapo binaries and resource files and workloads runners into
+a provided destination directory.
+
+Options:
+ -h Show this help message.
+ -d A path to the directory where to put all needed files.
+"
+
+main() {
+ while getopts ":hd:" option; do
+ if [[ ${OPTARG} == -* ]]; then
+ exit_with_error "Option -${option} requires an argument." >&2
+ fi
+ case "${option}" in
+ h) info "${usage}"; exit ;;
+ d) DEST_DIR=${OPTARG}
+ ;;
+ \?)
+ error "Illegal option: -${OPTARG}" >&2
+ error "${usage}"
+ exit 1
+ ;;
+ :)
+ exit_with_error "Option -${OPTARG} requires an argument." >&2
+ ;;
+ esac
+ done
+
+ if [ -z ${DEST_DIR} ]; then
+ exit_with_error "Please, use -d argument to specify the location of Linaro tree."
+ fi
+
+ if [ ! -d ${DEST_DIR} ]; then
+ exit_with_error "The directory ${DEST_DIR} does not exist. Please specify a valid path" \
+ "to your Linaro tree."
+ fi
+
+ if [ -z "${JAVA_HOME}" ]; then
+ exit_with_error "Please, set JAVA_HOME environment variable to path to Java8 jdk and" \
+ "re-run the script."
+ else
+ JAVA_VERSION=$("${JAVA_HOME}/bin/java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
+ info "Detected Java version ${JAVA_VERSION:0:3}"
+ if [[ ${JAVA_VERSION:0:3} != "1.8" ]]; then
+ exit_with_error "Please update JAVA_HOME environment variable with the location of Java 8"
+ fi
+ fi
+
+ cd $(dirname "$0")
+
+ # copy wrappers
+ info "Copying wrappers"
+ safe cp -r wrappers/dacapo ${DEST_DIR}/benchmarks/benchmarks
+
+ # build DaCapo
+ if [[ -d dacapo_src ]]; then
+ safe rm -rf dacapo_src
+ fi
+ mkdir dacapo_src
+ cd dacapo_src
+
+ local -r DACAPO_REPO="https://github.com/dacapobench/dacapobench.git"
+ info "Cloning ${DACAPO_REPO} into dacapo_src..."
+ safe git clone --branch master ${DACAPO_REPO}
+
+ safe cd dacapobench
+ # commit id that is used as a base for all patches
+ local -r DACAPO_COMMIT="6cf03808b686896eb092c038d6add7d9384f03f5"
+ info "Reseting to ${DACAPO_COMMIT}"
+ safe git reset --hard ${DACAPO_COMMIT}
+
+ info "Applying patches..."
+ safe patch -p1 <../../patches/dacapo_patch.patch
+
+ safe cd benchmarks
+
+ # See https://github.com/dacapobench/dacapobench/tree/dev-chopin "Building" section
+ # for more info on how to build DaCapo
+ info "Building DaCapo benchmarks..."
+ safe ant
+
+ # Ant is expected to package everything into JAR file
+ # with the name that includes commit id
+ local -r GENERATED_JAR_NAME="dacapo-9.12-MR1-git+6cf03808.jar"
+ safe mv ${GENERATED_JAR_NAME} dacapo.jar
+
+ # Removing these JAR files to fix an error for duplicate .class files
+ safe zip -d dacapo.jar /jar/dacapo-digest.jar
+ safe zip -d dacapo.jar /jar/xercesImpl.jar /jar/xml-apis.jar
+ safe zip -d dacapo.jar /jar/derby.jar /jar/derbyclient.jar /jar/derbynet.jar /jar/derbytools.jar
+
+ info "Copying dacapo.jar..."
+ local -r LIB_DIR=${DEST_DIR}/benchmarks/benchmarks/lib
+ if [[ ! -d ${LIB_DIR} ]]; then
+ safe mkdir -p ${LIB_DIR}
+ else
+ if [[ -f ${LIB_DIR}/dacapo.jar ]]; then
+ safe rm ${LIB_DIR}/dacapo.jar
+ fi
+ fi
+ safe cp dacapo.jar ${LIB_DIR}/
+
+ local -r DACAPO_RESOURCES_DIR=${DEST_DIR}/benchmarks/benchmarks/resources/dacapo
+ if [[ -d ${DACAPO_RESOURCES_DIR} ]]; then
+ safe rm -rf ${DACAPO_RESOURCES_DIR}
+ fi
+ safe mkdir -p ${DACAPO_RESOURCES_DIR}/dat
+ safe mkdir -p ${DACAPO_RESOURCES_DIR}/cnf
+
+ local -r DACAPO_PATCHES_DIR="../../../patches"
+ #avrora
+ info "Copying Avrora files..."
+ safe patch bms/avrora/avrora.cnf <${DACAPO_PATCHES_DIR}/avrora_conf.patch
+ safe cp bms/avrora/dist/dat/* ${DACAPO_RESOURCES_DIR}/dat/
+ safe cp bms/avrora/*.cnf ${DACAPO_RESOURCES_DIR}/cnf/
+
+ #h2
+ info "Copying H2 files..."
+ safe patch bms/h2/h2.cnf <${DACAPO_PATCHES_DIR}/h2_conf.patch
+ safe cp bms/h2/*.cnf ${DACAPO_RESOURCES_DIR}/cnf/
+
+ #xalan
+ info "Copying Xalan files..."
+ safe patch bms/xalan/xalan.cnf <${DACAPO_PATCHES_DIR}/xalan_conf.patch
+ safe cp bms/xalan/dist/dat/* ${DACAPO_RESOURCES_DIR}/dat/
+ safe cp bms/xalan/*.cnf ${DACAPO_RESOURCES_DIR}/cnf/
+}
+
+main "$@"
diff --git a/dacapo/wrappers/dacapo/avrora/AvroraBench.java b/dacapo/wrappers/dacapo/avrora/AvroraBench.java
new file mode 100644
index 0000000..0f4ba23
--- /dev/null
+++ b/dacapo/wrappers/dacapo/avrora/AvroraBench.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Linaro Limited. All rights reserved.
+ *
+ * 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.
+ *
+ */
+
+package benchmarks.dacapo.avrora;
+
+import benchmarks.dacapo.base.BaseBench;
+import org.dacapo.harness.Avrora;
+
+public final class AvroraBench extends BaseBench<Avrora> {
+ public AvroraBench() {
+ super("avrora.cnf", "default");
+ }
+
+ public void timeBenchmark(int iters) {
+ super.timeBenchmark(iters);
+ }
+}
diff --git a/dacapo/wrappers/dacapo/base/BaseBench.java b/dacapo/wrappers/dacapo/base/BaseBench.java
new file mode 100644
index 0000000..728efd3
--- /dev/null
+++ b/dacapo/wrappers/dacapo/base/BaseBench.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2021 Linaro Limited. All rights reserved.
+ *
+ * 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.
+ *
+ */
+
+package benchmarks.dacapo.base;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.lang.reflect.Type;
+import java.lang.reflect.ParameterizedType;
+
+import org.dacapo.harness.Benchmark;
+import org.dacapo.harness.Callback;
+import org.dacapo.harness.CommandLineArgs;
+import org.dacapo.parser.Config;
+
+public class BaseBench<T extends Benchmark> {
+ private T bench;
+ private CommandLineArgs args;
+ private Callback callback;
+
+ public BaseBench(String configFileName, String sizeArg) {
+ try {
+ InputStream stream = new FileInputStream(new File("resources/dacapo/cnf/"+configFileName));
+ Config config = Config.parse(stream);
+
+ File scratch = new File("./resources/");
+
+ String[] cmdArgs = {"-s", sizeArg};
+ this.args = new CommandLineArgs(cmdArgs);
+
+ this.callback = new Callback(args);
+ callback.init(config);
+
+ this.bench = createBench("resources/dacapo/", config, scratch);
+ // First call to run should trigger call to prepare.
+ // We want to call it here instead of timeBenchmark to avoid
+ // including it in total time.
+ this.bench.run(callback, args.getSize());
+ }
+ catch (Exception e) {
+ System.out.println("Benchmark has failed to initialize!");
+ e.printStackTrace();
+ }
+ }
+
+ public void timeBenchmark(int iters) {
+ try {
+ for (int i = 0; i<iters; i++) {
+ bench.run(callback, args.getSize());
+ }
+ }
+ catch (Exception e) {
+ System.out.println("Benchmark has failed to run!");
+ e.printStackTrace();
+ }
+ }
+
+ @SuppressWarnings ("unchecked")
+ public Class<T> getTypeParameterClass()
+ {
+ Type type = getClass().getGenericSuperclass();
+ ParameterizedType paramType = (ParameterizedType) type;
+ return (Class<T>) paramType.getActualTypeArguments()[0];
+ }
+
+ public T createBench(String pathToResources, Config config, File scratch) {
+ T instance = null;
+ try {
+ Class<T> klass = getTypeParameterClass();
+ instance = klass.getDeclaredConstructor(String.class, Config.class, File.class)
+ .newInstance(pathToResources, config, scratch);
+ } catch (Exception e) {
+ System.out.println("Failed to create an instance of benchmark");
+ e.printStackTrace();
+ }
+
+ return instance;
+ }
+}
diff --git a/dacapo/wrappers/dacapo/h2/H2Bench.java b/dacapo/wrappers/dacapo/h2/H2Bench.java
new file mode 100644
index 0000000..6e150da
--- /dev/null
+++ b/dacapo/wrappers/dacapo/h2/H2Bench.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Linaro Limited. All rights reserved.
+ *
+ * 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.
+ *
+ */
+
+package benchmarks.dacapo.h2;
+
+import benchmarks.dacapo.base.BaseBench;
+import org.dacapo.harness.H2;
+
+public final class H2Bench extends BaseBench<H2> {
+ public H2Bench() {
+ super("h2.cnf", "small");
+ }
+
+ public void timeBenchmark(int iters) {
+ super.timeBenchmark(iters);
+ }
+}
diff --git a/dacapo/wrappers/dacapo/xalan/XalanBench.java b/dacapo/wrappers/dacapo/xalan/XalanBench.java
new file mode 100644
index 0000000..d8bcfea
--- /dev/null
+++ b/dacapo/wrappers/dacapo/xalan/XalanBench.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Linaro Limited. All rights reserved.
+ *
+ * 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.
+ *
+ */
+
+package benchmarks.dacapo.xalan;
+
+import benchmarks.dacapo.base.BaseBench;
+import org.dacapo.harness.Xalan;
+
+public final class XalanBench extends BaseBench<Xalan> {
+ public XalanBench() {
+ super("xalan.cnf", "default");
+ }
+
+ public void timeBenchmark(int iters) {
+ super.timeBenchmark(iters);
+ }
+}