Skip to content

Commit

Permalink
Fix style/typing feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesousa-TT committed Jan 21, 2025
1 parent ca9a961 commit 28b9d4a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 39 deletions.
47 changes: 22 additions & 25 deletions include/ttmlir/Dialect/TTKernel/IR/TTKernelOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def TTKernel_NocSemaphoreWaitMinOp : TTKernel_Op<"noc_semaphore_wait_min"> {
let summary = "NocSemaphoreWaitMin";
let description = [{
A blocking call that waits until the value of a local L1 memory address on
the Tensix core executing this function becomes equal to a target value.
the Tensix core executing this function becomes equal or greater than a target value.
This L1 memory address is used as a semaphore of size 4 Bytes, as a
synchronization mechanism. Also, see *noc_semaphore_set*.
}];
Expand All @@ -613,7 +613,11 @@ def TTKernel_NocSemaphoreSetMulticastOp : TTKernel_Op<"noc_semaphore_set_multica
*noc_semaphore_set_multicast_loopback_src* can be used.
}];

let arguments = (ins TTKernel_L1Addr:$src_local_l1_addr, TTKernel_NocAddr:$dst_noc_addr_multicast, I32:$num_dests, BoolAttr:$linked, BoolAttr:$multicast_path_reserve);
let arguments = (ins TTKernel_L1Addr:$src_local_l1_addr,
TTKernel_NocAddr:$dst_noc_addr_multicast,
I32:$num_dests,
BoolAttr:$linked,
BoolAttr:$multicast_path_reserve);
}

def TTKernel_NocSemaphoreSetMulticastLoopbackOp : TTKernel_Op<"noc_semaphore_set_multicast_loopback_src"> {
Expand All @@ -634,7 +638,11 @@ def TTKernel_NocSemaphoreSetMulticastLoopbackOp : TTKernel_Op<"noc_semaphore_set
regular non multicast operations such as *noc_async_write* in this case.
}];

let arguments = (ins TTKernel_L1Addr:$src_local_l1_addr, TTKernel_NocAddr:$dst_noc_addr_multicast, I32:$num_dests, BoolAttr:$linked, BoolAttr:$multicast_path_reserve);
let arguments = (ins TTKernel_L1Addr:$src_local_l1_addr,
TTKernel_NocAddr:$dst_noc_addr_multicast,
I32:$num_dests,
BoolAttr:$linked,
BoolAttr:$multicast_path_reserve);
}

//===----------------------------------------------------------------------===//
Expand All @@ -649,7 +657,7 @@ def TTKernel_GetArgValOp : TTKernel_Op<"get_arg_val"> {

let arguments = (ins I32:$arg_index);

let results = (outs I32:$arg_val);
let results = (outs AnyTypeOf<[TTKernel_Semaphore, I32]>:$arg_val);
}

//===----------------------------------------------------------------------===//
Expand All @@ -662,11 +670,20 @@ def TTKernel_CastToL1PtrOp : TTKernel_Op<"reinterpret_cast<volatile tt_l1_ptr ui
Cast specified addr to L1 pointer.
}];

let arguments = (ins TTKernel_L1Addr:$addr);
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);
}

//===----------------------------------------------------------------------===//
// TTKernel Multicast NoC operations
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -790,24 +807,4 @@ def TTKernel_GetWritePtrOp : TTKernel_Op<"get_write_ptr"> {
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: 0 additions & 10 deletions include/ttmlir/Dialect/TTKernel/IR/TTKernelOpsTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ def TTKernel_NocAddr : TTKernel_Type<"NocAddr", "noc_addr"> {
let description = "Noc address type in TTKernel dialect";
}

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";
}

def TTKernel_ThreadTypeAttr : EnumAttr<TTKernel_Dialect, TTKernel_ThreadType, "thread"> {
let assemblyFormat = "`<` $value `>`";
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Conversion/TTKernelToEmitC/TTKernelToEmitC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ class ConvertTTKernelToEmitCPass
TTMetalToEmitCOpaqueRewriter<ttkernel::CopyTileOp>,
TTMetalToEmitCOpaqueRewriter<ttkernel::ExpTileInitOp>,
TTMetalToEmitCOpaqueRewriter<ttkernel::ExpTileOp>,
TTMetalToEmitCOpaqueRewriter<ttkernel::GetWritePtrOp>,
TTMetalToEmitCOpaqueRewriter<ttkernel::CastToL1PtrOp>>(
TTMetalToEmitCOpaqueRewriter<ttkernel::GetWritePtrOp>>(
typeConverter, funcOp.getContext());

patterns.add<TTMetalToEmitCOpaqueRewriter<ttkernel::GetNocAddrXYOp>>(
Expand Down
4 changes: 2 additions & 2 deletions lib/Dialect/TTMetal/IR/TTMetalOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ ::mlir::LogicalResult DispatchOp::verify() {
// Assert block inputs are CBs
for (auto &region : getRegions()) {
for (auto arg : region.getArguments()) {
if (!(mlir::isa<ttkernel::CBType>(arg.getType()) ||
mlir::isa<ttkernel::SemaphoreType>(arg.getType()))) {
if (!mlir::isa<ttkernel::CBType>(arg.getType()) &&
!mlir::isa<ttkernel::SemaphoreType>(arg.getType())) {
return emitOpError("Block inputs must be CBType or SemType");
}
}
Expand Down

0 comments on commit 28b9d4a

Please sign in to comment.