Skip to content

Commit 2902e17

Browse files
committed
[GR-68237] Fix GraalWasm SIMD performance issues found through vector-trunc-sat, vector-narrow and vector-q15mulr.
PullRequest: graal/21696
2 parents b0e0eea + 0026244 commit 2902e17

File tree

13 files changed

+394
-102
lines changed

13 files changed

+394
-102
lines changed

vm/mx.vm/mx_vm_gate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,11 @@ def gate_truffle_native_tck_wasm(tasks):
748748
mx.abort("Cannot resolve the `wasm:WASM` language distribution. To resolve this, import the wasm suite using `--dynamicimports /wasm`.")
749749
native_image_context, svm = graalvm_svm()
750750
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
751-
_svm_truffle_tck(native_image, 'wasm', wasm_language)
751+
_svm_truffle_tck(native_image, 'wasm', wasm_language,
752+
# native-image sets -Djdk.internal.lambda.disableEagerInitialization=true by default,
753+
# which breaks Vector API's isNonCapturingLambda assertion. We override this property
754+
# for the GraalWasm Truffle Native TCK.
755+
additional_options=['-Djdk.internal.lambda.disableEagerInitialization=false'])
752756

753757
def gate_maven_downloader(tasks):
754758
with Task('Maven Downloader prepare maven repo', tasks, tags=[VmGateTasks.maven_downloader]) as t:

wasm/scripts/run-wat-micro-benchmarks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ VM=$2
99
VM_CONFIG=$3
1010
UPLOAD_CMD=$4
1111

