MonteCarlo Results from SKILL script

P

p_ritter

Guest
Dear Community,

one of my MC output parameters is computed from a skill script. This
script creates some files on the harddisc, performs its computations on
these files and returns a scalar.

However, since the computation takes a while (30sec), the result is not
returned to Spectre in time - this results in

--- monte carlo error message ---

Error found by spectre during Monte Carlo analysis `mc1'.

mc1_designParamVals: Error evaluating ocean expression `enob=ENOB(127
256
5)'.

---

Curiously, the script is started and the results are computed properly
(since the files are created on the harddisc) - but Spectre's oceanEval()
(see below) simply seems not to wait for the Skill script to be finshed.

I appreciate any kind of comment!

P. Ritter

My spectre version:
spectre (ver. 5.0.33.021904 -- 19 Feb 2004).
(I know there are updated versions but I cannot modify the installation)

--- The SKILL script

procedure( ENOBS( M N SamplingPoint)
let( ()

; -- create temporary ocean file which samples the transient
comparator output
; signals v(out0n)..v(out14n) and v(out0p)..v(out14p)
; samples are stored in temporary folder /var/tmp
; !! relies on global variable PSF_DIR to find the results of the
monte carlo
; !! simulation

oceanfile=outfile("/var/tmp/mc_enob_oceanout.ocn")
fprintf(oceanfile "simulator 'spectre\n")
[....]
fprintf(oceanfile "exit()\n")
close(oceanfile)

; -- start ocean to execute the file generated in the step before

system("ocean -nograph < /var/tmp/mc_enob_oceanout.ocn >
~/oceanlog.log")

; -- create matlab script to run on data exported by ocean

matlabfile=outfile("/var/tmp/mc_enob_matlabout.csh")
fprintf(matlabfile "#!/bin/csh\n")
fprintf(matlabfile "unsetenv DISPLAY\n")
fprintf(matlabfile "matlab >&! ~/matlablog.log << EOF\n")
[...]
fprintf(matlabfile "enobfile=fopen('/var/tmp/mc_enob_matlabres.il',
'w');\n")
fprintf(matlabfile "fprintf(enobfile, 'enob=%%d', enob);\n")
fprintf(matlabfile "fclose(enobfile);\n")
fprintf(matlabfile "exit\n")
fprintf(matlabfile "EOF\n")

close(matlabfile)

; -- run script

system("chmod a+x /var/tmp/mc_enob_matlabout.csh")
system("/var/tmp/mc_enob_matlabout.csh")

; -- read result computed by matlab

load("/var/tmp/mc_enob_matlabres.il")
enob
)
)


--- The spectre input.scs
[...]
mc1 montecarlo numruns=100 seed=1 variations=mismatch donominal=yes \
scalarfile="../monteCarlo/mcdata" paramfile="../monteCarlo/mcparam" \
saveprocessparams=yes processparamfile="../monteCarlo/processParam" \
processscalarfile="../monteCarlo/processData" {
tran tran stop=26.6n write="spectre.ic"
[...]
export enob=oceanEval("ENOB(127 256 5)")
}

--
Message posted using http://www.talkaboutcad.com/group/comp.cad.cadence/
More information at http://www.talkaboutcad.com/faq.html
 
Riad KACED wrote:
Hi There,

A quick glance at your code shows you are using the 'system' skill
command to process your data.
Well, 'system' pawns a separate UNIX process to execute a command. But
once the command thrown outside skill using 'system', no interaction
is left In other words, you skill script will continue its execustion
up to the end regadless the progress of the command sent with
'system'.
I don't think so. I'm lazy to verify this formally right now, but as far as I remember system() will
run the command through the shell, and hang until the shell returns. So I guess, unless you
explicitly launch your command as a background process, it will really wait until completion.

Even so, I don't know why you are launching a separate ocean process ; your procedure is evaluated
in ocean already...


export enob=oceanEval("ENOB(127 256 5)")
This is the part that tickles me... A little up, where your procedure is defined, the function name
is spelled differently :

procedure( ENOBS( M N SamplingPoint)

If that's not simply a typo in your post, could well be a source of error :) But wouldn't explain
why the files are created on the hard disk as you mention (weren't they here before by any chance ?).

Other than that, the code seems fine. First thing would be to validate it in Ocean standalone, at
least you'll get proper error messages.

Cheers,
Stéphane
 
Hi There,

A quick glance at your code shows you are using the 'system' skill
command to process your data.
Well, 'system' pawns a separate UNIX process to execute a command. But
once the command thrown outside skill using 'system', no interaction
is left In other words, you skill script will continue its execustion
up to the end regadless the progress of the command sent with
'system'.

If you need to make your skill waiting for the execution of an
external Job, which seems the case here, you have better to use the
Inter Process Communication functions instead of system. With IPC
skill functions, you can communicate either synchronously or
asynchronously with the child process.
The IPC functions are well explained in the following document :

Interprocess Communication SKILL Functions Reference : $CDSHOME/doc/
skipcref/skipcref.pdf

A quick example of using IPC functions is :

cidHost = ipcBeginProcess("uname -n")
ipcWait(cidHost)
ridHost=car(parseString(ipcReadProcess(cidHost) "\n"))

The sequence is : Begin, wait, read ...

Hope this help you in solving your issues.

Good luck !

Riad.
 
Riad, Stephane,

thanks for your hints, unfortunately neither one turned out to change
anything. Started the ENOBS routine in ocean itself (not embedded in an
MCAnalysis) everything works fine and the shell is locked until the result
is returned. ENOB was indeed a spelling mistake when modifying the code for
the forum.

However, what might be interesting is that the ENOBS procedure seems not
be started until the MonteCarlo simulation has finshed - at least the
files are created just in the moment the MC is either aborted via CTRL-C
or completed. In the very same moment, > top shows that the awd and matlab
processes are started ... :-/

I guess that
export enob=oceanEval("ENOB(127 256 5)")
wants to use the same "ocean shell" as the actual MCanalysis, and
therefore just starts the ENOBS-procedure when the MC Analysis is over ..

Is that possible? How can I fix that? ;-)

Thank you very much in advance,

P. Ritter

--
Message posted using http://www.talkaboutcad.com/group/comp.cad.cadence/
More information at http://www.talkaboutcad.com/faq.html
 
Hi,

1. You're Stéphane, unless it's run in the background, the system
command holds the skill code until it's completed.I tried the "system"
with/without the '&', the results confirmed your statements. Thanks !

2. I'm a little bit surprised that your ENOB call gets only at the end
of the MC analysis, that's odd. According to the Spectre
Documentation, the MC runs according to the following algorithm :

perform nominal run if requested
if any errors in nominal run then stop
for each Monte Carlo iteration {
if process variations specified then
apply "process" variation to parameters
if mismatch variations specified then
for each subcircuit instance {
apply "mismatch" variation to parameters
}
for each child analysis {
run child analysis
evaluate any export statements and
store results in a scalar data file
}
}

3.Well, your problem is a liitle bit tricky and very hard to debug
without a concrete run (at least with my level of experience).I
honestly think you're flow is a little bit complex. I would advice to
make a clean single ocean script and then run it from your unix
terminal by invoking the ocean shell and then load the ocean file. You
will avoid the ocean -nograph and stuff. Just one more thing when your
run your MC from unix.Copying the input.scs only is not sufficient to
run MC. I think it is worth copying the whole simulation directory.

I'm afaraid I'm not fit enough to go any further so far ...
So good luck !

Riad.
 
2. I'm a little bit surprised that your ENOB call gets only at the end
of the MC analysis, that's odd. According to the Spectre
Documentation, the MC runs according to the following algorithm :
I was curious so I did a couple of tests (with spectre 6.1.1), and I couldn't reproduce the problem.
My exports are evaluated at every iteration, and even launching an external program with system()
that lasts more than 60secs doesn't seem to disturb the simulator anyhow.

My guess is that a real error is happening in your code. Of course with no error message, it ain't
always easy to locate. You might want to write some debug output to a text file.


Cheers,
Stéphane
 

Welcome to EDABoard.com

Sponsor

Back
Top