clean up PIM CMake
update README.md
This commit is contained in:
10
README.md
10
README.md
@@ -29,7 +29,7 @@ Remember to set ```-DCMAKE_BUILD_TYPE=Debug``` for developing on Raptor
|
|||||||
|
|
||||||
Moreover, if compiling with build type debug, it is also suggested to use
|
Moreover, if compiling with build type debug, it is also suggested to use
|
||||||
mold as linker (you will need to install it if you don't have it already)
|
mold as linker (you will need to install it if you don't have it already)
|
||||||
to reduce memory usage during linking. You can use it with:
|
to reduce memory usage during linking. You can use it by setting the options:
|
||||||
```
|
```
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" \
|
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" \
|
||||||
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold"
|
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold"
|
||||||
@@ -38,8 +38,16 @@ to reduce memory usage during linking. You can use it with:
|
|||||||
### Raptor
|
### Raptor
|
||||||
|
|
||||||
Use the following commands to build Raptor.
|
Use the following commands to build Raptor.
|
||||||
|
|
||||||
Remember to set ```-DCMAKE_BUILD_TYPE=Debug``` for developing on Raptor.
|
Remember to set ```-DCMAKE_BUILD_TYPE=Debug``` for developing on Raptor.
|
||||||
|
|
||||||
|
Also in this case, it is suggested to use mold as linker to reduce link time and memory usage,
|
||||||
|
setting the options:
|
||||||
|
```
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" \
|
||||||
|
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold"
|
||||||
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
|||||||
@@ -10,37 +10,54 @@ set(PIM_INCLUDE_PATH ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
|
|||||||
set(PIM_ONNX_MLIR_SRC_ROOT ${ONNX_MLIR_SRC_ROOT})
|
set(PIM_ONNX_MLIR_SRC_ROOT ${ONNX_MLIR_SRC_ROOT})
|
||||||
set(PIM_ONNX_MLIR_BIN_ROOT ${ONNX_MLIR_BIN_ROOT})
|
set(PIM_ONNX_MLIR_BIN_ROOT ${ONNX_MLIR_BIN_ROOT})
|
||||||
|
|
||||||
add_subdirectory(Common)
|
set(PIM_PUBLIC_INCLUDE_DIRS
|
||||||
add_subdirectory(Compiler)
|
|
||||||
add_subdirectory(Conversion)
|
|
||||||
add_subdirectory(Dialect)
|
|
||||||
|
|
||||||
add_onnx_mlir_library(OMPIMAccel
|
|
||||||
PimAccelerator.cpp
|
|
||||||
Pass/CountInstructionPass.cpp
|
|
||||||
Pass/EmitPimJsonPass.cpp
|
|
||||||
Pass/MessagePass.cpp
|
|
||||||
Pass/PimConstantFolding/Common.cpp
|
|
||||||
Pass/PimConstantFolding/Patterns/ConstantPatterns.cpp
|
|
||||||
Pass/PimConstantFolding/PimConstantFoldingPass.cpp
|
|
||||||
Pass/PimConstantFolding/Patterns/SubviewPatterns.cpp
|
|
||||||
Pass/PimHostVerificationPass.cpp
|
|
||||||
|
|
||||||
EXCLUDE_FROM_OM_LIBS
|
|
||||||
|
|
||||||
INCLUDE_DIRS PUBLIC
|
|
||||||
${ONNX_MLIR_SRC_ROOT}/include
|
${ONNX_MLIR_SRC_ROOT}/include
|
||||||
${ONNX_MLIR_SRC_ROOT}
|
${ONNX_MLIR_SRC_ROOT}
|
||||||
${PIM_ONNX_MLIR_SRC_ROOT}
|
${PIM_ONNX_MLIR_SRC_ROOT}
|
||||||
${PIM_SRC_ROOT}
|
${PIM_SRC_ROOT}
|
||||||
${PIM_BIN_ROOT}
|
${PIM_BIN_ROOT}
|
||||||
${PIM_INCLUDE_PATH}
|
${PIM_INCLUDE_PATH}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PIM_COMPILER_INCLUDE_DIRS
|
||||||
|
${PIM_SRC_ROOT}
|
||||||
|
${PIM_BIN_ROOT}
|
||||||
|
${PIM_ONNX_MLIR_SRC_ROOT}
|
||||||
|
${PIM_ONNX_MLIR_BIN_ROOT}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PIM_ACCEL_INCLUDE_DIRS
|
||||||
|
${PIM_ONNX_MLIR_SRC_ROOT}
|
||||||
|
${PIM_ONNX_MLIR_BIN_ROOT}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PIM_GENERATED_INCLUDE_DIRS
|
||||||
|
${PIM_INCLUDE_PATH}
|
||||||
|
)
|
||||||
|
|
||||||
|
function(add_pim_library name)
|
||||||
|
add_onnx_mlir_library(${name} STATIC ${ARGN})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
add_subdirectory(Dialect)
|
||||||
|
add_subdirectory(Common)
|
||||||
|
add_subdirectory(Pass)
|
||||||
|
add_subdirectory(Compiler)
|
||||||
|
add_subdirectory(Conversion)
|
||||||
|
|
||||||
|
add_pim_library(OMPIMAccel
|
||||||
|
PimAccelerator.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
|
INCLUDE_DIRS PUBLIC
|
||||||
|
${PIM_PUBLIC_INCLUDE_DIRS}
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
onnx
|
onnx
|
||||||
OMAccelerator
|
OMAccelerator
|
||||||
OMPimCompilerUtils
|
OMPimCompilerUtils
|
||||||
OMCompilerUtils
|
OMPimPasses
|
||||||
OMONNXOps
|
OMONNXOps
|
||||||
SpatialOps
|
SpatialOps
|
||||||
PimOps
|
PimOps
|
||||||
@@ -48,5 +65,6 @@ add_onnx_mlir_library(OMPIMAccel
|
|||||||
OMSpatialToGraphviz
|
OMSpatialToGraphviz
|
||||||
OMSpatialToPim
|
OMSpatialToPim
|
||||||
OMPimCommon
|
OMPimCommon
|
||||||
|
OMPimBufferization
|
||||||
MLIRTensorInferTypeOpInterfaceImpl
|
MLIRTensorInferTypeOpInterfaceImpl
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
add_onnx_mlir_library(OMPimCommon
|
add_pim_library(OMPimCommon
|
||||||
PimCommon.cpp
|
PimCommon.cpp
|
||||||
|
|
||||||
EXCLUDE_FROM_OM_LIBS
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
INCLUDE_DIRS PUBLIC
|
INCLUDE_DIRS PUBLIC
|
||||||
${ONNX_MLIR_SRC_ROOT}/include
|
${PIM_PUBLIC_INCLUDE_DIRS}
|
||||||
${ONNX_MLIR_SRC_ROOT}
|
|
||||||
${PIM_ONNX_MLIR_SRC_ROOT}
|
|
||||||
${PIM_SRC_ROOT}
|
|
||||||
${PIM_BIN_ROOT}
|
|
||||||
${PIM_INCLUDE_PATH}
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
onnx
|
onnx
|
||||||
OMPimCompilerUtils
|
|
||||||
SpatialOps
|
SpatialOps
|
||||||
PimOps
|
PimOps
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,44 +1,37 @@
|
|||||||
get_property(OMLibs GLOBAL PROPERTY ONNX_MLIR_LIBS)
|
add_pim_library(OMPimCompilerOptions
|
||||||
|
|
||||||
add_onnx_mlir_library(OMPimCompilerOptions
|
|
||||||
PimCompilerOptions.cpp
|
PimCompilerOptions.cpp
|
||||||
|
|
||||||
EXCLUDE_FROM_OM_LIBS
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
INCLUDE_DIRS PRIVATE
|
INCLUDE_DIRS PRIVATE
|
||||||
${PIM_SRC_ROOT}
|
${PIM_COMPILER_INCLUDE_DIRS}
|
||||||
${PIM_BIN_ROOT}
|
|
||||||
${PIM_ONNX_MLIR_SRC_ROOT}
|
|
||||||
${PIM_ONNX_MLIR_BIN_ROOT}
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
${OMLibs}
|
|
||||||
OMCompilerOptions
|
OMCompilerOptions
|
||||||
|
|
||||||
ACCEL_INCLUDE_DIRS PRIVATE
|
ACCEL_INCLUDE_DIRS PRIVATE
|
||||||
${PIM_ONNX_MLIR_SRC_ROOT}
|
${PIM_ACCEL_INCLUDE_DIRS}
|
||||||
${PIM_ONNX_MLIR_BIN_ROOT}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_onnx_mlir_library(OMPimCompilerUtils
|
add_pim_library(OMPimCompilerUtils
|
||||||
PimCompilerUtils.cpp
|
PimCompilerUtils.cpp
|
||||||
PimCodeGen.cpp
|
PimCodeGen.cpp
|
||||||
|
../Pass/EmitPimJsonPass.cpp
|
||||||
|
|
||||||
EXCLUDE_FROM_OM_LIBS
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
INCLUDE_DIRS PRIVATE
|
INCLUDE_DIRS PRIVATE
|
||||||
${PIM_SRC_ROOT}
|
${PIM_COMPILER_INCLUDE_DIRS}
|
||||||
${PIM_BIN_ROOT}
|
|
||||||
${PIM_ONNX_MLIR_SRC_ROOT}
|
|
||||||
${PIM_ONNX_MLIR_BIN_ROOT}
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
${OMLibs}
|
|
||||||
OMCompilerUtils
|
|
||||||
OMPimCompilerOptions
|
OMPimCompilerOptions
|
||||||
|
OMPimCommon
|
||||||
|
OMPimBufferization
|
||||||
|
OMPimPasses
|
||||||
|
OMONNXToSpatial
|
||||||
|
OMSpatialToPim
|
||||||
OMCompilerPasses
|
OMCompilerPasses
|
||||||
|
|
||||||
ACCEL_INCLUDE_DIRS PRIVATE
|
ACCEL_INCLUDE_DIRS PRIVATE
|
||||||
${PIM_ONNX_MLIR_SRC_ROOT}
|
${PIM_ACCEL_INCLUDE_DIRS}
|
||||||
${PIM_ONNX_MLIR_BIN_ROOT}
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "src/Accelerators/PIM/Compiler/PimCompilerOptions.hpp"
|
#include "src/Accelerators/PIM/Compiler/PimCompilerOptions.hpp"
|
||||||
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
||||||
#include "src/Compiler/CompilerPasses.hpp"
|
#include "src/Compiler/CompilerPasses.hpp"
|
||||||
#include "src/Compiler/CompilerUtils.hpp"
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace mlir;
|
using namespace mlir;
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
#include "llvm-project/clang/include/clang/Basic/LLVM.h"
|
#include "llvm-project/clang/include/clang/Basic/LLVM.h"
|
||||||
#include "llvm/Support/JSON.h"
|
#include "llvm/Support/JSON.h"
|
||||||
|
|
||||||
|
#include "onnx-mlir/Compiler/OMCompilerTypes.h"
|
||||||
|
|
||||||
#include "Common/ValueMap.hpp"
|
#include "Common/ValueMap.hpp"
|
||||||
#include "src/Accelerators/PIM/Compiler/PimCompilerUtils.hpp"
|
|
||||||
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
||||||
|
|
||||||
namespace onnx_mlir {
|
namespace onnx_mlir {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
||||||
#include "src/Accelerators/PIM/Pass/PimPasses.hpp"
|
#include "src/Accelerators/PIM/Pass/PimPasses.hpp"
|
||||||
#include "src/Compiler/CompilerPasses.hpp"
|
#include "src/Compiler/CompilerPasses.hpp"
|
||||||
#include "src/Compiler/CompilerUtils.hpp"
|
|
||||||
|
|
||||||
#define DEBUG_TYPE "PimCompilerUtils"
|
#define DEBUG_TYPE "PimCompilerUtils"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS ONNXToSpatial.td)
|
|||||||
mlir_tablegen(ONNXToSpatial.hpp.inc -gen-rewriters "-I${ONNX_MLIR_SRC_ROOT}")
|
mlir_tablegen(ONNXToSpatial.hpp.inc -gen-rewriters "-I${ONNX_MLIR_SRC_ROOT}")
|
||||||
add_public_tablegen_target(ONNXToSpatialIncGen)
|
add_public_tablegen_target(ONNXToSpatialIncGen)
|
||||||
|
|
||||||
add_onnx_mlir_library(OMONNXToSpatial
|
add_pim_library(OMONNXToSpatial
|
||||||
Patterns/Math/Gemm.cpp
|
Patterns/Math/Gemm.cpp
|
||||||
Patterns/Math/Conv.cpp
|
Patterns/Math/Conv.cpp
|
||||||
Patterns/Math/MatMul.cpp
|
Patterns/Math/MatMul.cpp
|
||||||
@@ -17,10 +17,13 @@ add_onnx_mlir_library(OMONNXToSpatial
|
|||||||
ONNXToSpatialPass.cpp
|
ONNXToSpatialPass.cpp
|
||||||
Common.cpp
|
Common.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
ONNXToSpatialIncGen
|
ONNXToSpatialIncGen
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
|
MLIRTosaDialect
|
||||||
OMCompilerOptions
|
OMCompilerOptions
|
||||||
OMPimCompilerOptions
|
OMPimCompilerOptions
|
||||||
OMONNXOps
|
OMONNXOps
|
||||||
@@ -28,5 +31,5 @@ add_onnx_mlir_library(OMONNXToSpatial
|
|||||||
OMPimCommon
|
OMPimCommon
|
||||||
|
|
||||||
ACCEL_INCLUDE_DIRS PRIVATE
|
ACCEL_INCLUDE_DIRS PRIVATE
|
||||||
${PIM_INCLUDE_PATH}
|
${PIM_GENERATED_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
add_onnx_mlir_rewriter(SpatialToGraphviz)
|
add_onnx_mlir_rewriter(SpatialToGraphviz)
|
||||||
|
|
||||||
add_onnx_mlir_library(OMSpatialToGraphviz
|
add_pim_library(OMSpatialToGraphviz
|
||||||
SpatialToGraphviz.cpp
|
SpatialToGraphviz.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
|
MLIRTosaDialect
|
||||||
OMCompilerOptions
|
OMCompilerOptions
|
||||||
OMPimCommon
|
OMPimCommon
|
||||||
OMONNXOps
|
OMONNXOps
|
||||||
SpatialOps
|
SpatialOps
|
||||||
|
|
||||||
ACCEL_INCLUDE_DIRS PRIVATE
|
ACCEL_INCLUDE_DIRS PRIVATE
|
||||||
${PIM_INCLUDE_PATH}
|
${PIM_GENERATED_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,19 +2,22 @@ set(LLVM_TARGET_DEFINITIONS SpatialToPim.td)
|
|||||||
mlir_tablegen(SpatialToPim.hpp.inc -gen-rewriters "-I${ONNX_MLIR_SRC_ROOT}")
|
mlir_tablegen(SpatialToPim.hpp.inc -gen-rewriters "-I${ONNX_MLIR_SRC_ROOT}")
|
||||||
add_public_tablegen_target(SpatialToPimIncGen)
|
add_public_tablegen_target(SpatialToPimIncGen)
|
||||||
|
|
||||||
add_onnx_mlir_library(OMSpatialToPim
|
add_pim_library(OMSpatialToPim
|
||||||
SpatialToPimPass.cpp
|
SpatialToPimPass.cpp
|
||||||
Common.cpp
|
Common.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
SpatialToPimIncGen
|
SpatialToPimIncGen
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
|
MLIRTosaDialect
|
||||||
OMCompilerOptions
|
OMCompilerOptions
|
||||||
OMPimCommon
|
OMPimCommon
|
||||||
SpatialOps
|
SpatialOps
|
||||||
PimOps
|
PimOps
|
||||||
|
|
||||||
ACCEL_INCLUDE_DIRS PRIVATE
|
ACCEL_INCLUDE_DIRS PRIVATE
|
||||||
${PIM_INCLUDE_PATH}
|
${PIM_GENERATED_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ add_onnx_mlir_dialect_doc(pim Pim.td)
|
|||||||
|
|
||||||
add_subdirectory(Transforms/Bufferization)
|
add_subdirectory(Transforms/Bufferization)
|
||||||
|
|
||||||
add_onnx_mlir_library(PimOps
|
add_pim_library(PimOps
|
||||||
PimOps.hpp
|
PimOps.hpp
|
||||||
PimOps.cpp
|
PimOps.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
OMPimIncGen
|
OMPimIncGen
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,15 @@ set(LLVM_TARGET_DEFINITIONS PimBufferization.td)
|
|||||||
mlir_tablegen(PimBufferization.hpp.inc -gen-rewriters "-I${ONNX_MLIR_SRC_ROOT}")
|
mlir_tablegen(PimBufferization.hpp.inc -gen-rewriters "-I${ONNX_MLIR_SRC_ROOT}")
|
||||||
add_public_tablegen_target(PimBufferizationIncGen)
|
add_public_tablegen_target(PimBufferizationIncGen)
|
||||||
|
|
||||||
add_onnx_mlir_library(OMPimBufferization
|
add_pim_library(OMPimBufferization
|
||||||
PimBufferizationPass.cpp
|
PimBufferizationPass.cpp
|
||||||
OpBufferizationInterfaces.hpp
|
OpBufferizationInterfaces.hpp
|
||||||
OpBufferizationInterfaces.cpp
|
OpBufferizationInterfaces.cpp
|
||||||
Common.hpp
|
Common.hpp
|
||||||
Common.cpp
|
Common.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
PimBufferizationIncGen
|
PimBufferizationIncGen
|
||||||
|
|
||||||
@@ -17,5 +19,5 @@ add_onnx_mlir_library(OMPimBufferization
|
|||||||
PimOps
|
PimOps
|
||||||
|
|
||||||
ACCEL_INCLUDE_DIRS PRIVATE
|
ACCEL_INCLUDE_DIRS PRIVATE
|
||||||
${PIM_INCLUDE_PATH}
|
${PIM_GENERATED_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
add_onnx_mlir_dialect(Spatial spat)
|
add_onnx_mlir_dialect(Spatial spat)
|
||||||
add_onnx_mlir_dialect_doc(spat Spatial.td)
|
add_onnx_mlir_dialect_doc(spat Spatial.td)
|
||||||
|
|
||||||
|
add_pim_library(SpatialOps
|
||||||
add_onnx_mlir_library(SpatialOps
|
|
||||||
SpatialOps.cpp
|
SpatialOps.cpp
|
||||||
Transforms/SpatialBufferizableOpInterface.cpp
|
Transforms/SpatialBufferizableOpInterface.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
OMONNXIncGen
|
OMONNXIncGen
|
||||||
OMSpatialIncGen
|
OMSpatialIncGen
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
LINK_LIBS PUBLIC
|
||||||
MLIRIR
|
MLIRIR
|
||||||
|
MLIRBufferizationDialect
|
||||||
|
MLIRBufferizationTransforms
|
||||||
OMMlirDialects
|
OMMlirDialects
|
||||||
|
OMONNXOps
|
||||||
|
OMPimCompilerOptions
|
||||||
|
PimOps
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "src/Accelerators/PIM/Common/PimCommon.hpp"
|
|
||||||
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
||||||
#include "src/Accelerators/PIM/Dialect/Spatial/SpatialOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Spatial/SpatialOps.hpp"
|
||||||
#include "src/Accelerators/PIM/Dialect/Spatial/Transforms/SpatialBufferizableOpInterface.hpp"
|
#include "src/Accelerators/PIM/Dialect/Spatial/Transforms/SpatialBufferizableOpInterface.hpp"
|
||||||
@@ -39,6 +38,55 @@ memref::AllocOp createEmptyFromType(Type resultType, Location loc, RewriterBase&
|
|||||||
|
|
||||||
const llvm::StringRef PRECOMPUTED_OTHER_CORE_ID_ATTR_NAME("precomp_other_core_id");
|
const llvm::StringRef PRECOMPUTED_OTHER_CORE_ID_ATTR_NAME("precomp_other_core_id");
|
||||||
|
|
||||||
|
static FailureOr<Operation*> getOtherEndOfChannel(Operation* op, bool opIsReceive) {
|
||||||
|
auto channelNewOp = op->getOperand(0).getDefiningOp<spatial::SpatChannelNewOp>();
|
||||||
|
if (!channelNewOp) {
|
||||||
|
op->emitError("User of Channel must have the first operand created by ChannelNewOp.");
|
||||||
|
return failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto channelUsers = channelNewOp->getUsers();
|
||||||
|
auto usersIterator = channelUsers.begin();
|
||||||
|
auto firstUser = *usersIterator;
|
||||||
|
++usersIterator;
|
||||||
|
if (usersIterator == channelUsers.end()) {
|
||||||
|
op->emitError("Operand generated by ChannelNewOp must have two users, only one found.");
|
||||||
|
channelNewOp->dump();
|
||||||
|
op->dump();
|
||||||
|
channelNewOp->getParentOp()->dump();
|
||||||
|
return failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto secondUser = *usersIterator;
|
||||||
|
++usersIterator;
|
||||||
|
if (usersIterator != channelUsers.end()) {
|
||||||
|
op->emitError("Operand generated by ChannelNewOp must have two users, more than two found.");
|
||||||
|
return failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
Operation* otherUser = nullptr;
|
||||||
|
if (firstUser == op)
|
||||||
|
otherUser = secondUser;
|
||||||
|
else if (secondUser == op)
|
||||||
|
otherUser = firstUser;
|
||||||
|
else {
|
||||||
|
op->emitError("Operand generated by ChannelNewOp must have two users and one of them must be the current op.");
|
||||||
|
return failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opIsReceive && !isa<spatial::SpatChannelSendOp>(otherUser)) {
|
||||||
|
op->emitError("Operand generated by ChannelNewOp has two users, but the other one is not a ChannelSendOp.");
|
||||||
|
return failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!opIsReceive && !isa<spatial::SpatChannelReceiveOp>(otherUser)) {
|
||||||
|
op->emitError("Operand generated by ChannelNewOp has two users, but the other one is not a ChannelReceiveOp.");
|
||||||
|
return failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
return otherUser;
|
||||||
|
}
|
||||||
|
|
||||||
llvm::FailureOr<uint32_t> getCoreIdOfOtherEndOfChannel(Operation* op, bool opIsReceive, RewriterBase& rewriter) {
|
llvm::FailureOr<uint32_t> getCoreIdOfOtherEndOfChannel(Operation* op, bool opIsReceive, RewriterBase& rewriter) {
|
||||||
|
|
||||||
// This function requires the existence of ChannelNewOp and the other
|
// This function requires the existence of ChannelNewOp and the other
|
||||||
@@ -49,7 +97,7 @@ llvm::FailureOr<uint32_t> getCoreIdOfOtherEndOfChannel(Operation* op, bool opIsR
|
|||||||
if (precomputedOtherCoreId)
|
if (precomputedOtherCoreId)
|
||||||
return cast<IntegerAttr>(precomputedOtherCoreId).getInt();
|
return cast<IntegerAttr>(precomputedOtherCoreId).getInt();
|
||||||
|
|
||||||
auto notOpUserOpt = getOtherEndOfChannel(op, opIsReceive, rewriter);
|
auto notOpUserOpt = getOtherEndOfChannel(op, opIsReceive);
|
||||||
if (failed(notOpUserOpt))
|
if (failed(notOpUserOpt))
|
||||||
return failure();
|
return failure();
|
||||||
Operation* notOpUser = *notOpUserOpt;
|
Operation* notOpUser = *notOpUserOpt;
|
||||||
|
|||||||
15
src/PIM/Pass/CMakeLists.txt
Normal file
15
src/PIM/Pass/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
add_pim_library(OMPimPasses
|
||||||
|
CountInstructionPass.cpp
|
||||||
|
MessagePass.cpp
|
||||||
|
PimConstantFolding/Common.cpp
|
||||||
|
PimConstantFolding/Patterns/ConstantPatterns.cpp
|
||||||
|
PimConstantFolding/PimConstantFoldingPass.cpp
|
||||||
|
PimConstantFolding/Patterns/SubviewPatterns.cpp
|
||||||
|
PimHostVerificationPass.cpp
|
||||||
|
|
||||||
|
EXCLUDE_FROM_OM_LIBS
|
||||||
|
|
||||||
|
LINK_LIBS PUBLIC
|
||||||
|
MLIRLinalgDialect
|
||||||
|
OMPimCommon
|
||||||
|
)
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Pim/PimOps.hpp"
|
||||||
#include "src/Accelerators/PIM/Dialect/Spatial/SpatialOps.hpp"
|
#include "src/Accelerators/PIM/Dialect/Spatial/SpatialOps.hpp"
|
||||||
#include "src/Compiler/CompilerUtils.hpp"
|
|
||||||
|
|
||||||
using namespace mlir;
|
using namespace mlir;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
#include "mlir/IR/BuiltinOps.h"
|
||||||
#include "mlir/Pass/Pass.h"
|
#include "mlir/Pass/Pass.h"
|
||||||
|
|
||||||
#include "src/Compiler/CompilerUtils.hpp"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
using namespace mlir;
|
using namespace mlir;
|
||||||
|
|
||||||
@@ -17,7 +18,10 @@ struct MessagePass : PassWrapper<MessagePass, OperationPass<ModuleOp>> {
|
|||||||
: message(message) {}
|
: message(message) {}
|
||||||
MessagePass(const MessagePass& pass) {}
|
MessagePass(const MessagePass& pass) {}
|
||||||
|
|
||||||
void runOnOperation() final { showCompilePhase(message); }
|
void runOnOperation() final {
|
||||||
|
llvm::outs() << message << "\n";
|
||||||
|
llvm::outs().flush();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|||||||
Reference in New Issue
Block a user