12-
for benchmark in vector-double-mul vector-double-nearest vector-double-round vector-int-add vector-int-mix vector-int-mul
12+
for benchmark in vector-double-mul vector-double-nearest vector-double-round vector-int-add vector-int-mix vector-int-mul vector-narrow vector-q15mulr vector-trunc-sat
1313
do
1414
mx --dy /compiler --kill-with-sigquit benchmark \
1515
"--machine-name=${MACHINE_NAME}" \
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
zero-memory = true
2+
interpreter-iterations = 1
3+
sync-noinline-iterations = 1
4+
sync-inline-iterations = 0
5+
async-iterations = 1050
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int 1
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
;;
2+
;; Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3+
;; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
;;
5+
;; The Universal Permissive License (UPL), Version 1.0
6+
;;
7+
;; Subject to the condition set forth below, permission is hereby granted to any
8+
;; person obtaining a copy of this software, associated documentation and/or
9+
;; data (collectively the "Software"), free of charge and under any and all
10+
;; copyright rights in the Software, and any and all patent rights owned or
11+
;; freely licensable by each licensor hereunder covering either (i) the
12+
;; unmodified Software as contributed to or provided by such licensor, or (ii)
13+
;; the Larger Works (as defined below), to deal in both
14+
;;
15+
;; (a) the Software, and
16+
;;
17+
;; (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
;; one is included with the Software each a "Larger Work" to which the Software
19+
;; is contributed by such licensors),
20+
;;
21+
;; without restriction, including without limitation the rights to copy, create
22+
;; derivative works of, display, perform, and distribute the Software and make,
23+
;; use, sell, offer for sale, import, export, have made, and have sold the
24+
;; Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
;; either these or other terms.
26+
;;
27+
;; This license is subject to the following condition:
28+
;;
29+
;; The above copyright notice and either this complete permission notice or at a
30+
;; minimum a reference to the UPL must be included in all copies or substantial
31+
;; portions of the Software.
32+
;;
33+
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
;; SOFTWARE.
40+
;;
41+
(module
42+
(type $int_func (func (result i32)))
43+
(type $proc (func))
44+
(type $teardown_func (func (param i32)))
45+
46+
(global $iterations i32 (i32.const 1000000))
47+
48+
(memory $memory (export "memory") 0)
49+
50+
(func (export "benchmarkSetupEach") (type $proc))
51+
52+
(func (export "benchmarkTeardownEach") (type $teardown_func))
53+
54+
(func (export "benchmarkRun") (type $int_func)
55+
(local $i i32)
56+
(local $acc v128)
57+
(local $x v128)
58+
(local $y v128)
59+
60+
(loop $bench_loop
61+
(local.set $x (i16x8.add (local.get $x) (v128.const i16x8 1 2 3 4 5 6 7 8)))
62+
(local.set $y (i16x8.add (local.get $y) (v128.const i16x8 9 10 11 12 13 14 15 16)))
63+
(local.set $acc (i8x16.add (local.get $acc) (i8x16.narrow_i16x8_s (local.get $x) (local.get $y))))
64+
65+
;; Increment loop counter and exit loop
66+
(local.set $i (i32.add (local.get $i) (i32.const 1)))
67+
(br_if $bench_loop (i32.lt_s (local.get $i) (global.get $iterations)))
68+
)
69+
70+
(v128.any_true (local.get $acc))
71+
)
72+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
zero-memory = true
2+
interpreter-iterations = 1
3+
sync-noinline-iterations = 1
4+
sync-inline-iterations = 0
5+
async-iterations = 1050
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int 1
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
;;
2+
;; Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3+
;; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
;;
5+
;; The Universal Permissive License (UPL), Version 1.0
6+
;;
7+
;; Subject to the condition set forth below, permission is hereby granted to any
8+
;; person obtaining a copy of this software, associated documentation and/or
9+
;; data (collectively the "Software"), free of charge and under any and all
10+
;; copyright rights in the Software, and any and all patent rights owned or
11+
;; freely licensable by each licensor hereunder covering either (i) the
12+
;; unmodified Software as contributed to or provided by such licensor, or (ii)
13+
;; the Larger Works (as defined below), to deal in both
14+
;;
15+
;; (a) the Software, and
16+
;;
17+
;; (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
;; one is included with the Software each a "Larger Work" to which the Software
19+
;; is contributed by such licensors),
20+
;;
21+
;; without restriction, including without limitation the rights to copy, create
22+
;; derivative works of, display, perform, and distribute the Software and make,
23+
;; use, sell, offer for sale, import, export, have made, and have sold the
24+
;; Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
;; either these or other terms.
26+
;;
27+
;; This license is subject to the following condition:
28+
;;
29+
;; The above copyright notice and either this complete permission notice or at a
30+
;; minimum a reference to the UPL must be included in all copies or substantial
31+
;; portions of the Software.
32+
;;
33+
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
;; SOFTWARE.
40+
;;
41+
(module
42+
(type $int_func (func (result i32)))
43+
(type $proc (func))
44+
(type $teardown_func (func (param i32)))
45+
46+
(global $iterations i32 (i32.const 1000000))
47+
48+
(memory $memory (export "memory") 0)
49+
50+
(func (export "benchmarkSetupEach") (type $proc))
51+
52+
(func (export "benchmarkTeardownEach") (type $teardown_func))
53+
54+
(func (export "benchmarkRun") (type $int_func)
55+
(local $i i32)
56+
(local $v v128)
57+
(local.set $v (v128.const i16x8 30000 31000 31500 20000 22500 12345 32145 123))
58+
59+
(loop $bench_loop
60+
(local.set $v (i16x8.q15mulr_sat_s (local.get $v) (v128.const i16x8 30000 3101 31499 34343 23123 4321 321 33333)))
61+
62+
;; Increment loop counter and exit loop
63+
(local.set $i (i32.add (local.get $i) (i32.const 1)))
64+
(br_if $bench_loop (i32.lt_s (local.get $i) (global.get $iterations)))
65+
)
66+
67+
(v128.any_true (local.get $v))
68+
)
69+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
zero-memory = true
2+
interpreter-iterations = 1
3+
sync-noinline-iterations = 1
4+
sync-inline-iterations = 0
5+
async-iterations = 1050
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int 1

0 commit comments

Comments
 (0)