source: trunk/IPs/systemC/processor/Morpheo/Script/execute_n.sh @ 112

Last change on this file since 112 was 112, checked in by rosiere, 15 years ago

1) Stat_list : fix retire old and new register bug
2) Stat_list : remove read_counter and valid flag, because validation of destination is in retire step (not in commit step)
3) Model : add class Model (cf Morpheo.sim)
4) Allocation : alloc_interface_begin and alloc_interface_end to delete temporary array.
5) Script : add distexe.sh
6) Add Comparator, Multiplier, Divider. But this component are not implemented
7) Software : add Dhrystone

  • Property svn:keywords set to Id
File size: 2.9 KB
RevLine 
[85]1#!/bin/bash
2
[82]3#-----------------------------------------------------------
4# $Id: execute_n.sh 112 2009-03-18 22:36:26Z rosiere $
5#-----------------------------------------------------------
[2]6
[112]7#-----[ global variable ]-----------------------------------
[2]8
[112]9#-----[ nb_cpu ]--------------------------------------------
10function nb_cpu ()
[2]11{
[112]12    local FILE_CPUINFO=/proc/cpuinfo;
13    if test ! -f ${FILE_CPUINFO}; then
14        echo "\"${FILE_CPUINFO}\" don't exist."
15        usage;
16    fi;
17
18    #eval "${1}=`grep -c \"processor\" ${FILE_CPUINFO}`";
19    grep -c "processor" ${FILE_CPUINFO};
20}
21
22#-----[ execute_n_usage ]-----------------------------------
23function execute_n_usage ()
24{
25    echo "Usage     : ${0} word_dir file [ nb_process ]";
[78]26    echo "Arguments : ";
[112]27    echo " * work_dir   : directory to execute command";
[78]28    echo " * file       : list of command";
29    echo " * nb_process : number of process (default (and maximum) is the number of processor)";
[2]30    echo "";
[78]31    echo "Note      : ";
32    echo " * This script, for each command, create a directory : Task_X (X is the number of command), and execute the command in this directory.";
33    echo " * Two file is generate : \"output\" is the output of the execution, and \"command\" is the command lunch.";
[112]34#   echo " * A command empty (no command on a line of file) is a synchronisation with all process"
35    echo " * Don't forgot the final end of line (else the last command is not executed)";
[2]36    echo "";
37    exit;
38}
39
[112]40#-----[ execute_n_test_usage ]------------------------------
41function execute_n_test_usage ()
[2]42{
[112]43    if test ${#} -ne 2 -a ${#} -ne 3; then
44        execute_n_usage;
[2]45    fi;
46
[112]47    if test ! -d ${1}; then
48        echo "Directory ${1} is invalid";
49    fi;
[2]50
[112]51    if test -z "${MORPHEO_SCRIPT}"; then
52        echo "Environment variable MORPHEO_SCRIPT is not set";
53        distexe_usage;
[2]54    fi;
55
[112]56    if test ! -f ${2}; then
57        echo "File \"${2}\" don't exist";
58        execute_n_usage;
[2]59    fi;
60
[112]61    if test ! -s ${2}; then
62        echo "File \"${2}\" is empty";
63        execute_n_usage;
[2]64    fi;
65}
66
[112]67#-----[ execute_n_main ]------------------------------------
68function execute_n ()
[2]69{
[112]70    local -i NB_PROCESS=$(nb_cpu);
71    local -i CPT;
72    local    WORK_DIR=${1};
73    local    FILE_CMD=${2};
74    local    FILE_CPT;
75    local    FILE_CPU;
76    local    ID="cpu-${HOSTNAME}-$$"
[2]77
[112]78    execute_n_test_usage ${*};
[2]79
[112]80    if test ${#} -eq 2; then
81        if test ${3} -lt ${NB_PROCESS}; then
82            NB_PROCESS=${3};
[2]83        fi;
84    fi;
85
[112]86    FILE_CPT="${WORK_DIR}/control-"$(basename ${FILE_CMD});
87    FILE_CPU="${WORK_DIR}/${ID}";
[2]88
[112]89    echo "  * <${HOSTNAME}> ${NB_PROCESS} process";
[2]90
91    local -i IT_NB_PROCESS=1;
92    local -i PID=$$;
93
[112]94    echo "${NB_PROCESS}" > ${FILE_CPU};
[2]95
96    # create the same number of thread that processor
[112]97    while test ${IT_NB_PROCESS} -le ${NB_PROCESS}; do
98        ${MORPHEO_SCRIPT}/execute.sh ${WORK_DIR} ${FILE_CMD} ${FILE_CPT} ${FILE_CPU} &
99        IT_NB_PROCESS=$((${IT_NB_PROCESS}+1));
[2]100
[112]101        if test "$$" -ne ${PID}; then
[2]102            break;
103        fi;
104    done
105}
106
107#-----[ Corps ]---------------------------------------------
[112]108execute_n ${*};
Note: See TracBrowser for help on using the repository browser.