1#!/bin/bash 2# Copyright 2021-2022 Huawei Technologies Co., Ltd 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================ 16 17set -e 18 19# check and set options 20parse_device() 21{ 22 if [[ "X$RUN_TESTCASES" == "Xon" && "X$DEVICE" != "X" ]]; then 23 echo "WARNING:Option -e can't be set while option -t on/ut is set, reset device to empty." 24 DEVICE="" 25 fi 26 27 # Parse device 28 # Process build option 29 export IFS_ORIGIN=$IFS 30 export IFS=":" 31 for D in $DEVICE; 32 do 33 if [[ "X$D" == "Xgpu" ]]; then 34 export ENABLE_GPU="on" 35 export GPU_BACKEND="cuda" 36 ENABLE_CPU="on" 37 ENABLE_MPI="on" 38 # version default 10.1 39 if [[ "X$DEVICE_VERSION" == "X" ]]; then 40 DEVICE_VERSION=10.1 41 fi 42 if [[ "X$DEVICE_VERSION" != "X11.6" && "X$DEVICE_VERSION" != "X11.1" && "X$DEVICE_VERSION" != "X10.1" ]]; then 43 echo "Invalid value ${DEVICE_VERSION} for option -V" 44 usage 45 exit 1 46 fi 47 export CUDA_VERSION="$DEVICE_VERSION" 48 export DEVICE_VERSION= 49 elif [[ "X$D" == "Xrocm" ]]; then 50 export ENABLE_GPU="on" 51 export GPU_BACKEND="rocm" 52 ENABLE_CPU="on" 53 ENABLE_MPI="on" 54 export ENABLE_AKG="off" 55 elif [[ "X$D" == "Xd" || "X$D" == "Xascend" ]]; then 56 # version default 910 57 if [[ "X$DEVICE_VERSION" == "X" ]]; then 58 DEVICE_VERSION=910 59 fi 60 # building 310 package by giving specific -V 310 instruction 61 if [[ "X$DEVICE_VERSION" == "X310" ]]; then 62 ENABLE_ACL="on" 63 export ENABLE_AKG="off" 64 # universal ascend package, building 910b package by giving specific -V 910b instruction 65 elif [[ "X$DEVICE_VERSION" == "X910" || "X$DEVICE_VERSION" == "X910b" ]]; then 66 export ENABLE_D="on" 67 export ENABLE_ACL="on" 68 ENABLE_CPU="on" 69 export ENABLE_MPI="on" 70 export ENABLE_INTERNAL_KERNELS="on" 71 export ASCEND_GLOBAL_LOG_LEVEL=3 72 export ASCEND_SLOG_PRINT_TO_STDOUT=1 73 else 74 echo "Invalid value ${DEVICE_VERSION} for option -V" 75 usage 76 exit 1 77 fi 78 export DEVICE_VERSION= 79 elif [[ "X$D" == "Xcpu" ]]; then 80 export ENABLE_CPU="on" 81 export ENABLE_MPI="on" 82 elif [[ "X$D" == "X" ]]; then 83 : 84 else 85 echo "Invalid value ${DEVICE} for option -e" 86 usage 87 exit 1 88 fi 89 done 90 export IFS=$IFS_ORIGIN 91 if [[ "X$ENABLE_AKG" == "Xon" && "X$ENABLE_D" != "Xon" && "X$ENABLE_CPU" == "Xon" ]]; then 92 # check llvm version for akg 93 HAS_LLVM=`bash ${BASEPATH}/scripts/build/akg_find_llvm.sh` 94 export USE_LLVM=$HAS_LLVM 95 fi 96 export ENABLE_DVM="off" 97 source ${BASEPATH}/scripts/build/check_binary_file.sh 98 if [[ "X$ENABLE_INTERNAL_KERNELS" == "Xon" ]]; then 99 source ${BASEPATH}/scripts/build/check_and_build_ms_kernels_internal.sh 100 fi 101} 102