Skip to content

Commit

Permalink
Add JNI tests
Browse files Browse the repository at this point in the history
Add 8 types of JNI tests to measure JNI call overhead.

Signed-off-by: Nigel Yu <yunigel@ca.ibm.com>
  • Loading branch information
NigelYiboYu committed Jul 25, 2018
1 parent 6dc31d7 commit fe3e787
Show file tree
Hide file tree
Showing 18 changed files with 811 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,3 +21,4 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

77 changes: 77 additions & 0 deletions JNI-test-scripts/linux/build-dll.sh
@@ -0,0 +1,77 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
######

if [[ ! -f $SDK_DIR/bin/java ]]; then
echo "Java not found"
exit -1
fi

echo "Using this Java SDK"
$SDK_DIR/bin/java -version

# HOME_DIR is the root of bumblebench
cd ../../
HOME_DIR=`pwd`

echo Using $HOME_DIR as bumblebench home directory.

rm -f ./*.o
rm -f ./*.so


CPP_DIR="$HOME_DIR/net/adoptopenjdk/bumblebench/jni/c++/"
export INC_PATH=" -I$HOME_DIR -I$CPP_DIR -I$SDK_DIR/include/zos -I$SDK_DIR/include/ "

#
# Generate header files for our JNI Java class
#
$SDK_DIR/bin/javah net.adoptopenjdk.bumblebench.jni.CallOverheadTestcases


#
# Compile the C++ libraries
# Step 1. ascii->ebcdic conversion
#
#
cd $CPP_DIR

echo "Using HOME_DIR $HOME_DIR"
echo "Using JDK_HOME $JDK_HOME"
echo "Clearing old builds"

rm -fv ./*.so
rm -fv ./*.o


CPP_DIR="$HOME_DIR/net/adoptopenjdk/bumblebench/jni/c++/"
cd $CPP_DIR

rm -f ./*.o
rm -f ./*.so

mv $HOME_DIR/*.h $CPP_DIR/


CPP_FILES=`find . | grep '\.cpp' | tr '\n' ' '`

CXXFLAGS="-shared -v -fPIC -std=c++11 -O1"
INC_PATH="-I$CPP_DIR -I$JDK_HOME/include/ -I$JDK_HOME/include/linux "


# use g++. gcc requires -lstdc++
g++ $CXXFLAGS -o libjnibench.so $INC_PATH $CPP_FILES

mv $CPP_DIR/*.so $HOME_DIR/

cd $HOME_DIR
50 changes: 50 additions & 0 deletions JNI-test-scripts/linux/run-JNI-test
@@ -0,0 +1,50 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
######

if [[ ! -f $SDK_DIR/bin/java ]]; then
echo "Java not found"
exit -1
fi


JAVA=$SDK_DIR/bin/java

echo "Using this Java"
$JAVA -version


##########################################################
# use bumblebench directory as test home dir
##########################################################
cd ../..
HOME_DIR=`pwd`

#
# set up library path for z/OS
#
export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH

# run all the testcases
# Add -DBumbleBench.listOptions to see all available options
$JAVA -jar BumbleBench.jar NoParamNoRetBench

$JAVA -jar BumbleBench.jar ParamNoRetBench

$JAVA -jar BumbleBench.jar ParamAndRetBench

$JAVA -jar BumbleBench.jar SetLongFieldBench

$JAVA -jar BumbleBench.jar SetStaticLongFieldBench

$JAVA -jar BumbleBench.jar ArrayReadWriteRegionBench
1 change: 1 addition & 0 deletions JNI-test-scripts/win/build-dll.sh
@@ -0,0 +1 @@
# NOT IMPLEMENTED
98 changes: 98 additions & 0 deletions JNI-test-scripts/zos/build-dll.sh
@@ -0,0 +1,98 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
######

if [[ ! -f $SDK_DIR/bin/java ]]; then
echo "Java not found"
exit -1
fi

echo "Using this Java SDK"
$SDK_DIR/bin/java -version

# HOME_DIR is the root of bumblebench
cd ../../
HOME_DIR=`pwd`

echo Using $HOME_DIR as bumblebench home directory.

rm -f ./*.o
rm -f ./*.so


CPP_DIR="$HOME_DIR/net/adoptopenjdk/bumblebench/jni/c++/"
export INC_PATH=" -I$HOME_DIR -I$CPP_DIR -I$SDK_DIR/include/zos -I$SDK_DIR/include/ "

#
# Generate header files for our JNI Java class
#
$SDK_DIR/bin/javah net.adoptopenjdk.bumblebench.jni.CallOverheadTestcases


#
# Compile the C++ libraries
# Step 1. ascii->ebcdic conversion
#
#
cd $CPP_DIR

rm -f ./*.so
rm -f ./*.o
rm -f ./*.asmlist

CPP_FILES=`find . | grep '\.cpp' | tr '\n' ' '`

if [[ ! -f "EBCDIC_DONE" ]]; then
iconv -fISO8859-1 -tIBM-1047 CallOverheadTestcases.cpp > CallOverheadTestcases.cpp-ebc
iconv -fISO8859-1 -tIBM-1047 Portal.h > Portal.h-ebc
rm -f Portal.h CallOverheadTestcases.cpp
mv Portal.h-ebc Portal.h
mv CallOverheadTestcases.cpp-ebc CallOverheadTestcases.cpp
touch EBCDIC_DONE
fi

mv $HOME_DIR/*.h $CPP_DIR/

#
# Compile the C++ libraries
# Step 2. compile
#
#
# make a Std non-xplink JNI benchmark DLL
#
#
# NOTE: xlc can't handle files with the same name. Hence, the **JavaObject.cpp file names.
#
echo "Making 32-bit standard non-xplink JNI benchmark DLL"
export CXXFLAGS="-qlist=no-xplink.asmlist -Dnullptr=NULL -Wc,convlit(ISO8859-1) -Wc,NOANSIALIAS -q32 -Wc,noxplink -O -qlanglvl=extended0x -Wc,DLL,EXPORTALL -Wa,DLL -Wc,ARCH(7) -Wc,TUNE(10) "
xlC $CXXFLAGS -o libstdlinkjnibench.so $INC_PATH $CPP_FILES


echo "Making 32-bit xplink JNI benchmark DLL"
export CXXFLAGS="-qlist=xplink32.asmlist -Dnullptr=NULL -Wc,convlit(ISO8859-1) -Wc,NOANSIALIAS -q32 -Wc,xplink -O -qlanglvl=extended0x -Wc,DLL,EXPORTALL -Wa,DLL -Wc,ARCH(7) -Wc,TUNE(10) "
xlC $CXXFLAGS -o libxplinkjnibench31.so $INC_PATH $CPP_FILES


echo "Making 64-bit xplink JNI benchmark DLL"
rm -f ./*.o
export CXXFLAGS=" -qlist=xplink64.asmlist -Dnullptr=NULL -Wc,convlit(ISO8859-1) -Wc,NOANSIALIAS -Wc,xplink -Wc,lp64 -O -qlanglvl=extended0x -Wc,DLL,EXPORTALL -Wa,DLL -Wc,ARCH(7) -Wc,TUNE(10) "
xlC $CXXFLAGS -o libxplinkjnibench64.so $INC_PATH $CPP_FILES



#
#
# Move all DLL to bumblebench home directory
#
mv $CPP_DIR/*.so $HOME_DIR/
cd $HOME_DIR
45 changes: 45 additions & 0 deletions JNI-test-scripts/zos/run-JNI-test.sh
@@ -0,0 +1,45 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
######

JAVA=$SDK_DIR/bin/java


#
# use bumblebench directory as test home dir
cd ../..
HOME_DIR=`pwd`

#
# z/OS specific. Default to test 64-bit
#
cp -f libxplinkjnibench64.so libjnibench.so

#
# set up library path for z/OS
#
export LIBPATH=./:$LIBPATH


# Add -DBumbleBench.listOptions to see all available options
$JAVA -jar BumbleBench.jar NoParamNoRetBench

$JAVA -jar BumbleBench.jar ParamNoRetBench

$JAVA -jar BumbleBench.jar ParamAndRetBench

$JAVA -jar BumbleBench.jar SetLongFieldBench

$JAVA -jar BumbleBench.jar SetStaticLongFieldBench

$JAVA -jar BumbleBench.jar ArrayReadWriteRegionBench

0 comments on commit fe3e787

Please sign in to comment.