Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions make/devkit/createSleef.sh
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
35 changes: 35 additions & 0 deletions src/jdk.incubator.vector/linux/legal/sleef.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## SLEEF v3.6.1

### 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.

```
41 changes: 41 additions & 0 deletions src/jdk.incubator.vector/linux/native/libvectormath/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-DSLEEF_ENFORCE_SVE=ON can be removed.


### Step 3: Import the SLEEF files into the JDK

SLEEF source:

* ${SLEEF_SRC_DIR}/common/misc.h

Generated files (aarch64):

* ${SLEEF_BUILD_DIR}/include/sleefinline_advsimd.h
* ${SLEEF_BUILD_DIR}/include/sleefinline_sve.h

Generated files (riscv64):

* ${SLEEF_BUILD_DIR}/include/sleefinline_rvvm1.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.
Comment on lines +37 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines can be removed now.

Loading