Skip to content
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

Random test now available for the adder. Fails with a stack overflow … #6

Merged
merged 3 commits into from
Nov 8, 2022

Conversation

stevenmburns
Copy link
Owner

…on examples with 650 bits

@stevenmburns
Copy link
Owner Author

@mkorbel1 Is there a way to increase the stack size in Dart so that we don't hit a stack overflow error when working with 650 bit adders? Is there a lot of recursion inside the Dart simulator that might be causing this?

smburns@smburns-XPS-13-9370:~/ROHD/dart-pg/sklansky$ dart test test/sklansky_test.dart --plain-name 'adderRandom adder_650'
00:01 +0 -1: adderRandom adder_650 [E]                                                                                               
  Stack Overflow
  package:rohd/src/values/logic_value.dart 280:41  LogicValue.toString.<fn>
  dart:core                                        new _GrowableList.generate
  package:rohd/src/values/logic_value.dart 280:12  LogicValue.toString
  package:rohd/src/values/logic_value.dart 127:23  LogicValue.of.<fn>
  dart:core                                        new _GrowableList._ofEfficientLengthIterable
  package:rohd/src/modules/bus.dart 151:62         Swizzle._execute
  package:rohd/src/modules/bus.dart 143:9          new Swizzle.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/gates.dart 207:9        _TwoInputBitwiseGate._execute
  package:rohd/src/modules/gates.dart 194:7        _TwoInputBitwiseGate._setup.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/bus.dart 85:14          BusSubset._execute
  package:rohd/src/modules/bus.dart 76:7           BusSubset._setup.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/bus.dart 152:9          Swizzle._execute
  package:rohd/src/modules/bus.dart 143:9          new Swizzle.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/gates.dart 207:9        _TwoInputBitwiseGate._execute
  package:rohd/src/modules/gates.dart 194:7        _TwoInputBitwiseGate._setup.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/bus.dart 85:14          BusSubset._execute
  package:rohd/src/modules/bus.dart 76:7           BusSubset._setup.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/bus.dart 152:9          Swizzle._execute
  package:rohd/src/modules/bus.dart 143:9          new Swizzle.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  .                                                ...
  .                                                ...
  package:rohd/src/modules/gates.dart 194:7        _TwoInputBitwiseGate._setup.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/modules/bus.dart 85:14          BusSubset._execute
  package:rohd/src/modules/bus.dart 76:7           BusSubset._setup.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  package:rohd/src/logic.dart 271:7                Logic._connect.<fn>
  package:rohd/src/logic.dart 446:25               Logic.put
  test/sklansky_test.dart 145:11                   testAdderRandom.<fn>
  

To run this test again: dart test test/sklansky_test.dart -p vm --plain-name 'adderRandom adder_650'
adder: 3304706197836812759313325637912508255537535214315586495879430796578571070866797883083557183765831691174296207740223668164073333337864819475213625961188542909505648205287396707218007041970145732200 2483203407525067014820450385970580323274998194533180467780631588296854441716914817004833724537803739030759912953399505954458672186486717092210015017386647456960309740172996485603211241546754820001 1115970412916751870245216299645990262121867417426241594746969246546567741362027056306336189514647116831726395690262501032386771889663088057212915787179643037695915398915481883936355110656378285577 1115970412916751870245216299645990262121867417426241594746969246546567741362027056306336189514647116831726395690262501032386771889663088057212915787179643037695915398915481883936355110656378285577
...

@mkorbel1
Copy link

mkorbel1 commented Nov 7, 2022

I haven't seen this before. From the stack trace, I think the chain of Logic.put is the signal propagating through the design. I don't know of a way to increase the stack size but I haven't tried before. I'll experiment a bit with this.

@mkorbel1
Copy link

mkorbel1 commented Nov 8, 2022

I don't think there's an easy way to just increase the stack size in Dart, though it is apparently possible (I think down this route: https://unix.stackexchange.com/questions/127602/default-stack-size-for-pthreads/127615#127615).

However, I have some paths to go down that I think should make this much harder to hit while also improving simulation performance. I also might have a way to make it so you'll never hit this. I'll keep you updated!

I think this only would affect really long combinational chains of logic.

@stevenmburns stevenmburns merged commit 2d773cb into main Nov 8, 2022
@stevenmburns
Copy link
Owner Author

stevenmburns commented Nov 8, 2022 via email

@mkorbel1
Copy link

@stevenmburns I didn't fully fix the issue yet, but the changes in this PR should significantly mitigate the issue and allow longer chains of combinational logic. A full fix requires a bigger set of changes.
intel/rohd#199

@mkorbel1
Copy link

@stevenmburns ROHD v0.4.1 was just released, including the mitigation that helps with this issue
https://pub.dev/packages/rohd/changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants