Skip to content

Commit 88b0d73

Browse files
committed
Add developer docs for Vector API
1 parent 979cfc6 commit 88b0d73

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/DEVELOPMENT.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,35 @@ allows static code analysis tools (e.g. Error Prone's `MissingCasesInEnumSwitch`
144144
check) report a problem when the enum definition is updated but the code using
145145
it is not.
146146

147+
### Vector API
148+
It's safe to assume that the JVM has the Vector API
149+
([JEP 508](https://openjdk.org/jeps/508)) enabled and available at runtime, but
150+
not safe to assume that the Vector API implementation will perform faster than
151+
equivalent scalar code on whatever hardware the engine happens to be running on.
152+
153+
Different CPU hardware can exhibit dramatically different performance
154+
characteristics, so it's important to use hardware feature detection to
155+
determine under which scenarios a vectorized approach will be faster for
156+
each implementation. Vectorized code should be tested on AMD, ARM, and Intel
157+
CPUs to verify the benefits hold on each of those platforms before deciding
158+
to enable a given code path on each of those platforms. Also note that ARM CPUs
159+
can exhibit significant differences from between hardware generations as well
160+
as between Apple Silicon and datacenter class CPUs.
161+
162+
When adding implementations that use the Vector API, prefer the following
163+
approach unless the specifics of the situation dictate otherwise:
164+
* Provide an equivalent scalar implementation in code, if one does not already
165+
exist.
166+
* Use configuration flags and hardware support detection to ensure that
167+
vectorized implementation is only selected when running on hardware where it is
168+
expected to perform better than its scalar equivalent.
169+
* Add tests that ensure the behavior of the vectorized and scalar
170+
implementations match.
171+
* Include micro-benchmarks that demonstrate the performance benefits of the
172+
vectorized implementation compared to the scalar equivalent logic. Ensure that
173+
the benefits hold for all CPU architectures on which the vectorized
174+
implementation is enabled.
175+
147176
## Keep pom.xml clean and sorted
148177

149178
There are several plugins in place to keep pom.xml clean.

0 commit comments

Comments
 (0)