Skip to content
Snippets Groups Projects
Commit 6ba01c42 authored by Enol Fernandez's avatar Enol Fernandez
Browse files

use awk for getting unique lines instead of sort.

parent 60655970
Branches
Tags
No related merge requests found
...@@ -56,16 +56,13 @@ scheduler_get_machinefile () { ...@@ -56,16 +56,13 @@ scheduler_get_machinefile () {
export MPI_START_HOST_SLOTS_FILE=$MPI_START_TEMP_FILE export MPI_START_HOST_SLOTS_FILE=$MPI_START_TEMP_FILE
sort -n < $CONDOR_CONTACT_FILE | awk '{print $2}' > $MPI_START_MACHINEFILE sort -n < $CONDOR_CONTACT_FILE | awk '{print $2}' > $MPI_START_MACHINEFILE
# assume CONDOR allocation of machines is "sane" # assume CONDOR allocation of machines is "sane"
cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " | awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
# this is a subshell, variables changes here are not changed outside! # this is a subshell, variables changes here are not changed outside!
while read line; do while read host; do
slots=`echo $line | cut -f1 -d" "` slots=`grep -c "$host" $MPI_START_MACHINEFILE`
host=`echo $line | cut -f2 -d" "`
echo $host >> $MPI_START_HOSTFILE echo $host >> $MPI_START_HOSTFILE
echo $host $slots >> $MPI_START_HOST_SLOTS_FILE echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
done done
# this only works in bash
# < <( cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " )
export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l` export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l`
export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1` export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l` export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l`
......
...@@ -43,16 +43,14 @@ build_lsb_hosts () { ...@@ -43,16 +43,14 @@ build_lsb_hosts () {
for host in $LSB_HOSTS; do for host in $LSB_HOSTS; do
echo $host >> $MPI_START_MACHINEFILE echo $host >> $MPI_START_MACHINEFILE
done done
cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " | awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
# this is a subshell, variables changes here are not changed outside! # this is a subshell, variables changes here are not changed outside!
while read line; do while read host; do
slots=`echo $line | cut -f1 -d" "` slots=`grep -c "$host" $MPI_START_MACHINEFILE`
host=`echo $line | cut -f2 -d" "`
echo $host >> $MPI_START_HOSTFILE echo $host >> $MPI_START_HOSTFILE
echo $host $slots >> $MPI_START_HOST_SLOTS_FILE echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
done done
export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l` export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l`
export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l` export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l`
return 0 return 0
} }
...@@ -88,7 +86,6 @@ build_lsb_mcpu_hosts () { ...@@ -88,7 +86,6 @@ build_lsb_mcpu_hosts () {
done done
export MPI_START_NHOSTS=$total_hosts export MPI_START_NHOSTS=$total_hosts
export MPI_START_NSLOTS=$total_slots export MPI_START_NSLOTS=$total_slots
export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
return 0 return 0
} }
...@@ -104,5 +101,8 @@ scheduler_get_machinefile () { ...@@ -104,5 +101,8 @@ scheduler_get_machinefile () {
else else
build_lsb_mcpu_hosts build_lsb_mcpu_hosts
fi fi
st=$?
export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
return $st
} }
...@@ -36,16 +36,13 @@ scheduler_get_machinefile () { ...@@ -36,16 +36,13 @@ scheduler_get_machinefile () {
mpi_start_mktemp mpi_start_mktemp
export MPI_START_HOST_SLOTS_FILE=$MPI_START_TEMP_FILE export MPI_START_HOST_SLOTS_FILE=$MPI_START_TEMP_FILE
cat $PBS_NODEFILE > $MPI_START_MACHINEFILE cat $PBS_NODEFILE > $MPI_START_MACHINEFILE
cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " | awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
# this is a subshell, variables changes here are not changed outside! # this is a subshell, variables changes here are not changed outside!
while read line; do while read host; do
slots=`echo $line | cut -f1 -d" "` slots=`grep -c "$host" $MPI_START_MACHINEFILE`
host=`echo $line | cut -f2 -d" "`
echo $host >> $MPI_START_HOSTFILE echo $host >> $MPI_START_HOSTFILE
echo $host $slots >> $MPI_START_HOST_SLOTS_FILE echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
done done
# this only works in bash
# < <( cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " )
export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l` export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l`
export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1` export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l` export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l`
......
...@@ -51,11 +51,10 @@ scheduler_get_machinefile () { ...@@ -51,11 +51,10 @@ scheduler_get_machinefile () {
return 13 return 13
fi fi
fi fi
cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " | awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
# this is a subshell, variables changes here are not changed outside! # this is a subshell, variables changes here are not changed outside!
while read line; do while read host; do
slots=`echo $line | cut -f1 -d" "` slots=`grep -c "$host" $MPI_START_MACHINEFILE`
host=`echo $line | cut -f2 -d" "`
echo $host >> $MPI_START_HOSTFILE echo $host >> $MPI_START_HOSTFILE
echo $host $slots >> $MPI_START_HOST_SLOTS_FILE echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment