Changeset 124 for trunk/IPs/systemC/processor/Morpheo/Script
- Timestamp:
- Jun 17, 2009, 2:11:25 PM (16 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Script
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Script/distexe.sh
r112 r124 4 4 # $Id$ 5 5 #----------------------------------------------------------- 6 7 VERSION="1.0" 6 8 7 9 # Need : test, echo, cd, dirname, basename, ssh … … 39 41 } 40 42 43 #-----[ my_date ]------------------------------------------- 44 function my_date () 45 { 46 date +"%F %T"; 47 } 48 41 49 #-----[ distexe_test_usage ]-------------------------------- 42 50 function distexe_test_usage () … … 67 75 fi; 68 76 fi; 77 } 69 78 79 #-----[ header ]-------------------------------------------- 80 function header () 81 { 82 echo "distexe ${VERSION}"; 70 83 } 71 84 … … 80 93 cd -; 81 94 82 # Abso ulte path of work directory83 local DIR_EXE;95 # Absolute path of work directory 96 local PATH_EXE; 84 97 if test ${#} -eq 2; then 85 cd ${2} ;86 DIR_EXE=${PWD};87 cd - ;98 cd ${2} &> /dev/null; 99 PATH_EXE=${PWD}; 100 cd - &> /dev/null; 88 101 else 89 DIR_EXE=${PWD};102 PATH_EXE=${PWD}; 90 103 fi; 104 105 header; 106 echo " * {"$(my_date)"} <${HOSTNAME}> file : ${FILE_CMD}"; 107 echo " * {"$(my_date)"} <${HOSTNAME}> path : ${PATH_EXE}"; 91 108 92 109 local hosts="${DISTEXE_HOSTS}"; … … 96 113 local -i nb_process=$(echo ${line} | cut -d/ -f2); 97 114 98 echo " *station : ${host} (${nb_process}) ... ";115 echo " * {"$(my_date)"} <${HOSTNAME}> station : ${host} (${nb_process}) ... "; 99 116 100 117 # lunch service 101 local cmd="export MORPHEO_SCRIPT=${MORPHEO_SCRIPT};${MORPHEO_SCRIPT}/execute_n.sh ${ DIR_EXE} ${FILE_CMD} ${nb_process};";118 local cmd="export MORPHEO_SCRIPT=${MORPHEO_SCRIPT};${MORPHEO_SCRIPT}/execute_n.sh ${PATH_EXE} ${FILE_CMD} ${nb_process};"; 102 119 ssh ${host} ${cmd} & 103 120 done; 121 122 echo " * {"$(my_date)"} <${HOSTNAME}> all hosts working"; 123 104 124 } 105 125 -
trunk/IPs/systemC/processor/Morpheo/Script/execute.sh
r112 r124 28 28 function execute_usage () 29 29 { 30 echo "Usage : ${0} work_dir file_cmd file_cpt file_cpu";30 echo "Usage : ${0} path_work file_cmd file_cpt file_cpu id"; 31 31 echo "Arguments : "; 32 echo " * work_dir: directory to execute command";32 echo " * path_work : directory to execute command"; 33 33 echo " * file_cmd : list of command"; 34 34 echo " * file_cpt : file with the index of next command to execute"; 35 35 echo " * file_cpu : tmp file to stock the current index"; 36 echo " * id : identification"; 36 37 exit; 37 38 } … … 40 41 function execute_test_usage () 41 42 { 42 if test ${#} -ne 4; then43 if test ${#} -ne 5; then 43 44 execute_usage; 44 45 fi; … … 58 59 local -i CPT_OLD; 59 60 local -i CPT; 60 local WORK_DIR=${1};61 local PATH_WORK=${1}; 61 62 local FILE_CMD=${2}; 62 63 local FILE_CPT=${3}; 63 64 local FILE_CPU=${4}; 64 local LOCK_CPT="${WORK_DIR}/.lock-cpt"; 65 local LOCK_CPU="${WORK_DIR}/.lock-cpu"; 66 local FILE_CMD="distexe.command"; 67 local FILE_OUT="distexe.output"; 65 local ID=${5}; 66 local LOCK_CPT="${PATH_WORK}/.lock-cpt"; 67 local LOCK_CPU="${PATH_WORK}/.lock-cpu"; 68 local OUTPUT_FILE_INFO="distexe.info"; 69 local OUTPUT_FILE_CMD="distexe.command"; 70 local OUTPUT_FILE_OUT="distexe.output"; 68 71 72 # echo " * {"$(my_date)"} <${ID}> pid is $$"; 69 73 70 74 # Init CPT if this thread is the first 71 75 lock ${LOCK_CPT}; 72 76 if test ! -s ${FILE_CPT}; then 77 echo " * {"$(my_date)"} <${ID}> create counter file ${FILE_CPT}"; 73 78 echo "0" > ${FILE_CPT}; 74 79 fi; … … 83 88 done < ${FILE_CMD}; 84 89 85 echo " * <${HOSTNAME}-$$> {"$(my_date)"}is ready";90 echo " * {"$(my_date)"} <${ID}> is ready"; 86 91 87 92 # infinite loop … … 99 104 unlock ${LOCK_CPT}; 100 105 101 106 # test if this number is valid 102 107 if test ${CPT} -ge ${#COMMAND[*]}; then 103 108 CPT=${#COMMAND[*]}; … … 110 115 # while test ${CPT}_SYNC -lt ${CPT}; do 111 116 # if test -z "${COMMAND[${CPT}_SYNC]}"; then 112 # echo " * <${HOSTNAME}-$$> {"$(my_date)"}synchronisation [${CPT}_SYNC]";117 # echo " * {"$(my_date)"} <${ID}> synchronisation [${CPT}_SYNC]"; 113 118 # fi; 114 119 # CPT_SYNC=$((${CPT}_SYNC+1)); … … 122 127 # Test if command is empty ! 123 128 if test ! -z "${COMMAND[${CPT}]}"; then 124 local CURREN_DIR=${PWD};125 cd ${ WORK_DIR}&> /dev/null;129 local PATH_CURRENT=${PWD}; 130 cd ${PATH_WORK} &> /dev/null; 126 131 mkdir "Task_${CPT}" &> /dev/null; 127 132 cd "Task_${CPT}" &> /dev/null; 128 echo " * <${HOSTNAME}-$$> {"$(my_date)"} execute command [${CPT}] : ${COMMAND[${CPT}]}"; 129 echo "${COMMAND[${CPT}]}" > ${FILE_CMD}; 130 # chmod +x ${FILE_CMD}; 131 eval "${COMMAND[${CPT}]}" &> ${FILE_OUT}; 132 cd ${CURREN_DIR} &> /dev/null; 133 # echo " * {"$(my_date)"} <${ID}> execute command [${CPT}] : ${COMMAND[${CPT}]}"; 134 echo " * {"$(my_date)"} <${ID}> execute command [${CPT}]"; 135 echo "id : ${ID}" > ${OUTPUT_FILE_INFO}; 136 echo "host : ${HOSTNAME}" >> ${OUTPUT_FILE_INFO}; 137 echo "pid : $$" >> ${OUTPUT_FILE_INFO}; 138 echo "date : "$(my_date) >> ${OUTPUT_FILE_INFO}; 139 echo "#!/bin/bash" > ${OUTPUT_FILE_CMD}; 140 echo 'source ${HOME}/.bashrc;' >> ${OUTPUT_FILE_CMD}; 141 echo "${COMMAND[${CPT}]}" >> ${OUTPUT_FILE_CMD}; 142 chmod +x ${OUTPUT_FILE_CMD}; 143 ./${OUTPUT_FILE_CMD} &> ${OUTPUT_FILE_OUT}; 144 cd ${PATH_CURRENT} &> /dev/null; 133 145 fi; 134 146 done; 135 147 136 echo " * <${HOSTNAME}-$$> {"$(my_date)"}is done";148 echo " * {"$(my_date)"} <${ID}> is done"; 137 149 138 150 lock ${LOCK_CPU}; … … 143 155 144 156 if test ${CPT} -eq 0; then 145 echo " * <${HOSTNAME}-$$> {"$(my_date)"} All task is executed";157 echo " * {"$(my_date)"} <${ID}> All task is executed on this host"; 146 158 rm ${FILE_CPU}; 147 159 fi; -
trunk/IPs/systemC/processor/Morpheo/Script/execute_n.sh
r112 r124 5 5 #----------------------------------------------------------- 6 6 7 #-----[ global variable ]----------------------------------- 7 #-----[ my_date ]------------------------------------------- 8 function my_date () 9 { 10 date +"%F %T"; 11 } 8 12 9 13 #-----[ nb_cpu ]-------------------------------------------- … … 23 27 function execute_n_usage () 24 28 { 25 echo "Usage : ${0} word_dirfile [ nb_process ]";29 echo "Usage : ${0} path_word file [ nb_process ]"; 26 30 echo "Arguments : "; 27 echo " * work_dir: directory to execute command";31 echo " * path_work : directory to execute command"; 28 32 echo " * file : list of command"; 29 33 echo " * nb_process : number of process (default (and maximum) is the number of processor)"; … … 51 55 if test -z "${MORPHEO_SCRIPT}"; then 52 56 echo "Environment variable MORPHEO_SCRIPT is not set"; 53 distexe_usage;57 execute_n_usage; 54 58 fi; 55 59 … … 70 74 local -i NB_PROCESS=$(nb_cpu); 71 75 local -i CPT; 72 local WORK_DIR=${1};76 local PATH_WORK=${1}; 73 77 local FILE_CMD=${2}; 74 78 local FILE_CPT; … … 78 82 execute_n_test_usage ${*}; 79 83 80 if test ${#} -eq 2; then84 if test ${#} -eq 3; then 81 85 if test ${3} -lt ${NB_PROCESS}; then 82 86 NB_PROCESS=${3}; 83 fi; 87 fi; 84 88 fi; 85 89 86 FILE_CPT="${ WORK_DIR}/control-"$(basename ${FILE_CMD});87 FILE_CPU="${ WORK_DIR}/${ID}";90 FILE_CPT="${PATH_WORK}/control-"$(basename ${FILE_CMD}); 91 FILE_CPU="${PATH_WORK}/${ID}"; 88 92 89 echo " * <${HOSTNAME}> ${NB_PROCESS} process";93 echo " * {"$(my_date)"} <${HOSTNAME}> ${NB_PROCESS} process"; 90 94 91 95 local -i IT_NB_PROCESS=1; … … 96 100 # create the same number of thread that processor 97 101 while test ${IT_NB_PROCESS} -le ${NB_PROCESS}; do 98 ${MORPHEO_SCRIPT}/execute.sh ${ WORK_DIR} ${FILE_CMD} ${FILE_CPT} ${FILE_CPU}&102 ${MORPHEO_SCRIPT}/execute.sh ${PATH_WORK} ${FILE_CMD} ${FILE_CPT} ${FILE_CPU} "${HOSTNAME}-${IT_NB_PROCESS}" & 99 103 IT_NB_PROCESS=$((${IT_NB_PROCESS}+1)); 100 104 … … 103 107 fi; 104 108 done 109 110 echo " * {"$(my_date)"} <${HOSTNAME}> all process working"; 105 111 } 106 112
Note: See TracChangeset
for help on using the changeset viewer.