PYNQ: PYTHON PRODUCTIVITY FOR ZYNQ

Is the PYNQ library safe to import across different processes simultaneously?

Hi again Friends,

Since there is only one set of hardware (hardware meaning PS peripherals and hard IP as well, not just PL IP), is it safe to have more than one Python or iPython instance import pynq?

Is there anything executed upon import that actually modifies the state of anything physical? So that if a second import of pynq occurred in another process would it potentially interfere with what is going or went on with the first?

I am aware that a user has to be careful and organize things so that mutual exclusion is achieved with single entities. I’m pondering here side affects from the import to say PS peripherals, AXI ports or something else.

A follow up question would be if all pynq library objects are destroyed do they leave the hardware in it’s current state or does it attempt to modify anything in destructor code?

Thank you again for supporting the community here!

It is possible to use PYNQ from multiple processes but some care is needed to ensure everything works correctly as we don’t do much guarding against accessing the same hardware simultaneously. The main thing to be aware of is that creating an Overlay instance will download the bitstream unless you pass download=False to the constructor.

If you want an example of this in action you can have a look at notebooks in the ZCU104 Demo I created which are designed to be run in together. In this example the Mixer notebook brings up the hardware design and the Filter and Logo notebooks act on specific IP once the bitstream is up and loaded.

Note that the hardware blocks are not thread-safe (two processes writing to different registers will give you undefined behaviour) so if you want two processes accessing the same IP you will need to implement your own access sharing mechanism. In the ZCU104 demo this isn’t necessary as each notebook is accessing a disjoint set of IP blocks in the design.

Peter

1 Like