-
Notifications
You must be signed in to change notification settings - Fork 22
Support Fully Asynchronous DMAs #114
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
base: devel
Are you sure you want to change the base?
Changes from all commits
91fd369
c3d298c
417313e
f28ff1e
0a8bef3
ea6a842
174af2b
ab912c1
a3244ec
d7fd038
95a11d1
9169b3f
79a7226
dbf46c2
700af21
7886d56
ea4dd12
b17f791
c1e242b
0e8d74e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,22 +7,20 @@ | |
| from Deeploy.DeeployTypes import CodeGenVerbosity, CodeTransformationPass, ExecutionBlock, NetworkContext, _NoVerbosity | ||
| from Deeploy.TilingExtension.AsyncDma import AsyncDma | ||
| from Deeploy.TilingExtension.CodeTransformationPasses.DoubleBufferingTilingCodeGeneration import \ | ||
| DoubleBufferingTilingCodeGeneration | ||
| DoubleBufferingTilingCodeGeneration, ProfilingDoubleBufferingTilingMixIn | ||
| from Deeploy.TilingExtension.CodeTransformationPasses.SingleBufferingTilingCodeGeneration import \ | ||
| SingleBufferingTilingCodeGeneration | ||
| from Deeploy.TilingExtension.CodeTransformationPasses.TilingPrototypes import DoubleBufferingTilingMixIn, \ | ||
| ProfilingDoubleBufferingTilingMixIn, ProfilingSingleBufferingTilingMixIn, SingleBufferingTilingMixIn | ||
| ProfilingSingleBufferingTilingMixIn, SingleBufferingTilingCodeGeneration | ||
|
|
||
|
|
||
| class PULPL3TilingGenerationSB(SingleBufferingTilingCodeGeneration, SingleBufferingTilingMixIn): | ||
| class PULPL3TilingGenerationSB(SingleBufferingTilingCodeGeneration): | ||
| pass | ||
|
|
||
|
|
||
| class ProfilingPULPL3TilingGenerationSB(SingleBufferingTilingCodeGeneration, ProfilingSingleBufferingTilingMixIn): | ||
| pass | ||
|
Comment on lines
19
to
20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix MRO so profiling mixins override base methods. Reorder bases: mixin first. -class ProfilingPULPL3TilingGenerationSB(SingleBufferingTilingCodeGeneration, ProfilingSingleBufferingTilingMixIn):
+class ProfilingPULPL3TilingGenerationSB(ProfilingSingleBufferingTilingMixIn, SingleBufferingTilingCodeGeneration):
pass
@@
-class ProfilingPULPL3TilingGenerationDB(DoubleBufferingTilingCodeGeneration, ProfilingDoubleBufferingTilingMixIn):
+class ProfilingPULPL3TilingGenerationDB(ProfilingDoubleBufferingTilingMixIn, DoubleBufferingTilingCodeGeneration):
passAlso applies to: 27-28 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| class PULPL3TilingGenerationDB(DoubleBufferingTilingCodeGeneration, DoubleBufferingTilingMixIn): | ||
| class PULPL3TilingGenerationDB(DoubleBufferingTilingCodeGeneration): | ||
| pass | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,31 +5,41 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from typing import Dict, Tuple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation, VariableBuffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from Deeploy.TilingExtension.AsyncDma import AsyncDma, DmaDirection, Future, TensorGroupWaitingStrategy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from Deeploy.TilingExtension.AsyncDma import AsyncDma, DmaDirection, Future, PerTensorWaitingStrategy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class SnitchBarrierFuture(Future): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _initTemplate = NodeTemplate("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _deinitTemplate = NodeTemplate("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _allocTemplate = NodeTemplate("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _waitTemplate = NodeTemplate("if (snrt_is_dm_core()) snrt_dma_wait_all();") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # LMACAN: TODO: Add single transfer waiting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class SnitchFuture(Future): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _initTemplate = NodeTemplate("uint16_t ${name};") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _initTemplate = NodeTemplate("snrt_dma_txid_t ${name} = (snrt_dma_txid_t) -1;") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _deinitTemplate = NodeTemplate("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _waitTemplate = NodeTemplate("if (snrt_is_dm_core()) snrt_dma_wait(${name});") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _allocTemplate = NodeTemplate("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _waitTemplate = NodeTemplate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "if ( (${name} != ( (snrt_dma_txid_t) -1) ) && snrt_is_dm_core() ) snrt_dma_wait(${name});") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class SnitchDma(AsyncDma): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _transferTemplates = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NodeTemplate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "if (snrt_is_dm_core()) snrt_dma_start_2d(${dest}, ${src}, ${size}, ${stride_dest}, ${stride_src}, ${repeat});" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NodeTemplate(""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (snrt_is_dm_core()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ${future} = snrt_dma_start_2d(${dest}, ${src}, ${size}, ${stride_dest}, ${stride_src}, ${repeat}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // WIESEP: Hack as otherwise the last commited DMA transaction ID can never be resolved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| snrt_dma_start_2d(${dest}, ${dest}, 1, 0, 0, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _waitingStrategy = TensorGroupWaitingStrategy(SnitchBarrierFuture, "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _waitingStrategy = PerTensorWaitingStrategy(SnitchFuture) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
32
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotate class attributes with ClassVar to satisfy RUF012 and signal intent. mark mutable class attrs as ClassVar. Apply: -from typing import Dict, Tuple
+from typing import Dict, Tuple, ClassVar
+from Deeploy.TilingExtension.AsyncDma import AsyncDma, DmaDirection, Future, PerTensorWaitingStrategy, AsyncDmaWaitingStrategy
@@
-class SnitchDma(AsyncDma):
+class SnitchDma(AsyncDma):
- _transferTemplates = {
+ _transferTemplates: ClassVar[Dict[int, NodeTemplate]] = {
@@
- _waitingStrategy = PerTensorWaitingStrategy(SnitchFuture)
+ _waitingStrategy: ClassVar[AsyncDmaWaitingStrategy] = PerTensorWaitingStrategy(SnitchFuture)Based on static analysis hints 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.13.3)32-41: Mutable class attributes should be annotated with (RUF012) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def __init__(self, transferTemplates: Dict[int, NodeTemplate] = _transferTemplates) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| super().__init__(transferTemplates) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -43,13 +53,13 @@ def checkTransfer(self, ctxt: NetworkContext, externalBuffer: VariableBuffer, lo | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def transferOpRepr(self, externalBuffer: VariableBuffer, localBuffer: VariableBuffer, shape: Tuple[int, ...], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strideExt: Tuple[int, ...], strideLoc: Tuple[int, ...], direction: DmaDirection, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| future: Future) -> OperatorRepresentation: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _ = future | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| operatorRepresentation: OperatorRepresentation = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "dest": localBuffer.name if direction == "ExternalToLocal" else externalBuffer.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "src": externalBuffer.name if direction == "ExternalToLocal" else localBuffer.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "repeat": shape[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "size": shape[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "stride_dest": strideLoc[0] if direction == "ExternalToLocal" else strideExt[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "stride_src": strideExt[0] if direction == "ExternalToLocal" else strideLoc[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "future": future.name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return operatorRepresentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix MRO so profiling mixins override base methods.
Place Profiling*MixIn before the CodeGeneration base.
Also applies to: 27-28
🤖 Prompt for AI Agents