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
Line 
1#!/bin/bash
2
3#-----------------------------------------------------------
4# $Id: execute_n.sh 112 2009-03-18 22:36:26Z rosiere $
5#-----------------------------------------------------------
6
7#-----[ global variable ]-----------------------------------
8
9#-----[ nb_cpu ]--------------------------------------------
10function nb_cpu ()
11{
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 ]";
26    echo "Arguments : ";
27    echo " * work_dir   : directory to execute command";
28    echo " * file       : list of command";
29    echo " * nb_process : number of process (default (and maximum) is the number of processor)";
30    echo "";
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.";
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)";
36    echo "";
37    exit;
38}
39
40#-----[ execute_n_test_usage ]------------------------------
41function execute_n_test_usage ()
42{
43    if test ${#} -ne 2 -a ${#} -ne 3; then
44        execute_n_usage;
45    fi;
46
47    if test ! -d ${1}; then
48        echo "Directory ${1} is invalid";
49    fi;
50
51    if test -z "${MORPHEO_SCRIPT}"; then
52        echo "Environment variable MORPHEO_SCRIPT is not set";
53        distexe_usage;
54    fi;
55
56    if test ! -f ${2}; then
57        echo "File \"${2}\" don't exist";
58        execute_n_usage;
59    fi;
60
61    if test ! -s ${2}; then
62        echo "File \"${2}\" is empty";
63        execute_n_usage;
64    fi;
65}
66
67#-----[ execute_n_main ]------------------------------------
68function execute_n ()
69{
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}-$$"
77
78    execute_n_test_usage ${*};
79
80    if test ${#} -eq 2; then
81        if test ${3} -lt ${NB_PROCESS}; then
82            NB_PROCESS=${3};
83        fi;
84    fi;
85
86    FILE_CPT="${WORK_DIR}/control-"$(basename ${FILE_CMD});
87    FILE_CPU="${WORK_DIR}/${ID}";
88
89    echo "  * <${HOSTNAME}> ${NB_PROCESS} process";
90
91    local -i IT_NB_PROCESS=1;
92    local -i PID=$$;
93
94    echo "${NB_PROCESS}" > ${FILE_CPU};
95
96    # create the same number of thread that processor
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));
100
101        if test "$$" -ne ${PID}; then
102            break;
103        fi;
104    done
105}
106
107#-----[ Corps ]---------------------------------------------
108execute_n ${*};
Note: See TracBrowser for help on using the repository browser.