• 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. How to reinvoke an ocean script

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 15356
  • 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

How to reinvoke an ocean script

ExcaIibur
ExcaIibur over 6 years ago

I am recently encountering a challenge that an ocean script leaks memory over time. If nothing is done to deal with it, the script will eventually crash.

I want to make the script more robust in the sense that when it detects memory usage over certain boundary, it will stop the script, release the memory and start the script again.

What I have in mind is to use combination of bash and ocean. The bash script will be in an outer loop to control the execution of the ocean script. 

What I am not sure about is how the outter loop communicates with the ocean script, maybe the most stupid idea is to let the ocean script write to some intermediate file and the bash script to constantly monitor the content of that file. So, I am looking for input regarding how the outter loop can catch this 'break' in the inner loop of ocean script.

Below is the pseudo code i have in mind:

#!/bin/bash

ocean; enter ocean environment

load("ocean.ocn")

if memoryAllocated() > [some threshold]

then tell ocean.ocn to stop

exit; exit ocean environment to free leaked memory

;detect this event has occurred

ocean ; enter ocean environment again

load("ocean.ocn") ; repeat the process

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    In general there shouldn't be a memory leak with OCEAN, unless you are reading lots of waveform data and keeping it in variables. That said, there have been some recent improvements (in IC618/ICADVM181 ISR5) to further improve the memory usage so that when ViVA and ADE sessions are closed, we do a better job of releasing waveform-related memory. You may need to call ocnCloseSession() in your script to force that.

    However, coming back to your request, you can do this by communicating via the exit status of the OCEAN script, using the optional argument to the exit() function. For example, with this OCEAN script (I called it "bashything.ocn" even though it's not doing anything OCEAN related - this is just to illustrate it:

    printf("Hello World\n")
    exit(23)

    Then your bash script:

    #!/bin/bash

    ocean -restore bashything.ocn
    echo "STATUS IS " $?

    The script is then using $? to retrieve the exit status from the previous command. This will print the output info from ocean, and then "STATUS IS 23" afterwards...

    You can then adapt this idea to suit your needs.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ExcaIibur
    ExcaIibur over 6 years ago in reply to Andrew Beckett

    If I want to keep this control script in ocean format as well, do you know what is the equivalent syntax to catch the exit status of a ocean script or function

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to ExcaIibur

    If you're using a SKILL program (OCEAN is just SKILL) to launch ocean, then you could do:

    cid=ipcBeginProcess("unset CDS_MPS_SESSION; ocean -restore bashything.ocn")
    ipcWait(cid)
    printf("EXIT STATUS IS %L\n" ipcGetExitStatus(cid))

    This blocks until the code is finished (you can't call ipcGetExitStatus until it's finished of course). Or you could use the asynchronous approach:

    procedure(MyPrintStuff(cid data)
      printf("%s" data)
    )

    procedure(MyExitHandler(cid status)
      printf("EXITED WITH STATUS: %L\n" status)
    )

    cid=ipcBeginProcess("unset CDS_MPS_SESSION; ocean -restore bashything.ocn" "" 'MyPrintStuff 'MyPrintStuff 'MyExitHandler)

    Regards,

    Andrew.

    • 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