• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Running parallel processes in SKILL code

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 15844
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Running parallel processes in SKILL code

imrefer
imrefer over 7 years ago

Hi,

I am writing an oceanXL script to launch multiple runs in parallel. While I set each run with ocnxlRun( ?waitUntilDone nil) in the loop to set up the circuit, after all runs are defined and launched I then wait for the runs to end with ocnxlWaitUntilDone('All). 

In the mean time, there could be a lot of runs and potentially taking a few days to finish. I want to be able to monitor a few finished simulation results to determine whether I want to continue with all simulations. So here in the attached eample I inserted a block of code to look for the results directory. The problem is, the while loop seems to block the execution of the ocnxlRun's and will not produce any results until I exit the while loop.

Obviously I can't put the monitor block after the ocnxlWaitUntilDone('All) command since it will wait for all to finish and defeat the purpose. My question is, can I launch a parallel process to monitor the progress of the simulations?

Thanks in advance for any help.

Ed

  • Cancel
Parents
  • skillUser
    skillUser over 7 years ago

    Hi Ed,

    I may not fully understand your situation but a suggestion might be to run (and schedule to repeat) a SKILL command using IPC  asynchronously that performs the check for you and sets a (global) flag that the rest of the code can check the value of. The asynchronous IPC calls essentially allow you to run the checks in the background. Some (pseudo/partial) code might help to illustrate this:

    procedure(runResMon()
      ipcBeginProcess("externalResMonScript" "" 'resMonDataHandler 'resMonErrHandler 'resMonExitHandler)
    )
    procedure(resMonExitHandler(cid status)   ;; a zero exit status means the data says to continue   if(zerop(status) then     ResMon = 0  ;; is this needed?     ocnxlWaitUntilDone('All) ;; not sure if you should do this here or in the 'main event loop'   else     hiRegTimer("runResMon()" 5*600)  ;; 600 is 1 minute so 5*600 is in 5 minutes' time   ) )
    ;; do sim set up first, then runResMon()

    The idea is that you start the simulations and then start a results monitor, when that returns it starts another results monitor in 5 minutes if the results are not back yet. If a result monitor comes back with a zero exit status then this is the signal for everything else to continue (and we don't need to call another results monitor).  Asynchronous coding can be tricky so you need to have semaphores (e.g. global flags) to communicate between the different 'moving parts' - I typically include a "stop" flag that prevents scheduling another (future) call to the repeating process if the flag is set, to help prevent possible runaway (once the sequence starts how else would you stop a particular procedure from being called?).


    I hope that this might help you.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • skillUser
    skillUser over 7 years ago

    Hi Ed,

    I may not fully understand your situation but a suggestion might be to run (and schedule to repeat) a SKILL command using IPC  asynchronously that performs the check for you and sets a (global) flag that the rest of the code can check the value of. The asynchronous IPC calls essentially allow you to run the checks in the background. Some (pseudo/partial) code might help to illustrate this:

    procedure(runResMon()
      ipcBeginProcess("externalResMonScript" "" 'resMonDataHandler 'resMonErrHandler 'resMonExitHandler)
    )
    procedure(resMonExitHandler(cid status)   ;; a zero exit status means the data says to continue   if(zerop(status) then     ResMon = 0  ;; is this needed?     ocnxlWaitUntilDone('All) ;; not sure if you should do this here or in the 'main event loop'   else     hiRegTimer("runResMon()" 5*600)  ;; 600 is 1 minute so 5*600 is in 5 minutes' time   ) )
    ;; do sim set up first, then runResMon()

    The idea is that you start the simulations and then start a results monitor, when that returns it starts another results monitor in 5 minutes if the results are not back yet. If a result monitor comes back with a zero exit status then this is the signal for everything else to continue (and we don't need to call another results monitor).  Asynchronous coding can be tricky so you need to have semaphores (e.g. global flags) to communicate between the different 'moving parts' - I typically include a "stop" flag that prevents scheduling another (future) call to the repeating process if the flag is set, to help prevent possible runaway (once the sequence starts how else would you stop a particular procedure from being called?).


    I hope that this might help you.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • imrefer
    imrefer over 7 years ago in reply to skillUser

    Hi Lawrence,

    Thank you so much for your reply. A colleague of mine suggested a similar approach, and I ran into more problems. Let me describe it in more detail, and see if you can suggest a better way.

    First when I ran my simulation script without the result monitor, at various times in the console window these messages appear sequencially:

    Ocean.473 1/2 completed.
    Ocean.472 1/2 completed.

    ..etc.

    So I decided to first redirect the stdout to a file, and then fork out a child process with ipcBeginProcess("ocean -replay dataProcess.ocn") like you suggested.

    The dataProcess.ocn script will monitor this file and with each new line it will read it and use rdb=axlReadHistoryResDB("Ocean.473"?session ocnxlGetSession()) to get to the database file and do some data processing. Then it will wait X minutes to get the next line in the file and repeat the process.

    When I ran this script independently, it seemed to have worked. But if I ran it from the main script as a child process, it returned an error saying the database file is write locked. It makes sense since the main loop is still trying to write more results into it.

    My question is, is there another function similar to axlReadHistoryResDB but as a readonly function to access the DB?

    Also in general do you think there might be a better approach?

    My goals are:

    1) run simulations in parallel.

    2) As each simulation is finished, I do the data processing, and wait for the next simulation to finish.

    In my implementation, I don't have too much communication between the main and child processes. I only signal the end of the simulations from the main process (redirect it to the monitored file) and at the end probe the child process to see if it's finished.

    I am very new to Ocean programming and the whole approach might be very inefficient.

    Thanks again for your help.

    Ed

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information