1 #!/bin/bash 2 cat >/dev/null<<LICENSE 3 /* 4 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. 5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 * 7 * This code is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License version 2 only, as 9 * published by the Free Software Foundation. Oracle designates this 10 * particular file as subject to the "Classpath" exception as provided 11 * by Oracle in the LICENSE file that accompanied this code. 12 * 13 * This code is distributed in the hope that it will be useful, but WITHOUT 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 * version 2 for more details (a copy is included in the LICENSE file that 17 * accompanied this code). 18 * 19 * You should have received a copy of the GNU General Public License version 20 * 2 along with this work; if not, write to the Free Software Foundation, 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 * 23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 24 * or visit www.oracle.com if you need additional information or have any 25 * questions. 26 */ 27 LICENSE 28 29 30 31 if [ $# -eq 0 ]; then 32 echo 'usage:' 33 echo ' bash hatrun.bash [headless] backend package args ...' 34 echo ' headless : Optional passes -Dheadless=true to app' 35 echo ' backend : native-opencl|native-cuda|native-hip|native-spirv|native-ptx|native-mock|java-mt|java-seq' 36 echo ' package : the examples package (and dirname under hat/examples)' 37 echo ' Class name is assumed to be package.Main ' 38 elif [[ -d build ]] ; then 39 export OPTS="" 40 export VMOPTS="" 41 export JARS="" 42 43 export VMOPTS="${VMOPTS} --add-modules jdk.incubator.code" 44 export VMOPTS="${VMOPTS} --enable-preview" 45 export VMOPTS="${VMOPTS} --enable-native-access=ALL-UNNAMED" 46 export VMOPTS="${VMOPTS} --add-exports=java.base/jdk.internal=ALL-UNNAMED" 47 48 export HEADLESS="${1}" 49 if [[ "${HEADLESS}" = "headless" ]] ; then 50 echo HEADLESS=${HEADLESS} 51 shift 1 52 export OPTS="${OPTS} -Dheadless=true" 53 else 54 echo "Not headless" 55 fi 56 57 export BACKEND="${1}" 58 echo BACKEND=${BACKEND} 59 export BACKEND_JAR=build/hat-backend-${BACKEND}-1.0.jar 60 61 export JARS=build/hat-1.0.jar 62 echo BACKEND_JAR=${BACKEND_JAR} 63 if [[ ! -f ${BACKEND_JAR} ]] ;then 64 echo "no backend ${BACKEND_JAR}" 65 exit 1 66 fi 67 export JARS=${JARS}:${BACKEND_JAR} 68 if [[ "$1" = "spirv" ]] ;then 69 export JARS=${JARS}:build/levelzero.jar:build/beehive-spirv-lib-0.0.4.jar; 70 fi 71 export OPTS="${OPTS} -Djava.library.path=build:/usr/local/lib" 72 shift 1 73 74 export EXAMPLE="${1}" 75 echo EXAMPLE=${EXAMPLE} 76 export EXAMPLE_JAR=build/hat-example-${EXAMPLE}-1.0.jar 77 if [[ -f ${EXAMPLE_JAR} ]] ;then 78 export JARS=${JARS}:${EXAMPLE_JAR} 79 shift 1 80 else 81 echo "no example ${EXAMPLE_JAR}" 82 exit 1 83 fi 84 echo JARS=${JARS} 85 echo VMOPTS=${VMOPTS} 86 echo OPTS=${OPTS} 87 echo java \${VMOPTS} \${OPTS} --class-path \${JARS} \${EXAMPLE}.Main $* 88 echo java ${VMOPTS} ${OPTS} --class-path ${JARS} ${EXAMPLE}.Main $* 89 java ${VMOPTS} ${OPTS} --class-path ${JARS} ${EXAMPLE}.Main $* 90 else 91 echo No build dir 92 exit 1 93 fi