Changeset 138 for trunk/IPs/systemC/processor/Morpheo/Script
- Timestamp:
- May 12, 2010, 7:34:01 PM (15 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Script
- Files:
-
- 8 added
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Script/distexe.sh
r128 r138 5 5 #----------------------------------------------------------- 6 6 7 declare VERSION="1.0" 8 declare -i SLEEP=3 9 10 # Need : test, echo, cd, dirname, basename, ssh, ps aux 7 #-----[ global variable ]----------------------------------- 8 declare VERSION="1.3" 9 declare -i SLEEP=2; 10 declare -i TRAP=0; 11 12 # Need : test, echo, cd, dirname, basename, ssh, ps aux, ls, wc, sed 13 # lock.sh, unlock.sh, date.sh, nb_cpu.sh, distexe_execute_n.sh, distexe_execute.sh 11 14 12 15 #-----[ distexe_usage ]------------------------------------- … … 23 26 echo " A line can content many shell command."; 24 27 echo " Don't forgot the final end of line (else the last command is not executed)"; 25 echo " example : "; 28 echo " * For each command, a directory (in work directory) is created : Task_X (X is the number of line in command file)."; 29 echo " The command is execute in this directory. (Warning, set your environment ! but we source .bashrc)."; 30 echo " Three file is generate :"; 31 echo " - \"distexe.info\" content information as host, pid ..."; 32 echo " - \"distexe.output\" is the output (standard and error) of the execution"; 33 echo " - \"distexe.command\" is the command launch."; 34 # echo " * A command empty (no command on a line of file) is a synchronisation with all process" 35 echo " * The environment variable DISTEXE_HOSTS list hosts to execute command"; 36 echo " After each host, a number is to the number of process. It's optionnal, the default value is the number of processor."; 37 echo " * All hosts must have network file systems (per example nfs or samba)"; 38 echo " Work directory must be in this network file systems !"; 39 echo ""; 40 echo "Example : "; 41 echo " # Create command file"; 26 42 echo ' echo "export PATH=${PATH}:${HOME}/my_appli/bin; my_appli 13" > command_file.txt'; 27 43 echo ' echo "export PATH=${PATH}:${HOME}/my_appli/bin; my_appli 21" >> command_file.txt'; 28 44 echo ' echo "export PATH=${PATH}:${HOME}/my_appli/bin; my_appli 7" >> command_file.txt'; 29 echo ' echo "" >> command_file.txt'; 30 echo " * For each command, a directory (in work directory) is created : Task_X (X is the number of line in command file)."; 31 echo " The command is execute in this directory. (Warning, set your environment !)."; 32 echo " Two file is generate : \"distexe.output\" is the output (standard and error) of the execution, and \"distexe.command\" is the command lunch."; 33 # echo " * A command empty (no command on a line of file) is a synchronisation with all process" 34 echo " * The environment variable DISTEXE_HOSTS list hosts to execute command"; 35 echo " After each host, a number is to the number of process. It's optionnal, the default value is the number of processor."; 36 echo " example :"; 45 echo ' echo "" >> command_file.txt'; 46 echo " # Set hosts list variable"; 37 47 echo ' export DISTEXE_HOSTS="localhost/1 nod/4 gdi/2"'; 38 echo " * All hosts must have network file systems (per example nfs or samba)";39 echo " Work directory must be in this network file systems !";40 echo ""; 48 echo " # Execute distexe"; 49 echo " ${0} command_file.txt;"; 50 41 51 exit; 42 }43 44 #-----[ my_date ]-------------------------------------------45 function my_date ()46 {47 date +"%F %T";48 52 } 49 53 … … 81 85 function header () 82 86 { 83 echo "distexe ${VERSION}"; 87 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> =========================================="; 88 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> distexe ${VERSION}"; 89 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> =========================================="; 90 } 91 92 #-----[ distexe_wait_end ]---------------------------------- 93 function distexe_wait_end() 94 { 95 while true; do 96 97 nb_file=$(ls -1 ${PREFIX_FILE_HOST}* 2>/dev/null| wc -l); 98 99 if test ${nb_file} -eq 0; then 100 break; 101 fi; 102 103 # wait (to not have 100% cpu) 104 sleep ${SLEEP}; 105 done; 106 107 rm -f ${FILE_CPT}; 108 }; 109 110 #-----[ distexe_no_trap ]----------------------------------- 111 function distexe_no_trap() 112 { 113 TRAP=1; 114 } 115 116 #-----[ distexe_trap ]-------------------------------------- 117 function distexe_trap() 118 { 119 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> Trap signal detected"; 120 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> !!!!!!!!!!!!!!!! Trap signal detected !!!!!!!!!!!!!!!!"; 121 122 local -a files_host=($(ls ${PREFIX_FILE_HOST}* 2>/dev/null)); 123 local -i nb_files_host=${#files_host[*]}; 124 125 if test ${nb_files_host} -ne 0; then 126 for file_host in ${files_host[*]}; do 127 128 local host=$(basename ${file_host} |sed s/$(basename ${PREFIX_FILE_HOST})//); 129 130 # ssh can not set yet pid in file_host 131 local -i nb_word=0; 132 while test ${nb_word} -eq 0; do 133 nb_word=$(echo ${file_host} |wc -m); 134 done; 135 136 ${MORPHEO_SCRIPT}/lock.sh ${LOCK_HOST}; 137 138 if test -f ${file_host}; then 139 local cmd="kill -s SIGINT $(cat ${file_host})"; 140 ssh ${host} ${cmd}; 141 fi; 142 143 ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_HOST}; 144 done; 145 fi; 146 147 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> >>>>>>>>>>>>>>>> Trap signal detected >>>>>>>>>>>>>>>>"; 148 149 distexe_wait_end; 150 151 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> ################ Trap signal detected ################"; 152 153 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> an error occure"; 154 exit 1; 84 155 } 85 156 … … 87 158 function distexe () 88 159 { 160 trap distexe_no_trap INT TERM; 161 89 162 distexe_test_usage ${*}; 90 163 … … 104 177 fi; 105 178 106 local FILE_CPT="${PATH_EXE}/control-"$(basename ${FILE_CMD}); 107 179 local FILE_CPT="${PATH_EXE}/distexe-control-"$(basename ${FILE_CMD}); 180 local LOCK_HOST="${PATH_EXE}/distexe-host-lock"; 181 local PREFIX_FILE_HOST="${PATH_EXE}/distexe-host-"; 182 local PREFIX_FILE_PROCESS="${PATH_EXE}/distexe-process-"; 183 local hosts="${DISTEXE_HOSTS}"; 184 108 185 header; 109 186 110 echo " * {"$(my_date)"} <${HOSTNAME}> file : ${FILE_CMD}"; 111 echo " * {"$(my_date)"} <${HOSTNAME}> path : ${PATH_EXE}"; 112 echo " * {"$(my_date)"} <${HOSTNAME}> sleep : ${SLEEP}"; 113 114 local hosts="${DISTEXE_HOSTS}"; 115 local -a commands; 116 local -i cpt=0; 187 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> file : ${FILE_CMD}"; 188 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> path : ${PATH_EXE}"; 189 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> sleep : ${SLEEP}"; 190 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> hosts : ${hosts}"; 117 191 118 192 for line in ${hosts}; do … … 120 194 local -i nb_process=$(echo ${line} | cut -d/ -f2); 121 195 122 echo " * {"$(my_date)"} <${HOSTNAME}> station : ${host} (${nb_process}) ... ";123 124 196 # lunch service 125 local cmd="export MORPHEO_SCRIPT=${MORPHEO_SCRIPT};${MORPHEO_SCRIPT}/execute_n.sh ${PATH_EXE} ${FILE_CMD} ${FILE_CPT} ${nb_process};"; 126 ssh ${host} ${cmd} & 127 128 commands[${cpt}]="${cmd}"; 129 cpt=$((${cpt}+1)); 197 local FILE_HOST=${PREFIX_FILE_HOST}'${HOSTNAME}'; 198 199 local valid=$(ssh ${host} "if test -f ${FILE_HOST}; then echo \"ko\"; else touch ${FILE_HOST}; echo \"ok\"; fi"); 200 201 if test ${valid} = "ok"; then 202 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> station : ${host} (${nb_process} process(es))"; 203 204 local cmd="export MORPHEO_SCRIPT=${MORPHEO_SCRIPT};. ${MORPHEO_SCRIPT}/distexe_execute_n.sh ${PATH_EXE} ${FILE_CMD} ${FILE_CPT} ${FILE_HOST} ${LOCK_HOST} ${PREFIX_FILE_PROCESS} ${SLEEP} ${nb_process};"; 205 206 ssh ${host} ${cmd} & 207 else 208 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> station \"${host}\" is already used"; 209 fi; 130 210 done; 131 211 132 echo " * {"$(my_date)"} <${HOSTNAME}> all hosts working"; 133 134 cpt=0; 135 while test ${cpt} -lt ${#commands[*]}; do 136 local -i res=1 137 138 while true; do 139 res=$(ps aux | grep -c "${commands[${cpt}]}"); 140 141 if test ${res} -eq 0; then 142 break; 143 fi; 144 145 # wait (to not have 100% cpu) 146 sleep ${SLEEP}; 147 done 148 149 cpt=$((${cpt}+1)); 150 done; 151 152 echo " * {"$(my_date)"} <${HOSTNAME}> all hosts is done"; 153 rm ${FILE_CPT}; 212 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> all hosts working"; 213 214 trap distexe_trap INT TERM; 215 216 if test ${TRAP} -eq 1; then 217 distexe_trap; 218 fi; 219 220 # Wait end ok all Task 221 distexe_wait_end; 222 223 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> all hosts is done"; 154 224 } 155 225 -
trunk/IPs/systemC/processor/Morpheo/Script/distexe_execute.sh
r136 r138 6 6 7 7 #-----[ global variable ]----------------------------------- 8 declare -i TRAP=0; 8 9 9 #-----[ lock ]----------------------------------------------10 function lock()10 #-----[ distexe_execute_usage ]----------------------------- 11 function distexe_execute_usage () 11 12 { 12 lockfile -1 ${1}; 13 } 14 15 #-----[ unlock ]-------------------------------------------- 16 function unlock () 17 { 18 rm -f ${1}; 19 } 20 21 #-----[ my_date ]------------------------------------------- 22 function my_date () 23 { 24 date +"%F %T"; 25 } 26 27 #-----[ execute_usage ]------------------------------------- 28 function execute_usage () 29 { 30 echo "Usage : ${0} path_work file_cmd file_cpt file_cpu id"; 13 echo "Usage : ${0} path_work file_cmd file_cpt file_host lock_process id"; 31 14 echo "Arguments : "; 32 echo " * path_work : directory to execute command"; 33 echo " * file_cmd : list of command"; 34 echo " * file_cpt : file with the index of next command to execute"; 35 echo " * file_cpu : tmp file to stock the current index"; 36 echo " * id : identification"; 15 echo " * path_work : directory to execute command"; 16 echo " * file_cmd : list of command"; 17 echo " * file_cpt : file with the index of next command to execute"; 18 echo " * file_process : if file is present, station is running"; 19 echo " * lock_process : file to lock process"; 20 echo " * id : identification"; 37 21 exit; 38 22 } 39 23 40 #-----[ execute_test_usage ]--------------------------------41 function execute_test_usage ()24 #-----[ distexe_execute_test_usage ]------------------------ 25 function distexe_execute_test_usage () 42 26 { 43 if test ${#} -ne 5; then 44 execute_usage; 27 if test ${#} -ne 6; then 28 distexe_execute_usage; 29 fi; 30 31 if test -z "${MORPHEO_SCRIPT}"; then 32 echo "Environment variable MORPHEO_SCRIPT is not set"; 33 distexe_execute_usage; 45 34 fi; 46 35 … … 50 39 } 51 40 52 #-----[ execute ]-------------------------------------------53 function execute()41 #-----[ distexe_execute_end ]---------------------------- 42 function distexe_execute_end() 54 43 { 44 ${MORPHEO_SCRIPT}/lock.sh ${LOCK_PROCESS}; 45 rm -f ${FILE_PROCESS}; 46 ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_PROCESS}; 47 } 48 49 #-----[ distexe_execute_no_trap ]------------------------ 50 function distexe_execute_no_trap() 51 { 52 TRAP=1; 53 } 54 55 #-----[ distexe_execute_trap ]--------------------------- 56 function distexe_execute_trap() 57 { 58 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> %%%%%%%%%%%%%%%% HITTTTTTTTTTTTTTTTTT %%%%%%%%%%%%%%%%"; 59 60 rm -f ${LOCK_CPT} 61 62 distexe_execute_end; 63 exit 1; 64 } 65 66 #-----[ distexe_execute ]----------------------------------- 67 function distexe_execute () 68 { 69 trap distexe_execute_no_trap INT TERM; 70 55 71 # test_usage 56 execute_test_usage ${*};72 distexe_execute_test_usage ${*}; 57 73 58 74 local -a COMMAND; … … 62 78 local FILE_CMD=${2}; 63 79 local FILE_CPT=${3}; 64 local FILE_ CPU=${4};65 local ID=${5};66 local LOCK_CPT="${PATH_WORK}/.lock-cpt";67 local LOCK_CP U="${PATH_WORK}/.lock-cpu";80 local FILE_PROCESS=${4}; 81 local LOCK_PROCESS=${5}; 82 local ID=${6}; 83 local LOCK_CPT="${PATH_WORK}/distexe-cpt-lock"; 68 84 local OUTPUT_FILE_INFO="distexe.info"; 69 85 local OUTPUT_FILE_CMD="distexe.command"; 70 86 local OUTPUT_FILE_OUT="distexe.output"; 71 87 72 # echo " * {"$(my_date)"} <${ID}> pid is $$";88 echo $$ > ${FILE_PROCESS}; 73 89 90 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> pid is $$"; 74 91 # Init CPT if this thread is the first 75 lock${LOCK_CPT};92 ${MORPHEO_SCRIPT}/lock.sh ${LOCK_CPT}; 76 93 if test ! -s ${FILE_CPT}; then 77 echo " * {"$( my_date)"} <${ID}> create counter file ${FILE_CPT}";94 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> create counter file ${FILE_CPT}"; 78 95 echo "0" > ${FILE_CPT}; 79 96 fi; 80 unlock ${LOCK_CPT}; 97 ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_CPT}; 98 99 trap distexe_execute_trap INT TERM; 100 101 if test ${TRAP} -eq 1; then 102 distexe_execute_trap; 103 fi; 81 104 82 105 # read, line by line, the command file and write in array … … 97 120 done; 98 121 99 echo " * {"$( my_date)"} <${ID}> is ready";122 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> is ready"; 100 123 101 124 # infinite loop … … 108 131 109 132 # Read the index, and increase 110 lock${LOCK_CPT};133 ${MORPHEO_SCRIPT}/lock.sh ${LOCK_CPT}; 111 134 CPT=$(cat ${FILE_CPT}); 112 135 echo "$((${CPT}+1))" > ${FILE_CPT}; 113 unlock${LOCK_CPT};136 ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_CPT}; 114 137 115 138 # test if this number is valid … … 124 147 # while test ${CPT}_SYNC -lt ${CPT}; do 125 148 # if test -z "${COMMAND[${CPT}_SYNC]}"; then 126 # echo " * {"$( my_date)"} <${ID}> synchronisation [${CPT}_SYNC]";149 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> synchronisation [${CPT}_SYNC]"; 127 150 # fi; 128 151 # CPT_SYNC=$((${CPT}_SYNC+1)); … … 139 162 local MAX=$((${NB_COMMAND}-1)); 140 163 141 # echo " * {"$( my_date)"} <${ID}> execute command [${NUM}] : ${COMMAND[${CPT}]}";142 echo " * {"$( my_date)"} <${ID}> command [${NUM}/${MAX}] : execute";164 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> execute command [${NUM}] : ${COMMAND[${CPT}]}"; 165 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> command [${NUM}/${MAX}] : execute"; 143 166 local PATH_CURRENT=${PWD}; 144 167 … … 149 172 echo "host : ${HOSTNAME}" >> ${OUTPUT_FILE_INFO}; 150 173 echo "pid : $$" >> ${OUTPUT_FILE_INFO}; 151 echo "date : "$( my_date) >> ${OUTPUT_FILE_INFO};174 echo "date : "$(${MORPHEO_SCRIPT}/date.sh) >> ${OUTPUT_FILE_INFO}; 152 175 echo "#!/bin/bash" > ${OUTPUT_FILE_CMD}; 153 176 echo 'source ${HOME}/.bashrc;' >> ${OUTPUT_FILE_CMD}; … … 156 179 ./${OUTPUT_FILE_CMD} &> ${OUTPUT_FILE_OUT}; 157 180 cd ${PATH_CURRENT} &> /dev/null; 158 echo " * {"$( my_date)"} <${ID}> command [${NUM}/${MAX}] : done";181 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> command [${NUM}/${MAX}] : done"; 159 182 fi; 160 183 done; 161 184 162 echo " * {"$(my_date)"} <${ID}> is done"; 163 164 lock ${LOCK_CPU}; 165 CPT=$(cat ${FILE_CPU}); # read the index 166 CPT=$((${CPT}-1)); 167 echo "${CPT}" > ${FILE_CPU}; # write the next index 168 unlock ${LOCK_CPU}; 185 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> is done"; 169 186 170 if test ${CPT} -eq 0; then 171 echo " * {"$(my_date)"} <${ID}> All task is executed on this host"; 172 rm ${FILE_CPU}; 173 fi; 187 distexe_execute_end; 174 188 } 175 189 176 190 #-----[ Corps ]--------------------------------------------- 177 execute ${*};191 distexe_execute ${*}; -
trunk/IPs/systemC/processor/Morpheo/Script/distexe_execute_n.sh
r135 r138 5 5 #----------------------------------------------------------- 6 6 7 #-----[ my_date ]------------------------------------------- 8 function my_date () 7 #-----[ global variable ]----------------------------------- 8 declare -i TRAP=0; 9 10 #-----[ distexe_execute_n_usage ]--------------------------- 11 function distexe_execute_n_usage () 9 12 { 10 date +"%F %T"; 11 } 12 13 #-----[ nb_cpu ]-------------------------------------------- 14 function nb_cpu () 15 { 16 local FILE_CPUINFO=/proc/cpuinfo; 17 if test ! -f ${FILE_CPUINFO}; then 18 echo "\"${FILE_CPUINFO}\" don't exist." 19 usage; 20 fi; 21 22 #eval "${1}=`grep -c \"processor\" ${FILE_CPUINFO}`"; 23 grep -c "processor" ${FILE_CPUINFO}; 24 } 25 26 #-----[ execute_n_usage ]----------------------------------- 27 function execute_n_usage () 28 { 29 echo "Usage : ${0} path_word file_cmd file_cpt [ nb_process ]"; 13 echo "Usage : ${0} path_work file_cmd file_cpt file_host lock_host prefix_file_process sleep [ nb_process ]"; 30 14 echo "Arguments : "; 31 echo " * path_work : directory to execute command"; 32 echo " * file_cmd : list of command"; 33 echo " * file_cpt : file to control"; 34 echo " * nb_process : number of process (default (and maximum) is the number of processor)"; 15 echo " * path_work : directory to execute command"; 16 echo " * file_cmd : list of command"; 17 echo " * file_cpt : file to control"; 18 echo " * file_host ; file host"; 19 echo " * lock_host ; file lock host"; 20 echo " * prefix_file_process : prefix of process's file"; 21 echo " * sleep : time in second to sleep"; 22 echo " * nb_process : number of process (default (and maximum) is the number of processor)"; 35 23 echo ""; 36 24 echo "Note : "; … … 43 31 } 44 32 45 #-----[ execute_n_test_usage ]------------------------------46 function execute_n_test_usage ()33 #-----[ distexe_execute_n_test_usage ]---------------------- 34 function distexe_execute_n_test_usage () 47 35 { 48 if test ${#} -ne 3 -a ${#} -ne 4; then 49 execute_n_usage; 36 if test ${#} -ne 7 -a ${#} -ne 8; then 37 distexe_execute_n_usage; 38 fi; 39 40 if test -z "${MORPHEO_SCRIPT}"; then 41 echo "Environment variable MORPHEO_SCRIPT is not set"; 42 distexe_execute_n_usage; 50 43 fi; 51 44 … … 54 47 fi; 55 48 56 if test -z "${MORPHEO_SCRIPT}"; then57 echo "Environment variable MORPHEO_SCRIPT is not set";58 execute_n_usage;59 fi;60 61 49 if test ! -f ${2}; then 62 50 echo "File \"${2}\" don't exist"; 63 execute_n_usage;51 distexe_execute_n_usage; 64 52 fi; 65 53 66 54 if test ! -s ${2}; then 67 55 echo "File \"${2}\" is empty"; 68 execute_n_usage;56 distexe_execute_n_usage; 69 57 fi; 70 58 } 71 59 72 #-----[ execute_n_main ]------------------------------------73 function execute_n()60 #-----[ distexe_execute_n_wait_end ]------------------------ 61 function distexe_execute_n_wait_end () 74 62 { 75 local -i NB_PROCESS=$(nb_cpu); 63 while true; do 64 65 nb_file=$(ls -1 ${PREFIX_FILE_PROCESS}* 2>/dev/null| wc -l); 66 67 if test ${nb_file} -eq 0; then 68 break; 69 fi; 70 71 # wait (to not have 100% cpu) 72 sleep ${SLEEP}; 73 done; 74 75 ${MORPHEO_SCRIPT}/lock.sh ${LOCK_HOST}; 76 rm -f ${FILE_HOST}; 77 ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_HOST}; 78 } 79 80 #-----[ distexe_execute_n_no_trap ]------------------------- 81 function distexe_execute_n_no_trap() 82 { 83 TRAP=1; 84 } 85 86 #-----[ distexe_execute_n_trap ]---------------------------- 87 function distexe_execute_n_trap () 88 { 89 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> Trap signal detected"; 90 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> 1111111111111111 Trap signal detected 1111111111111111"; 91 92 local -a files_process=($(ls ${PREFIX_FILE_PROCESS}* 2>/dev/null)); 93 local -i nb_files_process=${#files_process[*]}; 94 95 if test ${nb_files_process} -ne 0; then 96 for file_process in ${files_process[*]}; do 97 # ssh can not set yet pid in file_process 98 local -i nb_word=0; 99 while test ${nb_word} -eq 0; do 100 nb_word=$(echo ${file_process} |wc -m); 101 done; 102 103 ${MORPHEO_SCRIPT}/lock.sh ${LOCK_PROCESS}; 104 105 if test -f ${file_process}; then 106 pid=$(cat ${file_process}); 107 108 #ps aux | grep distexe; 109 110 kill -s SIGINT ${pid}; 111 fi; 112 113 ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_PROCESS}; 114 done; 115 fi; 116 117 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> 2222222222222222 Trap signal detected 2222222222222222"; 118 119 distexe_execute_n_wait_end; 120 121 # echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> 3333333333333333 Trap signal detected 3333333333333333"; 122 123 exit 1; 124 } 125 126 #-----[ distexe_execute_n_main ]---------------------------- 127 function distexe_execute_n () 128 { 129 trap distexe_execute_n_no_trap INT TERM; 130 131 local -i NB_PROCESS=$(${MORPHEO_SCRIPT}/nb_cpu.sh); 76 132 local -i CPT; 77 133 local PATH_WORK=${1}; 78 134 local FILE_CMD=${2}; 79 135 local FILE_CPT=${3}; 80 local FILE_CPU; 81 local ID="cpu-${HOSTNAME}-$$" 136 local FILE_HOST=${4}; 137 local LOCK_HOST=${5}; 138 local PREFIX_FILE_PROCESS="${6}${HOSTNAME}-"; 139 local LOCK_PROCESS="${PREFIX_FILE_PROCESS}lock"; 140 local -i SLEEP=${7}; 141 echo $$ > ${FILE_HOST}; 82 142 83 execute_n_test_usage ${*};143 distexe_execute_n_test_usage ${*}; 84 144 85 if test ${#} -eq 4; then86 if test ${ 4} -lt ${NB_PROCESS}; then87 NB_PROCESS=${ 4};145 if test ${#} -eq 8; then 146 if test ${8} -lt ${NB_PROCESS}; then 147 NB_PROCESS=${8}; 88 148 fi; 89 149 fi; 90 150 91 FILE_CPU="${PATH_WORK}/${ID}"; 92 93 echo " * {"$(my_date)"} <${HOSTNAME}> ${NB_PROCESS} process"; 151 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> ${NB_PROCESS} process"; 94 152 95 153 local -i IT_NB_PROCESS=1; 96 154 local -i PID=$$; 97 155 98 echo "${NB_PROCESS}" > ${FILE_CPU};99 100 156 # create the same number of thread that processor 101 157 while test ${IT_NB_PROCESS} -le ${NB_PROCESS}; do 102 ${MORPHEO_SCRIPT}/execute.sh ${PATH_WORK} ${FILE_CMD} ${FILE_CPT} ${FILE_CPU} "${HOSTNAME}-${IT_NB_PROCESS}" & 158 local FILE_CPU=${PREFIX_FILE_PROCESS}${IT_NB_PROCESS}; 159 160 touch ${FILE_CPU}; 161 ${MORPHEO_SCRIPT}/distexe_execute.sh ${PATH_WORK} ${FILE_CMD} ${FILE_CPT} ${FILE_CPU} ${LOCK_PROCESS} "${HOSTNAME}-${IT_NB_PROCESS}" & 103 162 IT_NB_PROCESS=$((${IT_NB_PROCESS}+1)); 104 163 … … 108 167 done 109 168 110 echo " * {"$(my_date)"} <${HOSTNAME}> all process working"; 169 echo " * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${HOSTNAME}> all process working"; 170 171 trap distexe_execute_n_trap INT TERM; 172 173 if test ${TRAP} -eq 1; then 174 distexe_execute_n_trap; 175 fi; 176 177 # Wait end ok all Task 178 distexe_execute_n_wait_end; 111 179 } 112 180 113 181 #-----[ Corps ]--------------------------------------------- 114 execute_n ${*};182 distexe_execute_n ${*}; -
trunk/IPs/systemC/processor/Morpheo/Script/lock.sh
r85 r138 5 5 #----------------------------------------------------------- 6 6 7 #-----[ usage ]---------------------------------------------8 function usage ()7 #-----[ lock_usage ]---------------------------------------- 8 function lock_usage () 9 9 { 10 10 echo "Usage : ${0} file"; 11 echo "Arguments : ";12 echo ' * file : you can see the lock at "${MORPHEO_HOME}/lock/$(basename file).lock"';13 echo "Notes :";14 echo " * Morpheo's environnement must be positionned.";15 11 16 12 exit; … … 20 16 function lock () 21 17 { 18 if test ${#} -ne 1; then 19 lock_usage ${*}; 20 fi; 21 22 22 lockfile -1 ${1}; 23 23 } 24 24 25 #-----[ main ]----------------------------------------------26 function main ()27 {28 LOCK_DIRECTORY="${MORPHEO_HOME}/lock";29 30 if test ${#} -ne 1 -o -z ${MORPHEO_HOME} -o ! -d ${LOCK_DIRECTORY}; then31 usage ${*};32 fi;33 34 lock "${LOCK_DIRECTORY}/$(basename ${1}).lock"35 }36 37 25 #-----[ Corps ]--------------------------------------------- 38 main${*}26 lock ${*} -
trunk/IPs/systemC/processor/Morpheo/Script/unlock.sh
r85 r138 5 5 #----------------------------------------------------------- 6 6 7 #-----[ u sage ]---------------------------------------------8 function u sage ()7 #-----[ unlock_usage ]-------------------------------------- 8 function unlock_usage () 9 9 { 10 10 echo "Usage : ${0} file"; 11 echo "Arguments : ";12 echo ' * file : you can see the lock at "${MORPHEO_HOME}/lock/$(basename file).lock"';13 echo "Notes :";14 echo " * Morpheo's environnement must be positionned.";15 11 16 12 exit; … … 20 16 function unlock () 21 17 { 18 if test ${#} -ne 1; then 19 unlock_usage ${*}; 20 fi; 21 22 22 rm -f ${1}; 23 23 } 24 24 25 #-----[ main ]----------------------------------------------26 function main ()27 {28 LOCK_DIRECTORY="${MORPHEO_HOME}/lock";29 30 if test ${#} -ne 1 -o -z ${MORPHEO_HOME} -o ! -d ${LOCK_DIRECTORY}; then31 usage ${*};32 fi;33 34 unlock "${LOCK_DIRECTORY}/$(basename ${1}).lock"35 }36 37 25 #-----[ Corps ]--------------------------------------------- 38 main${*}26 unlock ${*} -
trunk/IPs/systemC/processor/Morpheo/Script/version.sh
r137 r138 4 4 # $Id$ 5 5 #----------------------------------------------------------- 6 file_version="${MORPHEO_TOPLEVEL}/Version";7 8 6 #-----[ usage ]--------------------------------------------- 9 7 function usage () 10 8 { 11 echo "Usage : ${0} action"; 12 echo "Arguments : "; 13 echo " * action"; 14 echo " * add : add all file unpresent in project and set proprity"; 15 echo " * commit : update revision number and commit"; 16 echo " * status : print only locally modified items"; 17 echo " * status_new : print only locally new items"; 18 echo " * help : print this message"; 19 echo "Note :"; 9 echo "Usage : ${0} action"; 10 echo "Arguments : "; 11 echo " * action"; 12 echo " * add : add all file unpresent in project and set proprity"; 13 echo " * commit : update revision number and commit"; 14 echo " * status : print only locally modified items"; 15 echo " * status_new : print only locally new items"; 16 echo " * status_delete : print only locally new items"; 17 echo " * help : print this message"; 18 echo "Note :"; 20 19 echo " * Morpheo's environnement must be positionned."; 21 20 exit; … … 34 33 fi; 35 34 35 local file_version="${MORPHEO_TOPLEVEL}/Version"; 36 local major_version="0"; 37 local minor_version="2"; 38 local codename="Castor"; 39 36 40 export LC_ALL=C; 37 41 export EDITOR="emacs"; 38 42 39 pwd=${PWD};43 local pwd=${PWD}; 40 44 41 45 case ${1} in … … 44 48 45 49 # +1 because is the next revision 46 major_version=0; 47 minor_version=2; 48 codename="Castor"; 49 50 revision=$(($(export LC_ALL=C; svnversion | tr -d [:alpha:] | cut -d : -f 2) + 1)); 51 date_day=$(date +%d); 52 date_month=$(date +%m); 53 date_year=$(date +%Y); 50 local revision=$(($(export LC_ALL=C; svnversion | tr -d [:alpha:] | cut -d : -f 2) + 1)); 51 local date_day=$(date +%d); 52 local date_month=$(date +%m); 53 local date_year=$(date +%Y); 54 54 55 55 echo "${major_version} ${minor_version} ${revision} ${codename} ${date_day} ${date_month} ${date_year}" > ${file_version}; … … 88 88 cd ${pwd}; 89 89 ;; 90 91 "status_delete") 92 cd ${MORPHEO_TOPLEVEL}; 93 94 svn status | grep '!'; 95 96 cd ${pwd}; 97 ;; 90 98 91 99 "help") -
trunk/IPs/systemC/processor/Morpheo/Script/xilinx_extract_info.sh
r100 r138 17 17 #} 18 18 19 #-----[ info ]----------------------------------------------20 function info()19 #-----[ xilinx_extract_info_usage ]------------------------- 20 function xilinx_extract_info_usage() 21 21 { 22 echo "===== ${1}"; 23 grep "Number of Slice Registers" ${1}; 24 grep "Number of Slice LUTs" ${1}; 25 grep "Number used as Logic" ${1}; 26 grep "Number used as Memory" ${1}; 27 grep "Number used as RAM" ${1}; 28 grep "Maximum Frequency" ${1}; 22 echo "${0} option [files]"; 23 echo "Arguments : "; 24 echo ' * files : lists of files. If empty, take *.fpga.log'; 25 echo " * -s : print summary section"; 26 echo " * -t : print timing section"; 27 exit 1; 28 } 29 30 #-----[ xilinx_extract_info_summary ]----------------------- 31 function xilinx_extract_info_summary () 32 { 33 summary_line_begin=$(grep -n "Device utilization summary:" ${1} | cut -d : -f 1); 34 summary_line_end=$(grep -n "Partition Resource Summary:" ${1} | cut -d : -f 1); 35 36 head -n $(($summary_line_end-1)) ${1} | tail -n $(($summary_line_end-$summary_line_begin)); 37 } 38 39 #-----[ xilinx_extract_info_timing ]------------------------ 40 function xilinx_extract_info_timing () 41 { 42 timing_line_begin=$(grep -n "Timing Summary:" ${1} | cut -d : -f 1); 43 timing_line_end=$(grep -n "Timing Detail:" ${1} | cut -d : -f 1); 44 45 head -n $(($timing_line_end-1)) ${1} | tail -n $(($timing_line_end-$timing_line_begin)); 29 46 } 30 47 31 48 #-----[ main ]---------------------------------------------- 32 function main()49 function xilinx_extract_info() 33 50 { 34 if test $# -eq 0; then 51 local summary=0; 52 local timing=0; 53 local nb_params=$#; 54 set -- $(getopt :tsh "$@") 55 for arg 56 do case "$arg" in 57 -t) timing=1; nb_params=$((nb_params-1));; 58 -s) summary=1; nb_params=$((nb_params-1));; 59 -h) xilinx_extract_info_usage ${*}; break;; 60 --) if test ${summary} -eq 0 -a ${timing} -eq 0; then 61 summary=1; 62 timing=1; 63 fi; 64 65 esac 66 done 67 68 echo $nb_params; 69 if test $nb_params -eq 0; then 35 70 files="*.fpga.log"; 36 71 else … … 39 74 40 75 for i in $files; do 41 info $i; 76 if test -f ${i}; then 77 echo "===================| ${i}"; 78 79 if test ${summary} -ne 0; then 80 xilinx_extract_info_summary $i; 81 fi; 82 if test ${timing} -ne 0; then 83 xilinx_extract_info_timing $i; 84 fi; 85 fi; 42 86 done 43 87 } 44 88 45 89 #-----[ Corps ]--------------------------------------------- 46 main${*}90 xilinx_extract_info ${*} 47 91
Note: See TracChangeset
for help on using the changeset viewer.