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

chisel refactoring to enable split main <-> test #104

Merged
merged 19 commits into from
May 10, 2024
Merged

Conversation

jorendumoulin
Copy link

@jorendumoulin jorendumoulin commented May 8, 2024

See here my proposals to be able to split testing and source code without errors.
This includes the following:

  • remove the emitVerilog statements: they should be implemented by the user of the streamer with the correct parameters (like it is done in snax: Add wrapper and template generation #100). If these are useful for testing and we still want to keep them somewhere, I can reimplement them in a test.
  • removed most of the default argument assignments, as most of them held an arbitrary value (defaults should only be set if this value will be used in almost all cases)
  • some slight argument renaming to enable the split

@jorendumoulin jorendumoulin marked this pull request as ready for review May 8, 2024 09:58
Copy link

@rgantonio rgantonio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it does look cleaner because all test files are collated (collected/aggregated). My only worry is:

  1. Will it break when I generate new parameters? I left some comments on parts that i think are critical.
  2. Will it also break @xiaoling-yi 's flow? Haha, make sure to discuss together and meet half-way 😄

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this file too make sure to add those I mean one of those and test if they generate properly: sbt "runMain snax.streamer.MacStreamerTop "

// streamertop for MAC
object MacStreamerTop extends App {
  emitVerilog(
    new StreamerTop(
      StreamerParams(
        temporalAddrGenUnitParams =
          MacStreamerParameters.temporalAddrGenUnitParams,
        fifoReaderParams = MacStreamerParameters.fifoReaderParams,
        fifoWriterParams = MacStreamerParameters.fifoWriterParams,
        stationarity = MacStreamerParameters.stationarity,
        dataReaderParams = MacStreamerParameters.dataReaderParams,
        dataWriterParams = MacStreamerParameters.dataWriterParams
      )
    ),
    Array("--target-dir", "generated/streamertop/mac")
  )
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above!

Array("--target-dir", "generated/")
)

}
Copy link
Collaborator

@xiaoling-yi xiaoling-yi May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote to put the parameter example for instancing gemm and simd back. We can write some comments in the code to say this example configuration is for which accelerator. Because I think 1) these example configurations are good for people to understand how to configure the streamer for different use cases as the configuration format of the streamer is quite complicated. 2) making sure the streamer still works after any modification for these configurations is essential. 3) These configurations show the streamer's reusability, working for different accelerators.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright! As discussed: we like to avoid having code that is not used anywhere. Therefore the example configuration is displayed in the added documentation. The tests for different configurations are run through the automatic generation of scala parameters using the .hjson configuration files! For now this is only ALU but when the other accelerators are added these will be tested as well!

Copy link
Collaborator

@xiaoling-yi xiaoling-yi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this PR looks good to me, I just have some small comments. Please kindly check it!

@@ -0,0 +1,5 @@
generated
project
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, two files in the ./hw/chisel/project folder is used, which are plugins.sbt and build.properties

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, yes I missed this, I excluded those two files!


<p align="center">
<img src="./docs/microarch.svg" alt="">
</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This figure is disappeared!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-added it!

| tcdm_req | write | io_data_tcdm_req_0_bits_write | 1| Out| The signal indicates this request is for CSR write or read. |
| tcdm_req | valid | io_data_tcdm_req_0_valid | 1| Out| The signal indicates if this request is valid. |
| tcdm_req | ready | io_data_tcdm_req_0_ready | 1| Int| The signal indicates if the TCDM is ready for this CSR request. |
| | . | . | . | . | There can be a large number of tcdm_req ports depending on the spatial unrolling factors for the data readers and the data writers. tcdm_req ports for readers have lower index number. A detailed mapping for the tcdm_req ports and the data mover ports can be found at `Streamer.scala` line 269-311.|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line number is 330-372 now. Or we can delete the line number here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I just deleted it because it might change later

| offset + [0..temporalDim - 1] | temporalLoopBoundCSRs | temporal loop bound for each temporal dimension. |
| offset + temporalDim + [0..temdataMoverNum * temporalDimporalDim - 1] | temporalLoopSrtidesCSRs | temporal loop strides for each temporal dimension and for each data mover. |
| offset + temporalDim + dataMoverNum * temporalDim + [0..spatialDim.sum - 1] | spatialLoopSrtidesCSRs | spatial loop strides for each data mover and for corresponding spatial dimension. The spatial dimension for each data mover can be different. It depends on the accelerator. |
| offset + temporalDim + dataMoverNum * temporalDim + spatialDim.sum + [0..dataMoverNum - 1] | basePtrCSRs | base pointers for each data mover. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the status CSR here too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

Array("--target-dir", "generated/")
)

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the modular system verilog generation test back? It is useful for modular generation and tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the modular system verilog genration?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the code like this:
emitVerilog( new SpatialAddrGenUnit(SpatialAddrGenUnitParams()), Array("--target-dir", "generated/streamer") )
for testing the system verilog genration for each module.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not want people to use subparts as systemverilog components, right?
The testing of systemverilog generation is done by the top module, the only one that we are going to use. All lower modules are included in this test. Having them separate is duplicated testing, and is confusing as we don't want to generate verilog for the modules separately. Does that make sense?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I understand your point of view. I am fine to merge this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thank you!

Copy link

@rgantonio rgantonio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will give the go signal here but I prefer Xiaoling gives the final go signal since she uses this more closely than I do 😄

Otherwise, I am okay with it. Let's just make sure to fill-in the CSR manager docu.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's better we dump images in our repo? I have images that were dumped in a google drive then sent the link to the gh pages 😅 what do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of people seem to have a lot of opinions about this but in the end it doesn't seem to matter much 😅 . The only worry about Google Drive links is that if they disappear they are gone forever. Maybe the best way is including it as github user content, I'll change it to that!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually surprised we put the README's in this PR already. For the CSR Manager we do that in a separate PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ideally it should've been included previously, but I never noticed. We need it here because the readme replaces some code that wasn't used and thus removed. For the CSR manager we indeed best separate it. Although is there already documentation for this? The streamer readme is just a copy from the old repo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a new issue #106 for this 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the streamer test parameter be in the streamer folder?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was an error. I fixed it!

Array("--target-dir", "generated/")
)

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the code like this:
emitVerilog( new SpatialAddrGenUnit(SpatialAddrGenUnitParams()), Array("--target-dir", "generated/streamer") )
for testing the system verilog genration for each module.

@rgantonio rgantonio added the clean up To keep repos clean label May 10, 2024
@jorendumoulin jorendumoulin merged commit 1285d77 into main May 10, 2024
20 checks passed
rgantonio pushed a commit that referenced this pull request Jun 10, 2024
* dnn: Increase error threshold in FA-2

* dnn: Switch to naive FP32 as baseline fails in FlashAttention-2

* target: Re-introduce FlashAttention in CI

---------

Co-authored-by: Viviane Potocnik <[email protected]>
Co-authored-by: Luca Colagrande <[email protected]>
rgantonio pushed a commit that referenced this pull request Jun 10, 2024
* light refactoring to enable split main <-> test

* enable CI to actually run the Chisel unit tests

* remove unused instance parameters

* formatting

* cleaning up some test params

* resolve trailing space

* add chisel .gitignore

* add verilog generator scripts to test

* use TestParameters

* move test parameters back to /tests

* add streamer documentation

* rename documentation file

* add chisel readme

* add documentation image

* update image path

* address comments

* update streamer.md image

* Delete hw/chisel/doc/microarch.svg

* move test parameters to correct folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean up To keep repos clean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants