Register
It is currently Sat Oct 25, 2014 5:54 am

Scope for IO redirection? [SOLVED]


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sat Jan 29, 2011 8:27 pm   

Joined: Sat Jan 29, 2011 8:09 pm
Posts: 2
Hi everyone,

I'm trying to script several passes of some SPEC CPU 2000 benchmarks for some research looking into how different processes compete for cache resources on a multi-core system.

I have time scheduled on the target system tomorrow, so I need this resolved quickly.

Here's the problem:

Below is a command, which I have stored in the variable $TASK
Code:
cputrack -evf -t -T0.1 -c pic0=l2_lines_in,sys -o sched5_pass1_L2.txt /cs/systems/CMPT886/home/pss10/886-assign1/runbind -p0  /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/exe/crafty_base.sol-x86 < /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/data/ref/input/crafty.in

Here it is again, with some newlines and indentation to make it more readable:
Code:
cputrack -evf -t -T0.1 -c pic0=l2_lines_in,sys -o sched5_pass1_L2.txt
   /cs/systems/CMPT886/home/pss10/886-assign1/runbind -p0 
      /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/exe/crafty_base.sol-x86
         < /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/data/ref/input/crafty.in &


It does the following:
  1. Run "cputrack", counting L2 cache misses, and storing the output in the file sched5_pass1_L2.txt
  2. The program that cputrack will track is "runbind", which simply runs a program on processor 0
  3. Runbind itself takes the actual benchmark (SPEC CPU's Crafty, a chess program)
  4. Finally, "crafty" takes the crafty.in file, which is a series of chess moves for it to compete against

This is where it gets weird

If I run the command on the Bash command line myself, using the exact command from the first CODE block in this post (followed by an ampersand to background it), it works fine. The following output is produced:
Code:
[1] 127800
bash-3.2$ pid 127802 bound to proc 0.
Will wait for 127802.
Will exec program /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/exe/crafty_base.sol-x86 to run on processor 0.
   Arguments are: /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/exe/crafty_base.sol-x86

Crafty v14.3

< TRUNCATED - program runs fine >

HOWEVER, If I run it from withing a bash script using the following command:
Code:
${TASK} &

it does NOT work. I get the following result:
Code:
pid 127780 bound to proc 0.
Will wait for 127780.
Will exec program /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/exe/crafty_base.sol-x86 to run on processor 0.
   Arguments are: /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/exe/crafty_base.sol-x86 < /cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/data/ref/input/crafty.in

Crafty v14.3

ERROR "<" is unknown command-line option
ERROR "/cs/systems/CMPT886/home/pss10/886-assign1/spec/186.crafty/data/ref/input/crafty.in" is unknown command-line option


It appears that in the first case, the "< crafty.in" portion is not seen as an argument, and is instead piped in as desired. However, when running in the script, the "< crafty.in" is treated as an argument, which Crafty doesn't recognize.

Is there some sort of scope issue? Can I place something like parenthesis somewhere to clear up any ambiguities?

Thank you! Your help will be greatly appreciated!


Last edited by stoanhart on Sun Jan 30, 2011 1:57 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Sun Jan 30, 2011 4:15 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
Hi,

try to make it a function instead of a variable:
Code:
task() {
path="/cs/systems/CMPT886/home/pss10/886-assign1"
spec="spec/186.crafty"
cputrack -evf -t -T0.1 -c pic0=l2_lines_in,sys \
         -o sched5_pass1_L2.txt "$path/runbind" \
         -p0 "$path/$spec/exe/crafty_base.sol-x86" < "$path/$spec/data/ref/input/crafty.in"
}


Top
 Profile  
 PostPosted: Sun Jan 30, 2011 1:39 pm   

Joined: Sat Jan 29, 2011 8:09 pm
Posts: 2
Thanks for the response, Watael.

Before I could try your method, someone in my group suggested that I simply prefix my command with eval, and it worked!

Now I use:
Code:
eval ${TASK} &
and all is fine!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP