1#!/bin/bash 2# Copyright 2021 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 if [[ "X$DEVICE" == "Xgpu" ]]; then 30 export ENABLE_GPU="on" 31 ENABLE_CPU="on" 32 ENABLE_MPI="on" 33 # version default 10.1 34 if [[ "X$DEVICE_VERSION" == "X" ]]; then 35 DEVICE_VERSION=10.1 36 fi 37 if [[ "X$DEVICE_VERSION" != "X11.1" && "X$DEVICE_VERSION" != "X10.1" ]]; then 38 echo "Invalid value ${DEVICE_VERSION} for option -V" 39 usage 40 exit 1 41 fi 42 export CUDA_VERSION="$DEVICE_VERSION" 43 elif [[ "X$DEVICE" == "Xd" || "X$DEVICE" == "Xascend" ]]; then 44 # version default 910 45 if [[ "X$DEVICE_VERSION" == "X" ]]; then 46 DEVICE_VERSION=910 47 fi 48 # building 310 package by giving specific -V 310 instruction 49 if [[ "X$DEVICE_VERSION" == "X310" ]]; then 50 ENABLE_ACL="on" 51 # universal ascend package 52 elif [[ "X$DEVICE_VERSION" == "X910" ]]; then 53 export ENABLE_D="on" 54 export ENABLE_ACL="on" 55 ENABLE_CPU="on" 56 export ENABLE_MPI="on" 57 else 58 echo "Invalid value ${DEVICE_VERSION} for option -V" 59 usage 60 exit 1 61 fi 62 elif [[ "X$DEVICE" == "Xcpu" ]]; then 63 export ENABLE_CPU="on" 64 elif [[ "X$DEVICE" == "X" ]]; then 65 : 66 else 67 echo "Invalid value ${DEVICE} for option -e" 68 usage 69 exit 1 70 fi 71}