Ignore:
Timestamp:
May 12, 2010, 7:34:01 PM (14 years ago)
Author:
rosiere
Message:

1) add counters_t type for interface
2) fix in check load in load_store_unit
3) add parameters (but not yet implemented)
4) change environment and add script (distcc_env.sh ...)
5) add warning if an unser change rename flag with l.mtspr instruction
6) ...

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  
    55#-----------------------------------------------------------
    66
    7 declare    VERSION="1.0"
    8 declare -i SLEEP=3
    9 
    10 # Need : test, echo, cd, dirname, basename, ssh, ps aux
     7#-----[ global variable ]-----------------------------------
     8declare    VERSION="1.3"
     9declare -i SLEEP=2;
     10declare -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
    1114
    1215#-----[ distexe_usage ]-------------------------------------
     
    2326    echo "   A line can content many shell command.";
    2427    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";
    2642    echo '   echo "export PATH=${PATH}:${HOME}/my_appli/bin; my_appli 13"  > command_file.txt';
    2743    echo '   echo "export PATH=${PATH}:${HOME}/my_appli/bin; my_appli 21" >> command_file.txt';
    2844    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";
    3747    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
    4151    exit;
    42 }
    43 
    44 #-----[ my_date ]-------------------------------------------
    45 function my_date ()
    46 {
    47     date +"%F %T";
    4852}
    4953
     
    8185function header ()
    8286{
    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 ]----------------------------------
     93function 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 ]-----------------------------------
     111function distexe_no_trap()
     112{
     113    TRAP=1;
     114}
     115
     116#-----[ distexe_trap ]--------------------------------------
     117function 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;
    84155}
    85156
     
    87158function distexe ()
    88159{
     160    trap distexe_no_trap INT TERM;
     161
    89162    distexe_test_usage ${*};
    90163
     
    104177    fi;
    105178
    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
    108185    header;
    109186
    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}";
    117191
    118192    for line in ${hosts}; do
     
    120194        local -i nb_process=$(echo ${line} | cut -d/ -f2);
    121195
    122         echo "  * {"$(my_date)"} <${HOSTNAME}> station : ${host} (${nb_process}) ... ";
    123 
    124196        # 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;
    130210    done;
    131211
    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";
    154224}
    155225
  • trunk/IPs/systemC/processor/Morpheo/Script/distexe_execute.sh

    r136 r138  
    66
    77#-----[ global variable ]-----------------------------------
     8declare -i TRAP=0;
    89
    9 #-----[ lock ]----------------------------------------------
    10 function lock ()
     10#-----[ distexe_execute_usage ]-----------------------------
     11function distexe_execute_usage ()
    1112{
    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";
    3114    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";
    3721    exit;
    3822}
    3923
    40 #-----[ execute_test_usage ]--------------------------------
    41 function execute_test_usage ()
     24#-----[ distexe_execute_test_usage ]------------------------
     25function distexe_execute_test_usage ()
    4226{
    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;
    4534    fi;
    4635
     
    5039}
    5140
    52 #-----[ execute ]-------------------------------------------
    53 function execute ()
     41#-----[ distexe_execute_end ]----------------------------
     42function distexe_execute_end()
    5443{
     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 ]------------------------
     50function distexe_execute_no_trap()
     51{
     52    TRAP=1;
     53}
     54
     55#-----[ distexe_execute_trap ]---------------------------
     56function 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 ]-----------------------------------
     67function distexe_execute ()
     68{
     69    trap distexe_execute_no_trap INT TERM;
     70
    5571    # test_usage
    56     execute_test_usage ${*};
     72    distexe_execute_test_usage ${*};
    5773
    5874    local -a COMMAND;
     
    6278    local    FILE_CMD=${2};
    6379    local    FILE_CPT=${3};
    64     local    FILE_CPU=${4};
    65     local    ID=${5};
    66     local    LOCK_CPT="${PATH_WORK}/.lock-cpt";
    67     local    LOCK_CPU="${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";
    6884    local    OUTPUT_FILE_INFO="distexe.info";
    6985    local    OUTPUT_FILE_CMD="distexe.command";
    7086    local    OUTPUT_FILE_OUT="distexe.output";
    7187
    72 #   echo "  * {"$(my_date)"} <${ID}> pid is $$";
     88    echo $$ > ${FILE_PROCESS};
    7389
     90#   echo "  * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> pid is $$";
    7491    # Init CPT if this thread is the first
    75     lock   ${LOCK_CPT};
     92    ${MORPHEO_SCRIPT}/lock.sh   ${LOCK_CPT};
    7693    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}";
    7895        echo "0" > ${FILE_CPT};
    7996    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;
    81104
    82105    # read, line by line, the command file and write in array
     
    97120    done;
    98121
    99     echo "  * {"$(my_date)"} <${ID}> is ready";
     122    echo "  * {"$(${MORPHEO_SCRIPT}/date.sh)"} <${ID}> is ready";
    100123
    101124    # infinite loop
     
    108131
    109132        # Read the index, and increase
    110         lock   ${LOCK_CPT};
     133        ${MORPHEO_SCRIPT}/lock.sh   ${LOCK_CPT};
    111134        CPT=$(cat ${FILE_CPT});
    112135        echo "$((${CPT}+1))" > ${FILE_CPT};
    113         unlock ${LOCK_CPT};
     136        ${MORPHEO_SCRIPT}/unlock.sh ${LOCK_CPT};
    114137
    115138        # test if this number is valid
     
    124147#       while test ${CPT}_SYNC -lt ${CPT}; do
    125148#           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]";
    127150#           fi;
    128151#           CPT_SYNC=$((${CPT}_SYNC+1));
     
    139162            local MAX=$((${NB_COMMAND}-1));
    140163
    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";
    143166            local PATH_CURRENT=${PWD};
    144167
     
    149172            echo "host : ${HOSTNAME}" >>  ${OUTPUT_FILE_INFO};
    150173            echo "pid  : $$"          >>  ${OUTPUT_FILE_INFO};
    151             echo "date : "$(my_date)  >>  ${OUTPUT_FILE_INFO};
     174            echo "date : "$(${MORPHEO_SCRIPT}/date.sh)  >>  ${OUTPUT_FILE_INFO};
    152175            echo "#!/bin/bash"         >  ${OUTPUT_FILE_CMD};
    153176            echo 'source ${HOME}/.bashrc;' >>  ${OUTPUT_FILE_CMD};
     
    156179            ./${OUTPUT_FILE_CMD}      &>  ${OUTPUT_FILE_OUT};
    157180            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";
    159182        fi;
    160183    done;
    161184
    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";
    169186   
    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;
    174188}
    175189
    176190#-----[ Corps ]---------------------------------------------
    177 execute ${*};
     191distexe_execute ${*};
  • trunk/IPs/systemC/processor/Morpheo/Script/distexe_execute_n.sh

    r135 r138  
    55#-----------------------------------------------------------
    66
    7 #-----[ my_date ]-------------------------------------------
    8 function my_date ()
     7#-----[ global variable ]-----------------------------------
     8declare -i TRAP=0;
     9
     10#-----[ distexe_execute_n_usage ]---------------------------
     11function distexe_execute_n_usage ()
    912{
    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 ]";
    3014    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)";
    3523    echo "";
    3624    echo "Note      : ";
     
    4331}
    4432
    45 #-----[ execute_n_test_usage ]------------------------------
    46 function execute_n_test_usage ()
     33#-----[ distexe_execute_n_test_usage ]----------------------
     34function distexe_execute_n_test_usage ()
    4735{
    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;
    5043    fi;
    5144
     
    5447    fi;
    5548
    56     if test -z "${MORPHEO_SCRIPT}"; then
    57         echo "Environment variable MORPHEO_SCRIPT is not set";
    58         execute_n_usage;
    59     fi;
    60 
    6149    if test ! -f ${2}; then
    6250        echo "File \"${2}\" don't exist";
    63         execute_n_usage;
     51        distexe_execute_n_usage;
    6452    fi;
    6553
    6654    if test ! -s ${2}; then
    6755        echo "File \"${2}\" is empty";
    68         execute_n_usage;
     56        distexe_execute_n_usage;
    6957    fi;
    7058}
    7159
    72 #-----[ execute_n_main ]------------------------------------
    73 function execute_n ()
     60#-----[ distexe_execute_n_wait_end ]------------------------
     61function distexe_execute_n_wait_end ()
    7462{
    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 ]-------------------------
     81function distexe_execute_n_no_trap()
     82{
     83    TRAP=1;
     84}
     85
     86#-----[ distexe_execute_n_trap ]----------------------------
     87function 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 ]----------------------------
     127function distexe_execute_n ()
     128{
     129    trap distexe_execute_n_no_trap INT TERM;
     130
     131    local -i NB_PROCESS=$(${MORPHEO_SCRIPT}/nb_cpu.sh);
    76132    local -i CPT;
    77133    local    PATH_WORK=${1};
    78134    local    FILE_CMD=${2};
    79135    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};
    82142
    83     execute_n_test_usage ${*};
     143    distexe_execute_n_test_usage ${*};
    84144
    85     if test ${#} -eq 4; then
    86         if test ${4} -lt ${NB_PROCESS}; then
    87             NB_PROCESS=${4};
     145    if test ${#} -eq 8; then
     146        if test ${8} -lt ${NB_PROCESS}; then
     147            NB_PROCESS=${8};
    88148        fi;   
    89149    fi;
    90150
    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";
    94152
    95153    local -i IT_NB_PROCESS=1;
    96154    local -i PID=$$;
    97155
    98     echo "${NB_PROCESS}" > ${FILE_CPU};
    99 
    100156    # create the same number of thread that processor
    101157    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}" &
    103162        IT_NB_PROCESS=$((${IT_NB_PROCESS}+1));
    104163
     
    108167    done
    109168
    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;
    111179}
    112180
    113181#-----[ Corps ]---------------------------------------------
    114 execute_n ${*};
     182distexe_execute_n ${*};
  • trunk/IPs/systemC/processor/Morpheo/Script/lock.sh

    r85 r138  
    55#-----------------------------------------------------------
    66
    7 #-----[ usage ]---------------------------------------------
    8 function usage ()
     7#-----[ lock_usage ]----------------------------------------
     8function lock_usage ()
    99{
    1010    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.";
    1511
    1612    exit;
     
    2016function lock ()
    2117{
     18    if test ${#} -ne 1; then
     19        lock_usage ${*};
     20    fi;
     21
    2222    lockfile -1 ${1};
    2323}
    2424
    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}; then
    31         usage ${*};
    32     fi;
    33 
    34     lock "${LOCK_DIRECTORY}/$(basename ${1}).lock"
    35 }
    36 
    3725#-----[ Corps ]---------------------------------------------
    38 main ${*}
     26lock ${*}
  • trunk/IPs/systemC/processor/Morpheo/Script/unlock.sh

    r85 r138  
    55#-----------------------------------------------------------
    66
    7 #-----[ usage ]---------------------------------------------
    8 function usage ()
     7#-----[ unlock_usage ]--------------------------------------
     8function unlock_usage ()
    99{
    1010    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.";
    1511
    1612    exit;
     
    2016function unlock ()
    2117{
     18    if test ${#} -ne 1; then
     19        unlock_usage ${*};
     20    fi;
     21
    2222    rm -f ${1};
    2323}
    2424
    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}; then
    31         usage ${*};
    32     fi;
    33 
    34     unlock "${LOCK_DIRECTORY}/$(basename ${1}).lock"
    35 }
    36 
    3725#-----[ Corps ]---------------------------------------------
    38 main ${*}
     26unlock ${*}
  • trunk/IPs/systemC/processor/Morpheo/Script/version.sh

    r137 r138  
    44# $Id$
    55#-----------------------------------------------------------
    6 file_version="${MORPHEO_TOPLEVEL}/Version";
    7 
    86#-----[ usage ]---------------------------------------------
    97function usage ()
    108{
    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               :";
    2019    echo " * Morpheo's environnement must be positionned.";
    2120    exit;
     
    3433    fi;
    3534
     35    local file_version="${MORPHEO_TOPLEVEL}/Version";
     36    local major_version="0";
     37    local minor_version="2";
     38    local codename="Castor";
     39
    3640    export LC_ALL=C;
    3741    export EDITOR="emacs";
    3842
    39     pwd=${PWD};
     43    local pwd=${PWD};
    4044   
    4145    case ${1} in
     
    4448   
    4549            # +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);
    5454           
    5555            echo "${major_version} ${minor_version} ${revision} ${codename} ${date_day} ${date_month} ${date_year}" > ${file_version};
     
    8888            cd ${pwd};
    8989            ;;
     90
     91        "status_delete")
     92            cd ${MORPHEO_TOPLEVEL};
     93
     94            svn status | grep '!';
     95
     96            cd ${pwd};
     97            ;;
    9098           
    9199        "help")
  • trunk/IPs/systemC/processor/Morpheo/Script/xilinx_extract_info.sh

    r100 r138  
    1717#}
    1818
    19 #-----[ info ]----------------------------------------------
    20 function info ()
     19#-----[ xilinx_extract_info_usage ]-------------------------
     20function xilinx_extract_info_usage()
    2121{
    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 ]-----------------------
     31function 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 ]------------------------
     40function 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));
    2946}
    3047
    3148#-----[ main ]----------------------------------------------
    32 function main ()
     49function xilinx_extract_info()
    3350{
    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
    3570        files="*.fpga.log";
    3671    else
     
    3974
    4075    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;
    4286    done
    4387}
    4488
    4589#-----[ Corps ]---------------------------------------------
    46 main ${*}
     90xilinx_extract_info ${*}
    4791
Note: See TracChangeset for help on using the changeset viewer.