StanfordAHA/garnet

Magma-lang/mantle version

jiayi-wang98 opened this issue · 11 comments

Hi,

I was trying to build this from scratch. And I'm getting this error "BUILD THE CGRA ERROR: init() got an unexpected keyword argument 'name_map'" when I tried to "python garnet.py --width 32 --height 16 --verilog".

Currently, I'm using python==3.8, magma-lang==2.0.70, mantle==2.0.6.

Here's the shortened log:

--- GARNET-BUILD ()
....

--- Genesis Is Starting Work On Your Design ---

....


--- Genesis Finished Generating Your Design ---

Generating LALR tables
....
Ordt complete Sun Feb 04 23:55:42 PST 2024

  • BUILD THE CGRA
    Traceback (most recent call last):
    File "garnet.py", line 971, in
    main()
    File "garnet.py", line 888, in main
    garnet = Garnet(args)
    File "garnet.py", line 67, in init
    self.interconnect = create_cgra(**cc_args.dict)
    File "/homes/iws/jwang710/aha_ws/garnet/cgra/util_onyx.py", line 490, in create_cgra
    core = PeakCore(pe_fc, ready_valid=ready_valid)
    File "/homes/iws/jwang710/aha_ws/garnet/peak_core/peak_core.py", line 135, in init
    self.wrapper = _PeakWrapper(peak_generator)
    File "/homes/iws/jwang710/aha_ws/garnet/peak_core/peak_core.py", line 36, in call
    self = super().call(peak_generator)
    File "/homes/iws/jwang710/aha_ws/garnet/peak_core/peak_core.py", line 52, in init
    circuit = peak_generator(MagmaFamily())
    File "/homes/iws/jwang710/aha_ws/garnet/src/peak/peak/features.py", line 141, in call
    res = self.fc(*args, **kwargs)
    File "/homes/iws/jwang710/aha_ws/garnet/src/lassen/lassen/sim.py", line 21, in PE_fc
    DataReg = gen_register_mode(DATAWIDTH, 0)(family)
    File "/homes/iws/jwang710/aha_ws/garnet/src/peak/peak/features.py", line 141, in call
    res = self.fc(*args, **kwargs)
    File "/homes/iws/jwang710/aha_ws/garnet/src/lassen/lassen/mode.py", line 30, in RegisterMode_fc
    Reg = family.gen_register(T, init)
    File "/homes/iws/jwang710/aha_ws/garnet/src/peak/peak/family.py", line 382, in gen_register
    return m.Register(T, init,
    File "/homes/iws/jwang710/python/lib/python3.8/site-packages/magma_lang-2.0.75-py3.8.egg/magma/generator.py", line 102, in call
    this = _make_type(cls, *args, **kwargs)
    File "/homes/iws/jwang710/python/lib/python3.8/site-packages/magma_lang-2.0.75-py3.8.egg/magma/generator.py", line 75, in _make_type
    cls.init(dummy, *args, **kwargs)
    TypeError: init() got an unexpected keyword argument 'name_map'.

I tried to use different versions of magma-lang and mantle but these error still occurs.

Could you kindly share which version of python/magma/mantle/... packages you are using and running for the current repo? I really appreciate any help.

Thank you,
Jiayi

We generally use a docker container for all our builds. I don't suppose you have access to stanfordaha/garnet:latest on dockerhub?

When/if you get access to the docker container, you would do something like

  $ source /aha/bin/activate
  $ cd /aha/garnet; python garnet.py <flags>

And/or there is a handy wrapper

  $ source /aha/bin/activate
  $ aha garnet <flags>

Or if you still want/need to try it without the container, here is what happens when I do "pip freeze"...here you can see what versions we use for magma, magma_lang etc.

-e git+https://github.com/StanfordAHA/aha@e8b1a79b645e8148093505c6c68388fdd616d587#egg=aha
antlr4-python3-runtime==4.13.1
-e [git+https://github.com/kuree/archipelago@8013be9085c42a5884495319667ffb7d0414be53#egg=archipelago&subdirectory=../../archipelago](mailto:git+https://github.com/kuree/archipelago@8013be9085c42a5884495319667ffb7d0414be53#egg=archipelago&subdirectory=../../archipelago)
-e [git+https://github.com/leonardt/ast_tools@c8d7f0dd41fb41b9fe35f80b45b26e633c213d0d#egg=ast_tools&subdirectory=../../ast_tools](mailto:git+https://github.com/leonardt/ast_tools@c8d7f0dd41fb41b9fe35f80b45b26e633c213d0d#egg=ast_tools&subdirectory=../../ast_tools)
astor==0.8.1
-e [git+https://github.com/joyliu37/BufferMapping@8ef41175ab512bf0938283beb65d099935522990#egg=buffer_mapping&subdirectory=../../BufferMapping](mailto:git+https://github.com/joyliu37/BufferMapping@8ef41175ab512bf0938283beb65d099935522990#egg=buffer_mapping&subdirectory=../../BufferMapping)
-e [git+https://github.com/stanfordaha/canal@2d45854de21099f282c1f3e2ad558c32134101fc#egg=canal&subdirectory=../../canal](mailto:git+https://github.com/stanfordaha/canal@2d45854de21099f282c1f3e2ad558c32134101fc#egg=canal&subdirectory=../../canal)
certifi==2024.2.2
charset-normalizer==3.3.2
colorama==0.4.6
colorlog==6.8.2
-e [git+https://github.com/leonardt/pycoreir@5699e3c3fb9612f0a28cbeeaba1abfdb68680a62#egg=coreir&subdirectory=../../pycoreir](mailto:git+https://github.com/leonardt/pycoreir@5699e3c3fb9612f0a28cbeeaba1abfdb68680a62#egg=coreir&subdirectory=../../pycoreir)
-e [git+https://github.com/cristian-mattarei/cosa@141be4b23f4012c6ad5676907d7c211ae2b6614a#egg=CoSA&subdirectory=../../cosa](mailto:git+https://github.com/cristian-mattarei/cosa@141be4b23f4012c6ad5676907d7c211ae2b6614a#egg=CoSA&subdirectory=../../cosa)
DagVisitor==1.0.1
dataclasses==0.6
DeCiDa==1.1.5
delegator.py==0.1.1
docker==7.0.0
exceptiongroup==1.2.0
-e [git+https://github.com/leonardt/fault@3c3028f2fbaaa4ecf5527d6290a9ce5cc61be99a#egg=fault&subdirectory=../../fault](mailto:git+https://github.com/leonardt/fault@3c3028f2fbaaa4ecf5527d6290a9ce5cc61be99a#egg=fault&subdirectory=../../fault)
-e [git+https://github.com/stanfordaha/gemstone@072f1d67e6e6f0a654f429183e99b37c38f3eb08#egg=gemstone&subdirectory=../../gemstone](mailto:git+https://github.com/stanfordaha/gemstone@072f1d67e6e6f0a654f429183e99b37c38f3eb08#egg=gemstone&subdirectory=../../gemstone)
genesis2==0.0.6
git-me-the-url==2.1.0
gitdb==4.0.11
GitPython==3.1.41
gmpy2==2.1.5
graphviz==0.20.1
-e [git+https://github.com/leonardt/hwtypes@aa051b31e330b44dcb67834af0e454b58d7aa2d8#egg=hwtypes&subdirectory=../../hwtypes](mailto:git+https://github.com/leonardt/hwtypes@aa051b31e330b44dcb67834af0e454b58d7aa2d8#egg=hwtypes&subdirectory=../../hwtypes)
idna==3.6
importlib-metadata==7.0.1
importlib-resources==6.1.1
iniconfig==2.0.0
Jinja2==3.1.3
jsonpickle==3.0.2
-e [git+https://github.com/kuree/kratos@8c95d3073db27fd0d2cbe58197d07ec091a028bf#egg=kratos&subdirectory=../../kratos](mailto:git+https://github.com/kuree/kratos@8c95d3073db27fd0d2cbe58197d07ec091a028bf#egg=kratos&subdirectory=../../kratos)
-e [git+https://github.com/StanfordAHA/lake@4625f4c96bef5e441600648af572e8a681fa658d#egg=lake_aha&subdirectory=../../lake](mailto:git+https://github.com/StanfordAHA/lake@4625f4c96bef5e441600648af572e8a681fa658d#egg=lake_aha&subdirectory=../../lake)
-e [git+https://github.com/stanfordaha/lassen@f0af7eb7a6b71e92e87bed64bb2a79dcdb4be8b0#egg=lassen&subdirectory=../../lassen](mailto:git+https://github.com/stanfordaha/lassen@f0af7eb7a6b71e92e87bed64bb2a79dcdb4be8b0#egg=lassen&subdirectory=../../lassen)
libcst==1.1.0
-e [git+https://github.com/phanrahan/magma@266aaee29d14238976e085ce69ef27f8aab3a81f#egg=magma_lang&subdirectory=../../magma](mailto:git+https://github.com/phanrahan/magma@266aaee29d14238976e085ce69ef27f8aab3a81f#egg=magma_lang&subdirectory=../../magma)
Mako==1.3.2
-e [git+https://github.com/phanrahan/mantle@8193cf6df60f5be7f198e55d74d9a196abec8342#egg=mantle&subdirectory=../../mantle](mailto:git+https://github.com/phanrahan/mantle@8193cf6df60f5be7f198e55d74d9a196abec8342#egg=mantle&subdirectory=../../mantle)
Markdown==3.5.2
MarkupSafe==2.1.5
-e [git+https://github.com/rdaly525/MetaMapper@06e0e6f58e4278b65b90414a88be707e2eb8f0a5#egg=metamapper&subdirectory=../../MetaMapper](mailto:git+https://github.com/rdaly525/MetaMapper@06e0e6f58e4278b65b90414a88be707e2eb8f0a5#egg=metamapper&subdirectory=../../MetaMapper)
-e [git+https://github.com/mflowgen/mflowgen.git@345f2545f1f11305bfb7c29047c3cb2974a333ae#egg=mflowgen&subdirectory=../../mflowgen](mailto:git+https://github.com/mflowgen/mflowgen.git@345f2545f1f11305bfb7c29047c3cb2974a333ae#egg=mflowgen&subdirectory=../../mflowgen)
mypy-extensions==1.0.0
networkx==3.1
numpy==1.24.4
ordered-set==4.1.0
packaging==21.3
pandas==2.0.3
-e [git+https://github.com/cdonovick/peak@7846f13c32877472e01bfbc5221fc19c041d207c#egg=peak&subdirectory=../../peak](mailto:git+https://github.com/cdonovick/peak@7846f13c32877472e01bfbc5221fc19c041d207c#egg=peak&subdirectory=../../peak)
-e [git+https://github.com/jack-melchert/peak_generator@a00a468bc5940771c27bb9b62c8cc1f058b94760#egg=peak_gen&subdirectory=../../peak_generator](mailto:git+https://github.com/jack-melchert/peak_generator@a00a468bc5940771c27bb9b62c8cc1f058b94760#egg=peak_gen&subdirectory=../../peak_generator)
peakrdl-html==2.10.1
pexpect==4.9.0
pluggy==1.4.0
ply==3.11
-e [git+https://github.com/upscale-project/pono.git@b243cef7ea0c98840e7e012f5ce30f3430b1edcc#egg=pono&subdirectory=../../pono/build/python](mailto:git+https://github.com/upscale-project/pono.git@b243cef7ea0c98840e7e012f5ce30f3430b1edcc#egg=pono&subdirectory=../../pono/build/python)
ptyprocess==0.7.0
PuLP==2.8.0
py==1.11.0
-e [git+https://github.com/kuree/cgra_pnr@2b10ecb73f98c195a0535b31edf5d0c4032219c3#egg=pycyclone&subdirectory=../../cgra_pnr/cyclone](mailto:git+https://github.com/kuree/cgra_pnr@2b10ecb73f98c195a0535b31edf5d0c4032219c3#egg=pycyclone&subdirectory=../../cgra_pnr/cyclone)
pydot==2.0.0
pyparsing==3.1.1
PySMT==0.9.5
pysv==0.3.1
pytest==8.0.0
python-dateutil==2.8.2
python-markdown-math==0.8
-e [git+https://github.com/kuree/cgra_pnr@2b10ecb73f98c195a0535b31edf5d0c4032219c3#egg=pythunder&subdirectory=../../cgra_pnr/thunder](mailto:git+https://github.com/kuree/cgra_pnr@2b10ecb73f98c195a0535b31edf5d0c4032219c3#egg=pythunder&subdirectory=../../cgra_pnr/thunder)
pytz==2024.1
pyverilog==1.3.0
PyYAML==6.0.1
requests==2.31.0
requirements-parser==0.5.0
-e [git+https://github.com/weiya711/sam.git@ef1598f20579751ca2bace70592e476d4c077527#egg=sam&subdirectory=../../sam](mailto:git+https://github.com/weiya711/sam.git@ef1598f20579751ca2bace70592e476d4c077527#egg=sam&subdirectory=../../sam)
scipy==1.10.1
six==1.16.0
smmap==5.0.1
-e git+https://github.com/makaimann/smt-switch@f2d7d3d6dfccc0b4d6b604563acd34629bac884d#egg=smt_switch&subdirectory=build/python
staticfg==0.9.5
systemrdl-compiler==1.27.3
tabulate==0.9.0
tomli==2.0.1
torch==1.7.1+cpu
types-setuptools==69.0.0.20240125
typing-extensions==4.9.0
typing-inspect==0.9.0
tzdata==2023.4
urllib3==1.26.15
z3-solver==4.12.5.0
zipp==3.17.0

We generally use a docker container for all our builds. I don't suppose you have access to stanfordaha/garnet:latest on dockerhub?

No I don't have access to the dockerhub. Can I get that access some way? Otherwise, I guess I can only try on my local machine.

Anyway, thank you so much!

Best,
Jiayi

I don't know how to get you on the dockerhub, but hopefully the information above will give you enough information to go forward on your local machine. Good luck!

Thank you so much. But it's still hard to run the example after trying to sync all the packages to the version mentioned.

I have tried to modify the requirements.txt to the following:

coreir>=2.0.123 # should be first so we get the latest version
-e git+https://github.com/StanfordAHA/gemstone.git@072f1d67e6e6f0a654f429183e99b37c38f3eb08#egg=gemstone
-e git+https://github.com/StanfordAHA/canal.git#egg=canal
-e git+https://github.com/phanrahan/peak.git#egg=peak
-e git+https://github.com/StanfordAHA/lassen.git#egg=lassen
-e git+https://github.com/Kuree/karst.git#egg=karst
-e git+https://github.com/joyliu37/BufferMapping#egg=buffer_mapping
-e git+https://github.com/pyhdi/pyverilog.git#egg=pyverilog
-e git+https://github.com/StanfordAHA/lake@4625f4c96bef5e441600648af572e8a681fa658d#egg=lake-aha
-e git+https://github.com/phanrahan/magma.git@266aaee29d14238976e085ce69ef27f8aab3a81f#egg=magma-lang
-e git+https://github.com/phanrahan/mantle.git@8193cf6df60f5be7f198e55d74d9a196abec8342#egg=mantle
-e git+https://github.com/jack-melchert/peak_generator#egg=peak_gen
-e git+https://github.com/rdaly525/MetaMapper#egg=metamapper
ordered_set
cosa
-e git+https://github.com/leonardt/fault.git@3c3028f2fbaaa4ecf5527d6290a9ce5cc61be99a#egg=fault
hwtypes
-e git+https://github.com/Kuree/archipelago.git@8013be9085c42a5884495319667ffb7d0414be53#egg=archipelago
systemrdl-compiler
peakrdl-html
pulp

But I still get the error message below:

  • BUILD THE CGRA
    strg_ub_thin_PondTop
    FOUND BULK
    INPUTS DICT
    {17: [{'strg_ub_thin_PondTop_flat': 'data_in_f_0'}, {'strg_ub_thin_PondTop_flat': 'data_in_f_1'}]}
    Printing mode map...
    {'strg_ub_thin_PondTop': (0, 'bulk')}
    Printing mode map...
    {'strg_ub_thin_PondTop': (0, 'bulk')}
    Variable: strt_addr has no sink
    Variable: strt_addr has no sink
    Variable: strt_addr has no sink
    Variable: strt_addr has no sink
    Traceback (most recent call last):
    File "garnet.py", line 971, in
    main()
    File "garnet.py", line 888, in main
    garnet = Garnet(args)
    File "garnet.py", line 67, in init
    self.interconnect = create_cgra(**cc_args.dict)
    File "/home/ubuntu/garnet/cgra/util_onyx.py", line 488, in create_cgra
    core = MemCore(use_sim_sram=use_sim_sram, gate_flush=not harden_flush, ready_valid=ready_valid)
    File "/home/ubuntu/garnet/memory_core/memory_core_magma.py", line 158, in init
    self.LT = LakeTop(data_width=self.data_width,
    File "/home/ubuntu/garnet/src/lake-aha/lake/top/lake_top.py", line 137, in init
    controllers.append(StrgUBVec(data_width=self.data_width,
    File "/home/ubuntu/garnet/src/lake-aha/lake/modules/strg_ub_vec.py", line 207, in init
    tb_only = StrgUBTBOnly(data_width=self.data_width,
    File "/home/ubuntu/garnet/src/lake-aha/lake/modules/tb_only.py", line 305, in init
    self.add_code(tb_to_out)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/kratos/generator.py", line 620, in add_always
    block_type, raw_sensitives, stmts = transform_stmt_block(self, fn, unroll_for=unroll_for,
    File "/home/ubuntu/.local/lib/python3.8/site-packages/kratos/pyast.py", line 1198, in transform_stmt_block
    src = astor.to_source(func_tree, pretty_source=__pretty_source)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/astor/code_gen.py", line 67, in to_source
    return pretty_source(generator.result)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/kratos/pyast.py", line 22, in __pretty_source
    return "".join(source)
    TypeError: sequence item 13: expected str instance, list found

And it seems a problem with Kratos so I checked the version of kratos and tried to install it by

pip install -e git+https://github.com/kuree/kratos@8c95d3073db27fd0d2cbe58197d07ec091a028bf#egg=kratos,
But still got errors for installing this kratos and tried multiple ways to manually build but all fails.

I guess its hard to set up the environment without the docker so I will probably give up this. But anyway thank you so much!

Here's one last thing you might try. I'm not sure what all these flags do, but this is what I use whenever I'm trying to build garnet RTL...

  $ flags="--width 4 --height 2 --pipeline_config_interval 8 -v --glb_tile_mem_size 256"
  $ flags+=" --interconnect-only"
  $ flags+=" --dump-config-reg"
  $ echo $flags | fold -sw 40  # optional
  $ python3 garnet.py $flags

Thank you so much although still not works. It would be really nice if you could send me the docker container file. I really appreciate it.

I guess you can try and build the docker from source, just like we do. The source lives in our StanfordAHA/aha.git repo. So maybe you'd do something like this;

# Boot up a docker image

  git clone https://github.com/StanfordAHA/aha aha
  cd aha
  docker build . -t "garnet:my_image"
  docker pull garnet:my_image
  docker run -id --name my_container garnet:my_image bash
  source /aha/bin/activate

# (inside docker now) Assemble RTL-build flags for quick 4x2 build

  width=4
  height=$((width/2))
  flags="--width $width --height $height --pipeline_config_interval 8 -v --glb_tile_mem_size 256"

# To build older "amber" version of the chip (also see aha/bin/rtl-goldcheck.sh)

  export WHICH_SOC=amber
  # Update docker to match necessary amber environment
  garnet/mflowgen/common/rtl/gen_rtl.sh -u | tee tmp-amber-updates.sh
  cat tmp-amber-updates.sh
  source tmp-amber-updates.sh

# OR To build newer "onyx" version of the chip, do this instead

  export WHICH_SOC=onyx
  flags="$flags --rv --sparse-cgra --sparse-cgra-combined"

# Build the chip; result should be in 'garnet/garnet.v'

  aha garnet $flags

# Assemble final design.v
  cd garnet
  cp garnet.v genesis_verif/garnet.v
  cat genesis_verif/* > design.v
  cat global_buffer/systemRDL/output/glb_pio.sv >> design.v
  cat global_buffer/systemRDL/output/glb_jrdl_decode.sv >> design.v
  cat global_buffer/systemRDL/output/glb_jrdl_logic.sv >> design.v
  cat global_controller/systemRDL/output/*.sv >> design.v

Thank you so much for the instructions. I can almost run this through now. here's actually what I have done.

#Boot up a docker image

git clone https://github.com/StanfordAHA/aha aha

cd aha
++ git submodule init update --recursive

sudo docker build . -t "garnet:my_image"
-- docker pull garnet:my_image (not work without access, can still run through without this)
sudo docker run -id --name my_container garnet:my_image bash
source /aha/bin/activate (not work, use "sudo docker exec -it aha_container bash" instead )

#(inside docker now) Assemble RTL-build flags for quick 4x2 build

width=4
height=$((width/2))
flags="--width $width --height $height --pipeline_config_interval 8 -v --glb_tile_mem_size 256"

#To build older "amber" version of the chip (also see aha/bin/rtl-goldcheck.sh)

export WHICH_SOC=amber
#Update docker to match necessary amber environment
garnet/mflowgen/common/rtl/gen_rtl.sh -u | tee tmp-amber-updates.sh
cat tmp-amber-updates.sh
source tmp-amber-updates.sh

#OR To build newer "onyx" version of the chip, do this instead

export WHICH_SOC=onyx
flags="$flags --rv --sparse-cgra --sparse-cgra-combined"

#Build the chip; result should be in 'garnet/garnet.v'

aha garnet $flags (assert error if executing flags="$flags --rv --sparse-cgra --sparse-cgra-combined". Can run if not execute flags=...)

#Assemble final design.v
cd garnet
cp garnet.v genesis_verif/garnet.v
cat genesis_verif/* > design.v
cat global_buffer/systemRDL/output/glb_pio.sv >> design.v
cat global_buffer/systemRDL/output/glb_jrdl_decode.sv >> design.v
cat global_buffer/systemRDL/output/glb_jrdl_logic.sv >> design.v
cat global_controller/systemRDL/output/*.sv >> design.v

Thank you a ton for helping me this.

can run through with docker built.

Oops @jiayi-wang98 they have just updated garnet master; the flags —rv, —sparse-cgra and —sparse-cgra-combined have been eliminated. Anyone who uses the updated version will instead have to use --include-sparse. But if you can make it run successfully without using any of these flags, that's fine too.