-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running multiple threads with Questa fails #877
Comments
Do the |
No, I have the same problem with or without it. |
I've managed to gain access to a Questa licens. It's only one but if I run with many threads it generally works well. It simply waits for the license. I've seen the problem once though but I have not been able to repeat. I'm not sure what the "implicit optimized design" it tries to create is but a first test is maybe to turn optimizations off to see if the problem is avoided. |
I have tried to run Questa with several threads and licenses some time ago. I think this fails because questa always tries to write something to the compiled database. I did not manage to disable the optimization step included in vsim (it is basically an implicit vopt) so that it does not happen... |
Same here. I already fought against this optimization step... if you try to disable it then other issues pop up so we have to live with it. Does VUnit provides an easy way to run the different test cases in different sub-folders inside the "vunit_out" folder? |
That would be a nice feature for running Questa in parallel: Tell vunit to build several vunit_out-folders with individual databases. |
I'm not sure if it is possible to completely disable Questa optimization. As far as I know, the best we can do is what @tasgomes already did in his example: pass In my experience, this sidesteps a lot of bugs that crash Questa but not Modelsim. However, note that Questa is still printing this:
So it seems like Questa is still doing something related to optimization, which Modelsim doesn't do. I would be very interested in a solution/workaround for this issue. |
There is no support today for multiple output directories. One could potentially create a workaround where a top-level run script calls a second level run script with different values for the I think we would need support from Siemens to get a rationale for this behavior. No matter what solution you have for parallelization you would run into this problem. Do Siemens have their own solution for this? Anyone knows? |
Assuming that it only needs write access when starting up the simulation one could have a solution that starts the individual threads with some temporal spacing. As a first test one could just set a fix time and then, if that works, one could handle it more dynamically by looking for lock files or similar. Could you try adding Line 414 in ce8db50
|
@LarsAsplund That seems to work for me. Without the
Here's the full printout from that test:
|
In order for us to refine this into a stable solutions we need to understand how Questa's locking mechanism works. Asking Siemens is a good start but I think that would require a support contract with them. Anyone that has that? |
I think the fundamental problem here is that |
Try adding this class to your run script from threading import Lock
from vunit.ostools import Process
class VOpt:
def __init__(self, vunit):
self._lock = Lock()
self._optimization_complete = False
self._vunit = vunit
for lib in vunit.get_libraries():
for tb in lib.get_test_benches(allow_empty=True):
tb.set_pre_config(self)
def __call__(self, output_path):
self._lock.acquire()
if not self._optimization_complete:
for lib in self._vunit.get_libraries():
for tb in lib.get_test_benches(allow_empty=True):
try:
args = [
str(Path(self._vunit._simulator_class.find_prefix()) / "vopt"),
"-work",
lib.name,
tb.name,
"-o",
f"{tb.name}_opt",
]
Process(args, cwd=str(Path(self._vunit._args.output_path) / "modelsim" / "libraries"))
except Process.NonZeroExitCode:
return False
self._optimization_complete = True
self._lock.release()
return True Then just before you call the VOpt(prj)
prj.main() The optimized design must be stored under a different name so change this line: vunit/vunit/sim_if/modelsim.py Line 269 in ce8db50
to config.library_name + "." + config.entity_name + "_opt" + architecture_suffix, I only have one license to test with but the note about |
I added the class to my sim/run.py script. And before I call # Call VUnit main
VOpt(vu)
vu.main(post_run=common.post_run) Then I modified the Now, I get this error even if I run in single-thread mode, so either I did something wrong or something else is still missing:
|
I see that there is a Process(args, cwd=str(Path(self._vunit._args.output_path) / "modelsim" / "libraries")) I would print proc = Process(args, cwd=str(Path(self._vunit._args.output_path) / "modelsim" / "libraries"))
proc.consume_output() |
Yes, I changed the output path from the default on the command line. You can see it in the first line of the previous console output: Since sometimes I run simulation using Modelsim or Questa, I like to have separated folders. This also allows me to run the same testbench in different simulators at the same time. I guess your workaround should work with this option then. To avoid this issue for now, I removed the
I already realized I was missing I don't see any Maybe the VOpt object is not even running?? |
The optimized design should be a directory in |
Oh I think I got it. I have a master I get now this one:
|
|
@LarsAsplund I updated the VUnit repo from 4.6.0 to master and After that, the parallel execution works fine with Questa :) Do you think the work-around below can make it to next release? |
Adding a native three-step approach is a bit more work. Since we haven't released for more than a year I feel that we should take what we have (more or less) and make a release of that first before committing to more work. If we can think of a nice API to avoid modifying |
@LarsAsplund Do you think now would be a good time to introduce the fix to allow Questa running with multiple threads? |
@tasgomes Going forward I'm thinking about theme-based releases where we gather related issues. I've yet to decide on themes and order of execution but I'm pretty sure that there would be a Questa theme and an OSVVM theme if we go with this approach |
I had a lot of trouble reproducing this fix, so I have attached an updated zip file with the fix included. My changes were:
The part that I really got stuck on was that this change is required (it's not just for printing out debug info): proc = Process(args, cwd=str(Path(self._vunit._args.output_path) / "modelsim" / "libraries"))
proc.consume_output() |
This is solved with #899 |
I have an issue when running multiple threads using the Questa simulator and the flag
-p
. I created a minimal example to reproduce the issue.The testbench implements a single test case:
In the
run.py
, I replicated the test case 10 times:It is expected that all test cases are executed and
pass
. This is true when single-thread is used. However, when running in multi-thread, sometimes there are test cases that fail due to some "lock" mechanism:Trimmed log:
As can be seen, the test cases do not communicate to each other so the goal of running in parallel is just to reduce execution time.
Multithreading using GHDL or Modelsim works fine.
The issue can be reproduced here:
questa_bug.zip
sim
folderpython -u run.py -o vunit_out/questa -p 8 --simulator questa --simulator-path C:/intelFPGA_pro/21.2/questa_fe/win64
Note that the issue is not reproducible 100%, sometimes it works (all test cases pass) but most of the times it does not.
Tools:
Python 3.9.0
VUnit 4.6.0
Questa Intel FPGA Edition-64 2021.2, Revision 2021.04, Date: Apr 13 2021
The text was updated successfully, but these errors were encountered: