Comments (6)
Have you done any profiling to find out why this could be? And are you sure this is not an issue with the simulator?
from cocotb.
I've tried it out with Verilator as the simulator and did not see the same kind of problem. I also ran with questa a wrapper file on top of the dut to emulate the assignment of the memory in the same way as was done in cocotb (but without using the VPI) and saw no performance degradation issues there. I think its a VPI issue but how to tell if its a problem on the CocoTB side of things or the questa side I'm not sure. I'm also not sure how I could just test the Questa side of the VPI.
When I ran the test again with MLEM_L2 = 16
and the cocotb profiler enabled (COCOTB_ENABLE_PROFILING=1
) I get the following call graph, that might be useful.
I don't fully understand it but it looks like there's a lot of calls to the GPI handler from Scheduler._do_writes
.
Looking at the code of the function:
async def _do_writes(self):
"""An internal coroutine that performs pending writes"""
while True:
await self._writes_pending.wait()
if self._mode != Scheduler._MODE_NORMAL:
await self._next_time_step
await self._read_write
while self._write_calls:
handle, (func, args) = self._write_calls.popitem(last=False)
func(*args)
self._writes_pending.clear()
It looks to me like we make a call to each handle in the _write_calls
list. I wonder if its possible to only use one handle for a logic array (or maybe that's infeasible, pointless or extremely problematic) or somehow parallelize the write calls to each GPI handler?
from cocotb.
I wonder if its possible to only use one handle for a logic array
That is already done. Unless you are explicitly doing something different.
somehow parallelize the write calls to each GPI handler?
The VPI, VHPI, FLI are probably not designed for that, and the GPI certainly isn't. Also there's no guarantee the same handle will appear in the list twice.
I wonder if the time reported in set_signal_value_int
is weird due to how profiling is collected or if it's really taking that long, which would be truly absurd.
I've tried it out with Verilator as the simulator and did not see the same kind of problem. I also ran with questa a wrapper file on top of the dut to emulate the assignment of the memory in the same way as was done in cocotb (but without using the VPI) and saw no performance degradation issues there. I think its a VPI issue but how to tell if its a problem on the CocoTB side of things or the questa side I'm not sure. I'm also not sure how I could just test the Questa side of the VPI.
I feel that this means the problem is the simulator, not cocotb. I would imagine that some simulators implement large arrays as sparse arrays or minimal length vectors until they are used. I'm guessing every write (or N writes) is causing a reallocation and copy and what you are doing is just hitting a performance corner case in Questa.
Does profiling other simulators show the same weird graph where 95% of the time is spend in set_signal_value_int
?
from cocotb.
I feel that this means the problem is the simulator, not cocotb. I would imagine that some simulators implement large arrays as sparse arrays or minimal length vectors until they are used. I'm guessing every write (or N writes) is causing a reallocation and copy and what you are doing is just hitting a performance corner case in Questa.
Right, I didn't really think about how the simulator might be implementing large arrays, I guess I assumed that it would be allocated at the start.
Does profiling other simulators show the same weird graph where 95% of the time is spend in
set_signal_value_int
?
No it doesn't seem like it. At least when I look at the profiling with verilator as the simulator the graph is very different and only 1.5% of the time is spent in set_signal_value_int
:
ok, so maybe it is just a performance issue with Questa then.
from cocotb.
I'd definitely file a bug with Questa if you can. I feel like this isn't too odd of a case and it shouldn't be pessimising it.
from cocotb.
Unless there is any other questions or issues, I'll close this. Feel free to reopen if needed.
from cocotb.
Related Issues (20)
- Support equality between `Array` and `list` and `tuple`
- Deprecate and provide better name for `LogicArray.integer`
- Vpi Package: >32 bit parameters are interpreted as Integers HOT 3
- vpiScope objects are not visible HOT 1
- Make `VERILATOR_SIM_DEBUG` functionality a runtime switch
- Add guide on how to upgrade from `BinaryValue` to `LogicArray`
- Change `ModifiableObject.drivers` and `ModifiableObject.loads` to be Python iterables
- Change names of `cocotb.external` and `cocotb.function`
- VPI does not find instance HOT 3
- Simulator support documentation Verilator
- `Dockerfile.gitpod` uses outdated tool versions
- Improve regression messages
- Document which simulators support Force/Release
- Support comparison between `LogicArray` and literal syntaxes
- Update pyproject.toml for changes to ruff's sections in 2.0
- Error regarding no root handle found HOT 3
- cocotb 1.8.1 + python 3.12.2 + activehdl 12 not working HOT 5
- VHDL using generic width for a package type doesn't work HOT 6
- Add rationale string to `skip` argument of `cocotb.test`
- [GPI] gpi_get_handle_by_name() implementations don't handle passing hierarchical path as subhandle name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cocotb.