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

[Direct Metal] Insert scaler CB in reduce kernels #1153

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/ttmlir/Dialect/TT/IR/TTOpsTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def TT_ChipDescAttr : TT_Attr<"ChipDesc", "chip_desc"> {

let extraClassDeclaration = [{
unsigned getUsableL1Size() const { return getL1Size() - getL1UnreservedBase(); }
unsigned getScratchL1RegionAddress() const;
unsigned getScratchL1RegionSize() const;
unsigned getUsableDramChannelSize() const { return getDramUnreservedEnd() - getDramUnreservedBase(); }
}];
}
Expand Down
78 changes: 77 additions & 1 deletion include/ttmlir/Dialect/TTKernel/IR/TTKernelOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,23 @@ def TTKernel_UntilizeBlockOp : TTKernel_Op<"untilize_block"> {
// TTKernel NOC operations
//===----------------------------------------------------------------------===//

def TTKernel_GetNocAddrXYOp : TTKernel_Op<"get_noc_addr_xy"> {
let summary = "GetNocAddrXY";
let description = [{
GetNocAddr api including core coordinates
}];

let arguments = (ins I32:$x, I32:$y, I32:$l1Address);
let results = (outs TTKernel_NocAddr:$nocAddr);
}

def TTKernel_GetNocAddrOp : TTKernel_Op<"get_noc_addr"> {
let summary = "GetNocAddr";
let description = [{
GetNocAddr
}];

let arguments = (ins I32:$x, I32:$y, I32:$l1Address);
let arguments = (ins I32:$l1Address);
let results = (outs TTKernel_NocAddr:$nocAddr);
}

Expand All @@ -452,6 +462,24 @@ def TTKernel_NocAsyncReadOp : TTKernel_Op<"noc_async_read"> {
let arguments = (ins TTKernel_NocAddr:$srcNocAddr, I32:$dstLocalL1Addr, I32:$size);
}

def TTKernel_NocAsyncReadOnePacketSetStateOp : TTKernel_Op<"noc_async_read_one_packet_set_state"> {
let summary = "NocAsyncReadOnePacketSetState";
let description = [{
NocAsyncReadOnePacketSetState
}];

let arguments = (ins TTKernel_NocAddr:$srcNocAddr, I32:$size);
}

def TTKernel_NocAsyncReadOnePacketWithStateOp : TTKernel_Op<"noc_async_read_one_packet_with_state"> {
let summary = "NocAsyncReadOnePacketWithState";
let description = [{
NocAsyncReadOnePacketWithState
}];

let arguments = (ins TTKernel_NocAddr:$srcNocAddr, AnyTypeOf<[I32, TTKernel_L1Addr]>:$dstLocalL1Addr);
}

def TTKernel_NocAsyncReadBarrierOp : TTKernel_Op<"noc_async_read_barrier"> {
let summary = "NocAsyncReadBarrier";
let description = [{
Expand Down Expand Up @@ -508,4 +536,52 @@ def TTKernel_UnreachableOp : TTKernel_Op<"unreachable", [Pure, ReturnLike, Termi
}];
}

def TTKernel_MemZerosBaseOp : TTKernel_Op<"mem_zeros_base"> {
let summary = "Op corresponding to MEM_ZEROS_BASE macro in kernels.";
let description = [{
Op corresponding to MEM_ZEROS_BASE macro in kernels.
}];

let results = (outs I32:$result);
}

def TTKernel_MemZerosSizeOp : TTKernel_Op<"mem_zeros_size"> {
let summary = "Op corresponding to MEM_ZEROS_SIZE macro in kernels.";
let description = [{
Op corresponding to MEM_ZEROS_SIZE macro in kernels.
}];

let results = (outs I32:$result);
}

def TTKernel_GetWritePtrOp : TTKernel_Op<"get_write_ptr"> {
let summary = "GetWritePtr";
let description = [{
GetWritePtr operation
}];

let arguments = (ins TTKernel_CB:$cb);
let results = (outs I32:$writePtr);
}

def TTKernel_CastToL1PtrOp : TTKernel_Op<"reinterpret_cast<volatile tt_l1_ptr uint32_t*>"> {
let summary = "CastToL1Ptr";
let description = [{
Cast specified addr to L1 pointer.
}];

let arguments = (ins AnyTypeOf<[I32, TTKernel_L1Addr]>:$addr);

let results = (outs TTKernel_L1AddrPtr:$l1_ptr);
}

def TTKernel_StoreToL1Op : TTKernel_Op<"store_to_l1"> {
let summary = "StoreToL1";
let description = [{
Store value to L1.
}];

let arguments = (ins I32:$value, TTKernel_L1AddrPtr:$l1_ptr, I32:$offset);
}

#endif
10 changes: 10 additions & 0 deletions include/ttmlir/Dialect/TTKernel/IR/TTKernelOpsTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,14 @@ def TTKernel_ReduceDimAttr : EnumAttr<TTKernel_Dialect, TTKernel_ReduceDim, "red
let assemblyFormat = "`<` $value `>`";
}

def TTKernel_L1Addr : TTKernel_Type<"L1Addr", "l1_addr"> {
let summary = "TTKernel l1 address";
let description = "L1 address type in TTKernel dialect";
}

def TTKernel_L1AddrPtr : TTKernel_Type<"L1AddrPtr", "l1_addr_ptr"> {
let summary = "TTKernel l1 address pointer";
let description = "L1 pointer address type in TTKernel dialect";
}

#endif
Loading
Loading