Firrtl runs of out of heap memory with large input
up vote
2
down vote
favorite
I'm attempting to run a verilog compiler pass on a 110MB Firrtl file and I'm consistently getting out of memory errors, despite giving it a roomy 12G heap space to play with. It seems like the problem is the parser, specifically ANTLR, making too many ArrayLists. Is 110MB considered far too large for a Firrtl circuit definition?
The file was produced with Chisel via Firrtl with --compiler=high
. My Firrtl version is 1.2-SNAPSHOT
(built locally) and Chisel is 3.2-SNAPSHOT
(also built locally).
$ JAVA_OPTS="-Xms8G -Xmx12G" ../firrtl/utils/bin/firrtl -i mnist_cnn_v4.fir -o mnist_cnn_v4.v -X verilog --no-check-comb-loops --no-dce --info-mode=ignore -ll Trace
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3688)
at java.base/java.util.ArrayList.grow(ArrayList.java:236)
at java.base/java.util.ArrayList.grow(ArrayList.java:241)
at java.base/java.util.ArrayList.add(ArrayList.java:466)
at java.base/java.util.ArrayList.add(ArrayList.java:479)
at org.antlr.v4.runtime.ParserRuleContext.addAnyChild(ParserRuleContext.java:134)
at org.antlr.v4.runtime.ParserRuleContext.addChild(ParserRuleContext.java:145)
at org.antlr.v4.runtime.Parser.consume(Parser.java:584)
at firrtl.antlr.FIRRTLParser.intLit(FIRRTLParser.java:2870)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:600)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.port(FIRRTLParser.java:418)
at firrtl.antlr.FIRRTLParser.module(FIRRTLParser.java:287)
at firrtl.antlr.FIRRTLParser.circuit(FIRRTLParser.java:189)
at firrtl.Parser$.$anonfun$parseCharStream$1(Parser.scala:42)
at firrtl.Parser$$$Lambda$94/1642030774.apply(Unknown Source)
at firrtl.Utils$.time(Utils.scala:186)
at firrtl.Parser$.parseCharStream(Parser.scala:33)
at firrtl.Parser$.parseFile(Parser.scala:25)
at firrtl.Driver$.$anonfun$getCircuit$5(Driver.scala:200)
at firrtl.Driver$$$Lambda$93/1571967156.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$3(Driver.scala:183)
at firrtl.Driver$$$Lambda$91/802600647.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$1(Driver.scala:183)
at firrtl.Driver$$$Lambda$88/2041416495.apply(Unknown Source)
jvm out-of-memory chisel
add a comment |
up vote
2
down vote
favorite
I'm attempting to run a verilog compiler pass on a 110MB Firrtl file and I'm consistently getting out of memory errors, despite giving it a roomy 12G heap space to play with. It seems like the problem is the parser, specifically ANTLR, making too many ArrayLists. Is 110MB considered far too large for a Firrtl circuit definition?
The file was produced with Chisel via Firrtl with --compiler=high
. My Firrtl version is 1.2-SNAPSHOT
(built locally) and Chisel is 3.2-SNAPSHOT
(also built locally).
$ JAVA_OPTS="-Xms8G -Xmx12G" ../firrtl/utils/bin/firrtl -i mnist_cnn_v4.fir -o mnist_cnn_v4.v -X verilog --no-check-comb-loops --no-dce --info-mode=ignore -ll Trace
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3688)
at java.base/java.util.ArrayList.grow(ArrayList.java:236)
at java.base/java.util.ArrayList.grow(ArrayList.java:241)
at java.base/java.util.ArrayList.add(ArrayList.java:466)
at java.base/java.util.ArrayList.add(ArrayList.java:479)
at org.antlr.v4.runtime.ParserRuleContext.addAnyChild(ParserRuleContext.java:134)
at org.antlr.v4.runtime.ParserRuleContext.addChild(ParserRuleContext.java:145)
at org.antlr.v4.runtime.Parser.consume(Parser.java:584)
at firrtl.antlr.FIRRTLParser.intLit(FIRRTLParser.java:2870)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:600)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.port(FIRRTLParser.java:418)
at firrtl.antlr.FIRRTLParser.module(FIRRTLParser.java:287)
at firrtl.antlr.FIRRTLParser.circuit(FIRRTLParser.java:189)
at firrtl.Parser$.$anonfun$parseCharStream$1(Parser.scala:42)
at firrtl.Parser$$$Lambda$94/1642030774.apply(Unknown Source)
at firrtl.Utils$.time(Utils.scala:186)
at firrtl.Parser$.parseCharStream(Parser.scala:33)
at firrtl.Parser$.parseFile(Parser.scala:25)
at firrtl.Driver$.$anonfun$getCircuit$5(Driver.scala:200)
at firrtl.Driver$$$Lambda$93/1571967156.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$3(Driver.scala:183)
at firrtl.Driver$$$Lambda$91/802600647.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$1(Driver.scala:183)
at firrtl.Driver$$$Lambda$88/2041416495.apply(Unknown Source)
jvm out-of-memory chisel
You can try adding this line to yourbashrc
file:export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Xmx8G -XX:MaxPermSize=1G -Xss2M"
NOTE: When you runChisel
this throws a warning sayingOpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
, but it has worked for me flawlessly
– Abhishek Tyagi
Nov 14 at 11:54
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm attempting to run a verilog compiler pass on a 110MB Firrtl file and I'm consistently getting out of memory errors, despite giving it a roomy 12G heap space to play with. It seems like the problem is the parser, specifically ANTLR, making too many ArrayLists. Is 110MB considered far too large for a Firrtl circuit definition?
The file was produced with Chisel via Firrtl with --compiler=high
. My Firrtl version is 1.2-SNAPSHOT
(built locally) and Chisel is 3.2-SNAPSHOT
(also built locally).
$ JAVA_OPTS="-Xms8G -Xmx12G" ../firrtl/utils/bin/firrtl -i mnist_cnn_v4.fir -o mnist_cnn_v4.v -X verilog --no-check-comb-loops --no-dce --info-mode=ignore -ll Trace
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3688)
at java.base/java.util.ArrayList.grow(ArrayList.java:236)
at java.base/java.util.ArrayList.grow(ArrayList.java:241)
at java.base/java.util.ArrayList.add(ArrayList.java:466)
at java.base/java.util.ArrayList.add(ArrayList.java:479)
at org.antlr.v4.runtime.ParserRuleContext.addAnyChild(ParserRuleContext.java:134)
at org.antlr.v4.runtime.ParserRuleContext.addChild(ParserRuleContext.java:145)
at org.antlr.v4.runtime.Parser.consume(Parser.java:584)
at firrtl.antlr.FIRRTLParser.intLit(FIRRTLParser.java:2870)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:600)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.port(FIRRTLParser.java:418)
at firrtl.antlr.FIRRTLParser.module(FIRRTLParser.java:287)
at firrtl.antlr.FIRRTLParser.circuit(FIRRTLParser.java:189)
at firrtl.Parser$.$anonfun$parseCharStream$1(Parser.scala:42)
at firrtl.Parser$$$Lambda$94/1642030774.apply(Unknown Source)
at firrtl.Utils$.time(Utils.scala:186)
at firrtl.Parser$.parseCharStream(Parser.scala:33)
at firrtl.Parser$.parseFile(Parser.scala:25)
at firrtl.Driver$.$anonfun$getCircuit$5(Driver.scala:200)
at firrtl.Driver$$$Lambda$93/1571967156.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$3(Driver.scala:183)
at firrtl.Driver$$$Lambda$91/802600647.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$1(Driver.scala:183)
at firrtl.Driver$$$Lambda$88/2041416495.apply(Unknown Source)
jvm out-of-memory chisel
I'm attempting to run a verilog compiler pass on a 110MB Firrtl file and I'm consistently getting out of memory errors, despite giving it a roomy 12G heap space to play with. It seems like the problem is the parser, specifically ANTLR, making too many ArrayLists. Is 110MB considered far too large for a Firrtl circuit definition?
The file was produced with Chisel via Firrtl with --compiler=high
. My Firrtl version is 1.2-SNAPSHOT
(built locally) and Chisel is 3.2-SNAPSHOT
(also built locally).
$ JAVA_OPTS="-Xms8G -Xmx12G" ../firrtl/utils/bin/firrtl -i mnist_cnn_v4.fir -o mnist_cnn_v4.v -X verilog --no-check-comb-loops --no-dce --info-mode=ignore -ll Trace
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3688)
at java.base/java.util.ArrayList.grow(ArrayList.java:236)
at java.base/java.util.ArrayList.grow(ArrayList.java:241)
at java.base/java.util.ArrayList.add(ArrayList.java:466)
at java.base/java.util.ArrayList.add(ArrayList.java:479)
at org.antlr.v4.runtime.ParserRuleContext.addAnyChild(ParserRuleContext.java:134)
at org.antlr.v4.runtime.ParserRuleContext.addChild(ParserRuleContext.java:145)
at org.antlr.v4.runtime.Parser.consume(Parser.java:584)
at firrtl.antlr.FIRRTLParser.intLit(FIRRTLParser.java:2870)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:600)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.field(FIRRTLParser.java:740)
at firrtl.antlr.FIRRTLParser.type(FIRRTLParser.java:647)
at firrtl.antlr.FIRRTLParser.port(FIRRTLParser.java:418)
at firrtl.antlr.FIRRTLParser.module(FIRRTLParser.java:287)
at firrtl.antlr.FIRRTLParser.circuit(FIRRTLParser.java:189)
at firrtl.Parser$.$anonfun$parseCharStream$1(Parser.scala:42)
at firrtl.Parser$$$Lambda$94/1642030774.apply(Unknown Source)
at firrtl.Utils$.time(Utils.scala:186)
at firrtl.Parser$.parseCharStream(Parser.scala:33)
at firrtl.Parser$.parseFile(Parser.scala:25)
at firrtl.Driver$.$anonfun$getCircuit$5(Driver.scala:200)
at firrtl.Driver$$$Lambda$93/1571967156.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$3(Driver.scala:183)
at firrtl.Driver$$$Lambda$91/802600647.apply(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)
at firrtl.Driver$.$anonfun$getCircuit$1(Driver.scala:183)
at firrtl.Driver$$$Lambda$88/2041416495.apply(Unknown Source)
jvm out-of-memory chisel
jvm out-of-memory chisel
asked Nov 11 at 1:22
alcorn
34817
34817
You can try adding this line to yourbashrc
file:export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Xmx8G -XX:MaxPermSize=1G -Xss2M"
NOTE: When you runChisel
this throws a warning sayingOpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
, but it has worked for me flawlessly
– Abhishek Tyagi
Nov 14 at 11:54
add a comment |
You can try adding this line to yourbashrc
file:export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Xmx8G -XX:MaxPermSize=1G -Xss2M"
NOTE: When you runChisel
this throws a warning sayingOpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
, but it has worked for me flawlessly
– Abhishek Tyagi
Nov 14 at 11:54
You can try adding this line to your
bashrc
file: export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Xmx8G -XX:MaxPermSize=1G -Xss2M"
NOTE: When you run Chisel
this throws a warning saying OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
, but it has worked for me flawlessly– Abhishek Tyagi
Nov 14 at 11:54
You can try adding this line to your
bashrc
file: export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Xmx8G -XX:MaxPermSize=1G -Xss2M"
NOTE: When you run Chisel
this throws a warning saying OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
, but it has worked for me flawlessly– Abhishek Tyagi
Nov 14 at 11:54
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
This is a known limitation of the parser and there are two workarounds, as suggested by Jack in this comment:
Use protobuf as the interface between Chisel and FIRRTL. Instead of using
chisel3.Driver.dumpFirrtl
, usechisel3.Driver.dumpProto
. The FIRRTL command line utility will automatically infer.pb
files as protobuf and use the appropriate deserializer as opposed to the ANTLR parser.Use
chisel3.Driver
to call FIRRTL directly instead of using the FIRRTL command line utility. This will still cause FIRRTL to be emitted for you to examine, but internally the Chisel representation is converted directly to FIRRTL without going through parsing. Try:
val args = Array("-o", "mnist_cnn_v4.v",
"-X", "verilog",
"--no-check-comb-loops",
"--no-dce",
"--info-mode=ignore",
"-ll Trace")
chisel3.Driver.execute(args, () => new Foo) /* change Foo to your top module */
The latter in-memory conversion was added in Chisel3#829 and protobuf support was added in FIRRTL#832. Jack has some experiments referenced there of reading a 420MB FIRRTL file using different methods. Summarily, try to avoid using the parser if you have big FIRRTL files.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
This is a known limitation of the parser and there are two workarounds, as suggested by Jack in this comment:
Use protobuf as the interface between Chisel and FIRRTL. Instead of using
chisel3.Driver.dumpFirrtl
, usechisel3.Driver.dumpProto
. The FIRRTL command line utility will automatically infer.pb
files as protobuf and use the appropriate deserializer as opposed to the ANTLR parser.Use
chisel3.Driver
to call FIRRTL directly instead of using the FIRRTL command line utility. This will still cause FIRRTL to be emitted for you to examine, but internally the Chisel representation is converted directly to FIRRTL without going through parsing. Try:
val args = Array("-o", "mnist_cnn_v4.v",
"-X", "verilog",
"--no-check-comb-loops",
"--no-dce",
"--info-mode=ignore",
"-ll Trace")
chisel3.Driver.execute(args, () => new Foo) /* change Foo to your top module */
The latter in-memory conversion was added in Chisel3#829 and protobuf support was added in FIRRTL#832. Jack has some experiments referenced there of reading a 420MB FIRRTL file using different methods. Summarily, try to avoid using the parser if you have big FIRRTL files.
add a comment |
up vote
2
down vote
accepted
This is a known limitation of the parser and there are two workarounds, as suggested by Jack in this comment:
Use protobuf as the interface between Chisel and FIRRTL. Instead of using
chisel3.Driver.dumpFirrtl
, usechisel3.Driver.dumpProto
. The FIRRTL command line utility will automatically infer.pb
files as protobuf and use the appropriate deserializer as opposed to the ANTLR parser.Use
chisel3.Driver
to call FIRRTL directly instead of using the FIRRTL command line utility. This will still cause FIRRTL to be emitted for you to examine, but internally the Chisel representation is converted directly to FIRRTL without going through parsing. Try:
val args = Array("-o", "mnist_cnn_v4.v",
"-X", "verilog",
"--no-check-comb-loops",
"--no-dce",
"--info-mode=ignore",
"-ll Trace")
chisel3.Driver.execute(args, () => new Foo) /* change Foo to your top module */
The latter in-memory conversion was added in Chisel3#829 and protobuf support was added in FIRRTL#832. Jack has some experiments referenced there of reading a 420MB FIRRTL file using different methods. Summarily, try to avoid using the parser if you have big FIRRTL files.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
This is a known limitation of the parser and there are two workarounds, as suggested by Jack in this comment:
Use protobuf as the interface between Chisel and FIRRTL. Instead of using
chisel3.Driver.dumpFirrtl
, usechisel3.Driver.dumpProto
. The FIRRTL command line utility will automatically infer.pb
files as protobuf and use the appropriate deserializer as opposed to the ANTLR parser.Use
chisel3.Driver
to call FIRRTL directly instead of using the FIRRTL command line utility. This will still cause FIRRTL to be emitted for you to examine, but internally the Chisel representation is converted directly to FIRRTL without going through parsing. Try:
val args = Array("-o", "mnist_cnn_v4.v",
"-X", "verilog",
"--no-check-comb-loops",
"--no-dce",
"--info-mode=ignore",
"-ll Trace")
chisel3.Driver.execute(args, () => new Foo) /* change Foo to your top module */
The latter in-memory conversion was added in Chisel3#829 and protobuf support was added in FIRRTL#832. Jack has some experiments referenced there of reading a 420MB FIRRTL file using different methods. Summarily, try to avoid using the parser if you have big FIRRTL files.
This is a known limitation of the parser and there are two workarounds, as suggested by Jack in this comment:
Use protobuf as the interface between Chisel and FIRRTL. Instead of using
chisel3.Driver.dumpFirrtl
, usechisel3.Driver.dumpProto
. The FIRRTL command line utility will automatically infer.pb
files as protobuf and use the appropriate deserializer as opposed to the ANTLR parser.Use
chisel3.Driver
to call FIRRTL directly instead of using the FIRRTL command line utility. This will still cause FIRRTL to be emitted for you to examine, but internally the Chisel representation is converted directly to FIRRTL without going through parsing. Try:
val args = Array("-o", "mnist_cnn_v4.v",
"-X", "verilog",
"--no-check-comb-loops",
"--no-dce",
"--info-mode=ignore",
"-ll Trace")
chisel3.Driver.execute(args, () => new Foo) /* change Foo to your top module */
The latter in-memory conversion was added in Chisel3#829 and protobuf support was added in FIRRTL#832. Jack has some experiments referenced there of reading a 420MB FIRRTL file using different methods. Summarily, try to avoid using the parser if you have big FIRRTL files.
answered Nov 11 at 4:44
seldridge
62549
62549
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245026%2ffirrtl-runs-of-out-of-heap-memory-with-large-input%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can try adding this line to your
bashrc
file:export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -Xmx8G -XX:MaxPermSize=1G -Xss2M"
NOTE: When you runChisel
this throws a warning sayingOpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
, but it has worked for me flawlessly– Abhishek Tyagi
Nov 14 at 11:54