Skip to content

Commit

Permalink
[CIR][NFC] Match coding style with clang-format CI version
Browse files Browse the repository at this point in the history
  • Loading branch information
keryell committed Nov 22, 2024
1 parent 255225c commit 522e72b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
7 changes: 3 additions & 4 deletions include/aie/CIR/CIRToAIEPasses.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- CIRToAIEpasses.h ----------------------------------------------*- C++ -*-===//
//===- CIRToAIEpasses.h -----------------------------------------*- C++ -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand All @@ -23,8 +23,7 @@ namespace xilinx::AIE::CIR {
std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
createCIRToAIEPreparePass();

std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
createCIRToAIEPass();
std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> createCIRToAIEPass();

std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
createCIRToAIEInlineKernelLambdaPass();
Expand All @@ -36,6 +35,6 @@ createCIRToAIEDecaptureKernelPass();
#define GEN_PASS_REGISTRATION
#include "aie/CIR/CIRToAIEPasses.h.inc"

}
} // namespace xilinx::AIE::CIR

#endif
10 changes: 7 additions & 3 deletions include/aie/CIR/runtime/aie++/aie++.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ template <typename Channel> struct accessor {
// implemented"' failed.
//
// accessor(access_t& a) : storage {a} { aquire<Channel>(); }
accessor(access_t& a) { storage = &a; aquire<Channel>(); }
accessor(access_t& a) {
storage = &a;
aquire<Channel>();
}
auto& operator[](std::size_t index) { return (*storage)[index]; }
operator typename Channel::access_t&() { return *storage; }
operator typename Channel::access_t &() { return *storage; }
~accessor() { release<Channel>(); }
};

Expand Down Expand Up @@ -142,7 +145,8 @@ enum : std::int8_t { npu1 = 42 };
// "Unique" with the lambda is used to generate a different type for multiple
// instantiation, so we can have a design with several accelerators of the same
// type
template <auto DeviceModel = npu1, typename Unique = decltype([] {})> struct device {
template <auto DeviceModel = npu1, typename Unique = decltype([] {})>
struct device {
template <int X, int Y>
tile<X, Y, device> tile()
__attribute__((annotate("aie.device.tile", X, Y, DeviceModel,
Expand Down
3 changes: 2 additions & 1 deletion lib/CIR/CIRToAIEPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void eraseOpsAndUsers(OpRange &&opsToErase) {
llvm::SmallVector<mlir::Operation *> sorted{allOpsAndUsers.begin(),
allOpsAndUsers.end()};
mlir::computeTopologicalSorting(sorted);
LLVM_DEBUG(for (auto *op : sorted)
LLVM_DEBUG(for (auto *op
: sorted)
op->emitRemark("eraseOpsAndUsers: topologicalSort"));
for (auto *op : llvm::reverse(sorted)) {
LLVM_DEBUG(op->emitRemark("eraseOpsAndUsers: reverse"));
Expand Down
11 changes: 10 additions & 1 deletion test/CIR/aie++/empty.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
/* A tile with an empty program
Show that declaration of multiple devices of the same kind are actually
different types, allowing 2 devices in the same platform distinguished in a
type-safe way
*/

#include "aie++.hpp"

int main() {
aie::device<aie::npu1> d;
d.tile<2, 3>().program([]{});
d.tile<2, 3>().program([] {});
d.run();
// Check we can get another type for another accelerator of the same kind
aie::device<aie::npu1> other_device_unused;
auto unused_tile = other_device_unused.tile<2, 3>();

// Check the type safety
static_assert(!std::is_same_v<decltype(d), decltype(other_device_unused)>);
static_assert(
!std::is_same_v<decltype(d.tile<2, 3>()), decltype(unused_tile)>);
}
2 changes: 1 addition & 1 deletion test/CIR/aie++/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ int main() {
auto t = d.tile<1, 4>();
auto b = t.buffer<int, 8192>();
t.program([&] { b[3] = 14; });
d.tile<2, 3>().program([]{});
d.tile<2, 3>().program([] {});
d.run();
}

0 comments on commit 522e72b

Please sign in to comment.