Skip to content

Commit

Permalink
update llvm (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifield authored Jul 2, 2024
1 parent 60391cf commit 76460fe
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 47 deletions.
8 changes: 2 additions & 6 deletions include/aie/Dialect/AIEX/AIETokenAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ namespace xilinx::AIEX {
class TokenAnalysis {
AIE::DeviceOp &device;
llvm::DenseMap<llvm::StringRef, int> tokenSymbols;
llvm::DenseMap<llvm::StringRef, llvm::SmallVector<mlir::Operation *, 4>>
std::vector<std::pair<llvm::StringRef, std::vector<mlir::Operation *>>>
tokenAcqMap;
llvm::DenseMap<llvm::StringRef, llvm::SmallVector<mlir::Operation *, 4>>
std::vector<std::pair<llvm::StringRef, std::vector<mlir::Operation *>>>
tokenRelMap;
llvm::SmallVector<std::pair<mlir::Operation *, mlir::Operation *>, 4>
tokenChains;
Expand All @@ -47,10 +47,6 @@ class TokenAnalysis {

auto getTokenSymbols() const { return tokenSymbols; }

auto getTokenAcqMap() const { return tokenAcqMap; }

auto getTokenRelMap() const { return tokenRelMap; }

auto getTokenChains() const { return tokenChains; }

auto getTokenPairs() const { return tokenPairs; }
Expand Down
4 changes: 0 additions & 4 deletions lib/Dialect/AIEX/Transforms/AIECreateLocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ struct AIECreateLocksPass : public AIECreateLocksBase<AIECreateLocksPass> {
TokenAnalysis TA(device);
TA.runAnalysis();
LLVM_DEBUG(TA.print(llvm::dbgs()));
DenseMap<StringRef, SmallVector<Operation *, 4>> tokenAcqMap(
TA.getTokenAcqMap());
DenseMap<StringRef, SmallVector<Operation *, 4>> tokenRelMap(
TA.getTokenRelMap());
SmallVector<std::pair<Operation *, Operation *>, 4> tokenChains(
TA.getTokenChains());
SmallVector<std::pair<Operation *, Operation *>, 4> tokenPairs(
Expand Down
28 changes: 23 additions & 5 deletions lib/Dialect/AIEX/Utils/AIETokenAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ using namespace xilinx;
using namespace xilinx::AIE;
using namespace xilinx::AIEX;

static void tokenMapPushBack(
std::vector<std::pair<llvm::StringRef, std::vector<mlir::Operation *>>>
&map,
StringRef tokenName, Operation *op) {
for (auto &pair : map) {
if (pair.first == tokenName) {
pair.second.push_back(op);
return;
}
}
map.push_back({tokenName, {op}});
}

void xilinx::AIEX::TokenAnalysis::runAnalysis() {

// Collecting token symbols
Expand All @@ -39,10 +52,10 @@ void xilinx::AIEX::TokenAnalysis::runAnalysis() {
assert(tokenSymbols.find(tokenName) != tokenSymbols.end() &&
"Token not found!");
if (op.acquire()) {
tokenAcqMap[tokenName].push_back(op.getOperation());
tokenMapPushBack(tokenAcqMap, tokenName, op.getOperation());
visitors[tokenName].push_back(op);
} else {
tokenRelMap[tokenName].push_back(op.getOperation());
tokenMapPushBack(tokenRelMap, tokenName, op.getOperation());
if (!visitors[tokenName].empty()) {
Operation *Op = visitors[tokenName].pop_back_val();
tokenPairs.push_back({Op, op.getOperation()});
Expand All @@ -53,8 +66,8 @@ void xilinx::AIEX::TokenAnalysis::runAnalysis() {
assert(tokenSymbols.find(tokenName) != tokenSymbols.end() &&
"Token not found!");
Operation *Op = op.getOperation();
tokenAcqMap[tokenName].push_back(Op);
tokenRelMap[tokenName].push_back(Op);
tokenMapPushBack(tokenAcqMap, tokenName, op.getOperation());
tokenMapPushBack(tokenRelMap, tokenName, op.getOperation());
tokenPairs.push_back({Op, Op});
}
});
Expand Down Expand Up @@ -91,7 +104,12 @@ void xilinx::AIEX::TokenAnalysis::runAnalysis() {
for (const auto &map : tokenRelMap) {
StringRef tokenName = map.first;
auto tokenRels = map.second;
auto tokenAcqs = tokenAcqMap[tokenName];
auto tokenAcqs = [&]() {
for (auto &pair : tokenAcqMap)
if (pair.first == tokenName)
return pair.second;
return std::vector<Operation *>();
}();
for (auto ROp : tokenRels) {

if (auto op = dyn_cast<UseTokenOp>(ROp))
Expand Down
15 changes: 14 additions & 1 deletion lib/Targets/AIETargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/JSON.h"

#include <set>

#define DEBUG_TYPE "aie-targets"

using namespace mlir;
Expand Down Expand Up @@ -161,9 +163,20 @@ void registerAIETranslations() {
DeviceOp targetOp = *(module.getOps<DeviceOp>().begin());

collectTiles(targetOp, tiles);
// sort the tiles for deterministic output
using tileType = std::pair<TileID, Operation *>;
struct tileCmp {
bool operator()(const tileType &lhs, const tileType &rhs) const {
return lhs.first < rhs.first;
}
};
std::set<tileType, tileCmp> sortedTiles;
for (auto tile : tiles)
sortedTiles.insert(tileType{tile.first, tile.second});

collectBuffers(targetOp, buffers);

for (auto tile : tiles) {
for (auto tile : sortedTiles) {
Operation *srcTileOp = tile.second;
TileID srcCoord = cast<TileOp>(srcTileOp).getTileID();
int srcCol = srcCoord.col;
Expand Down
1 change: 0 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ else ()
AIEPythonExtensions
COMMON_CAPI_LINK_LIBS
AIEAggregateCAPI
AIECAPI
)

endif ()
Expand Down
4 changes: 2 additions & 2 deletions test/create-locks/test_lock5.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// CHECK: %[[VAL_2:.*]] = aie.tile(4, 4)
// CHECK: %[[VAL_3:.*]] = aie.lock(%[[VAL_2]], 0)
// CHECK: %[[VAL_4:.*]] = aie.tile(3, 3)
// CHECK: %[[VAL_5:.*]] = aie.lock(%[[VAL_4]], 1)
// CHECK: %[[VAL_6:.*]] = aie.lock(%[[VAL_4]], 0)
// CHECK: %[[VAL_6:.*]] = aie.lock(%[[VAL_4]], 1)
// CHECK: %[[VAL_5:.*]] = aie.lock(%[[VAL_4]], 0)
// CHECK: %[[VAL_7:.*]] = aie.buffer(%[[VAL_4]]) : memref<256xi32>
// CHECK: %[[VAL_8:.*]] = aie.buffer(%[[VAL_2]]) : memref<256xi32>
// CHECK: %[[VAL_9:.*]] = aie.buffer(%[[VAL_0]]) : memref<256xi32>
Expand Down
12 changes: 6 additions & 6 deletions test/create-locks/test_lock6.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
// CHECK: aie.end
// CHECK: }
// CHECK: %[[VAL_15:.*]] = aie.mem(%[[VAL_0]]) {
// CHECK: aie.use_lock(%[[VAL_1]], Acquire, 0)
// CHECK: aie.dma_bd(%[[VAL_9]] : memref<256xi32>, 0, 256)
// CHECK: aie.use_lock(%[[VAL_1]], Release, 1)
// CHECK: aie.use_lock(%[[VAL_2]], Acquire, 0)
// CHECK: aie.dma_bd(%[[VAL_10]] : memref<256xi32>, 0, 256)
// CHECK: aie.dma_bd(%[[VAL_9]] : memref<256xi32>, 0, 256)
// CHECK: aie.use_lock(%[[VAL_2]], Release, 1)
// CHECK: aie.use_lock(%[[VAL_1]], Acquire, 0)
// CHECK: aie.dma_bd(%[[VAL_10]] : memref<256xi32>, 0, 256)
// CHECK: aie.use_lock(%[[VAL_1]], Release, 1)
// CHECK: aie.end
// CHECK: }
// CHECK: %[[VAL_18:.*]] = aie.core(%[[VAL_5]]) {
Expand All @@ -56,10 +56,10 @@
// CHECK: aie.end
// CHECK: }
// CHECK: %[[VAL_20:.*]] = aie.core(%[[VAL_0]]) {
// CHECK: aie.use_lock(%[[VAL_2]], Acquire, 1)
// CHECK: aie.use_lock(%[[VAL_1]], Acquire, 1)
// CHECK: aie.use_lock(%[[VAL_1]], Release, 0)
// CHECK: aie.use_lock(%[[VAL_2]], Acquire, 1)
// CHECK: aie.use_lock(%[[VAL_2]], Release, 0)
// CHECK: aie.use_lock(%[[VAL_1]], Release, 0)
// CHECK: aie.end
// CHECK: }
// CHECK: aie.flow(%[[VAL_5]], DMA : 0, %[[VAL_0]], DMA : 0)
Expand Down
24 changes: 12 additions & 12 deletions test/generate-mmap/test_mmap0.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
// RUN: aie-translate --tilecol=4 --tilerow=4 --aie-generate-bcf %s | FileCheck --check-prefix=BCF44 %s
// RUN: aie-translate --tilecol=4 --tilerow=4 --aie-generate-ldscript %s | FileCheck --check-prefix=LD44 %s

// CHECK-LABEL: Tile(5, 4)
// CHECK: _symbol y 0x28000 32
// CHECK-LABEL: Tile(3, 4)
// CHECK: _symbol x 0x28000 32
// CHECK: _symbol a 0x38000 16
// CHECK: _symbol b 0x38010 64
// CHECK: _symbol c 0x38050 1024
// CHECK-LABEL: Tile(4, 3)
// CHECK: _symbol a 0x30000 16
// CHECK: _symbol b 0x30010 64
// CHECK: _symbol c 0x30050 1024
// CHECK: _symbol z 0x38000 32
// CHECK-LABEL: Tile(4, 4)
// CHECK: _symbol z 0x20000 32
// CHECK: _symbol a 0x28000 16
Expand All @@ -26,16 +34,8 @@
// CHECK: _symbol b 0x20010 64
// CHECK: _symbol c 0x20050 1024
// CHECK: _symbol t 0x38000 32
// CHECK-LABEL: Tile(4, 3)
// CHECK: _symbol a 0x30000 16
// CHECK: _symbol b 0x30010 64
// CHECK: _symbol c 0x30050 1024
// CHECK: _symbol z 0x38000 32
// CHECK-LABEL: Tile(3, 4)
// CHECK: _symbol x 0x28000 32
// CHECK: _symbol a 0x38000 16
// CHECK: _symbol b 0x38010 64
// CHECK: _symbol c 0x38050 1024
// CHECK-LABEL: Tile(5, 4)
// CHECK: _symbol y 0x28000 32

// BCF44: _entry_point _main_init
// BCF44-NEXT: _symbol core_4_4 _after _main_init
Expand Down
8 changes: 4 additions & 4 deletions test/generate-mmap/test_mmap1.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

// RUN: aie-translate --aie-generate-mmap %s | FileCheck %s

// CHECK-LABEL: Tile(4, 4)
// CHECK-NOT: _symbol a
// CHECK-LABEL: Tile(2, 4)
// CHECK: _symbol a 0x38000 16
// CHECK-LABEL: Tile(3, 3)
// CHECK: _symbol a 0x30000 16
// CHECK-LABEL: Tile(3, 5)
// CHECK: _symbol a 0x20000 16
// CHECK-LABEL: Tile(3, 4)
// CHECK: _symbol a 0x28000 16
// CHECK-LABEL: Tile(3, 5)
// CHECK: _symbol a 0x20000 16
// CHECK-LABEL: Tile(4, 4)
// CHECK-NOT: _symbol a

module @test_mmap1 {
aie.device(xcvc1902) {
Expand Down
8 changes: 4 additions & 4 deletions test/generate-mmap/test_mmap2.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

// RUN: aie-translate --aie-generate-mmap %s | FileCheck %s

// CHECK-LABEL: Tile(2, 3)
// CHECK-NOT: _symbol a
// CHECK-LABEL: Tile(3, 2)
// CHECK: _symbol a 0x30000 16
// CHECK-LABEL: Tile(3, 3)
// CHECK: _symbol a 0x38000 16
// CHECK-LABEL: Tile(2, 3)
// CHECK-NOT: _symbol a
// CHECK-LABEL: Tile(4, 3)
// CHECK: _symbol a 0x28000 16
// CHECK-LABEL: Tile(3, 4)
// CHECK: _symbol a 0x20000 16
// CHECK-LABEL: Tile(4, 3)
// CHECK: _symbol a 0x28000 16

module @test_mmap1 {
aie.device(xcvc1902) {
Expand Down
2 changes: 2 additions & 0 deletions tools/aie-visualize/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ target_link_libraries(aie-visualize
MLIRAIEVecDialect
MLIRAIEVecToLLVM
MLIRAIEVecTransforms
MLIRBuiltinToLLVMIRTranslation
MLIRXLLVMToLLVMIRTranslation
MLIRLLVMToLLVMIRTranslation
ADF
AIE
AIETransforms
Expand Down
4 changes: 2 additions & 2 deletions utils/clone-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
##===----------------------------------------------------------------------===##

# The LLVM commit to use.
LLVM_PROJECT_COMMIT=a50bcc03cbaecf6473c6bf41f4497758a7876f3d
DATETIME=2024061721
LLVM_PROJECT_COMMIT=ae570d82e8c021f45209830db8c9c7bb79bed394
DATETIME=2024070115
WHEEL_VERSION=19.0.0.$DATETIME+${LLVM_PROJECT_COMMIT:0:8}

############################################################################################
Expand Down

0 comments on commit 76460fe

Please sign in to comment.