OpenJDK / valhalla / valhalla
changeset 55686:1152a6dfc320 lworld
8222361: [lworld] Convert benchmarks into JEP230 style micros
author | skuksenko |
---|---|
date | Thu, 30 May 2019 18:19:11 -0700 |
parents | 1a80dd639dbd |
children | 335cf115f9e8 |
files | make/test/BuildMicrobenchmark.gmk test/benchmarks/README.html test/benchmarks/pom.xml test/benchmarks/src/main/java/oracle/micro/valhalla/AckermannBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/AcmpBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/ArraycopyBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/ArrayfillBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/ArraysumBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/InvokeBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/ListsumBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/MapBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/MatrixBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/SearchBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/SortBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/TraversalBase.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/Ackermann1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/Ackermann2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/Ackermann8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/AckermannMix.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/IsCmp.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/IsNull.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/TrivialEquals.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/TrivialNotEquals.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraycopy/Arraycopy1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraycopy/Arraycopy2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraycopy/Arraycopy8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arrayfill/Arrayfill1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arrayfill/Arrayfill2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arrayfill/Arrayfill8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraysum/Arraysum1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraysum/Arraysum2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraysum/Arraysum8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/convcopy/Convcopy1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/convcopy/Convcopy2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/convcopy/Convcopy8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/invoke/Invoke.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/listsum/Listsum1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/listsum/Listsum2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/listsum/Listsum8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/map/Get.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/map/Put.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/map/Walk.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/matrix/Boxed.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/matrix/Primitive.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/search/Search1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/search/Search2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/search/Search8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Primitive1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Sort1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Sort2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Sort8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/traversal/Boxed.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/traversal/Primitive.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/types/Box1.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/types/Box2.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/types/Box8.java test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/util/HashMap.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/Ackermann1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/Ackermann2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/Ackermann8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/AckermannMix.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraycopy/Arraycopy1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraycopy/Arraycopy2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraycopy/Arraycopy8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arrayfill/Arrayfill1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arrayfill/Arrayfill2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arrayfill/Arrayfill8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraysum/Arraysum1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraysum/Arraysum2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraysum/Arraysum8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/convcopy/Convcopy1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/convcopy/Convcopy2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/convcopy/Convcopy8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/invoke/Invoke.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/listsum/Listsum1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/listsum/Listsum2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/listsum/Listsum8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/GetValue.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/PutValue.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkIteratorCursor.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkValueCursor.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkValueEntry.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkValueTotal.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/matrix/Value.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/search/Search1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/search/Search2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/search/Search8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/sort/Sort1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/sort/Sort2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/sort/Sort8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/traversal/Value.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/types/Value1.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/types/Value2.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/types/Value8.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/util/HashMapIteratorCursor.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/util/HashMapValueCursor.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/util/HashMapValueEntry.java test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/util/HashMapValueTotal.java test/benchmarks/src/main/java/oracle/micro/valhalla/types/PNumber.java test/benchmarks/src/main/java/oracle/micro/valhalla/types/Total.java test/benchmarks/src/main/java/oracle/micro/valhalla/util/AbstractMap.java test/benchmarks/src/main/java/oracle/micro/valhalla/util/Cursor.java test/micro/org/openjdk/bench/valhalla/ACmpBase.java test/micro/org/openjdk/bench/valhalla/AckermannBase.java test/micro/org/openjdk/bench/valhalla/CallBase.java test/micro/org/openjdk/bench/valhalla/MatrixBase.java test/micro/org/openjdk/bench/valhalla/README.txt test/micro/org/openjdk/bench/valhalla/SizedBase.java test/micro/org/openjdk/bench/valhalla/TraversalBase.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsCmpBranch.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsCmpResult.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsNotCmpBranch.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsNotCmpResult.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsNotNullBranch.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsNotNullResult.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsNullBranch.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/IsNullResult.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/TrivialEquals.java test/micro/org/openjdk/bench/valhalla/baseline/acmp/TrivialNotEquals.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Arraycopy1.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Arraycopy2.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Arraycopy8.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Copy1.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Copy2.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Copy8.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Set1.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Set2.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Set8.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Sum1.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Sum2.java test/micro/org/openjdk/bench/valhalla/baseline/arrays/Sum8.java test/micro/org/openjdk/bench/valhalla/baseline/callconv/Ackermann0.java test/micro/org/openjdk/bench/valhalla/baseline/callconv/Ackermann1.java test/micro/org/openjdk/bench/valhalla/baseline/callconv/Ackermann2.java test/micro/org/openjdk/bench/valhalla/baseline/callconv/Ackermann8.java test/micro/org/openjdk/bench/valhalla/baseline/callconv/CallConv.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Copy1.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Copy2.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Copy8.java test/micro/org/openjdk/bench/valhalla/baseline/fields/NodePrim1.java test/micro/org/openjdk/bench/valhalla/baseline/fields/NodePrim2.java test/micro/org/openjdk/bench/valhalla/baseline/fields/NodePrim8.java test/micro/org/openjdk/bench/valhalla/baseline/fields/NodeRef1.java test/micro/org/openjdk/bench/valhalla/baseline/fields/NodeRef2.java test/micro/org/openjdk/bench/valhalla/baseline/fields/NodeRef8.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Set1.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Set2.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Set8.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Sum1.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Sum2.java test/micro/org/openjdk/bench/valhalla/baseline/fields/Sum8.java test/micro/org/openjdk/bench/valhalla/baseline/invoke/Interface.java test/micro/org/openjdk/bench/valhalla/baseline/invoke/ObjectHashCodeExplicit.java test/micro/org/openjdk/bench/valhalla/baseline/invoke/ObjectHashCodeImplicit.java test/micro/org/openjdk/bench/valhalla/baseline/matrix/Complex.java test/micro/org/openjdk/bench/valhalla/baseline/matrix/Primitive.java test/micro/org/openjdk/bench/valhalla/baseline/matrix/Reference.java test/micro/org/openjdk/bench/valhalla/baseline/traversal/Covariance.java test/micro/org/openjdk/bench/valhalla/baseline/traversal/Primitive.java test/micro/org/openjdk/bench/valhalla/baseline/traversal/Reference.java test/micro/org/openjdk/bench/valhalla/baseline/types/Ref1.java test/micro/org/openjdk/bench/valhalla/baseline/types/Ref2.java test/micro/org/openjdk/bench/valhalla/baseline/types/Ref8.java test/micro/org/openjdk/bench/valhalla/baseline/types/Utils.java test/micro/org/openjdk/bench/valhalla/lworld/acmp/IsCmpBranch1.java test/micro/org/openjdk/bench/valhalla/lworld/acmp/IsCmpBranch2.java test/micro/org/openjdk/bench/valhalla/lworld/acmp/IsCmpBranch8.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Arraycopy1.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Arraycopy2.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Arraycopy8.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Copy1.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Copy2.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Copy8.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Set1.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Set2.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Set8.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Sum1.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Sum2.java test/micro/org/openjdk/bench/valhalla/lworld/arrays/Sum8.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/Ackermann0.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/Ackermann1.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/Ackermann2.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/Ackermann8.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/CallConv1.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/CallConv2.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/CallConv4.java test/micro/org/openjdk/bench/valhalla/lworld/callconv/CallConv8.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Copy1.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Copy2.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Copy8.java test/micro/org/openjdk/bench/valhalla/lworld/fields/NodeBox1.java test/micro/org/openjdk/bench/valhalla/lworld/fields/NodeBox2.java test/micro/org/openjdk/bench/valhalla/lworld/fields/NodeBox8.java test/micro/org/openjdk/bench/valhalla/lworld/fields/NodeVal1.java test/micro/org/openjdk/bench/valhalla/lworld/fields/NodeVal2.java test/micro/org/openjdk/bench/valhalla/lworld/fields/NodeVal8.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Set1.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Set2.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Set8.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Sum1.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Sum2.java test/micro/org/openjdk/bench/valhalla/lworld/fields/Sum8.java test/micro/org/openjdk/bench/valhalla/lworld/invoke/Interface.java test/micro/org/openjdk/bench/valhalla/lworld/invoke/ObjectHashCodeExplicit.java test/micro/org/openjdk/bench/valhalla/lworld/invoke/ObjectHashCodeImplicit.java test/micro/org/openjdk/bench/valhalla/lworld/matrix/Boxed.java test/micro/org/openjdk/bench/valhalla/lworld/matrix/Complex.java test/micro/org/openjdk/bench/valhalla/lworld/matrix/Value.java test/micro/org/openjdk/bench/valhalla/lworld/traversal/Boxed.java test/micro/org/openjdk/bench/valhalla/lworld/traversal/Covariance.java test/micro/org/openjdk/bench/valhalla/lworld/traversal/Value.java test/micro/org/openjdk/bench/valhalla/lworld/types/Utils.java test/micro/org/openjdk/bench/valhalla/lworld/types/Val1.java test/micro/org/openjdk/bench/valhalla/lworld/types/Val2.java test/micro/org/openjdk/bench/valhalla/lworld/types/Val8.java test/micro/org/openjdk/bench/valhalla/types/Vector.java |
diffstat | 216 files changed, 11106 insertions(+), 11316 deletions(-) [+] |
line wrap: on
line diff
--- a/make/test/BuildMicrobenchmark.gmk Thu May 30 09:25:24 2019 -0400 +++ b/make/test/BuildMicrobenchmark.gmk Thu May 30 18:19:11 2019 -0700 @@ -85,7 +85,7 @@ # Build microbenchmark suite for the current JDK $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \ SETUP := MICROBENCHMARK_JAVA_COMPILER, \ - ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH) -Xlint -Xlint:-processing -Werror, \ + ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH) -Xlint -Xlint:-processing -Werror -XDallowWithFieldOperator, \ SRC := $(MICROBENCHMARK_SRC), \ BIN := $(MICROBENCHMARK_CLASSES), \ ))
--- a/test/benchmarks/README.html Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,544 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> -<meta charset="UTF-8"> -<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--> -<meta name="viewport" content="width=device-width, initial-scale=1.0"> -<meta name="generator" content="Asciidoctor 1.5.5"> -<meta name="author" content="Sergey Kuksenko"> -<title>Valhalla/L-Words microbenchmarks description</title> -<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"> -<style> -/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */ -/* Remove comment around @import statement below when using as a custom stylesheet */ -/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/ -article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block} -audio,canvas,video{display:inline-block} -audio:not([controls]){display:none;height:0} -[hidden],template{display:none} -script{display:none!important} -html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%} -a{background:transparent} -a:focus{outline:thin dotted} -a:active,a:hover{outline:0} -h1{font-size:2em;margin:.67em 0} -abbr[title]{border-bottom:1px dotted} -b,strong{font-weight:bold} -dfn{font-style:italic} -hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0} -mark{background:#ff0;color:#000} -code,kbd,pre,samp{font-family:monospace;font-size:1em} -pre{white-space:pre-wrap} -q{quotes:"\201C" "\201D" "\2018" "\2019"} -small{font-size:80%} -sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} -sup{top:-.5em} -sub{bottom:-.25em} -img{border:0} -svg:not(:root){overflow:hidden} -figure{margin:0} -fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em} -legend{border:0;padding:0} -button,input,select,textarea{font-family:inherit;font-size:100%;margin:0} -button,input{line-height:normal} -button,select{text-transform:none} -button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer} -button[disabled],html input[disabled]{cursor:default} -input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0} -input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box} -input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none} -button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0} -textarea{overflow:auto;vertical-align:top} -table{border-collapse:collapse;border-spacing:0} -*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box} -html,body{font-size:100%} -body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased} -a:hover{cursor:pointer} -img,object,embed{max-width:100%;height:auto} -object,embed{height:100%} -img{-ms-interpolation-mode:bicubic} -.left{float:left!important} -.right{float:right!important} -.text-left{text-align:left!important} -.text-right{text-align:right!important} -.text-center{text-align:center!important} -.text-justify{text-align:justify!important} -.hide{display:none} -img,object,svg{display:inline-block;vertical-align:middle} -textarea{height:auto;min-height:50px} -select{width:100%} -.center{margin-left:auto;margin-right:auto} -.spread{width:100%} -p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6} -.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em} -div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr} -a{color:#2156a5;text-decoration:underline;line-height:inherit} -a:hover,a:focus{color:#1d4b8f} -a img{border:none} -p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility} -p aside{font-size:.875em;line-height:1.35;font-style:italic} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em} -h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0} -h1{font-size:2.125em} -h2{font-size:1.6875em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em} -h4,h5{font-size:1.125em} -h6{font-size:1em} -hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0} -em,i{font-style:italic;line-height:inherit} -strong,b{font-weight:bold;line-height:inherit} -small{font-size:60%;line-height:inherit} -code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} -ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} -ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em} -ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em} -ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit} -ul.square{list-style-type:square} -ul.circle{list-style-type:circle} -ul.disc{list-style-type:disc} -ul.no-bullet{list-style:none} -ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} -dl dt{margin-bottom:.3125em;font-weight:bold} -dl dd{margin-bottom:1.25em} -abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help} -abbr{text-transform:none} -blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} -blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)} -blockquote cite:before{content:"\2014 \0020"} -blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)} -blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} -@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2} -h1{font-size:2.75em} -h2{font-size:2.3125em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em} -h4{font-size:1.4375em}} -table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede} -table thead,table tfoot{background:#f7f8f7;font-weight:bold} -table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left} -table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)} -table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7} -table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em} -h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400} -.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table} -.clearfix:after,.float-group:after{clear:both} -*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word} -*:not(pre)>code.nobreak{word-wrap:normal} -*:not(pre)>code.nowrap{white-space:nowrap} -pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed} -em em{font-style:normal} -strong strong{font-weight:400} -.keyseq{color:rgba(51,51,51,.8)} -kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap} -.keyseq kbd:first-child{margin-left:0} -.keyseq kbd:last-child{margin-right:0} -.menuseq,.menu{color:rgba(0,0,0,.8)} -b.button:before,b.button:after{position:relative;top:-1px;font-weight:400} -b.button:before{content:"[";padding:0 3px 0 2px} -b.button:after{content:"]";padding:0 2px 0 3px} -p a>code:hover{color:rgba(0,0,0,.9)} -#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em} -#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table} -#header:after,#content:after,#footnotes:after,#footer:after{clear:both} -#content{margin-top:1.25em} -#content:before{content:none} -#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0} -#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8} -#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px} -#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap} -#header .details span:first-child{margin-left:-.125em} -#header .details span.email a{color:rgba(0,0,0,.85)} -#header .details br{display:none} -#header .details br+span:before{content:"\00a0\2013\00a0"} -#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)} -#header .details br+span#revremark:before{content:"\00a0|\00a0"} -#header #revnumber{text-transform:capitalize} -#header #revnumber:after{content:"\00a0"} -#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem} -#toc{border-bottom:1px solid #efefed;padding-bottom:.5em} -#toc>ul{margin-left:.125em} -#toc ul.sectlevel0>li>a{font-style:italic} -#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0} -#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none} -#toc li{line-height:1.3334;margin-top:.3334em} -#toc a{text-decoration:none} -#toc a:active{text-decoration:underline} -#toctitle{color:#7a2518;font-size:1.2em} -@media only screen and (min-width:768px){#toctitle{font-size:1.375em} -body.toc2{padding-left:15em;padding-right:0} -#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto} -#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em} -#toc.toc2>ul{font-size:.9em;margin-bottom:0} -#toc.toc2 ul ul{margin-left:0;padding-left:1em} -#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em} -body.toc2.toc-right{padding-left:0;padding-right:15em} -body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}} -@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0} -#toc.toc2{width:20em} -#toc.toc2 #toctitle{font-size:1.375em} -#toc.toc2>ul{font-size:.95em} -#toc.toc2 ul ul{padding-left:1.25em} -body.toc2.toc-right{padding-left:0;padding-right:20em}} -#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -#content #toc>:first-child{margin-top:0} -#content #toc>:last-child{margin-bottom:0} -#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em} -#footer-text{color:rgba(255,255,255,.8);line-height:1.44} -.sect1{padding-bottom:.625em} -@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}} -.sect1+.sect1{border-top:1px solid #efefed} -#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400} -#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em} -#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} -#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} -#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221} -.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} -.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} -table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0} -.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)} -table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit} -.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%} -.admonitionblock>table td.icon{text-align:center;width:80px} -.admonitionblock>table td.icon img{max-width:none} -.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase} -.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)} -.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0} -.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px} -.exampleblock>.content>:first-child{margin-top:0} -.exampleblock>.content>:last-child{margin-bottom:0} -.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -.sidebarblock>:first-child{margin-top:0} -.sidebarblock>:last-child{margin-bottom:0} -.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center} -.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0} -.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8} -.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1} -.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em} -.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal} -@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}} -@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}} -.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)} -.listingblock pre.highlightjs{padding:0} -.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px} -.listingblock pre.prettyprint{border-width:0} -.listingblock>.content{position:relative} -.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999} -.listingblock:hover code[data-lang]:before{display:block} -.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999} -.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"} -table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none} -table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45} -table.pyhltable td.code{padding-left:.75em;padding-right:0} -pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8} -pre.pygments .lineno{display:inline-block;margin-right:.25em} -table.pyhltable .linenodiv{background:none!important;padding-right:0!important} -.quoteblock{margin:0 1em 1.25em 1.5em;display:table} -.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em} -.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify} -.quoteblock blockquote{margin:0;padding:0;border:0} -.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} -.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0} -.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right} -.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)} -.quoteblock .quoteblock blockquote{padding:0 0 0 .75em} -.quoteblock .quoteblock blockquote:before{display:none} -.verseblock{margin:0 1em 1.25em 1em} -.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility} -.verseblock pre strong{font-weight:400} -.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex} -.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic} -.quoteblock .attribution br,.verseblock .attribution br{display:none} -.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)} -.quoteblock.abstract{margin:0 0 1.25em 0;display:block} -.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0} -.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none} -table.tableblock{max-width:100%;border-collapse:separate} -table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0} -table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede} -table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0} -table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0} -table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0} -table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0} -table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0} -table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0} -table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0} -table.frame-all{border-width:1px} -table.frame-sides{border-width:0 1px} -table.frame-topbot{border-width:1px 0} -th.halign-left,td.halign-left{text-align:left} -th.halign-right,td.halign-right{text-align:right} -th.halign-center,td.halign-center{text-align:center} -th.valign-top,td.valign-top{vertical-align:top} -th.valign-bottom,td.valign-bottom{vertical-align:bottom} -th.valign-middle,td.valign-middle{vertical-align:middle} -table thead th,table tfoot th{font-weight:bold} -tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7} -tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold} -p.tableblock>code:only-child{background:none;padding:0} -p.tableblock{font-size:1em} -td>div.verse{white-space:pre} -ol{margin-left:1.75em} -ul li ol{margin-left:1.5em} -dl dd{margin-left:1.125em} -dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} -ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} -ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none} -ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em} -ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em} -ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px} -ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden} -ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block} -ul.inline>li>*{display:block} -.unstyled dl dt{font-weight:400;font-style:normal} -ol.arabic{list-style-type:decimal} -ol.decimal{list-style-type:decimal-leading-zero} -ol.loweralpha{list-style-type:lower-alpha} -ol.upperalpha{list-style-type:upper-alpha} -ol.lowerroman{list-style-type:lower-roman} -ol.upperroman{list-style-type:upper-roman} -ol.lowergreek{list-style-type:lower-greek} -.hdlist>table,.colist>table{border:0;background:none} -.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none} -td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em} -td.hdlist1{font-weight:bold;padding-bottom:1.25em} -.literalblock+.colist,.listingblock+.colist{margin-top:-.5em} -.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1} -.colist>table tr>td:last-of-type{padding:.25em 0} -.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd} -.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0} -.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em} -.imageblock>.title{margin-bottom:0} -.imageblock.thumb,.imageblock.th{border-width:6px} -.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em} -.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0} -.image.left{margin-right:.625em} -.image.right{margin-left:.625em} -a.image{text-decoration:none;display:inline-block} -a.image object{pointer-events:none} -sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super} -sup.footnote a,sup.footnoteref a{text-decoration:none} -sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline} -#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em} -#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0} -#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;text-indent:-1.05em;margin-bottom:.2em} -#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none} -#footnotes .footnote:last-of-type{margin-bottom:0} -#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} -.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0} -.gist .file-data>table td.line-data{width:99%} -div.unbreakable{page-break-inside:avoid} -.big{font-size:larger} -.small{font-size:smaller} -.underline{text-decoration:underline} -.overline{text-decoration:overline} -.line-through{text-decoration:line-through} -.aqua{color:#00bfbf} -.aqua-background{background-color:#00fafa} -.black{color:#000} -.black-background{background-color:#000} -.blue{color:#0000bf} -.blue-background{background-color:#0000fa} -.fuchsia{color:#bf00bf} -.fuchsia-background{background-color:#fa00fa} -.gray{color:#606060} -.gray-background{background-color:#7d7d7d} -.green{color:#006000} -.green-background{background-color:#007d00} -.lime{color:#00bf00} -.lime-background{background-color:#00fa00} -.maroon{color:#600000} -.maroon-background{background-color:#7d0000} -.navy{color:#000060} -.navy-background{background-color:#00007d} -.olive{color:#606000} -.olive-background{background-color:#7d7d00} -.purple{color:#600060} -.purple-background{background-color:#7d007d} -.red{color:#bf0000} -.red-background{background-color:#fa0000} -.silver{color:#909090} -.silver-background{background-color:#bcbcbc} -.teal{color:#006060} -.teal-background{background-color:#007d7d} -.white{color:#bfbfbf} -.white-background{background-color:#fafafa} -.yellow{color:#bfbf00} -.yellow-background{background-color:#fafa00} -span.icon>.fa{cursor:default} -.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default} -.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c} -.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111} -.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900} -.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400} -.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000} -.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold} -.conum[data-value] *{color:#fff!important} -.conum[data-value]+b{display:none} -.conum[data-value]:after{content:attr(data-value)} -pre .conum[data-value]{position:relative;top:-.125em} -b.conum *{color:inherit!important} -.conum:not([data-value]):empty{display:none} -dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility} -h1,h2,p,td.content,span.alt{letter-spacing:-.01em} -p strong,td.content strong,div.footnote strong{letter-spacing:-.005em} -p,blockquote,dt,td.content,span.alt{font-size:1.0625rem} -p{margin-bottom:1.25rem} -.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em} -.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc} -.print-only{display:none!important} -@media print{@page{margin:1.25cm .75cm} -*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important} -a{color:inherit!important;text-decoration:underline!important} -a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important} -a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em} -abbr[title]:after{content:" (" attr(title) ")"} -pre,blockquote,tr,img,object,svg{page-break-inside:avoid} -thead{display:table-header-group} -svg{max-width:100%} -p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3} -h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid} -#toc,.sidebarblock,.exampleblock>.content{background:none!important} -#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important} -.sect1{padding-bottom:0!important} -.sect1+.sect1{border:0!important} -#header>h1:first-child{margin-top:1.25rem} -body.book #header{text-align:center} -body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0} -body.book #header .details{border:0!important;display:block;padding:0!important} -body.book #header .details span:first-child{margin-left:0!important} -body.book #header .details br{display:block} -body.book #header .details br+span:before{content:none!important} -body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important} -body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always} -.listingblock code[data-lang]:before{display:block} -#footer{background:none!important;padding:0 .9375em} -#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em} -.hide-on-print{display:none!important} -.print-only{display:block!important} -.hide-for-print{display:none!important} -.show-for-print{display:inherit!important}} -</style> -</head> -<body class="article"> -<div id="header"> -<h1>Valhalla/L-Words microbenchmarks description</h1> -<div class="details"> -<span id="author" class="author">Sergey Kuksenko</span><br> -<span id="email" class="email"><a href="mailto:sergey.kuksenko@oracle.com">sergey.kuksenko@oracle.com</a></span><br> -<span id="revnumber">version 0.5,</span> -<span id="revdate">2018-06-20</span> -</div> -<div id="toc" class="toc"> -<div id="toctitle">Table of Contents</div> -<ul class="sectlevel1"> -<li><a href="#_overall_structure">Overall structure</a></li> -<li><a href="#_general_description">General description</a></li> -</ul> -</div> -</div> -<div id="content"> -<div class="sect1"> -<h2 id="_overall_structure">Overall structure</h2> -<div class="sectionbody"> -<div class="paragraph"> -<p>At the current moment all key implemented benchmarks cover value types containing only primitive types (1, 2 and 8 <code>int</code> values), that allows to understand scalability with increase of fields in value type. -Combinations of <code>int</code> and <code>long</code> were checked, no differences were found and such benchmarks were omitted for simplicity.</p> -</div> -<div class="ulist"> -<div class="title">There are two kinds of baseline benchmarks:</div> -<ul> -<li> -<p><code>boxed</code> - old-style Java class,</p> -</li> -<li> -<p><code>primitive</code> - manual layout of primitive values into enclosing entity (array, class, method args, etc).</p> -</li> -</ul> -</div> -<div class="ulist"> -<div class="title">All benchmarks are split into two packages:</div> -<ul> -<li> -<p><code>oracle.micro.valhalla.baseline</code></p> -</li> -<li> -<p><code>oracle.micro.valhalla.lworld</code></p> -</li> -</ul> -</div> -<div class="paragraph"> -<p>(<em>such separation simplify compilation and execution baseline benchmarks with non-lworld jdk</em>)</p> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_general_description">General description</h2> -<div class="sectionbody"> -<div class="dlist"> -<dl> -<dt class="hdlist1"><code>invoke</code></dt> -<dd> -<p>Set of benchmarks covers cost of value type method invocation. Covers invocation directly from target type, invocation of Object’s method and invocation of interface method. Monomorphic, bimorphic and trimorphic calls are covered (<em>to check Cache Inline optimization</em>)<br> -<strong>N.B.</strong> The <code>invoke</code> microbenchmark results pretend to be fine-graine. Unfortunately, results depend not only on invocation cost but on <code>aaload</code> cost too. For example, recent comparison lworld vs non-lworld on <strong>baseline</strong> benchmarks has shown -10% slowdown due to lworld runtime checks for `aaload'. It’s a subject to further evaluation to remove or clarify such dependency.</p> -</dd> -<dt class="hdlist1"><code>ackermann</code></dt> -<dd> -<p>Covers cost of calling convention. Classic Ackermann function is used, measures cost of the single invocation where value types are passed as arguments and returned as result. Covered exact type formal parameters and interface type formal parameters.</p> -</dd> -<dt class="hdlist1"><code>arraycopy</code></dt> -<dd> -<p>Covers cost of copying data from one array into another array of the same type. <code>for</code> loop and <code>arraycopy</code> cases are implemented.</p> -</dd> -<dt class="hdlist1"><code>convcopy</code></dt> -<dd> -<p>Covers cost of copying data from one array into another with type conversion. Conversions: Object or interface to/from value type. <code>for</code> loop and <code>arraycopy</code> cases are implemented.</p> -</dd> -<dt class="hdlist1"><code>arrayfill</code></dt> -<dd> -<p>Covers cost of filling array with data. For value types flattened value type array, Object array and interface array are used.</p> -</dd> -<dt class="hdlist1"><code>arraysum</code></dt> -<dd> -<p>Covers cost of reading from array (and local variables). For boxed/value there are two versions - one version uses local variable of boxed/value type as reduction variable, the other has manual scalarization.</p> -</dd> -<dt class="hdlist1"><code>listsum</code></dt> -<dd> -<p>Covers cost of reading from linked list. Checks how values types are embedding into enclosing class.</p> -</dd> -<dt class="hdlist1"><code>traversal</code></dt> -<dd> -<p>Covers cost of random access readings from array. Targeting data locality. Different working set sizes are used to check all CPU caches hits impact.</p> -</dd> -<dt class="hdlist1"><code>matrix</code></dt> -<dd> -<p>Complex numbers matrix multiplication.</p> -</dd> -<dt class="hdlist1"><code>sort</code></dt> -<dd> -<p>Covers array sorting. Doesn’t use <code>Arrays.sort()</code>. Instead of this benchmarks have custom implementation of quick sort and merge sort. -<strong>N.B.</strong> <code>Arrays.sort</code> uses quick sort for primitives and merge sort for Java classes. Merge sort is used to preserve identity order. Value types doen’t have identity - may it we should move to quick sort in that case?</p> -</dd> -<dt class="hdlist1"><code>search</code></dt> -<dd> -<p>Binary search in sorted array.</p> -</dd> -<dt class="hdlist1"><code>map</code></dt> -<dd> -<p>Exprimental benchmarks to explore value types usage inside Java collections. Subject for removal when experiments will be finished.</p> -</dd> -</dl> -</div> -</div> -</div> -</div> -<div id="footer"> -<div id="footer-text"> -Version 0.5<br> -Last updated 2018-06-20 11:57:22 PDT -</div> -</div> -<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css"> -<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script> -<script>prettyPrint()</script> -</body> -</html> \ No newline at end of file
--- a/test/benchmarks/pom.xml Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>oracle.micro</groupId> - <artifactId>lwordsmicrobenchmarks</artifactId> - <packaging>jar</packaging> - <version>1.0-SNAPSHOT</version> - <name>valhalla lworlds microbenchmarks</name> - - <prerequisites> - <maven>3.0</maven> - </prerequisites> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <jmh.version>1.21</jmh.version> - <uberjar.name>benchmarks</uberjar.name> - </properties> - - <dependencies> - <dependency> - <groupId>org.openjdk.jmh</groupId> - <artifactId>jmh-core</artifactId> - <version>${jmh.version}</version> - </dependency> - <dependency> - <groupId>org.openjdk.jmh</groupId> - <artifactId>jmh-generator-annprocess</artifactId> - <version>${jmh.version}</version> - <scope>provided</scope> - </dependency> - </dependencies> - - - - <build> - <pluginManagement> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - </plugin> - <plugin> - <artifactId>maven-deploy-plugin</artifactId> - <version>2.8.1</version> - </plugin> - <plugin> - <artifactId>maven-install-plugin</artifactId> - <version>2.5.1</version> - </plugin> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <version>2.4</version> - </plugin> - <plugin> - <artifactId>maven-javadoc-plugin</artifactId> - <version>2.10.4</version> - </plugin> - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <version>2.6</version> - </plugin> - <plugin> - <artifactId>maven-site-plugin</artifactId> - <version>3.3</version> - </plugin> - <plugin> - <artifactId>maven-source-plugin</artifactId> - <version>2.2.1</version> - </plugin> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.20</version> - - </plugin> - </plugins> - </pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <compilerVersion>13</compilerVersion> - <source>13</source> - <target>13</target> - <compilerArgs> - <arg>-XDallowWithFieldOperator</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>2.3</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <finalName>${uberjar.name}</finalName> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <mainClass>org.openjdk.jmh.Main</mainClass> - </transformer> - <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> - <resource>META-INF/BenchmarkList</resource> - </transformer> - <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> - <resource>META-INF/CompilerHints</resource> - </transformer> - <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> - </transformers> - <filters> - <filter> - <artifact>*:*</artifact> - <excludes> - <exclude>META-INF/*.SF</exclude> - <exclude>META-INF/*.DSA</exclude> - <exclude>META-INF/*.RSA</exclude> - </excludes> - </filter> - </filters> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> - - -
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/AckermannBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public abstract class AckermannBase { - - // ackermann(1,1748)+ ackermann(2,1897)+ ackermann(3,8); == 9999999 calls - public static final int X1 = 1; - public static final int Y1 = 1748; - public static final int X2 = 2; - public static final int Y2 = 1897; - public static final int X3 = 3; - public static final int Y3 = 8; - - public static final int OPI = 9999999; - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/AcmpBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.Arrays; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -@Fork(1) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public abstract class AcmpBase { - - public static final int SIZE = 1024; - - /* - creates and returns array ob Objects where `eq` percent of values are equals to base array - */ - public static Object[] populate(Object[] base, int eq) { - Object[] objects2 = new Object[base.length]; - Arrays.setAll(objects2, i -> new Object()); - if (eq == 0) { - // nothing to do - } else if (eq >= 100) { - System.arraycopy(base, 0, objects2, 0, base.length); - } else { - new Random(42) - .ints(0, base.length) - .distinct() - .limit(eq * base.length / 100) - .forEach(i -> objects2[i] = base[i]); - } - return objects2; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/ArraycopyBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public class ArraycopyBase { - - @Param({"500", "10000000"}) - public static int size; - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/ArrayfillBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public abstract class ArrayfillBase { - - public static final int SIZE = 500; - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/ArraysumBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@BenchmarkMode(Mode.AverageTime) -@OutputTimeUnit(TimeUnit.MICROSECONDS) -@State(Scope.Thread) -public abstract class ArraysumBase { - - @Param({"500", "10000000"}) - public static int size; - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/InvokeBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public abstract class InvokeBase { - - public static final int SIZE = 300; - - public static Integer[] random2() { - Integer[] r = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) { - switch (i % 2) { - case 0: r[i] = 0; break; - case 1: r[i] = 1; break; - } - } - return r; - } - - public static Integer[] random3() { - Integer[] r = new Integer[SIZE]; - for (int i = 0; i < SIZE; i++) { - switch (i % 3) { - case 0: r[i] = 0; break; - case 1: r[i] = 1; break; - case 2: r[i] = 2; break; - } - } - return r; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/ListsumBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -@OutputTimeUnit(TimeUnit.MICROSECONDS) -public abstract class ListsumBase { - - @Param({"500", "10000000"}) - public static int size; - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/MapBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.MICROSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public class MapBase { - - @Param({"500", "1000000"}) - public int size; - - - public Random rnd; - public Integer[] keys; - public Integer[] nonKeys; - - public void init(int size) { - rnd = new Random(42); - Integer[] all = rnd.ints().distinct().limit(size * 2).boxed().toArray(Integer[]::new); - Collections.shuffle(Arrays.asList(all), rnd); - keys = Arrays.copyOfRange(all, 0, size); - nonKeys = Arrays.copyOfRange(all, size, size * 2); - - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/MatrixBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@OutputTimeUnit(TimeUnit.MICROSECONDS) -@Warmup(iterations = 3, time = 3) -@Measurement(iterations = 3, time = 8) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public class MatrixBase { - - - @Param({"10", "100"}) - public int size; - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/SearchBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public class SearchBase { - - public static final int OPS = 500; - - @Param({"500", "10000000"}) - public static int size; - - public static final int[] targets = new int[OPS]; - - public static void baseSetup() { - int stride = size/OPS; - assert stride > 0; - Integer[] t = new Integer[OPS]; - for (int i = 0; i < OPS; i++) { - t[i] = i*stride; - } - Collections.shuffle(Arrays.asList(t), new Random(42)); - for(int i=0; i< t.length; i++) { - targets[i] = t[i]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/SortBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.MICROSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public class SortBase { - - @Param({ "500", "1000000"}) - public int size; - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/TraversalBase.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla; - -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.TimeUnit; - -@Fork(3) -@Warmup(iterations = 3, time = 1) -@Measurement(iterations = 5, time = 1) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@BenchmarkMode(Mode.AverageTime) -@State(Scope.Thread) -public class TraversalBase { - - public static final int K = 1024; - -// @Param({"true", "false"}) - @Param({"true"}) - public boolean shuffle; - - public static int[] prepare(int size, boolean shuffled) { - int[] a = new int[size]; - if(shuffled) { - int x = 0; - do { - a[x] = (1103515245 * x + 12345) & (size - 1); - x = a[x]; - } while (x != 0); - } else { - for(int i = 0; i<size; i++) { - a[i] = i+1; - } - a[size-1] = 0; - } - return a; - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/Ackermann1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Ackermann1 extends AckermannBase { - - private static int ack_primitive(int x, int y) { - return x == 0 ? - y + 1 : - (y == 0 ? - ack_primitive(x - 1, 1) : - ack_primitive(x - 1, ack_primitive(x, y - 1))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int primitive() { - return ack_primitive(X1, Y1) + ack_primitive(X2, Y2) + ack_primitive(X3, Y3); - } - - public static final Box1 B1_ONE = new Box1(1); - public static final Box1 B1_X1 = B1_ONE; - public static final Box1 B1_Y1 = new Box1(1748); - public static final Box1 B1_X2 = new Box1(2); - public static final Box1 B1_Y2 = new Box1(1897); - public static final Box1 B1_X3 = new Box1(3); - public static final Box1 B1_Y3 = new Box1(8); - - - private static Box1 ack_boxed(Box1 x, Box1 y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_boxed(x.dec(), B1_ONE) : - ack_boxed(x.dec(), ack_boxed(x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int boxed() { - return ack_boxed(B1_X1, B1_Y1).totalsum() + ack_boxed(B1_X2, B1_Y2).totalsum() + ack_boxed(B1_X3, B1_Y3).totalsum(); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/Ackermann2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Ackermann2 extends AckermannBase { - - private static int ack_primitive(int x0, int x1, int y0, int y1) { - return (x0 + x1) == 0 ? - (y0 + y1 + 1) : - ((y0 + y1) == 0 ? - ack_primitive(x1, x0 - 1, 0, 1) : - ack_primitive(x1, x0 - 1, 0, ack_primitive(x0, x1, y1, y0 - 1))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int primitive() { - return ack_primitive(0, X1, 0, Y1) + ack_primitive(0, X2, 0, Y2) + ack_primitive(0, X3, 0, Y3); - } - - public static final Box2 B2_ONE = new Box2(0, 1); - public static final Box2 B2_X1 = B2_ONE; - public static final Box2 B2_Y1 = new Box2(0, 1748); - public static final Box2 B2_X2 = new Box2(0, 2); - public static final Box2 B2_Y2 = new Box2(0, 1897); - public static final Box2 B2_X3 = new Box2(0, 3); - public static final Box2 B2_Y3 = new Box2(0, 8); - - - private static Box2 ack_boxed(Box2 x, Box2 y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_boxed(x.dec(), B2_ONE) : - ack_boxed(x.dec(), ack_boxed(x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int boxed() { - return ack_boxed(B2_X1, B2_Y1).totalsum() + ack_boxed(B2_X2, B2_Y2).totalsum() + ack_boxed(B2_X3, B2_Y3).totalsum(); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/Ackermann8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Ackermann8 extends AckermannBase { - - private static int ack_primitive(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int y0, int y1, int y2, int y3, int y4, int y5, int y6, int y7) { - return (x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7) == 0 ? - (y0 + y1 + y2 + y3 + y4 + y5 + y6 + y7 + 1) : - ((y0 + y1 + y2 + y3 + y4 + y5 + y6 + y7) == 0 ? - ack_primitive(x1, x2, x3, x4, x5, x6, x7, x0 - 1, 0, 0, 0, 0, 0, 0, 0, 1) : - ack_primitive(x1, x2, x3, x4, x5, x6, x7, x0 - 1, 0, 0, 0, 0, 0, 0, 0, - ack_primitive(x0, x1, x2, x3, x4, x5, x6, x7, y1, y2, y3, y4, y5, y6, y7, y0 - 1))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int primitive() { - return ack_primitive(0, 0, 0, 0, 0, 0, 0, X1, 0, 0, 0, 0, 0, 0, 0, Y1) + - ack_primitive(0, 0, 0, 0, 0, 0, 0, X2, 0, 0, 0, 0, 0, 0, 0, Y2) + - ack_primitive(0, 0, 0, 0, 0, 0, 0, X3, 0, 0, 0, 0, 0, 0, 0, Y3); - } - - public static final Box8 B8_ONE = new Box8(0, 0, 0, 0, 0, 0, 0, 1); - public static final Box8 B8_X1 = B8_ONE; - public static final Box8 B8_Y1 = new Box8(0, 0, 0, 0, 0, 0, 0, 1748); - public static final Box8 B8_X2 = new Box8(0, 0, 0, 0, 0, 0, 0, 2); - public static final Box8 B8_Y2 = new Box8(0, 0, 0, 0, 0, 0, 0, 1897); - public static final Box8 B8_X3 = new Box8(0, 0, 0, 0, 0, 0, 0, 3); - public static final Box8 B8_Y3 = new Box8(0, 0, 0, 0, 0, 0, 0, 8); - - - private static Box8 ack_boxed(Box8 x, Box8 y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_boxed(x.dec(), B8_ONE) : - ack_boxed(x.dec(), ack_boxed(x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int boxed() { - return ack_boxed(B8_X1, B8_Y1).totalsum() + ack_boxed(B8_X2, B8_Y2).totalsum() + ack_boxed(B8_X3, B8_Y3).totalsum(); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/ackermann/AckermannMix.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.types.PNumber; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class AckermannMix extends AckermannBase { - - private static PNumber ack_interface(PNumber one, PNumber x, PNumber y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_interface(one, x.dec(), one) : - ack_interface(one, x.dec(), ack_interface(one , x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interface1() { - return ack_interface(Ackermann1.B1_ONE, Ackermann1.B1_X1, Ackermann1.B1_Y1).totalsum() + - ack_interface(Ackermann1.B1_ONE, Ackermann1.B1_X2, Ackermann1.B1_Y2).totalsum() + - ack_interface(Ackermann1.B1_ONE, Ackermann1.B1_X3, Ackermann1.B1_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interface2() { - return ack_interface(Ackermann2.B2_ONE, Ackermann2.B2_X1, Ackermann2.B2_Y1).totalsum() + - ack_interface(Ackermann2.B2_ONE, Ackermann2.B2_X2, Ackermann2.B2_Y2).totalsum() + - ack_interface(Ackermann2.B2_ONE, Ackermann2.B2_X3, Ackermann2.B2_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interface8() { - return ack_interface(Ackermann8.B8_ONE, Ackermann8.B8_X1, Ackermann8.B8_Y1).totalsum() + - ack_interface(Ackermann8.B8_ONE, Ackermann8.B8_X2, Ackermann8.B8_Y2).totalsum() + - ack_interface(Ackermann8.B8_ONE, Ackermann8.B8_X3, Ackermann8.B8_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interfaceMixDepth() { - return ack_interface(Ackermann1.B1_ONE, Ackermann1.B1_X1, Ackermann1.B1_Y1).totalsum() + - ack_interface(Ackermann2.B2_ONE, Ackermann2.B2_X2, Ackermann2.B2_Y2).totalsum() + - ack_interface(Ackermann8.B8_ONE, Ackermann8.B8_X3, Ackermann8.B8_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interfaceMixWidth() { - return ack_interface(Ackermann1.B1_ONE, Ackermann2.B2_X1, Ackermann8.B8_Y1).totalsum() + - ack_interface(Ackermann2.B2_ONE, Ackermann8.B8_X2, Ackermann1.B1_Y2).totalsum() + - ack_interface(Ackermann8.B8_ONE, Ackermann1.B1_X3, Ackermann2.B2_Y3).totalsum(); - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/IsCmp.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.acmp; - -import oracle.micro.valhalla.AcmpBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; -import org.openjdk.jmh.annotations.Param; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Arrays; - -public class IsCmp extends AcmpBase { - - Object[] objects1; - Object[] objects2; - - @Param({"0", "1", "25", "50", "75", "99", "100"}) - int eq; // how many elements objects1[i] and objects2[i] equals (in %) - - @Setup - public void setup() { - objects1 = new Object[SIZE]; - Arrays.setAll(objects1, i -> new Object()); - objects2 = populate(objects1, eq); - forcedWarmup(); - } - - public boolean sideB; - public int sideI; - - // that is required to cover all branches in acmp code - private void forcedWarmup() { - Object[] objects1 = new Object[SIZE]; - Arrays.setAll(objects1, i -> new Object()); - Object[] objects2 = populate(objects1, eq); - objects2[0] = objects1[0] = null; - objects2[1] = null; - objects2[2] = null; - sideI += isCmpSum(objects1, objects2); - sideB ^= isCmpXor(objects1, objects2); - sideI += isNotCmpSum(objects1, objects2); - sideB ^= isNotCmpXor(objects1, objects2); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public boolean isCmpValue() { - return isCmpXor(objects1, objects2); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public int isCmpBranch() { - return isCmpSum(objects1, objects2); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public boolean isNotCmpValue() { - return isNotCmpXor(objects1, objects2); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public int isNotCmpBranch() { - return isNotCmpSum(objects1, objects2); - } - - - private static boolean isCmpXor(Object[] objects1, Object[] objects2) { - boolean s = false; - for (int i = 0; i < SIZE; i++) { - s ^= objects1[i] == objects2[i]; - } - return s; - } - - private static int isCmpSum(Object[] objects1, Object[] objects2) { - int s = 0; - for (int i = 0; i < SIZE; i++) { - if (objects1[i] == objects2[i]) { - s += 1; - } else { - s -= 1; - } - } - return s; - } - - private static boolean isNotCmpXor(Object[] objects1, Object[] objects2) { - boolean s = false; - for (int i = 0; i < SIZE; i++) { - s ^= objects1[i] != objects2[i]; - } - return s; - } - - private static int isNotCmpSum(Object[] objects1, Object[] objects2) { - int s = 0; - for (int i = 0; i < SIZE; i++) { - if (objects1[i] != objects2[i]) { - s += 1; - } else { - s -= 1; - } - } - return s; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/IsNull.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.acmp; - -import oracle.micro.valhalla.AcmpBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; -import org.openjdk.jmh.annotations.Param; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Arrays; - -public class IsNull extends AcmpBase { - - Object[] objects; - - @Param({"0", "1", "25", "50", "75", "99", "100"}) - int nulls; // how many elements if objects[] are nulls (in %) - - @Setup - public void setup() { - objects = populate(new Object[SIZE], nulls); - forcedWarmup(); - } - - public boolean sideB; - public int sideI; - - // that is required to cover all branches in acmp code - private void forcedWarmup() { - Object[] objects = populate(new Object[SIZE], 50); - - sideI += isNullSum(objects); - sideB ^= isNullXor(objects); - sideI += isNotNullSum(objects); - sideB ^= isNotNullXor(objects); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public boolean isNullValue() { - return isNullXor(objects); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public int isNullBranch() { - return isNullSum(objects); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public boolean isNotNullValue() { - return isNotNullXor(objects); - } - - @OperationsPerInvocation(SIZE) - @Benchmark - public int isNotNullBranch() { - return isNotNullSum(objects); - } - - private static boolean isNullXor(Object[] objects) { - boolean s = false; - for (int i = 0; i < objects.length; i++) { - s ^= objects[i] == null; - } - return s; - } - - private static int isNullSum(Object[] objects) { - int s = 0; - for (int i = 0; i < objects.length; i++) { - if (objects[i] == null) { - s += 1; - } else { - s -= 1; - } - } - return s; - } - - private static boolean isNotNullXor(Object[] objects) { - boolean s = false; - for (int i = 0; i < objects.length; i++) { - s ^= objects[i] != null; - } - return s; - } - - private static int isNotNullSum(Object[] objects) { - int s = 0; - for (int i = 0; i < objects.length; i++) { - if (objects[i] != null) { - s += 1; - } else { - s -= 1; - } - } - return s; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/TrivialEquals.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.acmp; - -import oracle.micro.valhalla.AcmpBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; - -/* - * to provide proper measurement the benchmark have to be executed in two modes: - * -wm INDI - * -wm BULK - */ -public class TrivialEquals extends AcmpBase { - Object o1 = new Object(); - Object o2 = new Object(); - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static boolean cmpEquals(Object a, Object b) { - return a == b; // new acmp - } - - @Benchmark - public void isCmp_null_null() { - cmpEquals(null, null); - } - - @Benchmark - public void isCmp_o1_null() { - cmpEquals(o1, null); - } - - @Benchmark - public void isCmp_null_o1() { - cmpEquals(null, o1); - } - - @Benchmark - public void isCmp_o1_o1() { - cmpEquals(o1, o1); - } - - @Benchmark - public void isCmp_o1_o2() { - cmpEquals(o1, o2); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/acmp/TrivialNotEquals.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.acmp; - -import oracle.micro.valhalla.AcmpBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; - -/* - * to provide proper measurement the benchmark have to be executed in two modes: - * -wm INDI - * -wm BULK - */ -public class TrivialNotEquals extends AcmpBase { - Object o1 = new Object(); - Object o2 = new Object(); - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static boolean cmpNotEquals(Object a, Object b) { - return a != b; // new acmp - } - - @Benchmark - public void isNotCmp_null_null() { - cmpNotEquals(null, null); - } - - @Benchmark - public void isNotCmp_o1_null() { - cmpNotEquals(o1, null); - } - - @Benchmark - public void isNotCmp_null_o1() { - cmpNotEquals(null, o1); - } - - @Benchmark - public void isNotCmp_o1_o1() { - cmpNotEquals(o1, o1); - } - - @Benchmark - public void isNotCmp_o1_o2() { - cmpNotEquals(o1, o2); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraycopy/Arraycopy1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arraycopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.*; - -public class Arraycopy1 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StatePrimitive { - int[] src; - int[] dst; - - @Setup - public void setup() { - src = new int[size]; - for (int i = 0; i < src.length; i++) { - src[i] = i; - } - dst = new int[size]; - } - } - - @Benchmark - public Object loopPrimitive(StatePrimitive st) { - int[] src = st.src; - int[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyPrimitive(StatePrimitive st) { - int[] src = st.src; - int[] dst = st.dst; - System.arraycopy(src, 0, dst, 0, size); - return dst; - } - - @State(Scope.Thread) - public static class StateBoxed { - Box1[] src; - Box1[] dst; - - @Setup - public void setup() { - src = new Box1[size]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - dst = new Box1[size]; - } - } - - @Benchmark - public Object loopBoxed(StateBoxed st) { - Box1[] src = st.src; - Box1[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxed(StateBoxed st) { - Box1[] src = st.src; - Box1[] dst = st.dst; - System.arraycopy(src, 0, dst, 0, size); - return dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraycopy/Arraycopy2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arraycopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraycopy2 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StatePrimitive { - int[] src; - int[] dst; - - @Setup - public void setup() { - src = new int[size * 2]; - for (int i = 0, k = 0; i < src.length; i += 2, k += 2) { - src[i] = k; - src[i + 1] = k + 1; - } - dst = new int[size * 2]; - } - } - - @Benchmark - public Object loopPrimitive(StatePrimitive st) { - int[] src = st.src; - int[] dst = st.dst; - int len = size * 2; - for (int i = 0; i < len; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyPrimitive(StatePrimitive st) { - System.arraycopy(st.src, 0, st.dst, 0, size * 2); - return st.dst; - } - - @State(Scope.Thread) - public static class StateBoxed { - Box2[] src; - Box2[] dst; - - @Setup - public void setup() { - src = new Box2[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = new Box2(k, k + 1); - } - dst = new Box2[size]; - } - } - - @Benchmark - public Object loopBoxed(StateBoxed st) { - Box2[] src = st.src; - Box2[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxed(StateBoxed st) { - System.arraycopy(st.src, 0, st.dst, 0, size); - return st.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraycopy/Arraycopy8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arraycopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.baseline.types.Box2; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraycopy8 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StatePrimitive { - int[] src; - int[] dst; - - @Setup - public void setup() { - src = new int[size * 8]; - for (int i = 0, k = 0; i < src.length; i += 8, k += 8) { - src[i] = k; - src[i + 1] = k + 1; - src[i + 2] = k + 2; - src[i + 3] = k + 3; - src[i + 4] = k + 4; - src[i + 5] = k + 5; - src[i + 6] = k + 6; - src[i + 7] = k + 7; - } - dst = new int[size * 8]; - } - } - - @Benchmark - public Object loopPrimitive(StatePrimitive st) { - int[] src = st.src; - int[] dst = st.dst; - int len = size * 8; - for (int i = 0; i < len; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyPrimitive(StatePrimitive st) { - System.arraycopy(st.src, 0, st.dst, 0, size * 8); - return st.dst; - } - - @State(Scope.Thread) - public static class StateBoxed { - Box8[] src; - Box8[] dst; - - @Setup - public void setup() { - src = new Box8[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - dst = new Box8[size]; - } - } - - @Benchmark - public Object loopBoxed(StateBoxed st) { - Box8[] src = st.src; - Box8[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxed(StateBoxed st) { - System.arraycopy(st.src, 0, st.dst, 0, size); - return st.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arrayfill/Arrayfill1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arrayfill; - -import oracle.micro.valhalla.ArrayfillBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Arrayfill1 extends ArrayfillBase { - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object primitive() { - int[] values = new int[SIZE]; - for (int i = 0; i < values.length; i++) { - values[i] = i; - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object boxed() { - Box1[] values = new Box1[SIZE]; - for (int i = 0; i < values.length; i++) { - values[i] = new Box1(i); - } - return values; - } - - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arrayfill/Arrayfill2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arrayfill; - -import oracle.micro.valhalla.ArrayfillBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Arrayfill2 extends ArrayfillBase { - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object primitive() { - int[] values = new int[SIZE * 2]; - for (int i = 0, k = 0; i < values.length; i += 2, k += 2) { - values[i] = k; - values[i + 1] = k + 1; - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object boxed() { - Box2[] values = new Box2[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 2) { - values[i] = new Box2(k, k + 1); - } - return values; - } - - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arrayfill/Arrayfill8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arrayfill; - -import oracle.micro.valhalla.ArrayfillBase; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Arrayfill8 extends ArrayfillBase { - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object primitive() { - int[] values = new int[SIZE * 8]; - for (int i = 0, k = 0; i < values.length; i += 8, k += 8) { - values[i] = k; - values[i + 1] = k + 1; - values[i + 2] = k + 2; - values[i + 3] = k + 3; - values[i + 4] = k + 4; - values[i + 5] = k + 5; - values[i + 6] = k + 6; - values[i + 7] = k + 7; - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object boxed() { - Box8[] values = new Box8[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 8) { - values[i] = new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - return values; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraysum/Arraysum1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arraysum; - -import oracle.micro.valhalla.ArraysumBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraysum1 extends ArraysumBase { - - public static int[] setupPrimitive(int size) { - int[] values = new int[size]; - for (int i = 0; i < values.length; i++) { - values[i] = i; - } - return values; - } - - - public static int sumPrimitive(int[] values ) { - int sum = 0; - for (int i = 0; i < values.length; i++) { - sum += values[i]; - } - return sum; - } - - public static Box1[] setupBoxed(int size) { - Box1[] values = new Box1[size]; - for (int i = 0; i < values.length; i++) { - values[i] = new Box1(i); - } - return values; - } - - public static int sumScalarized(Box1[] values ) { - int sum = 0; - for (int i = 0; i < values.length; i++) { - sum += values[i].f0; - } - return sum; - } - - public static int sum(Box1[] values) { - Box1 sum = new Box1(0); - for (int i = 0; i < values.length; i++) { - sum = sum.add(values[i]); - } - return sum.totalsum(); - } - - @State(Scope.Thread) - public static class StatePrimitive { - int[] values; - - @Setup - public void setup() { - values = setupPrimitive(size); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - Box1[] values; - - @Setup - public void setup() { - values = setupBoxed(size); - } - } - - @Benchmark - public int boxedScalarized(StateBoxed st) { - return sumScalarized(st.values); - } - - @Benchmark - public int boxed(StateBoxed st) { - return sum(st.values); - } - - @Benchmark - public int primitive(StatePrimitive st) { - return sumPrimitive(st.values); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraysum/Arraysum2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arraysum; - -import oracle.micro.valhalla.ArraysumBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraysum2 extends ArraysumBase { - - public static int[] setupPrimitive(int size) { - int[] values = new int[size*2]; - for (int i = 0, k = 0; i < values.length; i += 2, k += 2) { - values[i] = k; - values[i + 1] = k + 1; - } - return values; - } - - - public static int sumPrimitive(int[] values ) { - int sum = 0; - for (int i = 0; i < values.length; i++) { - sum += values[i]; - } - return sum; - } - - public static Box2[] setupBoxed(int size) { - Box2[] values = new Box2[size]; - for (int i = 0, k = 0; i < values.length; i++, k += 2) { - values[i] = new Box2(k, k + 1); - } - - return values; - } - - public static int sumScalarized(Box2[] values ) { - int f0 = 0; - int f1 = 0; - for (int i = 0; i < values.length; i++) { - f0 += values[i].f0; - f1 += values[i].f1; - } - return f0 + f1; - } - - public static int sum(Box2[] values) { - Box2 sum = new Box2(0, 0); - for (int i = 0; i < values.length; i++) { - sum = sum.add(values[i]); - } - return sum.totalsum(); - } - - @State(Scope.Thread) - public static class StatePrimitive { - int[] values; - - @Setup - public void setup() { - values = setupPrimitive(size); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - Box2[] values; - - @Setup - public void setup() { - values = setupBoxed(size); - } - } - - @Benchmark - public int boxedScalarized(StateBoxed st) { - return sumScalarized(st.values); - } - - @Benchmark - public int boxed(StateBoxed st) { - return sum(st.values); - } - - @Benchmark - public int primitive(StatePrimitive st) { - return sumPrimitive(st.values); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/arraysum/Arraysum8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.arraysum; - -import oracle.micro.valhalla.ArraysumBase; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraysum8 extends ArraysumBase { - - public static int[] setupPrimitive(int size) { - int[] values = new int[size * 8]; - for (int i = 0, k = 0; i < values.length; i += 8, k += 8) { - values[i] = k; - values[i + 1] = k + 1; - values[i + 2] = k + 2; - values[i + 3] = k + 3; - values[i + 4] = k + 4; - values[i + 5] = k + 5; - values[i + 6] = k + 6; - values[i + 7] = k + 7; - } - return values; - } - - - public static int sumPrimitive(int[] values ) { - int sum = 0; - for (int i = 0; i < values.length; i++) { - sum += values[i]; - } - return sum; - } - - public static int sumPrimitive1(int[] values ) { - int f0 = 0; - int f1 = 0; - int f2 = 0; - int f3 = 0; - int f4 = 0; - int f5 = 0; - int f6 = 0; - int f7 = 0; - for (int i = 0; i < values.length; i += 8) { - f0 += values[i]; - f1 += values[i+1]; - f2 += values[i+2]; - f3 += values[i+3]; - f4 += values[i+4]; - f5 += values[i+5]; - f6 += values[i+5]; - f7 += values[i+7]; - } - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - public static Box8[] setupBoxed(int size) { - Box8[] values = new Box8[size]; - for (int i = 0, k = 0; i < values.length; i++, k += 8) { - values[i] = new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - return values; - } - - public static int sumScalarized(Box8[] values ) { - int f0 = 0; - int f1 = 0; - int f2 = 0; - int f3 = 0; - int f4 = 0; - int f5 = 0; - int f6 = 0; - int f7 = 0; - for (int i = 0; i < values.length; i++) { - f0 += values[i].f0; - f1 += values[i].f1; - f2 += values[i].f2; - f3 += values[i].f3; - f4 += values[i].f4; - f5 += values[i].f5; - f6 += values[i].f6; - f7 += values[i].f7; - } - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - public static int sum(Box8[] values) { - Box8 sum = new Box8(0, 0, 0, 0, 0, 0, 0, 0); - for (int i = 0; i < values.length; i++) { - sum = sum.add(values[i]); - } - return sum.totalsum(); - } - - @State(Scope.Thread) - public static class StatePrimitive { - int[] values; - - @Setup - public void setup() { - values = setupPrimitive(size); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - Box8[] values; - - @Setup - public void setup() { - values = setupBoxed(size); - } - } - - @Benchmark - public int boxedScalarized(StateBoxed st) { - return sumScalarized(st.values); - } - - @Benchmark - public int boxed(StateBoxed st) { - return sum(st.values); - } - - @Benchmark - public int primitive(StatePrimitive st) { - return sumPrimitive(st.values); - } - - @Benchmark - public int primitive1(StatePrimitive st) { - return sumPrimitive1(st.values); - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/convcopy/Convcopy1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.convcopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.baseline.types.Box1; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Convcopy1 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StateSrcBoxed { - Box1[] src; - - @Setup - public void setup() { - src = new Box1[size]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - } - } - - @State(Scope.Thread) - public static class StateDstBoxed { - Box1[] dst; - - @Setup - public void setup() { - dst = new Box1[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcObject { - Object[] src; - - @Setup - public void setup() { - src = new Object[size]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - } - } - - @State(Scope.Thread) - public static class StateDstObject { - Object[] dst; - - @Setup - public void setup() { - dst = new Object[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcInterface { - Total[] src; - - @Setup - public void setup() { - src = new Total[size]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - } - } - - @State(Scope.Thread) - public static class StateDstInterface { - Total[] dst; - - @Setup - public void setup() { - dst = new Total[size]; - } - } - - @Benchmark - public Object loopBoxedToObject(StateSrcBoxed srcst, StateDstObject dstst) { - Box1[] src = srcst.src; - Object[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxedToObject(StateSrcBoxed srcst, StateDstObject dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopObjectToBoxed(StateSrcObject srcst, StateDstBoxed dstst) { - Object[] src = srcst.src; - Box1[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Box1)src[i]; - } - return dst; - } - - @Benchmark - public Object copyObjectToBoxed(StateSrcObject srcst, StateDstBoxed dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopBoxedToInterface(StateSrcBoxed srcst, StateDstInterface dstst) { - Box1[] src = srcst.src; - Total[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxedToInterface(StateSrcBoxed srcst, StateDstInterface dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopInterfaceToBoxed(StateSrcInterface srcst, StateDstBoxed dstst) { - Total[] src = srcst.src; - Box1[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Box1)src[i]; - } - return dst; - } - - @Benchmark - public Object copyInterfaceToBoxed(StateSrcInterface srcst, StateDstBoxed dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/convcopy/Convcopy2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.convcopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.baseline.types.Box2; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Convcopy2 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StateSrcBoxed { - Box2[] src; - - @Setup - public void setup() { - src = new Box2[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = new Box2(k, k + 1); - } - } - } - - @State(Scope.Thread) - public static class StateDstBoxed { - Box2[] dst; - - @Setup - public void setup() { - dst = new Box2[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcObject { - Object[] src; - - @Setup - public void setup() { - src = new Object[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = new Box2(k, k + 1); - } - } - } - - @State(Scope.Thread) - public static class StateDstObject { - Object[] dst; - - @Setup - public void setup() { - dst = new Object[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcInterface { - Total[] src; - - @Setup - public void setup() { - src = new Total[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = new Box2(k, k + 1); - } - } - } - - @State(Scope.Thread) - public static class StateDstInterface { - Total[] dst; - - @Setup - public void setup() { - dst = new Total[size]; - } - } - - @Benchmark - public Object loopBoxedToObject(StateSrcBoxed srcst, StateDstObject dstst) { - Box2[] src = srcst.src; - Object[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxedToObject(StateSrcBoxed srcst, StateDstObject dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopObjectToBoxed(StateSrcObject srcst, StateDstBoxed dstst) { - Object[] src = srcst.src; - Box2[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Box2)src[i]; - } - return dst; - } - - @Benchmark - public Object copyObjectToBoxed(StateSrcObject srcst, StateDstBoxed dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopBoxedToInterface(StateSrcBoxed srcst, StateDstInterface dstst) { - Box2[] src = srcst.src; - Total[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxedToInterface(StateSrcBoxed srcst, StateDstInterface dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopInterfaceToBoxed(StateSrcInterface srcst, StateDstBoxed dstst) { - Total[] src = srcst.src; - Box2[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Box2)src[i]; - } - return dst; - } - - @Benchmark - public Object copyInterfaceToBoxed(StateSrcInterface srcst, StateDstBoxed dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/convcopy/Convcopy8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.convcopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.baseline.types.Box8; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Convcopy8 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StateSrcBoxed { - Box8[] src; - - @Setup - public void setup() { - src = new Box8[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - } - } - - @State(Scope.Thread) - public static class StateDstBoxed { - Box8[] dst; - - @Setup - public void setup() { - dst = new Box8[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcObject { - Object[] src; - - @Setup - public void setup() { - src = new Object[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - } - } - - @State(Scope.Thread) - public static class StateDstObject { - Object[] dst; - - @Setup - public void setup() { - dst = new Object[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcInterface { - Total[] src; - - @Setup - public void setup() { - src = new Total[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - } - } - - @State(Scope.Thread) - public static class StateDstInterface { - Total[] dst; - - @Setup - public void setup() { - dst = new Total[size]; - } - } - - @Benchmark - public Object loopBoxedToObject(StateSrcBoxed srcst, StateDstObject dstst) { - Box8[] src = srcst.src; - Object[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxedToObject(StateSrcBoxed srcst, StateDstObject dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopObjectToBoxed(StateSrcObject srcst, StateDstBoxed dstst) { - Object[] src = srcst.src; - Box8[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Box8)src[i]; - } - return dst; - } - - @Benchmark - public Object copyObjectToBoxed(StateSrcObject srcst, StateDstBoxed dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopBoxedToInterface(StateSrcBoxed srcst, StateDstInterface dstst) { - Box8[] src = srcst.src; - Total[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyBoxedToInterface(StateSrcBoxed srcst, StateDstInterface dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopInterfaceToBoxed(StateSrcInterface srcst, StateDstBoxed dstst) { - Total[] src = srcst.src; - Box8[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Box8)src[i]; - } - return dst; - } - - @Benchmark - public Object copyInterfaceToBoxed(StateSrcInterface srcst, StateDstBoxed dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/invoke/Invoke.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.invoke; - - -import oracle.micro.valhalla.InvokeBase; -import oracle.micro.valhalla.baseline.types.Box1; -import oracle.micro.valhalla.baseline.types.Box2; -import oracle.micro.valhalla.baseline.types.Box8; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.*; - -import java.util.concurrent.ThreadLocalRandom; - -public class Invoke extends InvokeBase { - - @State(Scope.Thread) - public static class StateBoxed { - Box1[] src; - - @Setup - public void setup() { - src = new Box1[SIZE]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeExactType(StateBoxed st) { - Box1[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].f0(); - } - return s; - } - - @State(Scope.Thread) - public static class StateObjectTarget1 { - Object[] src; - - @Setup - public void setup() { - src = new Object[SIZE]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeObject1(StateObjectTarget1 st) { - Object[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].hashCode(); - } - return s; - } - - - @State(Scope.Thread) - public static class StateObjectTarget2 { - Object[] src; - - @Setup - public void setup() { - src = new Object[SIZE]; - Integer[] d = random2(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = new Box1(i); - break; - case 1: - src[i] = new Box2(i, i + 1); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeObject2(StateObjectTarget2 st) { - Object[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].hashCode(); - } - return s; - } - - @State(Scope.Thread) - public static class StateObjectTarget3 { - Object[] src; - - @Setup - public void setup() { - src = new Object[SIZE]; - Integer[] d = random3(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = new Box1(i); - break; - case 1: - src[i] = new Box2(i, i + 1); - break; - case 2: - src[i] = new Box8(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeObject3(StateObjectTarget3 st) { - Object[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].hashCode(); - } - return s; - } - - @State(Scope.Thread) - public static class StateInterfaceTarget1 { - Total[] src; - - @Setup - public void setup() { - src = new Total[SIZE]; - for (int i = 0; i < src.length; i++) { - src[i] = new Box1(i); - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeInterface1(StateInterfaceTarget1 st) { - Total[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].totalsum(); - } - return s; - } - - - @State(Scope.Thread) - public static class StateInterfaceTarget2 { - Total[] src; - - @Setup - public void setup() { - src = new Total[SIZE]; - Integer[] d = random2(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = new Box1(i); - break; - case 1: - src[i] = new Box2(i, i + 1); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeInterface2(StateInterfaceTarget2 st) { - Total[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].totalsum(); - } - return s; - } - - @State(Scope.Thread) - public static class StateInterfaceTarget3 { - Total[] src; - - @Setup - public void setup() { - src = new Total[SIZE]; - for (int i = 0; i < src.length; i++) { - Integer[] d = random3(); - switch (d[i]) { - case 0: - src[i] = new Box1(i); - break; - case 1: - src[i] = new Box2(i, i + 1); - break; - case 2: - src[i] = new Box8(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeInterface3(StateInterfaceTarget3 st) { - Total[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].totalsum(); - } - return s; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/listsum/Listsum1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.listsum; - -import oracle.micro.valhalla.ListsumBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Listsum1 extends ListsumBase { - - static class BoxNode { - public Box1 value; - public BoxNode next; - - - public BoxNode(Box1 value, BoxNode next) { - this.value = value; - this.next = next; - } - } - - public static BoxNode setupBoxed(int size) { - BoxNode list = null; - for(int i=0; i< size; i++) { - list = new BoxNode(new Box1(i), list); - } - return list; - } - - public static int sumScalarized(BoxNode list) { - int sum = 0; - for (BoxNode n = list; n!=null; n = n.next) { - sum += n.value.f0; - } - return sum; - } - - public static int sum(BoxNode list) { - Box1 sum = new Box1(0); - for (BoxNode n = list; n!=null; n = n.next) { - sum = sum.add(n.value); - } - return sum.totalsum(); - } - - static class Node { - public int value; - public Node next; - - - public Node(int value, Node next) { - this.value = value; - this.next = next; - } - } - - - public static Node setupPrimitive(int size) { - Node list = null; - for(int i=0; i< size; i++) { - list = new Node(i, list); - } - return list; - } - - public static int sumPrimitive(Node list) { - int sum = 0; - for (Node n = list; n!=null; n = n.next) { - sum += n.value; - } - return sum; - } - - @State(Scope.Thread) - public static class StatePrimitive { - public Node list; - - @Setup - public void setup() { - list = setupPrimitive(size); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - public BoxNode list; - - @Setup - public void setup() { - list = setupBoxed(size); - } - } - - @Benchmark - public int boxedScalarized(StateBoxed st) { - return sumScalarized(st.list); - } - - @Benchmark - public int boxed(StateBoxed st) { - return sum(st.list); - } - - @Benchmark - public int primitive(StatePrimitive st) { - return sumPrimitive(st.list); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/listsum/Listsum2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.listsum; - -import oracle.micro.valhalla.ListsumBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Listsum2 extends ListsumBase { - - static class BoxNode { - public Box2 value; - public BoxNode next; - - - public BoxNode(Box2 value, BoxNode next) { - this.value = value; - this.next = next; - } - } - - - public static BoxNode setupBoxed(int size) { - BoxNode list = null; - for (int i = 0, k = 0; i < size; i++, k += 2) { - list = new BoxNode( new Box2(k, k+1), list); - } - return list; - } - - public static int sumScalarized(BoxNode list) { - int f0 = 0; - int f1 = 0; - for (BoxNode n = list; n!=null; n = n.next) { - f0 += n.value.f0; - f1 += n.value.f1; - } - return f0 + f1; - } - - public static int sum(BoxNode list) { - Box2 sum = new Box2(0,0); - for (BoxNode n = list; n!=null; n = n.next) { - sum = sum.add(n.value); - } - return sum.totalsum(); - } - - static class Node { - public int f0, f1; - public Node next; - - - public Node(int f0, int f1, Node next) { - this.f0 = f0; - this.f1 = f1; - this.next = next; - } - } - - - public static Node setupPrimitive(int size) { - Node list = null; - for (int i = 0, k = 0; i < size; i++, k += 2) { - list = new Node(k, k+1, list); - } - return list; - } - - public static int sumPrimitive(Node list) { - int f0 = 0; - int f1 = 0; - for (Node n = list; n!=null; n = n.next) { - f0 += n.f0; - f1 += n.f1; - } - return f0 + f1; - } - - @State(Scope.Thread) - public static class StatePrimitive { - public Node list; - - @Setup - public void setup() { - list = setupPrimitive(size); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - public BoxNode list; - - @Setup - public void setup() { - list = setupBoxed(size); - } - } - - @Benchmark - public int boxedScalarized(StateBoxed st) { - return sumScalarized(st.list); - } - - @Benchmark - public int boxed(StateBoxed st) { - return sum(st.list); - } - - @Benchmark - public int primitive(StatePrimitive st) { - return sumPrimitive(st.list); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/listsum/Listsum8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.listsum; - -import oracle.micro.valhalla.ListsumBase; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Listsum8 extends ListsumBase { - - static class BoxNode { - public Box8 value; - public BoxNode next; - - - public BoxNode(Box8 value, BoxNode next) { - this.value = value; - this.next = next; - } - } - - - public static BoxNode setupBoxed(int size) { - BoxNode list = null; - for (int i = 0, k = 0; i < size; i++, k += 8) { - list = new BoxNode(new Box8(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7), list); - - } - return list; - } - - public static int sumScalarized(BoxNode list) { - int f0 = 0; - int f1 = 0; - int f2 = 0; - int f3 = 0; - int f4 = 0; - int f5 = 0; - int f6 = 0; - int f7 = 0; - for (BoxNode n = list; n!=null; n = n.next) { - f0 += n.value.f0; - f1 += n.value.f1; - f2 += n.value.f2; - f3 += n.value.f3; - f4 += n.value.f4; - f5 += n.value.f5; - f6 += n.value.f6; - f7 += n.value.f7; - } - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - public static int sum(BoxNode list) { - Box8 sum = new Box8(0,0,0,0,0,0,0,0); - for (BoxNode n = list; n!=null; n = n.next) { - sum = sum.add(n.value); - } - return sum.totalsum(); - } - - static class Node { - public int f0, f1, f2, f3, f4, f5, f6, f7; - public Node next; - - - public Node(int f0, int f1, int f2, int f3, int f4, int f5, int f6, int f7, Node next) { - this.f0 = f0; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - this.f4 = f4; - this.f5 = f5; - this.f6 = f6; - this.f7 = f7; - this.next = next; - } - } - - - public static Node setupPrimitive(int size) { - Node list = null; - for (int i = 0, k = 0; i < size; i++, k += 8) { - list = new Node(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7, list); - } - return list; - } - - public static int sumPrimitive(Node list) { - int f0 = 0; - int f1 = 0; - int f2 = 0; - int f3 = 0; - int f4 = 0; - int f5 = 0; - int f6 = 0; - int f7 = 0; - for (Node n = list; n!=null; n = n.next) { - f0 += n.f0; - f1 += n.f1; - f2 += n.f2; - f3 += n.f3; - f4 += n.f4; - f5 += n.f5; - f6 += n.f6; - f7 += n.f7; - } - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - @State(Scope.Thread) - public static class StatePrimitive { - public Node list; - - @Setup - public void setup() { - list = setupPrimitive(size); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - public BoxNode list; - - @Setup - public void setup() { - list = setupBoxed(size); - } - } - - @Benchmark - public int boxedScalarized(StateBoxed st) { - return sumScalarized(st.list); - } - - @Benchmark - public int boxed(StateBoxed st) { - return sum(st.list); - } - - @Benchmark - public int primitive(StatePrimitive st) { - return sumPrimitive(st.list); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/map/Get.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.baseline.util.HashMap; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.infra.Blackhole; - -import java.util.Arrays; -import java.util.Collections; - -public class Get extends MapBase { - - HashMap<Integer, Integer> map; - Integer[] mixed; - - @Setup - public void setup() { - super.init(size); - map = new HashMap<>(); - for (Integer k : keys) { - map.put(k, k); - } - - mixed = new Integer[size]; - System.arraycopy(keys, 0, mixed, 0, size / 2); - System.arraycopy(nonKeys, 0, mixed, size / 2, size / 2); - Collections.shuffle(Arrays.asList(mixed), rnd); - } - - - @Benchmark - public void getHit(Blackhole bh) { - Integer[] keys = this.keys; - HashMap<Integer, Integer> map = this.map; - for (Integer k : keys) { - bh.consume(map.get(k)); - } - } - - @Benchmark - public void getMix(Blackhole bh) { - Integer[] keys = this.mixed; - HashMap<Integer, Integer> map = this.map; - for (Integer k : keys) { - bh.consume(map.get(k)); - } - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/map/Put.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.baseline.util.HashMap; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -public class Put extends MapBase { - - @Setup - public void setup() { - super.init(size); - } - - @Benchmark - public HashMap<Integer, Integer> put() { - Integer[] keys = this.keys; - HashMap<Integer, Integer> map = new HashMap<>(); - for (Integer k : keys) { - map.put(k, k); - } - return map; - } - - @Benchmark - public HashMap<Integer, Integer> putSized() { - Integer[] keys = this.keys; - HashMap<Integer, Integer> map = new HashMap<>(size*2); - for (Integer k : keys) { - map.put(k, k); - } - return map; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/map/Walk.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.baseline.util.HashMap; -import oracle.micro.valhalla.util.Cursor; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Iterator; - -public class Walk extends MapBase { - - HashMap<Integer, Integer> map; - - @Setup - public void setup() { - super.init(size); - map = new HashMap<>(); - for (Integer k : keys) { - map.put(k, k); - } - } - - @Benchmark - public int sumIterator() { - int s = 0; - for (Iterator<Integer> iterator = map.keyIterator(); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumIteratorHidden() { - int s = 0; - for (Iterator<Integer> iterator = hide(map.keyIterator()); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumCursor() { - int s = 0; - for (Cursor<Integer> cursor = map.keyCursor(); cursor.hasElement(); cursor = cursor.next()) { - s += cursor.get(); - } - return s; - } - - @Benchmark - public int sumCursorSpecialized() { - int s = 0; - for (HashMap.KeyCursor<Integer, Integer> cursor = HashMap.KeyCursor.of(map); cursor.hasElement(); cursor = cursor.nextEntry()) { - s += cursor.get(); - } - return s; - } - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static Iterator<Integer> hide(Iterator<Integer> it) { - return it; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/matrix/Boxed.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.matrix; - - -import oracle.micro.valhalla.MatrixBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Arrays; -import java.util.concurrent.ThreadLocalRandom; - -public class Boxed extends MatrixBase { - - public static final Box2 ZERO = new Box2(0, 0); - - public static Box2[][] multBoxedIJK(Box2[][] A, Box2[][] B) { - int size = A.length; - Box2[][] R = new Box2[size][size]; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - Box2 s = ZERO; - for (int k = 0; k < size; k++) { - s = s.add(A[i][k].mul(B[k][j])); - } - R[i][j] = s; - } - } - return R; - } - - public static Box2[][] multBoxedIKJ(Box2[][] A, Box2[][] B) { - int size = A.length; - Box2[][] R = new Box2[size][size]; - for (int i = 0; i < size; i++) { - Arrays.fill(R[i], ZERO); - } - for (int i = 0; i < size; i++) { - for (int k = 0; k < size; k++) { - Box2 aik = A[i][k]; - for (int j = 0; j < size; j++) { - R[i][j] = R[i][j].add(aik.mul(B[k][j])); - } - } - } - return R; - } - - Box2[][] A; - Box2[][] B; - - @Setup - public void setup() { - A = new Box2[size][size]; - populate(A); - B = new Box2[size][size]; - populate(B); - } - - private void populate(Box2[][] m) { - int size = m.length; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - m[i][j] = new Box2(ThreadLocalRandom.current().nextInt(), ThreadLocalRandom.current().nextInt()); - } - } - - } - - @Benchmark - public Box2[][] multIJK() { - return multBoxedIJK(A, B); - } - - @Benchmark - public Box2[][] multIKJ() { - return multBoxedIKJ(A, B); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/matrix/Primitive.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.matrix; - - -import oracle.micro.valhalla.MatrixBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -import java.util.concurrent.ThreadLocalRandom; - -public class Primitive extends MatrixBase { - - public static int[][] multBaselineIJK(int[][] A, int[][] B) { - int size = A.length; - int[][] R = new int[size][size * 2]; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - int s_re = 0; - int s_im = 0; - for (int k = 0; k < size; k++) { - int are = A[i][k * 2 + 0]; - int aim = A[i][k * 2 + 1]; - int bre = B[k][j * 2 + 0]; - int bim = B[k][j * 2 + 1]; - s_re += are * bre - aim * bim; - s_im += are * bim + bre * aim; - } - R[i][j * 2 + 0] = s_re; - R[i][j * 2 + 1] = s_im; - } - } - return R; - } - - public static int[][] multBaselineIKJ(int[][] A, int[][] B) { - int size = A.length; - int[][] R = new int[size][size * 2]; - for (int i = 0; i < size; i++) { - for (int k = 0; k < size; k++) { - int are = A[i][k * 2 + 0]; - int aim = A[i][k * 2 + 1]; - for (int j = 0; j < size; j++) { - int bre = B[k][j * 2 + 0]; - int bim = B[k][j * 2 + 1]; - R[i][j * 2 + 0] += are * bre - aim * bim; - R[i][j * 2 + 1] += are * bim + bre * aim; - } - } - } - return R; - } - - int[][] A; - int[][] B; - - @Setup - public void setup() { - A = new int[size][size*2]; - populate(A); - B = new int[size][size*2]; - populate(B); - } - - private void populate(int[][] m) { - int size = m.length; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - m[i][j*2+0] = ThreadLocalRandom.current().nextInt(); - m[i][j*2+1] = ThreadLocalRandom.current().nextInt(); - } - } - - } - - @Benchmark - public int[][] multIJK() { - return multBaselineIJK(A, B); - } - - @Benchmark - public int[][] multIKJ() { - return multBaselineIKJ(A, B); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/search/Search1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.search; - -import oracle.micro.valhalla.SearchBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -public class Search1 extends SearchBase { - - @State(Scope.Thread) - public static class StatePrimitive { - int[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new int[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = i; - } - } - } - - private static int binarySearch(int[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid]; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - @Benchmark - @OperationsPerInvocation(OPS) - public void primitive(StatePrimitive st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - Box1[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new Box1[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = new Box1(i); - } - } - } - - private static int binarySearch(Box1[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid].f0; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - - @Benchmark - @OperationsPerInvocation(OPS) - public void boxed(StateBoxed st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/search/Search2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.search; - -import oracle.micro.valhalla.SearchBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -public class Search2 extends SearchBase { - - @State(Scope.Thread) - public static class StatePrimitive { - int[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new int[size*2]; - for (int i = 0; i < arr.length; i+=2) { - arr[i] = i; - arr[i+1] = i; - } - } - } - - private static int binarySearch(int[] a, int key) { - int low = 0; - int high = a.length/2 - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid*2]; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - @Benchmark - @OperationsPerInvocation(OPS) - public void primitive(StatePrimitive st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - Box2[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new Box2[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = new Box2(i, i); - } - } - } - - private static int binarySearch(Box2[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid].f0; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - @Benchmark - @OperationsPerInvocation(OPS) - public void boxed(StateBoxed st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/search/Search8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.search; - -import oracle.micro.valhalla.SearchBase; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -public class Search8 extends SearchBase { - - @State(Scope.Thread) - public static class StatePrimitive { - int[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new int[size*8]; - for (int i = 0; i < arr.length; i+=8) { - arr[i] = i; - arr[i+1] = i; - arr[i+2] = i; - arr[i+3] = i; - arr[i+4] = i; - arr[i+5] = i; - arr[i+6] = i; - arr[i+7] = i; - } - } - } - - private static int binarySearch(int[] a, int key) { - int low = 0; - int high = a.length/8 - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid*8]; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - @Benchmark - @OperationsPerInvocation(OPS) - public void primitive(StatePrimitive st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - @State(Scope.Thread) - public static class StateBoxed { - Box8[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new Box8[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = new Box8(i, i, i, i, i, i, i, i); - } - } - } - - private static int binarySearch(Box8[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid].f0; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - - @Benchmark - @OperationsPerInvocation(OPS) - public void boxed(StateBoxed st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Primitive1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.sort; - -import oracle.micro.valhalla.SortBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Setup; - -import java.util.concurrent.ThreadLocalRandom; - -public class Primitive1 extends SortBase { - - public int[] makeRandomArray() { - int[] arr = new int[size]; - for (int i = 0; i < size; i++) { - arr[i] = ThreadLocalRandom.current().nextInt(); - } - return arr; - } - - - @Benchmark - public int[] quicksort() { - int[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public int[] mergeSort() { - int[] toSort = makeRandomArray(); - int[] aux = new int[toSort.length]; - System.arraycopy(toSort, 0, aux, 0 , toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - private static int compare(int a, int b) { - return Integer.compare(a, b); - } - - - //##########3 dual pivot quick sort############################## - - private static void sort1(int x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - int v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a); - vecswap(x, off, b - s, s); - s = Math.min(d - c, n - d - 1); - vecswap(x, b, n - s, s); - - // Recursively sort non-partition-elements - if ((s = b - a) > 1) - sort1(x, off, s); - if ((s = d - c) > 1) - sort1(x, n - s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(int x[], int a, int b) { - int t = x[a]; - x[a] = x[b]; - x[b] = t; - } - - /** - * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. - */ - private static void vecswap(int x[], int a, int b, int n) { - for (int i = 0; i < n; i++, a++, b++) - swap(x, a, b); - } - - /** - * Returns the index of the median of the three indexed integers. - */ - private static int med3(int x[], int a, int b, int c) { - return (compare(x[a], x[b]) < 0 ? - (compare(x[b], x[c]) < 0 ? b : compare(x[a], x[c]) < 0 ? c : a) : - (compare(x[b], x[c]) > 0 ? b : compare(x[a], x[c]) > 0 ? c : a)); - } - - - //########## merge sort############################## - - - private static void mergeSort(int[] src, - int[] dest, - int low, int high, int off) { - int length = high - low; - - // Insertion sort on smallest arrays - if (length < 7) { - for (int i = low; i < high; i++) - for (int j = i; j > low && compare(dest[j - 1], dest[j]) > 0; j--) - swap(dest, j, j - 1); - return; - } - - // Recursively sort halves of dest into src - int destLow = low; - int destHigh = high; - low += off; - high += off; - int mid = (low + high) >>> 1; - mergeSort(dest, src, low, mid, -off); - mergeSort(dest, src, mid, high, -off); - - // If list is already sorted, just copy from src to dest. This is an - // optimization that results in faster sorts for nearly ordered lists. - if (compare(src[mid - 1], src[mid]) <= 0) { - System.arraycopy(src, low, dest, destLow, length); - return; - } - - // Merge sorted halves (now in src) into dest - for (int i = destLow, p = low, q = mid; i < destHigh; i++) { - if (q >= high || p < mid && compare(src[p], src[q]) <= 0) - dest[i] = src[p++]; - else - dest[i] = src[q++]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Sort1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.sort; - -import oracle.micro.valhalla.SortBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Setup; - -import java.util.concurrent.ThreadLocalRandom; - -public class Sort1 extends SortBase { - - - public Box1[] makeRandomArray() { - Box1[] arr = new Box1[size]; - for (int i = 0; i < size; i++) { - arr[i] = new Box1 (ThreadLocalRandom.current().nextInt()); - } - return arr; - } - - @Benchmark - public Box1[] quicksort() { - Box1[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public Box1[] mergeSort() { - Box1[] toSort = makeRandomArray(); - Box1[] aux = new Box1[toSort.length]; - System.arraycopy(toSort, 0, aux, 0 , toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - - private static int compare(Box1 a, Box1 b) { - return Integer.compare(a.f0, b.f0); - - } - - - //##########3 dual pivot quick sort############################## - - private static void sort1(Box1 x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - Box1 v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a); - vecswap(x, off, b - s, s); - s = Math.min(d - c, n - d - 1); - vecswap(x, b, n - s, s); - - // Recursively sort non-partition-elements - if ((s = b - a) > 1) - sort1(x, off, s); - if ((s = d - c) > 1) - sort1(x, n - s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(Box1 x[], int a, int b) { - Box1 t = x[a]; - x[a] = x[b]; - x[b] = t; - } - - /** - * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. - */ - private static void vecswap(Box1 x[], int a, int b, int n) { - for (int i = 0; i < n; i++, a++, b++) - swap(x, a, b); - } - - /** - * Returns the index of the median of the three indexed integers. - */ - private static int med3(Box1 x[], int a, int b, int c) { - return (compare(x[a], x[b]) < 0 ? - (compare(x[b], x[c]) < 0 ? b : compare(x[a], x[c]) < 0 ? c : a) : - (compare(x[b], x[c]) > 0 ? b : compare(x[a], x[c]) > 0 ? c : a)); - } - - - //########## merge sort############################## - - - private static void mergeSort(Box1[] src, - Box1[] dest, - int low, int high, int off) { - int length = high - low; - - // Insertion sort on smallest arrays - if (length < 7) { - for (int i = low; i < high; i++) - for (int j = i; j > low && compare(dest[j - 1], dest[j]) > 0; j--) - swap(dest, j, j - 1); - return; - } - - // Recursively sort halves of dest into src - int destLow = low; - int destHigh = high; - low += off; - high += off; - int mid = (low + high) >>> 1; - mergeSort(dest, src, low, mid, -off); - mergeSort(dest, src, mid, high, -off); - - // If list is already sorted, just copy from src to dest. This is an - // optimization that results in faster sorts for nearly ordered lists. - if (compare(src[mid - 1], src[mid]) <= 0) { - System.arraycopy(src, low, dest, destLow, length); - return; - } - - // Merge sorted halves (now in src) into dest - for (int i = destLow, p = low, q = mid; i < destHigh; i++) { - if (q >= high || p < mid && compare(src[p], src[q]) <= 0) - dest[i] = src[p++]; - else - dest[i] = src[q++]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Sort2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.sort; - -import oracle.micro.valhalla.SortBase; -import oracle.micro.valhalla.baseline.types.Box2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Setup; - -import java.util.concurrent.ThreadLocalRandom; - -public class Sort2 extends SortBase { - - - public Box2[] makeRandomArray() { - Box2[] arr = new Box2[size]; - for (int i = 0; i < size; i++) { - arr[i] = new Box2 (ThreadLocalRandom.current().nextInt(),ThreadLocalRandom.current().nextInt()); - } - return arr; - } - - - @Benchmark - public Box2[] quicksort() { - Box2[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public Box2[] mergeSort() { - Box2[] toSort = makeRandomArray(); - Box2[] aux = new Box2[toSort.length]; - System.arraycopy(toSort, 0, aux, 0 , toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - private static int compare(Box2 a, Box2 b) { - int c0 = Integer.compare(a.f0, b.f0); - return c0!=0 ? c0: Integer.compare(a.f0, b.f0); - - } - - //##########3 dual pivot quick sort############################## - - private static void sort1(Box2 x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - Box2 v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a); - vecswap(x, off, b - s, s); - s = Math.min(d - c, n - d - 1); - vecswap(x, b, n - s, s); - - // Recursively sort non-partition-elements - if ((s = b - a) > 1) - sort1(x, off, s); - if ((s = d - c) > 1) - sort1(x, n - s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(Box2 x[], int a, int b) { - Box2 t = x[a]; - x[a] = x[b]; - x[b] = t; - } - - /** - * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. - */ - private static void vecswap(Box2 x[], int a, int b, int n) { - for (int i = 0; i < n; i++, a++, b++) - swap(x, a, b); - } - - /** - * Returns the index of the median of the three indexed integers. - */ - private static int med3(Box2 x[], int a, int b, int c) { - return (compare(x[a], x[b]) < 0 ? - (compare(x[b], x[c]) < 0 ? b : compare(x[a], x[c]) < 0 ? c : a) : - (compare(x[b], x[c]) > 0 ? b : compare(x[a], x[c]) > 0 ? c : a)); - } - - - //########## merge sort############################## - - - private static void mergeSort(Box2[] src, - Box2[] dest, - int low, int high, int off) { - int length = high - low; - - // Insertion sort on smallest arrays - if (length < 7) { - for (int i = low; i < high; i++) - for (int j = i; j > low && compare(dest[j - 1], dest[j]) > 0; j--) - swap(dest, j, j - 1); - return; - } - - // Recursively sort halves of dest into src - int destLow = low; - int destHigh = high; - low += off; - high += off; - int mid = (low + high) >>> 1; - mergeSort(dest, src, low, mid, -off); - mergeSort(dest, src, mid, high, -off); - - // If list is already sorted, just copy from src to dest. This is an - // optimization that results in faster sorts for nearly ordered lists. - if (compare(src[mid - 1], src[mid]) <= 0) { - System.arraycopy(src, low, dest, destLow, length); - return; - } - - // Merge sorted halves (now in src) into dest - for (int i = destLow, p = low, q = mid; i < destHigh; i++) { - if (q >= high || p < mid && compare(src[p], src[q]) <= 0) - dest[i] = src[p++]; - else - dest[i] = src[q++]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/sort/Sort8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.sort; - -import oracle.micro.valhalla.SortBase; -import oracle.micro.valhalla.baseline.types.Box8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Setup; - -import java.util.concurrent.ThreadLocalRandom; - -public class Sort8 extends SortBase { - - - - public Box8[] makeRandomArray() { - Box8[] arr = new Box8[size]; - for (int i = 0; i < size; i++) { - arr[i] = new Box8( - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt() - ); - } - return arr; - } - - @Benchmark - public Box8[] quicksort() { - Box8[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public Box8[] mergeSort() { - Box8[] toSort = makeRandomArray(); - Box8[] aux = new Box8[toSort.length]; - System.arraycopy(toSort, 0, aux, 0 , toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - - private static int compare(Box8 a, Box8 b) { - int c0 = Integer.compare(a.f0, b.f0); - if (c0 != 0) { - return c0; - } else { - int c1 = Integer.compare(a.f1, b.f1); - if (c1 != 0) { - return c1; - } else { - int c2 = Integer.compare(a.f2, b.f2); - if (c2 != 0) { - return c2; - } else { - int c3 = Integer.compare(a.f3, b.f3); - if (c3 != 0) { - return c3; - } else { - int c4 = Integer.compare(a.f4, b.f4); - if (c4 != 0) { - return c4; - } else { - int c5 = Integer.compare(a.f5, b.f5); - if (c5 != 0) { - return c5; - } else { - int c6 = Integer.compare(a.f6, b.f6); - if (c6 != 0) { - return c6; - } else { - return Integer.compare(a.f7, b.f7); - } - } - } - } - } - } - } - } - - - - //##########3 dual pivot quick sort############################## - - private static void sort1(Box8 x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - Box8 v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a); - vecswap(x, off, b - s, s); - s = Math.min(d - c, n - d - 1); - vecswap(x, b, n - s, s); - - // Recursively sort non-partition-elements - if ((s = b - a) > 1) - sort1(x, off, s); - if ((s = d - c) > 1) - sort1(x, n - s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(Box8 x[], int a, int b) { - Box8 t = x[a]; - x[a] = x[b]; - x[b] = t; - } - - /** - * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. - */ - private static void vecswap(Box8 x[], int a, int b, int n) { - for (int i = 0; i < n; i++, a++, b++) - swap(x, a, b); - } - - /** - * Returns the index of the median of the three indexed integers. - */ - private static int med3(Box8 x[], int a, int b, int c) { - return (compare(x[a], x[b]) < 0 ? - (compare(x[b], x[c]) < 0 ? b : compare(x[a], x[c]) < 0 ? c : a) : - (compare(x[b], x[c]) > 0 ? b : compare(x[a], x[c]) > 0 ? c : a)); - } - - - //########## merge sort############################## - - - private static void mergeSort(Box8[] src, - Box8[] dest, - int low, int high, int off) { - int length = high - low; - - // Insertion sort on smallest arrays - if (length < 7) { - for (int i = low; i < high; i++) - for (int j = i; j > low && compare(dest[j - 1], dest[j]) > 0; j--) - swap(dest, j, j - 1); - return; - } - - // Recursively sort halves of dest into src - int destLow = low; - int destHigh = high; - low += off; - high += off; - int mid = (low + high) >>> 1; - mergeSort(dest, src, low, mid, -off); - mergeSort(dest, src, mid, high, -off); - - // If list is already sorted, just copy from src to dest. This is an - // optimization that results in faster sorts for nearly ordered lists. - if (compare(src[mid - 1], src[mid]) <= 0) { - System.arraycopy(src, low, dest, destLow, length); - return; - } - - // Merge sorted halves (now in src) into dest - for (int i = destLow, p = low, q = mid; i < destHigh; i++) { - if (q >= high || p < mid && compare(src[p], src[q]) <= 0) - dest[i] = src[p++]; - else - dest[i] = src[q++]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/traversal/Boxed.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.traversal; - - -import oracle.micro.valhalla.TraversalBase; -import oracle.micro.valhalla.baseline.types.Box1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.OperationsPerInvocation; -import org.openjdk.jmh.annotations.Setup; - -public abstract class Boxed extends TraversalBase { - - Box1[] values; - - public void setup(int[] a) { - values = new Box1[a.length]; - for (int i = 0; i < a.length; i++) { - values[i] = new Box1(a[i]); - } - } - - @CompilerControl(CompilerControl.Mode.INLINE) - public static int walk(Box1[] a) { - int steps = 1; - for(int i = a[0].f0; i!=0; i=a[i].f0) steps++; - return steps; - } - - - public static class W0001 extends Boxed { - - private static final int SIZE = 1*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0004 extends Boxed { - - private static final int SIZE = 4*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0016 extends Boxed { - - private static final int SIZE = 16*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0032 extends Boxed { - - private static final int SIZE = 32*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0128 extends Boxed { - - private static final int SIZE = 128*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0256 extends Boxed { - - private static final int SIZE = 256*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W1024 extends Boxed { - - private static final int SIZE = 1024*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/traversal/Primitive.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.traversal; - - -import oracle.micro.valhalla.TraversalBase; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.OperationsPerInvocation; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Arrays; - -public abstract class Primitive extends TraversalBase { - - int[] values; - - public void setup(int[] a) { - values = Arrays.copyOf(a, a.length); - } - - @CompilerControl(CompilerControl.Mode.INLINE) - public static int walk(int[] a) { - int steps = 1; - for(int i = a[0]; i!=0; i=a[i]) steps++; - return steps; - } - - public static class W0001 extends Primitive { - - private static final int SIZE = 1*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0004 extends Primitive { - - private static final int SIZE = 4*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0016 extends Primitive { - - private static final int SIZE = 16*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0032 extends Primitive { - - private static final int SIZE = 32*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0128 extends Primitive { - - private static final int SIZE = 128*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W0256 extends Primitive { - - private static final int SIZE = 256*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - public static class W1024 extends Primitive { - - private static final int SIZE = 1024*K; - - @Setup - public void setup() { - setup(prepare(SIZE, shuffle)); - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public int walk() { - return walk(values); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/types/Box1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.types; - -import oracle.micro.valhalla.types.PNumber; - -public final class Box1 implements PNumber { - - public final int f0; - - public Box1(int f0) { - this.f0 = f0; - } - - public int f0() { - return f0; - } - - public Box1 add(Box1 v) { - return new Box1(this.f0 + v.f0); - } - - // Used to provide usages of both fields in bechmarks - public int totalsum() { - return f0 ; - } - - @Override - public int hashCode() { - return f0; - } - - @Override - public Box1 inc() { - return new Box1(f0 + 1); - } - - @Override - public Box1 dec() { - return new Box1(f0 - 1); - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/types/Box2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.types; - -import oracle.micro.valhalla.types.PNumber; - -public final class Box2 implements PNumber { - - public final int f0; - public final int f1; - - public Box2(int f0, int f1) { - this.f0 = f0; - this.f1 = f1; - } - - public int f0() { - return f0; - } - - public int f1() { - return f1; - } - - public int re() { - return f0; - } - - public int im() { - return f1; - } - - public Box2 add(Box2 v) { - return new Box2(this.f0 + v.f0, this.f1 + v.f1); - } - - public Box2 mul(Box2 v) { - int tre = this.f0; - int tim = this.f1; - int vre = v.f0; - int vim = v.f1; - return new Box2(tre * vre - tim * vim, tre * vim + vre * tim); - } - - // Used to provide usages of both fields in bechmarks - public int totalsum() { - return f0 + f1; - } - - @Override - public int hashCode() { - return f0 + f1; - } - - @Override - public Box2 inc() { - return new Box2(f1, f0 + 1); - } - - @Override - public Box2 dec() { - return new Box2(f1, f0 - 1); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/types/Box8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.types; - -import oracle.micro.valhalla.types.PNumber; - -public final class Box8 implements PNumber { - - public final int f0; - public final int f1; - public final int f2; - public final int f3; - public final int f4; - public final int f5; - public final int f6; - public final int f7; - - public Box8(int f0, int f1, int f2, int f3, int f4, int f5, int f6, int f7) { - this.f0 = f0; - this.f1 = f1; - this.f2 = f2; - this.f3 = f3; - this.f4 = f4; - this.f5 = f5; - this.f6 = f6; - this.f7 = f7; - } - - public int f0() { return f0; } - public int f1() { return f1; } - public int f2() { return f2; } - public int f3() { return f3; } - public int f4() { return f4; } - public int f5() { return f5; } - public int f6() { return f6; } - public int f7() { return f7; } - - public Box8 add(Box8 v) { - return new Box8(this.f0 + v.f0, this.f1 + v.f1, this.f2 + v.f2, this.f3 + v.f3, this.f4 + v.f4, this.f5 + v.f5, this.f6 + v.f6, this.f7 + v.f7); - } - - // Used to provide usages of all fields in bechmarks - public int totalsum() { - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - @Override - public int hashCode() { - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - @Override - public Box8 inc() { - return new Box8(f1, f2, f3, f4, f5, f6, f7, f0 + 1); - } - - @Override - public Box8 dec() { - return new Box8(f1, f2, f3, f4, f5, f6, f7, f0 - 1); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/baseline/util/HashMap.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,389 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package oracle.micro.valhalla.baseline.util; - -import oracle.micro.valhalla.util.AbstractMap; -import oracle.micro.valhalla.util.Cursor; - -import java.util.*; - -/* - * Baseline (ordinary) HashMap with Iterator and Cursor - */ -public class HashMap<K, V> extends AbstractMap<K, V> { - - Entry<K, V>[] table; - - public HashMap(int initialCapacity) { - super(); - if (initialCapacity < 0) - throw new IllegalArgumentException("Illegal initial capacity: " + - initialCapacity); - if (initialCapacity > MAXIMUM_CAPACITY) - initialCapacity = MAXIMUM_CAPACITY; - - // Find a power of 2 >= initialCapacity - int capacity = tableSizeFor(initialCapacity); - threshold = (int) (capacity * LOAD_FACTOR); - @SuppressWarnings({"rawtypes", "unchecked"}) - Entry<K, V>[] newTab = (Entry<K, V>[]) new Entry[capacity]; - table = newTab; - } - - public HashMap() { - this(DEFAULT_INITIAL_CAPACITY); - } - - static class Entry<K, V> implements Map.Entry<K, V> { - final K key; - V value; - Entry<K, V> next; - final int hash; - - Entry(int h, K k, V v, Entry<K, V> n) { - value = v; - next = n; - key = k; - hash = h; - } - - public final K getKey() { - return key; - } - - public final V getValue() { - return value; - } - - public final V setValue(V newValue) { - throw new UnsupportedOperationException(); - } - - public final boolean equals(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry) o; - return Objects.equals(getKey(), e.getKey()) && Objects.equals(getValue(), e.getValue()); - } - - public final int hashCode() { - return Objects.hashCode(key) ^ Objects.hashCode(value); - } - - public final String toString() { - return getKey() + "=" + getValue(); - } - - } - - //############################################ - @Override - public V get(K key) { - int hash = hash(key); - for (Entry<K, V> e = table[indexFor(hash, table.length)]; - e != null; - e = e.next) { - if (e.hash == hash && Objects.equals(key, e.key)) - return e.value; - } - return null; - } - - @Override - public V put(K key, V value) { - int hash = hash(key); - int i = indexFor(hash, table.length); - for (Entry<K,V> e = table[i]; e != null; e = e.next) { - if (e.hash == hash && Objects.equals(key, e.key)) { - V oldValue = e.value; - e.value = value; - return oldValue; - } - } - - modCount++; - Entry<K,V> e = table[i]; - table[i] = new Entry<>(hash, key, value, e); - if (size++ >= threshold) - resize(2 * table.length); - return null; - } - - void resize(int newCapacity) { - Entry<K,V>[] oldTable = table; - int oldCapacity = oldTable.length; - if (oldCapacity == MAXIMUM_CAPACITY) { - threshold = Integer.MAX_VALUE; - return; - } - @SuppressWarnings({"rawtypes","unchecked"}) - Entry<K,V>[] newTable = (Entry<K,V>[])new Entry[newCapacity]; - transfer(newTable); - table = newTable; - threshold = (int)(newCapacity * LOAD_FACTOR); - } - - /** - * Transfers all entries from current table to newTable. - */ - void transfer(Entry<K,V>[] newTable) { - Entry<K,V>[] src = table; - int newCapacity = newTable.length; - for (int j = 0; j < src.length; j++) { - Entry<K,V> e = src[j]; - if (e != null) { - src[j] = null; - do { - Entry<K,V> next = e.next; - int i = indexFor(e.hash, newCapacity); - e.next = newTable[i]; - newTable[i] = e; - e = next; - } while (e != null); - } - } - } - - @Override - public V remove(K key) { - int hash = hash(key); - int i = indexFor(hash, table.length); - Entry<K,V> prev = null; - Entry<K,V> e = table[i]; - - while (e != null) { - Entry<K,V> next = e.next; - if (e.hash == hash && Objects.equals(key, e.key)) { - modCount++; - size--; - if (prev == null) - table[i] = next; - else - prev.next = next; - return e.value; - } - prev = e; - e = next; - } - return null; - } - - private static int getFilledSlot(Entry[] t, int from) { - while (from < t.length && t[from] == null) { - from++; - } - return from; - } - - private class HashIterator { - Entry<K,V> next; // next entry to return - final int expectedModCount; // For fast-fail - int index; // current slot - - HashIterator() { - expectedModCount = modCount; - if (size > 0) { // advance to first entry - Entry<K,V>[] t = table; - int from = getFilledSlot(t, 0); - index = from; - next = (from < t.length) ? t[from] : null; - } - } - - public boolean hasNext() { - return next != null; - } - - public Entry<K,V> nextEntry() { - if (modCount != expectedModCount) - throw new ConcurrentModificationException(); - Entry<K,V> e = next; - if (e == null) - throw new NoSuchElementException(); - - if ((next = e.next) == null) { - Entry<K,V>[] t = table; - int from = getFilledSlot(t, index + 1); - index = from; - next = (from < t.length) ? t[from] : null; - } - return e; - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - } - - private class EntryIterator extends HashIterator implements Iterator<Map.Entry<K, V>> { - - public Map.Entry<K, V> next() { - return nextEntry(); - } - } - - private class KeyIterator extends HashIterator implements Iterator<K> { - - public K next() { - return nextEntry().key; - } - } - - private class ValueIterator extends HashIterator implements Iterator<V> { - - public V next() { - return nextEntry().value; - } - } - - @Override - public Iterator<K> keyIterator() { - return new KeyIterator(); - } - - @Override - public Iterator<V> valueIterator() { - return new ValueIterator(); - } - - @Override - public Iterator<Map.Entry<K, V>> entryIterator() { - return new EntryIterator(); - } - - @Override - public Cursor<Map.Entry<K, V>> entryCursor() { - return EntryCursor.of(this); - } - - @Override - public Cursor<K> keyCursor() { - return KeyCursor.of(this); - } - - public static class EntryCursor<K,V> implements Cursor<Map.Entry<K,V>> { - private final HashMap<K,V> map; - private final int expectedModCount; - private final int index; - private final Entry<K,V> current; - - public static <K,V> EntryCursor<K,V> of(HashMap<K,V> map) { - if (map.size > 0) { // advance to first entry - Entry<K, V>[] t = map.table; - int from = getFilledSlot(t, 0); - return new EntryCursor<K, V>(map, map.modCount, from, t[from]); - } else { - return new EntryCursor<K, V>(map, map.modCount, 0, null); - } - } - - EntryCursor(HashMap<K, V> map, int expectedModCount, int index, Entry<K, V> current) { - this.map = map; - this.expectedModCount = expectedModCount; - this.index = index; - this.current = current; - } - - public boolean hasElement() { - return current != null; - } - - public Map.Entry<K, V> get() { - return current; - } - - public Cursor<Map.Entry<K, V>> next() { - return nextEntry(); - } - - public EntryCursor<K, V> nextEntry() { - if(current == null) - throw new NoSuchElementException(); - if (map.modCount != expectedModCount) - throw new ConcurrentModificationException(); - Entry<K,V> e = current; - if (e.next == null) { - Entry<K, V>[] t = map.table; - int from = getFilledSlot(t, index + 1); - return new EntryCursor<K, V>(map, expectedModCount, from, (from < t.length) ? t[from] : null); - } else { - return new EntryCursor<K, V>(map, expectedModCount, index, e.next); - - } - } - } - - public static class KeyCursor<K,V> implements Cursor<K> { - private final HashMap<K,V> map; - private final int expectedModCount; - private final int index; - private final Entry<K,V> current; - - public static <K,V> KeyCursor<K,V> of(HashMap<K,V> map) { - if (map.size > 0) { // advance to first entry - Entry<K, V>[] t = map.table; - int from = getFilledSlot(t, 0); - return new KeyCursor<K, V>(map, map.modCount, from, t[from]); - } else { - return new KeyCursor<K, V>(map, map.modCount, 0, null); - } - } - - KeyCursor(HashMap<K, V> map, int expectedModCount, int index, Entry<K, V> current) { - this.map = map; - this.expectedModCount = expectedModCount; - this.index = index; - this.current = current; - } - - public boolean hasElement() { - return current != null; - } - - public K get() { - return current.key; - } - - public Cursor<K> next() { - return nextEntry(); - } - - public KeyCursor<K, V> nextEntry() { - if(current == null) - throw new NoSuchElementException(); - if (map.modCount != expectedModCount) - throw new ConcurrentModificationException(); - Entry<K,V> e = current; - if (e.next == null) { - Entry<K, V>[] t = map.table; - int from = getFilledSlot(t, index + 1); - return new KeyCursor<K, V>(map, expectedModCount, from, (from < t.length) ? t[from] : null); - } else { - return new KeyCursor<K, V>(map, expectedModCount, index, e.next); - - } - } - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/Ackermann1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -package oracle.micro.valhalla.lworld.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.lworld.types.Value1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Ackermann1 extends AckermannBase { - - public static final Value1 V1_ONE = Value1.of(1); - public static final Value1 V1_X1 = V1_ONE; - public static final Value1 V1_Y1 = Value1.of(1748); - public static final Value1 V1_X2 = Value1.of(2); - public static final Value1 V1_Y2 = Value1.of(1897); - public static final Value1 V1_X3 = Value1.of(3); - public static final Value1 V1_Y3 = Value1.of(8); - - - private static Value1 ack_value(Value1 x, Value1 y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_value(x.dec(), V1_ONE) : - ack_value(x.dec(), ack_value(x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int value() { - return ack_value(V1_X1, V1_Y1).totalsum() + ack_value(V1_X2, V1_Y2).totalsum() + ack_value(V1_X3, V1_Y3).totalsum(); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/Ackermann2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -package oracle.micro.valhalla.lworld.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Ackermann2 extends AckermannBase { - - public static final Value2 V2_ONE = Value2.of(0, 1); - public static final Value2 V2_X1 = V2_ONE; - public static final Value2 V2_Y1 = Value2.of(0, 1748); - public static final Value2 V2_X2 = Value2.of(0, 2); - public static final Value2 V2_Y2 = Value2.of(0, 1897); - public static final Value2 V2_X3 = Value2.of(0, 3); - public static final Value2 V2_Y3 = Value2.of(0, 8); - - - private static Value2 ack_value(Value2 x, Value2 y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_value(x.dec(), V2_ONE) : - ack_value(x.dec(), ack_value(x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int value() { - return ack_value(V2_X1, V2_Y1).totalsum() + ack_value(V2_X2, V2_Y2).totalsum() + ack_value(V2_X3, V2_Y3).totalsum(); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/Ackermann8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -package oracle.micro.valhalla.lworld.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.lworld.types.Value8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Ackermann8 extends AckermannBase { - - public static final Value8 V8_ONE = Value8.of(0, 0, 0, 0, 0, 0, 0, 1); - public static final Value8 V8_X1 = V8_ONE; - public static final Value8 V8_Y1 = Value8.of(0, 0, 0, 0, 0, 0, 0, 1748); - public static final Value8 V8_X2 = Value8.of(0, 0, 0, 0, 0, 0, 0, 2); - public static final Value8 V8_Y2 = Value8.of(0, 0, 0, 0, 0, 0, 0, 1897); - public static final Value8 V8_X3 = Value8.of(0, 0, 0, 0, 0, 0, 0, 3); - public static final Value8 V8_Y3 = Value8.of(0, 0, 0, 0, 0, 0, 0, 8); - - - private static Value8 ack_value(Value8 x, Value8 y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_value(x.dec(), V8_ONE) : - ack_value(x.dec(), ack_value(x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int value() { - return ack_value(V8_X1, V8_Y1).totalsum() + ack_value(V8_X2, V8_Y2).totalsum() + ack_value(V8_X3, V8_Y3).totalsum(); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/ackermann/AckermannMix.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -package oracle.micro.valhalla.lworld.ackermann; - -import oracle.micro.valhalla.AckermannBase; -import oracle.micro.valhalla.types.PNumber; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class AckermannMix extends AckermannBase { - - private static PNumber ack_interface(PNumber one, PNumber x, PNumber y) { - return x.totalsum() == 0 ? - y.inc() : - (y.totalsum() == 0 ? - ack_interface(one, x.dec(), one) : - ack_interface(one, x.dec(), ack_interface(one , x, y.dec()))); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interface1() { - return ack_interface(Ackermann1.V1_ONE, Ackermann1.V1_X1, Ackermann1.V1_Y1).totalsum() + - ack_interface(Ackermann1.V1_ONE, Ackermann1.V1_X2, Ackermann1.V1_Y2).totalsum() + - ack_interface(Ackermann1.V1_ONE, Ackermann1.V1_X3, Ackermann1.V1_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interface2() { - return ack_interface(Ackermann2.V2_ONE, Ackermann2.V2_X1, Ackermann2.V2_Y1).totalsum() + - ack_interface(Ackermann2.V2_ONE, Ackermann2.V2_X2, Ackermann2.V2_Y2).totalsum() + - ack_interface(Ackermann2.V2_ONE, Ackermann2.V2_X3, Ackermann2.V2_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interface8() { - return ack_interface(Ackermann8.V8_ONE, Ackermann8.V8_X1, Ackermann8.V8_Y1).totalsum() + - ack_interface(Ackermann8.V8_ONE, Ackermann8.V8_X2, Ackermann8.V8_Y2).totalsum() + - ack_interface(Ackermann8.V8_ONE, Ackermann8.V8_X3, Ackermann8.V8_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interfaceMixDepth() { - return ack_interface(Ackermann1.V1_ONE, Ackermann1.V1_X1, Ackermann1.V1_Y1).totalsum() + - ack_interface(Ackermann2.V2_ONE, Ackermann2.V2_X2, Ackermann2.V2_Y2).totalsum() + - ack_interface(Ackermann8.V8_ONE, Ackermann8.V8_X3, Ackermann8.V8_Y3).totalsum(); - } - - @Benchmark - @OperationsPerInvocation(OPI) - public int interfaceMixWidth() { - return ack_interface(Ackermann1.V1_ONE, Ackermann2.V2_X1, Ackermann8.V8_Y1).totalsum() + - ack_interface(Ackermann2.V2_ONE, Ackermann8.V8_X2, Ackermann1.V1_Y2).totalsum() + - ack_interface(Ackermann8.V8_ONE, Ackermann1.V1_X3, Ackermann2.V2_Y3).totalsum(); - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraycopy/Arraycopy1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -package oracle.micro.valhalla.lworld.arraycopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.lworld.types.Value1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraycopy1 extends ArraycopyBase { - - - @State(Scope.Thread) - public static class StateValue { - Value1[] src; - Value1[] dst; - - @Setup - public void setup() { - src = new Value1[size]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - dst = new Value1[size]; - } - } - - @Benchmark - public Object loopValue(StateValue st) { - Value1[] src = st.src; - Value1[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValue(StateValue st) { - System.arraycopy(st.src, 0, st.dst, 0, size); - return st.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraycopy/Arraycopy2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -package oracle.micro.valhalla.lworld.arraycopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraycopy2 extends ArraycopyBase { - - - @State(Scope.Thread) - public static class StateValue { - Value2[] src; - Value2[] dst; - - @Setup - public void setup() { - src = new Value2[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = Value2.of(k, k + 1); - } - dst = new Value2[size]; - } - } - - - @Benchmark - public Object loopValue(StateValue st) { - Value2[] src = st.src; - Value2[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValue(StateValue st) { - System.arraycopy(st.src, 0, st.dst, 0, size); - return st.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraycopy/Arraycopy8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -package oracle.micro.valhalla.lworld.arraycopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.lworld.types.Value8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Arraycopy8 extends ArraycopyBase { - - - @State(Scope.Thread) - public static class StateValue { - Value8[] src; - Value8[] dst; - - @Setup - public void setup() { - src = new Value8[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - dst = new Value8[size]; - } - } - - @Benchmark - public Object loopValue(StateValue st) { - Value8[] src = st.src; - Value8[] dst = st.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValue(StateValue st) { - Value8[] dst = st.dst; - System.arraycopy(st.src, 0, dst, 0, size); - return dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arrayfill/Arrayfill1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -package oracle.micro.valhalla.lworld.arrayfill; - -import oracle.micro.valhalla.ArrayfillBase; -import oracle.micro.valhalla.lworld.types.Value1; -import oracle.micro.valhalla.types.PNumber; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Arrayfill1 extends ArrayfillBase { - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object value() { - Value1[] values = new Value1[SIZE]; - for (int i = 0; i < values.length; i++) { - values[i] = Value1.of(i); - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object object() { - Object[] values = new Object[SIZE]; - for (int i = 0; i < values.length; i++) { - values[i] = Value1.of(i); - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object inter() { - PNumber[] values = new PNumber[SIZE]; - for (int i = 0; i < values.length; i++) { - values[i] = Value1.of(i); - } - return values; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arrayfill/Arrayfill2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -package oracle.micro.valhalla.lworld.arrayfill; - -import oracle.micro.valhalla.ArrayfillBase; -import oracle.micro.valhalla.lworld.types.Value2; -import oracle.micro.valhalla.types.PNumber; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Arrayfill2 extends ArrayfillBase { - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object value() { - Value2[] values = new Value2[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 2) { - values[i] = Value2.of(k, k + 1); - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object object() { - Object[] values = new Object[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 2) { - values[i] = Value2.of(k, k + 1); - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object inter() { - PNumber[] values = new PNumber[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 2) { - values[i] = Value2.of(k, k + 1); - } - return values; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arrayfill/Arrayfill8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -package oracle.micro.valhalla.lworld.arrayfill; - -import oracle.micro.valhalla.ArrayfillBase; -import oracle.micro.valhalla.lworld.types.Value8; -import oracle.micro.valhalla.types.PNumber; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.OperationsPerInvocation; - -public class Arrayfill8 extends ArrayfillBase { - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object value() { - Value8[] values = new Value8[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 8) { - values[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object objects() { - Object[] values = new Object[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 8) { - values[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - return values; - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object inter() { - PNumber[] values = new PNumber[SIZE]; - for (int i = 0, k = 0; i < values.length; i++, k += 8) { - values[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - return values; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraysum/Arraysum1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -package oracle.micro.valhalla.lworld.arraysum; - -import oracle.micro.valhalla.ArraysumBase; -import oracle.micro.valhalla.lworld.types.Value1; -import org.openjdk.jmh.annotations.*; - -public class Arraysum1 extends ArraysumBase { - - public static Value1[] setupValue(int size) { - Value1[] values = new Value1[size]; - for (int i = 0; i < values.length; i++) { - values[i] = Value1.of(i); - } - return values; - } - - public static int sumScalarized(Value1[] values ) { - int sum = 0; - for (int i = 0; i < values.length; i++) { - sum += values[i].f0; - } - return sum; - } - - public static int sum(Value1[] values) { - Value1 sum = Value1.of(0); - for (int i = 0; i < values.length; i++) { - sum = sum.add(values[i]); - } - return sum.totalsum(); - } - - Value1[] values; - - @Setup - public void setup() { - values = setupValue(size); - } - - @Benchmark - public int valueScalarized() { - return sumScalarized(values); - } - - @Benchmark - public int value() { - return sum(values); - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraysum/Arraysum2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -package oracle.micro.valhalla.lworld.arraysum; - -import oracle.micro.valhalla.ArraysumBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.*; - -public class Arraysum2 extends ArraysumBase { - - public static Value2[] setupValue(int size) { - Value2[] values = new Value2[size]; - for (int i = 0, k = 0; i < values.length; i++, k += 2) { - values[i] = Value2.of(k, k + 1); - } - return values; - } - - public static int sumScalarized(Value2[] values ) { - int f0 = 0; - int f1 = 0; - for (int i = 0; i < values.length; i++) { - f0 += values[i].f0; - f1 += values[i].f1; - } - return f0 + f1; - } - - public static int sum(Value2[] values) { - Value2 sum = Value2.of(0, 0); - for (int i = 0; i < values.length; i++) { - sum = sum.add(values[i]); - } - return sum.totalsum(); - } - - Value2[] values; - - @Setup - public void setup() { - values = setupValue(size); - } - - @Benchmark - public int valueScalarized() { - return sumScalarized(values); - } - - @Benchmark - public int value() { - return sum(values); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/arraysum/Arraysum8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -package oracle.micro.valhalla.lworld.arraysum; - -import oracle.micro.valhalla.ArraysumBase; -import oracle.micro.valhalla.lworld.types.Value8; -import org.openjdk.jmh.annotations.*; - -public class Arraysum8 extends ArraysumBase { - - public static Value8[] setupValue(int size) { - Value8[] values = new Value8[size]; - for (int i = 0, k = 0; i < values.length; i++, k += 8) { - values[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - return values; - } - - public static int sumScalarized(Value8[] values ) { - int f0 = 0; - int f1 = 0; - int f2 = 0; - int f3 = 0; - int f4 = 0; - int f5 = 0; - int f6 = 0; - int f7 = 0; - for (int i = 0; i < values.length; i++) { - f0 += values[i].f0; - f1 += values[i].f1; - f2 += values[i].f2; - f3 += values[i].f3; - f4 += values[i].f4; - f5 += values[i].f5; - f6 += values[i].f6; - f7 += values[i].f7; - } - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - public static int sum(Value8[] values) { - Value8 sum = Value8.of(0, 0, 0, 0, 0, 0, 0, 0); - for (int i = 0; i < values.length; i++) { - sum = sum.add(values[i]); - } - return sum.totalsum(); - } - - Value8[] values; - - @Setup - public void setup() { - values = setupValue(size); - } - - @Benchmark - public int valueScalarized() { - return sumScalarized(values); - } - - @Benchmark - public int value() { - return sum(values); - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/convcopy/Convcopy1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -package oracle.micro.valhalla.lworld.convcopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.lworld.types.Value1; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Convcopy1 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StateSrcValue { - Value1[] src; - - @Setup - public void setup() { - src = new Value1[size]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - } - } - - @State(Scope.Thread) - public static class StateDstValue { - Value1[] dst; - - @Setup - public void setup() { - dst = new Value1[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcObject { - Object[] src; - - @Setup - public void setup() { - src = new Object[size]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - } - } - - @State(Scope.Thread) - public static class StateDstObject { - Object[] dst; - - @Setup - public void setup() { - dst = new Object[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcInterface { - Total[] src; - - @Setup - public void setup() { - src = new Total[size]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - } - } - - @State(Scope.Thread) - public static class StateDstInterface { - Total[] dst; - - @Setup - public void setup() { - dst = new Total[size]; - } - } - - @Benchmark - public Object loopValueToObject(StateSrcValue srcst, StateDstObject dstst) { - Value1[] src = srcst.src; - Object[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValueToObject(StateSrcValue srcst, StateDstObject dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopObjectToValue(StateSrcObject srcst, StateDstValue dstst) { - Object[] src = srcst.src; - Value1[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Value1)src[i]; - } - return dst; - } - - @Benchmark - public Object copyObjectToValue(StateSrcObject srcst, StateDstValue dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopValueToInterface(StateSrcValue srcst, StateDstInterface dstst) { - Value1[] src = srcst.src; - Total[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValueToInterface(StateSrcValue srcst, StateDstInterface dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopInterfaceToValue(StateSrcInterface srcst, StateDstValue dstst) { - Total[] src = srcst.src; - Value1[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Value1)src[i]; - } - return dst; - } - - @Benchmark - public Object copyInterfaceToValue(StateSrcInterface srcst, StateDstValue dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/convcopy/Convcopy2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -package oracle.micro.valhalla.lworld.convcopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.lworld.types.Value2; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Convcopy2 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StateSrcValue { - Value2[] src; - - @Setup - public void setup() { - src = new Value2[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = Value2.of(k, k + 1); - } - } - } - - @State(Scope.Thread) - public static class StateDstValue { - Value2[] dst; - - @Setup - public void setup() { - dst = new Value2[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcObject { - Object[] src; - - @Setup - public void setup() { - src = new Object[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = Value2.of(k, k + 1); - } - } - } - - @State(Scope.Thread) - public static class StateDstObject { - Object[] dst; - - @Setup - public void setup() { - dst = new Object[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcInterface { - Total[] src; - - @Setup - public void setup() { - src = new Total[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 2) { - src[i] = Value2.of(k, k + 1); - } - } - } - - @State(Scope.Thread) - public static class StateDstInterface { - Total[] dst; - - @Setup - public void setup() { - dst = new Total[size]; - } - } - - @Benchmark - public Object loopValueToObject(StateSrcValue srcst, StateDstObject dstst) { - Value2[] src = srcst.src; - Object[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValueToObject(StateSrcValue srcst, StateDstObject dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopObjectToValue(StateSrcObject srcst, StateDstValue dstst) { - Object[] src = srcst.src; - Value2[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Value2)src[i]; - } - return dst; - } - - @Benchmark - public Object copyObjectToValue(StateSrcObject srcst, StateDstValue dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopValueToInterface(StateSrcValue srcst, StateDstInterface dstst) { - Value2[] src = srcst.src; - Total[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValueToInterface(StateSrcValue srcst, StateDstInterface dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopInterfaceToValue(StateSrcInterface srcst, StateDstValue dstst) { - Total[] src = srcst.src; - Value2[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Value2)src[i]; - } - return dst; - } - - @Benchmark - public Object copyInterfaceToValue(StateSrcInterface srcst, StateDstValue dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/convcopy/Convcopy8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -package oracle.micro.valhalla.lworld.convcopy; - -import oracle.micro.valhalla.ArraycopyBase; -import oracle.micro.valhalla.lworld.types.Value8; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; - -public class Convcopy8 extends ArraycopyBase { - - @State(Scope.Thread) - public static class StateSrcValue { - Value8[] src; - - @Setup - public void setup() { - src = new Value8[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - } - } - - @State(Scope.Thread) - public static class StateDstValue { - Value8[] dst; - - @Setup - public void setup() { - dst = new Value8[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcObject { - Object[] src; - - @Setup - public void setup() { - src = new Object[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - } - } - - @State(Scope.Thread) - public static class StateDstObject { - Object[] dst; - - @Setup - public void setup() { - dst = new Object[size]; - } - } - - @State(Scope.Thread) - public static class StateSrcInterface { - Total[] src; - - @Setup - public void setup() { - src = new Total[size]; - for (int i = 0, k = 0; i < src.length; i++, k += 8) { - src[i] = Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7); - } - } - } - - @State(Scope.Thread) - public static class StateDstInterface { - Total[] dst; - - @Setup - public void setup() { - dst = new Total[size]; - } - } - - @Benchmark - public Object loopValueToObject(StateSrcValue srcst, StateDstObject dstst) { - Value8[] src = srcst.src; - Object[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValueToObject(StateSrcValue srcst, StateDstObject dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopObjectToValue(StateSrcObject srcst, StateDstValue dstst) { - Object[] src = srcst.src; - Value8[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Value8)src[i]; - } - return dst; - } - - @Benchmark - public Object copyObjectToValue(StateSrcObject srcst, StateDstValue dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopValueToInterface(StateSrcValue srcst, StateDstInterface dstst) { - Value8[] src = srcst.src; - Total[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = src[i]; - } - return dst; - } - - @Benchmark - public Object copyValueToInterface(StateSrcValue srcst, StateDstInterface dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - - @Benchmark - public Object loopInterfaceToValue(StateSrcInterface srcst, StateDstValue dstst) { - Total[] src = srcst.src; - Value8[] dst = dstst.dst; - for (int i = 0; i < size; i++) { - dst[i] = (Value8)src[i]; - } - return dst; - } - - @Benchmark - public Object copyInterfaceToValue(StateSrcInterface srcst, StateDstValue dstst) { - System.arraycopy(srcst.src, 0, dstst.dst, 0, size); - return dstst.dst; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/invoke/Invoke.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,226 +0,0 @@ -package oracle.micro.valhalla.lworld.invoke; - - -import oracle.micro.valhalla.InvokeBase; -import oracle.micro.valhalla.lworld.types.Value1; -import oracle.micro.valhalla.lworld.types.Value2; -import oracle.micro.valhalla.lworld.types.Value8; -import oracle.micro.valhalla.types.Total; -import org.openjdk.jmh.annotations.*; - -public class Invoke extends InvokeBase { - - @State(Scope.Thread) - public static class StateValue { - Value1[] src; - - @Setup - public void setup() { - src = new Value1[SIZE]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeExactType(StateValue st) { - Value1[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].f0(); - } - return s; - } - - @State(Scope.Thread) - public static class StateObjectTarget1 { - Object[] src; - - @Setup - public void setup() { - src = new Object[SIZE]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeObject1(StateObjectTarget1 st) { - Object[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].hashCode(); - } - return s; - } - - - @State(Scope.Thread) - public static class StateObjectTarget2 { - Object[] src; - - @Setup - public void setup() { - src = new Object[SIZE]; - Integer[] d = random2(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = Value1.of(i); - break; - case 1: - src[i] = Value2.of(i, i + 1); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeObject2(StateObjectTarget2 st) { - Object[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].hashCode(); - } - return s; - } - - @State(Scope.Thread) - public static class StateObjectTarget3 { - Object[] src; - - @Setup - public void setup() { - src = new Object[SIZE]; - Integer[] d = random3(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = Value1.of(i); - break; - case 1: - src[i] = Value2.of(i, i + 1); - break; - case 2: - src[i] = Value8.of(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeObject3(StateObjectTarget3 st) { - Object[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].hashCode(); - } - return s; - } - - @State(Scope.Thread) - public static class StateInterfaceTarget1 { - Total[] src; - - @Setup - public void setup() { - src = new Total[SIZE]; - for (int i = 0; i < src.length; i++) { - src[i] = Value1.of(i); - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeInterface1(StateInterfaceTarget1 st) { - Total[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].totalsum(); - } - return s; - } - - - @State(Scope.Thread) - public static class StateInterfaceTarget2 { - Total[] src; - - @Setup - public void setup() { - src = new Total[SIZE]; - Integer[] d = random2(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = Value1.of(i); - break; - case 1: - src[i] = Value2.of(i, i + 1); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeInterface2(StateInterfaceTarget2 st) { - Total[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].totalsum(); - } - return s; - } - - @State(Scope.Thread) - public static class StateInterfaceTarget3 { - Total[] src; - - @Setup - public void setup() { - src = new Total[SIZE]; - Integer[] d = random3(); - for (int i = 0; i < src.length; i++) { - switch (d[i]) { - case 0: - src[i] = Value1.of(i); - break; - case 1: - src[i] = Value2.of(i, i + 1); - break; - case 2: - src[i] = Value8.of(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7); - break; - } - - } - } - } - - @Benchmark - @OperationsPerInvocation(SIZE) - public Object invokeInterface3(StateInterfaceTarget3 st) { - Total[] src = st.src; - int s = 0; - for (int i = 0; i < SIZE; i++) { - s += src[i].totalsum(); - } - return s; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/listsum/Listsum1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -package oracle.micro.valhalla.lworld.listsum; - -import oracle.micro.valhalla.ListsumBase; -import oracle.micro.valhalla.lworld.types.Value1; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -public class Listsum1 extends ListsumBase { - - static class Node { - public Value1 value; - public Node next; - - - public Node(Value1 value, Node next) { - this.value = value; - this.next = next; - } - } - - Node list = null; - - @Setup - public void setup() { - for (int i = 0; i < size; i++) { - list = new Node(Value1.of(i), list); - } - } - - public static int sumScalarized(Node list) { - int sum = 0; - for (Node n = list; n!=null; n = n.next) { - sum += n.value.f0; - } - return sum; - } - - public static int sum(Node list) { - Value1 sum = Value1.of(0); - for (Node n = list; n!=null; n = n.next) { - sum = sum.add(n.value); - } - return sum.totalsum(); - } - - @Benchmark - public int valueScalarized() { - return sumScalarized(list); - } - - @Benchmark - public int value() { - return sum(list); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/listsum/Listsum2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -package oracle.micro.valhalla.lworld.listsum; - -import oracle.micro.valhalla.ListsumBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -public class Listsum2 extends ListsumBase { - - static class Node { - public Value2 value; - public Node next; - - - public Node(Value2 value, Node next) { - this.value = value; - this.next = next; - } - } - - Node list = null; - - @Setup - public void setup() { - for (int i = 0, k = 0; i < size; i++, k += 2) { - list = new Node( Value2.of(k, k+1), list); - - } - } - - public static int sumScalarized(Node list) { - int f0 = 0; - int f1 = 0; - for (Node n = list; n!=null; n = n.next) { - f0 += n.value.f0; - f1 += n.value.f1; - } - return f0 + f1; - } - - public static int sum(Node list) { - Value2 sum = Value2.of(0,0); - for (Node n = list; n!=null; n = n.next) { - sum = sum.add(n.value); - } - return sum.totalsum(); - } - - @Benchmark - public int valueScalarized() { - return sumScalarized(list); - } - - @Benchmark - public int value() { - return sum(list); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/listsum/Listsum8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -package oracle.micro.valhalla.lworld.listsum; - -import oracle.micro.valhalla.ListsumBase; -import oracle.micro.valhalla.lworld.types.Value8; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -public class Listsum8 extends ListsumBase { - - static class Node { - public Value8 value; - public Node next; - - - public Node(Value8 value, Node next) { - this.value = value; - this.next = next; - } - } - - Node list = null; - - @Setup - public void setup() { - for (int i = 0, k = 0; i < size; i++, k += 8) { - list = new Node(Value8.of(k, k + 1, k + 2, k + 3, k + 4, k + 5, k + 6, k + 7), list); - } - } - - public static int sumScalarized(Node list) { - int f0 = 0; - int f1 = 0; - int f2 = 0; - int f3 = 0; - int f4 = 0; - int f5 = 0; - int f6 = 0; - int f7 = 0; - for (Node n = list; n!=null; n = n.next) { - f0 += n.value.f0; - f1 += n.value.f1; - f2 += n.value.f2; - f3 += n.value.f3; - f4 += n.value.f4; - f5 += n.value.f5; - f6 += n.value.f6; - f7 += n.value.f7; - } - return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7; - } - - public static int sum(Node list) { - Value8 sum = Value8.of(0,0,0,0,0,0,0,0); - for (Node n = list; n!=null; n = n.next) { - sum = sum.add(n.value); - } - return sum.totalsum(); - } - - @Benchmark - public int valueScalarized() { - return sumScalarized(list); - } - - @Benchmark - public int value() { - return sum(list); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/GetValue.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -package oracle.micro.valhalla.lworld.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.lworld.util.HashMapValueTotal; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.infra.Blackhole; - -import java.util.Arrays; -import java.util.Collections; - -public class GetValue extends MapBase { - - HashMapValueTotal<Integer, Integer> map; - - Integer[] mixed; - - @Setup - public void setup() { - super.init(size); - map = new HashMapValueTotal<>(); - for (Integer k : keys) { - map.put(k, k); - } - mixed = new Integer[size]; - System.arraycopy(keys, 0, mixed, 0, size / 2); - System.arraycopy(nonKeys, 0, mixed, size / 2, size / 2); - Collections.shuffle(Arrays.asList(mixed), rnd); - } - - @Benchmark - public void getHit(Blackhole bh) { - Integer[] keys = this.keys; - HashMapValueTotal<Integer, Integer> map = this.map; - for (Integer k : keys) { - bh.consume(map.get(k)); - } - } - - @Benchmark - public void getMix(Blackhole bh) { - Integer[] keys = this.mixed; - HashMapValueTotal<Integer, Integer> map = this.map; - for (Integer k : keys) { - bh.consume(map.get(k)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/PutValue.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -package oracle.micro.valhalla.lworld.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.lworld.util.HashMapValueTotal; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -public class PutValue extends MapBase { - - @Setup - public void setup() { - super.init(size); - } - - @Benchmark - public HashMapValueTotal<Integer, Integer> put() { - Integer[] keys = this.keys; - HashMapValueTotal<Integer, Integer> map = new HashMapValueTotal<>(); - for (Integer k : keys) { - map.put(k, k); - } - return map; - } - - @Benchmark - public HashMapValueTotal<Integer, Integer> putSized() { - Integer[] keys = this.keys; - HashMapValueTotal<Integer, Integer> map = new HashMapValueTotal<>(size*2); - for (Integer k : keys) { - map.put(k, k); - } - return map; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkIteratorCursor.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -package oracle.micro.valhalla.lworld.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.lworld.util.HashMapIteratorCursor; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Iterator; - -public class WalkIteratorCursor extends MapBase { - - HashMapIteratorCursor<Integer, Integer> map; - - @Setup - public void setup() { - super.init(size); - map = new HashMapIteratorCursor<>(); - for (Integer k : keys) { - map.put(k, k); - } - } - - @Benchmark - public int sumIterator() { - int s = 0; - for (Iterator<Integer> iterator = map.keyIterator(); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumIteratorHidden() { - int s = 0; - for (Iterator<Integer> iterator = hide(map.keyIterator()); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumCursor() { - int s = 0; - for (oracle.micro.valhalla.util.Cursor<Integer> cursor = map.keyCursor(); cursor.hasElement(); cursor = cursor.next()) { - s += cursor.get(); - } - return s; - } - - @Benchmark - public int sumCursorSpecialized() { - int s = 0; - for (HashMapIteratorCursor.KeyCursor<Integer, Integer> cursor = HashMapIteratorCursor.KeyCursor.of(map); cursor.hasElement(); cursor = cursor.nextEntry()) { - s += cursor.get(); - } - return s; - } - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static Iterator<Integer> hide(Iterator<Integer> it) { - return it; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkValueCursor.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -package oracle.micro.valhalla.lworld.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.lworld.util.HashMapValueCursor; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Iterator; - -public class WalkValueCursor extends MapBase { - - HashMapValueCursor<Integer, Integer> map; - - @Setup - public void setup() { - super.init(size); - map = new HashMapValueCursor<>(); - for (Integer k : keys) { - map.put(k, k); - } - } - - - @Benchmark - public int sumIterator() { - int s = 0; - for (Iterator<Integer> iterator = map.keyIterator(); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumIteratorHidden() { - int s = 0; - for (Iterator<Integer> iterator = hide(map.keyIterator()); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumCursor() { - int s = 0; - for (oracle.micro.valhalla.util.Cursor<Integer> cursor = map.keyCursor(); cursor.hasElement(); cursor = cursor.next()) { - s += cursor.get(); - } - return s; - } - - @Benchmark - public int sumCursorSpecialized() { - int s = 0; - for (HashMapValueCursor.KeyCursor<Integer, Integer> cursor = HashMapValueCursor.KeyCursor.of(map); cursor.hasElement(); cursor = cursor.nextEntry()) { - s += cursor.get(); - } - return s; - } - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static Iterator<Integer> hide(Iterator<Integer> it) { - return it; - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkValueEntry.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -package oracle.micro.valhalla.lworld.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.lworld.util.HashMapValueEntry; -import oracle.micro.valhalla.util.Cursor; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Iterator; - -public class WalkValueEntry extends MapBase { - - HashMapValueEntry<Integer, Integer> map; - - @Setup - public void setup() { - super.init(size); - map = new HashMapValueEntry<>(); - for (Integer k : keys) { - map.put(k, k); - } - } - - @Benchmark - public int sumIterator() { - int s = 0; - for (Iterator<Integer> iterator = map.keyIterator(); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumIteratorHidden() { - int s = 0; - for (Iterator<Integer> iterator = hide(map.keyIterator()); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumCursor() { - int s = 0; - for (Cursor<Integer> cursor = map.keyCursor(); cursor.hasElement(); cursor = cursor.next()) { - s += cursor.get(); - } - return s; - } - - @Benchmark - public int sumCursorSpecialized() { - int s = 0; - for (HashMapValueEntry.KeyCursor<Integer, Integer> cursor = HashMapValueEntry.KeyCursor.of(map); cursor.hasElement(); cursor = cursor.nextEntry()) { - s += cursor.get(); - } - return s; - } - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static Iterator<Integer> hide(Iterator<Integer> it) { - return it; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/map/WalkValueTotal.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -package oracle.micro.valhalla.lworld.map; - -import oracle.micro.valhalla.MapBase; -import oracle.micro.valhalla.lworld.util.HashMapValueTotal; -import oracle.micro.valhalla.util.Cursor; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.CompilerControl; -import org.openjdk.jmh.annotations.Setup; - -import java.util.Iterator; - -public class WalkValueTotal extends MapBase { - - HashMapValueTotal<Integer, Integer> map; - - @Setup - public void setup() { - super.init(size); - map = new HashMapValueTotal<>(); - for (Integer k : keys) { - map.put(k, k); - } - } - - @Benchmark - public int sumIterator() { - int s = 0; - for (Iterator<Integer> iterator = map.keyIterator(); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumIteratorHidden() { - int s = 0; - for (Iterator<Integer> iterator = hide(map.keyIterator()); iterator.hasNext(); ) { - s += iterator.next(); - } - return s; - } - - @Benchmark - public int sumCursor() { - int s = 0; - for (Cursor<Integer> cursor = map.keyCursor(); cursor.hasElement(); cursor = cursor.next()) { - s += cursor.get(); - } - return s; - } - - @Benchmark - public int sumCursorSpecialized() { - int s = 0; - for (HashMapValueTotal.KeyCursor<Integer, Integer> cursor = HashMapValueTotal.KeyCursor.of(map); cursor.hasElement(); cursor = cursor.nextEntry()) { - s += cursor.get(); - } - return s; - } - - @CompilerControl(CompilerControl.Mode.DONT_INLINE) - private static Iterator<Integer> hide(Iterator<Integer> it) { - return it; - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/matrix/Value.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -package oracle.micro.valhalla.lworld.matrix; - - -import oracle.micro.valhalla.MatrixBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Setup; - -import java.util.concurrent.ThreadLocalRandom; - -public class Value extends MatrixBase { - - public static Value2[][] multValueIJK(Value2[][] A, Value2[][] B) { - int size = A.length; - Value2[][] R = new Value2[size][size]; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - Value2 s = Value2.of(0, 0); - for (int k = 0; k < size; k++) { - s = s.add(A[i][k].mul(B[k][j])); - } - R[i][j] = s; - } - } - return R; - } - - public static Value2[][] multValueIKJ(Value2[][] A, Value2[][] B) { - int size = A.length; - Value2[][] R = new Value2[size][size]; - for (int i = 0; i < size; i++) { - for (int k = 0; k < size; k++) { - Value2 aik = A[i][k]; - for (int j = 0; j < size; j++) { - R[i][j] = R[i][j].add(aik.mul(B[k][j])); - } - } - } - return R; - } - - Value2[][] A; - Value2[][] B; - - @Setup - public void setup() { - A = new Value2[size][size]; - populate(A); - B = new Value2[size][size]; - populate(B); - } - - private void populate(Value2[][] m) { - int size = m.length; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - m[i][j] = Value2.of( ThreadLocalRandom.current().nextInt(), ThreadLocalRandom.current().nextInt()); - } - } - - } - - @Benchmark - public Value2[][] multIJK() { - return multValueIJK(A, B); - } - - @Benchmark - public Value2[][] multIKJ() { - return multValueIKJ(A, B); - } - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/search/Search1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -package oracle.micro.valhalla.lworld.search; - -import oracle.micro.valhalla.SearchBase; -import oracle.micro.valhalla.lworld.types.Value1; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -public class Search1 extends SearchBase { - - @State(Scope.Thread) - public static class StateValue { - Value1[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new Value1[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = Value1.of(i); - } - } - } - - private static int binarySearch(Value1[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid].f0; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - - @Benchmark - @OperationsPerInvocation(OPS) - public void value(StateValue st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/search/Search2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -package oracle.micro.valhalla.lworld.search; - -import oracle.micro.valhalla.SearchBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -public class Search2 extends SearchBase { - - @State(Scope.Thread) - public static class StateValue { - Value2[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new Value2[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = Value2.of(i, i); - } - } - } - - private static int binarySearch(Value2[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid].f0; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - - @Benchmark - @OperationsPerInvocation(OPS) - public void value(StateValue st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/search/Search8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -package oracle.micro.valhalla.lworld.search; - -import oracle.micro.valhalla.SearchBase; -import oracle.micro.valhalla.lworld.types.Value8; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -public class Search8 extends SearchBase { - - @State(Scope.Thread) - public static class StateValue { - Value8[] arr; - - @Setup - public void setup() { - baseSetup(); - arr = new Value8[size]; - for (int i = 0; i < arr.length; i++) { - arr[i] = Value8.of(i, i, i, i, i, i, i, i); - } - } - } - - private static int binarySearch(Value8[] a, int key) { - int low = 0; - int high = a.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midVal = a[mid].f0; - - if (midVal < key) - low = mid + 1; - else if (midVal > key) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found. - } - - - @Benchmark - @OperationsPerInvocation(OPS) - public void value(StateValue st, Blackhole bh) { - for (int t : targets) { - bh.consume(binarySearch(st.arr, t)); - } - } - - -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/sort/Sort1.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -package oracle.micro.valhalla.lworld.sort; - -import oracle.micro.valhalla.SortBase; -import oracle.micro.valhalla.lworld.types.Value1; -import org.openjdk.jmh.annotations.Benchmark; - -import java.util.concurrent.ThreadLocalRandom; - -public class Sort1 extends SortBase { - - public Value1[] makeRandomArray() { - Value1[] arr = new Value1[size]; - for (int i = 0; i < size; i++) { - arr[i] = Value1.of (ThreadLocalRandom.current().nextInt()); - } - return arr; - } - - @Benchmark - public Value1[] quicksort() { - Value1[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public Value1[] mergeSort() { - Value1[] toSort = makeRandomArray(); - Value1[] aux = new Value1[toSort.length]; - System.arraycopy(toSort, 0, aux, 0 , toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - - private static int compare(Value1 a, Value1 b) { - return Integer.compare(a.f0, b.f0); - - } - - //##########3 dual pivot quick sort############################## - - private static void sort1(Value1 x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - Value1 v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a); - vecswap(x, off, b - s, s); - s = Math.min(d - c, n - d - 1); - vecswap(x, b, n - s, s); - - // Recursively sort non-partition-elements - if ((s = b - a) > 1) - sort1(x, off, s); - if ((s = d - c) > 1) - sort1(x, n - s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(Value1 x[], int a, int b) { - Value1 t = x[a]; - x[a] = x[b]; - x[b] = t; - } - - /** - * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. - */ - private static void vecswap(Value1 x[], int a, int b, int n) { - for (int i = 0; i < n; i++, a++, b++) - swap(x, a, b); - } - - /** - * Returns the index of the median of the three indexed integers. - */ - private static int med3(Value1 x[], int a, int b, int c) { - return (compare(x[a], x[b]) < 0 ? - (compare(x[b], x[c]) < 0 ? b : compare(x[a], x[c]) < 0 ? c : a) : - (compare(x[b], x[c]) > 0 ? b : compare(x[a], x[c]) > 0 ? c : a)); - } - - - //########## merge sort############################## - - - private static void mergeSort(Value1[] src, - Value1[] dest, - int low, int high, int off) { - int length = high - low; - - // Insertion sort on smallest arrays - if (length < 7) { - for (int i = low; i < high; i++) - for (int j = i; j > low && compare(dest[j - 1], dest[j]) > 0; j--) - swap(dest, j, j - 1); - return; - } - - // Recursively sort halves of dest into src - int destLow = low; - int destHigh = high; - low += off; - high += off; - int mid = (low + high) >>> 1; - mergeSort(dest, src, low, mid, -off); - mergeSort(dest, src, mid, high, -off); - - // If list is already sorted, just copy from src to dest. This is an - // optimization that results in faster sorts for nearly ordered lists. - if (compare(src[mid - 1], src[mid]) <= 0) { - System.arraycopy(src, low, dest, destLow, length); - return; - } - - // Merge sorted halves (now in src) into dest - for (int i = destLow, p = low, q = mid; i < destHigh; i++) { - if (q >= high || p < mid && compare(src[p], src[q]) <= 0) - dest[i] = src[p++]; - else - dest[i] = src[q++]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/sort/Sort2.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -package oracle.micro.valhalla.lworld.sort; - -import oracle.micro.valhalla.SortBase; -import oracle.micro.valhalla.lworld.types.Value2; -import org.openjdk.jmh.annotations.Benchmark; - -import java.util.concurrent.ThreadLocalRandom; - -public class Sort2 extends SortBase { - - public Value2[] makeRandomArray() { - Value2[] arr = new Value2[size]; - for (int i = 0; i < size; i++) { - arr[i] = Value2.of(ThreadLocalRandom.current().nextInt(), ThreadLocalRandom.current().nextInt()); - } - return arr; - } - - - @Benchmark - public Value2[] quicksort() { - Value2[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public Value2[] mergeSort() { - Value2[] toSort = makeRandomArray(); - Value2[] aux = new Value2[toSort.length]; - System.arraycopy(toSort, 0, aux, 0, toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - private static int compare(Value2 a, Value2 b) { - int c0 = Integer.compare(a.f0, b.f0); - return c0 != 0 ? c0 : Integer.compare(a.f1, b.f1); - } - - - //##########3 dual pivot quick sort############################## - - private static void sort1(Value2 x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - Value2 v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a); - vecswap(x, off, b - s, s); - s = Math.min(d - c, n - d - 1); - vecswap(x, b, n - s, s); - - // Recursively sort non-partition-elements - if ((s = b - a) > 1) - sort1(x, off, s); - if ((s = d - c) > 1) - sort1(x, n - s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(Value2[] x, int a, int b) { - Value2 t = x[a]; - x[a] = x[b]; - x[b] = t; - } - - /** - * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)]. - */ - private static void vecswap(Value2[] x, int a, int b, int n) { - for (int i = 0; i < n; i++, a++, b++) - swap(x, a, b); - } - - /** - * Returns the index of the median of the three indexed integers. - */ - private static int med3(Value2[] x, int a, int b, int c) { - return (compare(x[a], x[b]) < 0 ? - (compare(x[b], x[c]) < 0 ? b : compare(x[a], x[c]) < 0 ? c : a) : - (compare(x[b], x[c]) > 0 ? b : compare(x[a], x[c]) > 0 ? c : a)); - } - - - //########## merge sort############################## - - - private static void mergeSort(Value2[] src, - Value2[] dest, - int low, int high, int off) { - int length = high - low; - - // Insertion sort on smallest arrays - if (length < 7) { - for (int i = low; i < high; i++) - for (int j = i; j > low && compare(dest[j - 1], dest[j]) > 0; j--) - swap(dest, j, j - 1); - return; - } - - // Recursively sort halves of dest into src - int destLow = low; - int destHigh = high; - low += off; - high += off; - int mid = (low + high) >>> 1; - mergeSort(dest, src, low, mid, -off); - mergeSort(dest, src, mid, high, -off); - - // If list is already sorted, just copy from src to dest. This is an - // optimization that results in faster sorts for nearly ordered lists. - if (compare(src[mid - 1], src[mid]) <= 0) { - System.arraycopy(src, low, dest, destLow, length); - return; - } - - // Merge sorted halves (now in src) into dest - for (int i = destLow, p = low, q = mid; i < destHigh; i++) { - if (q >= high || p < mid && compare(src[p], src[q]) <= 0) - dest[i] = src[p++]; - else - dest[i] = src[q++]; - } - } -}
--- a/test/benchmarks/src/main/java/oracle/micro/valhalla/lworld/sort/Sort8.java Thu May 30 09:25:24 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -package oracle.micro.valhalla.lworld.sort; - -import oracle.micro.valhalla.SortBase; -import oracle.micro.valhalla.lworld.types.Value8; -import org.openjdk.jmh.annotations.Benchmark; - -import java.util.concurrent.ThreadLocalRandom; - -public class Sort8 extends SortBase { - - public Value8[] makeRandomArray() { - Value8[] arr = new Value8[size]; - for (int i = 0; i < size; i++) { - arr[i] = Value8.of( - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt(), - ThreadLocalRandom.current().nextInt()); - } - return arr; - } - - @Benchmark - public Value8[] quicksort() { - Value8[] toSort = makeRandomArray(); - sort1(toSort, 0, toSort.length); - return toSort; - } - - @Benchmark - public Value8[] mergeSort() { - Value8[] toSort = makeRandomArray(); - Value8[] aux = new Value8[toSort.length]; - System.arraycopy(toSort, 0, aux, 0 , toSort.length); - mergeSort(aux, toSort, 0, toSort.length, 0); - return toSort; - } - - - private static int compare(Value8 a, Value8 b) { - int c0 = Integer.compare(a.f0, b.f0); - if (c0 != 0) { - return c0; - } else { - int c1 = Integer.compare(a.f1, b.f1); - if (c1 != 0) { - return c1; - } else { - int c2 = Integer.compare(a.f2, b.f2); - if (c2 != 0) { - return c2; - } else { - int c3 = Integer.compare(a.f3, b.f3); - if (c3 != 0) { - return c3; - } else { - int c4 = Integer.compare(a.f4, b.f4); - if (c4 != 0) { - return c4; - } else { - int c5 = Integer.compare(a.f5, b.f5); - if (c5 != 0) { - return c5; - } else { - int c6 = Integer.compare(a.f6, b.f6); - if (c6 != 0) { - return c6; - } else { - return Integer.compare(a.f7, b.f7); - } - } - } - } - } - } - } - } - - //##########3 dual pivot quick sort############################## - - private static void sort1(Value8 x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i = off; i < len + off; i++) - for (int j = i; j > off && compare(x[j - 1], x[j]) > 0; j--) - swap(x, j, j - 1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len / 8; - l = med3(x, l, l + s, l + 2 * s); - m = med3(x, m - s, m, m + s); - n = med3(x, n - 2 * s, n - s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } - Value8 v = x[m]; - - // Establish Invariant: v* (<v)* (>v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while (true) { - while (b <= c && compare(x[b], v) <= 0) { - if (compare(x[b], v) == 0) - swap(x, a++, b); - b++; - } - while (c >= b && compare(x[c], v) >= 0) { - if (compare(x[c], v) == 0) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a - off, b - a);