-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
8329816: Add SLEEF version 3.6.1 #19185
Draft
vidmik
wants to merge
1
commit into
openjdk:master
Choose a base branch
from
vidmik:8329816-sleef
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+14,313
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024, 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. Oracle designates this | ||
# particular file as subject to the "Classpath" exception as provided | ||
# by Oracle in the LICENSE file that accompanied this code. | ||
# | ||
# 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. | ||
# | ||
|
||
# This script cross-compiles SLEEF for a non-native platform. For example, | ||
# it can be used to build the aarch64 inline headers on an x64 machine by | ||
# doing something like: | ||
# | ||
# 1. cd <sleef> | ||
# 2. bash <jdk>/make/devkit/createSleef.sh aarch64-gcc.cmake <path-to>/devkit | ||
# | ||
# The second argument (the devkit path) should point to the devkit | ||
# directory in which devkit.info resides. | ||
# | ||
# After the build completes, the build result is available in the | ||
# <jdk>/build/sleef/build/cross directory. For example, the aarch64 | ||
# header files can be found in: | ||
# | ||
# <jdk>/build/sleef/cross/include/sleefinline_{advsimd,sve}.h | ||
# | ||
|
||
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)" | ||
BUILD_DIR="${SCRIPT_DIR}/../../build/sleef" | ||
|
||
set -eu | ||
|
||
if [ ! $# = 2 ]; then | ||
echo "Usage: $0 <cmake toolchain file> <devkit>" | ||
exit 1 | ||
fi | ||
|
||
CMAKE_TOOLCHAIN_FILE="$1" | ||
DEVKIT_ROOT="$2" | ||
|
||
if [ ! -f "${CMAKE_TOOLCHAIN_FILE}" ]; then | ||
echo "Failed to locate ${CMAKE_TOOLCHAIN_FILE}" | ||
exit 1 | ||
fi | ||
|
||
DEVKIT_INFO="${DEVKIT_ROOT}/devkit.info" | ||
if [ ! -f "${DEVKIT_INFO}" ]; then | ||
echo "Failed to locate ${DEVKIT_INFO}" | ||
exit 1 | ||
fi | ||
|
||
. "${DEVKIT_INFO}" | ||
|
||
export PATH="${PATH}:${DEVKIT_EXTRA_PATH}" | ||
|
||
BUILD_NATIVE_DIR="${BUILD_DIR}/native" | ||
BUILD_CROSS_DIR="${BUILD_DIR}/cross" | ||
|
||
mkdir -p "${BUILD_NATIVE_DIR}" | ||
cmake -S . -B "${BUILD_NATIVE_DIR}" | ||
cmake --build "${BUILD_NATIVE_DIR}" -j | ||
|
||
mkdir -p "${BUILD_CROSS_DIR}" | ||
cmake -S . -B "${BUILD_CROSS_DIR}" \ | ||
-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" \ | ||
-DNATIVE_BUILD_DIR="${BUILD_NATIVE_DIR}" \ | ||
-DSLEEF_BUILD_INLINE_HEADERS=TRUE | ||
cmake --build "${BUILD_CROSS_DIR}" -j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## SLEEF v3.6 | ||
|
||
### Notice | ||
``` | ||
Copyright © 2010-2024 SLEEF Project, Naoki Shibata and contributors | ||
``` | ||
|
||
### LICENSE | ||
``` | ||
|
||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this missing line break a mistake or intended? |
||
|
||
``` |
32 changes: 32 additions & 0 deletions
32
src/jdk.incubator.vector/linux/native/libvectormath/README
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Maintenance notes for importing SLEEF source code | ||
|
||
## Motivation | ||
When importing files from SLEEF, please follow below steps. | ||
|
||
## Steps of maintenance | ||
|
||
### Step 1: Clone the SLEEF repository | ||
Location: https://github.com/shibatch/sleef | ||
|
||
### Step 2: Build SLEEF | ||
There's a `make/devkit/createSleef.sh` helper script which can be used to build SLEEF. In particular, it includes cross-compilation functionality. | ||
|
||
If not using the helper script, the build steps can be found here: https://github.com/shibatch/sleef?tab=readme-ov-file#how-to-build-sleef | ||
|
||
NOTE: The following cmake options are necessary when building SLEEF: | ||
* -DSLEEF_BUILD_INLINE_HEADERS=ON | ||
* -DSLEEF_ENFORCE_SVE=ON | ||
|
||
### Step 3: Import the SLEEF files into the JDK | ||
SLEEF source and generated source: | ||
* ${SLEEF_SRC_DIR}/common/misc.h | ||
* ${SLEEF_BUILD_DIR}/include/sleefinline_advsimd.h | ||
* ${SLEEF_BUILD_DIR}/include/sleefinline_sve.h | ||
|
||
JDK target dir: | ||
* ${JDK_SRC_DIR}/jdk.incubator.vector/linux/native/libvectormath/ | ||
|
||
### Step 4: Make necessary changes to resolve any build issues in case there is any | ||
|
||
Currently, the only necessary change is: | ||
* make `Sleef_rempitabdp` and `Sleef_rempitabsp` in sleefinline_advsimd.h and sleefinline_sve.h `static` to avoid multiple definitions. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you'd need a different copy of sleef for each platform? The files you have put in
linux/native/libvectormath
, what platform are they for? Should we not put them in a platform-specific subdirectory?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's one or more.
we could, but not necessary, as long as they have different suffixes, and normally that suffixes indicate what platform it's for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, suffix works fine too. But the files currently in the patch is named e.g.
sleefinline_advsimd.h
, which does not indicate any platform at all. Is it a generic file, and the platform specific ones are still missing from this PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both
sleefinline_advsimd.h
andsleefinline_sve.h
are specific for arm.In the future, on riscv the corresponding file name will be
sleefinline_rvvm1.h
.Only
misc.h
is a generic file shared among platforms.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you mean that the
sve
suffix signals that it is for ARM. I thought you were talking about having a name likesleefinline_aarch64.h
.Sure, if the only files generated by sleef are ever .h files, the logic for chosing which to include can be done entirely by
#ifdef
s in the source code. But if there ever needs to be different .c or .cpp files to include in the build, the build system needs to be able to determine automatically if they should be included or included, and that can only be made if the path or the file name includes the CPU moniker.Personally, I think it would show good alignment with the prevailing norms in the JDK to also use this way of naming files for .h files. But I confess that for .h files it is more a matter of style, rather than a necessity from the build system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the information. I think the files from sleef will be .h headers only. I'm also fine to align with prevailing norms in the JDK, it's always good to do so.
Just a reminder for us in the future discussion of #18605, maybe we should consider this dir or file naming norms (e.g. currently there are vector_math_sve.c and vector_math_neon.c under src/jdk.incubator.vector/linux/native/libvectormath), as there will be more files related to different platforms added in the future, e.g. riscv64.