Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JVM Vector API? #47

Open
CommanderTvis opened this issue Jun 15, 2021 · 8 comments
Open

Use JVM Vector API? #47

CommanderTvis opened this issue Jun 15, 2021 · 8 comments

Comments

@CommanderTvis
Copy link

A possible way to implement the array are intrinsics introduced with JEP 338.

@dievsky
Copy link
Contributor

dievsky commented Jun 15, 2021

Last time I looked at it (half a year ago), there was no SIMD mathematics there, and viktor's "area of expertise" is exactly the SIMD mathematics (exp, log etc.).

@CommanderTvis
Copy link
Author

@dievsky
Copy link
Contributor

dievsky commented Jun 15, 2021

What exactly should I look for under that link?

@CommanderTvis
Copy link
Author

CommanderTvis commented Jun 15, 2021

Reliable runtime compilation and performance on x64 and AArch64 architectures: The Java runtime, specifically the HotSpot C2 compiler, shall compile, on capable x64 architectures, a sequence of vector operations to a corresponding sequence of vector hardware instructions, such as those supported by Streaming SIMD Extensions (SSE) and Advanced Vector Extensions (AVX) extensions, thereby generating efficient and performant code. The programmer shall have confidence that the vector operations they express will reliably map closely to associated hardware vector instructions. The same shall also apply to capable ARM AArch64 architectures compiling to a sequence of vector hardware instructions supported by Neon.

@dievsky
Copy link
Contributor

dievsky commented Jun 15, 2021

I must shamefully admit that it's pretty hard for me to communicate with people speaking in links and quotes.
My point was that (last time I checked) Vector API was missing SIMDized exponent, logarithm, etc, Your counterpoint was a link to the Vector API proposal and a quote of its broadly stated goals.
If you intended to say they have, in fact, implemented SIMDized exponent in the last six months, why not just say so? :))

@CommanderTvis
Copy link
Author

As for me, SIMD support means that at least vector arithmetic is optimized.

@CommanderTvis
Copy link
Author

I think it would be OK even if they didn't provide other elementary functions: there's nothing wrong in falling back into scalar mathematics for everything except arithmetic.

@dievsky
Copy link
Contributor

dievsky commented Jun 16, 2021

Ah, now I get it.

The funny thing is that the array loop arithmetic is already SIMDized, even in JDK 1.8. Every time I've checked, the C2 compiler successfully emitted AVX instructions for arithmetic operations. That's why we stopped delegating the arithmetic to JNI since 1.1.0: the JNI actually performs worse than a simple loop.

So switching to Vector API will currently make the code less readable and portable, while not improving the performance. (Well, okay, maybe the performance will improve by a couple percent because we will skip the warmup phase.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants