feat: Cross-core comm with TPUSH/TPOP#98
Merged
Conversation
Collaborator
|
Will merge this after #102 so we have a newer ptoas version. |
Collaborator
|
Collaborator
Author
Yes, ptoas generates the guards based on the
In a future PR we could do that, it should be a simple change but we still have a nesting level since we have the outer module. @to_ir_module(meta_data=meta_data, module=True)
def module():
@pto.func(kernel="cube")
def cube_kernel()
...But we should probably make the module implicit in the future since it's always needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cross-core comm with
TPUSH/TPOPThree example implementations of
TODO:
func.funcs, see mlir examples below. So far we have been usingpto.section.vector/cubeso how can we unify this in the dsl?pto_general.pywrappers, rather than just pure mlirNOTE:
TPUSH/TPOP/TFREEbut rather the higher level ops in pto dialect, such as_pto.TPushToAivOpA simple matmul -> transfer result to aiv -> store to GM from aiv:
We pass the kernel
x,y,fifowherexis the input16x16xfp32tensor,yis same shape where result will be stored, andfifois the buffer which is used for cross communication.Now steps are:
xin GM do a regular matmul sor1=x@xends up in anAcctile which can be transferred into aiv usingpto.push_to_aiv(through the GM bufferfifothat we allocated before program start).When
TPUSHis used on a TileType::Acc that resides in L0C it will use FIXP to write back tofifoin GM.The
TPOPinstruction handles waiting for the other core usingWAIT_FLAG_DEVIand also the loading fromfifobuffer into UB memory.Finally the regular
pto.tstoreis executed from theaivwhich writesr1into GM in theyslot.caller function
cube kernel
vector kernel
NOTE:
vid==0or usesplit=1and let each aiv write half)API update
No changes to current code, but add the possibility to have multiple
func.funcs in a module.Currently for a single function we can do:
to_ir_module(...)creates the module and function.Multi function support
To support mixed kernels where we have one entrypoint function and one vector/cube function we add the option to specify
module=Trueso the outer decorator is the module, while the inner functions become the mlir functions.