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# ============================================================================ 16set -e 17BASE_PATH=$( 18 cd "$(dirname $0)" 19 pwd 20) 21CONFIG_PATH=/home/workspace/mindspore_config 22export DEVICE_NUM=8 23export RANK_SIZE=$DEVICE_NUM 24source ${BASE_PATH}/env_hcom.sh 25unset SLOG_PRINT_TO_STDOUT 26export MINDSPORE_HCCL_CONFIG_PATH=$CONFIG_PATH/hccl/rank_table_${DEVICE_NUM}p.json 27 28process_pid=() 29for ((i = 0; i < $DEVICE_NUM; i++)); do 30 rm -rf ${BASE_PATH}/hcom_sparsetensor${i} 31 mkdir ${BASE_PATH}/hcom_sparsetensor${i} 32 cp -r ${BASE_PATH}/hcom_sparsetensor.py ${BASE_PATH}/hcom_sparsetensor${i}/ 33 cd ${BASE_PATH}/hcom_sparsetensor${i} 34 export RANK_ID=${i} 35 export DEVICE_ID=${i} 36 echo "start training for device $i" 37 env >env$i.log 38 pytest -s -v hcom_sparsetensor.py >test_hcom_sparsetensor_8p_log$i.log 2>&1 & 39 process_pid[${i}]=$(echo $!) 40done 41 42for ((i = 0; i < ${DEVICE_NUM}; i++)); do 43 wait ${process_pid[i]} 44 status=$(echo $?) 45 if [ "${status}" != "0" ]; then 46 echo "[ERROR] test_hcom_sparsetensor failed. status: ${status}" 47 exit 1 48 else 49 echo "[INFO] test_hcom_sparsetensor success." 50 fi 51done 52 53exit 0 54