Commit f337ba6f by Yijun Tan

add legalization & terminal assignment

parent fec93bd3
images/*
.vscode/*
.build/*
.data/*
build/*
data/*
test.cpp
test*
FFT*
a.exe
......@@ -7,19 +7,92 @@ set(CMAKE_DEPENDS_GENERATOR "MinGW Makefiles")
# The top level Makefile was generated from the following files:
set(CMAKE_MAKEFILE_DEPENDS
"CMakeCache.txt"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCCompiler.cmake.in"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCCompilerABI.c"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXCompiler.cmake.in"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXCompilerABI.cpp"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCompilerIdDetection.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompileFeatures.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompilerABI.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompilerId.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineRCCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeFindBinUtils.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeGenericSystem.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeMinGWFindMake.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeParseImplicitIncludeInfo.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeParseImplicitLinkInfo.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeParseLibraryArchitecture.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeRCCompiler.cmake.in"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeRCInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystem.cmake.in"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCompilerCommon.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestRCCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/ADSP-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/ARMCC-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/ARMClang-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/AppleClang-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Borland-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Bruce-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Clang-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Compaq-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Cray-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Embarcadero-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Fujitsu-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GHS-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-C.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-CXX.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-FindBinUtils.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/HP-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/HP-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IAR-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Intel-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IntelLLVM-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/MSVC-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/NVHPC-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/NVIDIA-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/PGI-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/PathScale-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SCO-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SDCC-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SunPro-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/TI-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Watcom-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XL-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XL-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XLClang-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/zOS-C-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Internal/FeatureTesting.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-Determine-CXX.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-C-ABI.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-C.cmake"
"C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-GNU-CXX-ABI.cmake"
......@@ -43,6 +116,12 @@ set(CMAKE_MAKEFILE_OUTPUTS
# Byproducts of CMake generate step:
set(CMAKE_MAKEFILE_PRODUCTS
"CMakeFiles/3.22.0-rc2/CMakeSystem.cmake"
"CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake"
"CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake"
"CMakeFiles/CMakeDirectoryInformation.cmake"
)
......
......@@ -80,12 +80,12 @@ clean: CMakeFiles/ppPlace.dir/clean
CMakeFiles/ppPlace.dir/all:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/depend
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/build
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=E:\iccad2023\ppp\build\CMakeFiles --progress-num=1,2,3,4,5,6 "Built target ppPlace"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=E:\iccad2023\ppp\build\CMakeFiles --progress-num=1,2,3,4,5,6,7 "Built target ppPlace"
.PHONY : CMakeFiles/ppPlace.dir/all
# Build rule for subdir invocation for target.
CMakeFiles/ppPlace.dir/rule: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles 6
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles 7
$(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 CMakeFiles/ppPlace.dir/all
$(CMAKE_COMMAND) -E cmake_progress_start E:\iccad2023\ppp\build\CMakeFiles 0
.PHONY : CMakeFiles/ppPlace.dir/rule
......
......@@ -13,6 +13,7 @@ set(CMAKE_DEPENDS_DEPENDENCY_FILES
"E:/iccad2023/ppp/src/Database.cpp" "CMakeFiles/ppPlace.dir/src/Database.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/Database.cpp.obj.d"
"E:/iccad2023/ppp/src/FFTBin.cpp" "CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj.d"
"E:/iccad2023/ppp/src/FFT_calculator.cpp" "CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj.d"
"E:/iccad2023/ppp/src/Legalizer.cpp" "CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj" "gcc" "CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj.d"
)
# Targets to which this target links.
......
......@@ -143,13 +143,29 @@ CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.s"
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S E:\iccad2023\ppp\src\FFT_calculator.cpp -o CMakeFiles\ppPlace.dir\src\FFT_calculator.cpp.s
CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj: CMakeFiles/ppPlace.dir/flags.make
CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj: CMakeFiles/ppPlace.dir/includes_CXX.rsp
CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj: ../src/Legalizer.cpp
CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj: CMakeFiles/ppPlace.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=E:\iccad2023\ppp\build\CMakeFiles --progress-num=$(CMAKE_PROGRESS_6) "Building CXX object CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj"
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -MD -MT CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj -MF CMakeFiles\ppPlace.dir\src\Legalizer.cpp.obj.d -o CMakeFiles\ppPlace.dir\src\Legalizer.cpp.obj -c E:\iccad2023\ppp\src\Legalizer.cpp
CMakeFiles/ppPlace.dir/src/Legalizer.cpp.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/ppPlace.dir/src/Legalizer.cpp.i"
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E E:\iccad2023\ppp\src\Legalizer.cpp > CMakeFiles\ppPlace.dir\src\Legalizer.cpp.i
CMakeFiles/ppPlace.dir/src/Legalizer.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/ppPlace.dir/src/Legalizer.cpp.s"
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S E:\iccad2023\ppp\src\Legalizer.cpp -o CMakeFiles\ppPlace.dir\src\Legalizer.cpp.s
# Object files for target ppPlace
ppPlace_OBJECTS = \
"CMakeFiles/ppPlace.dir/main.cpp.obj" \
"CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj" \
"CMakeFiles/ppPlace.dir/src/Database.cpp.obj" \
"CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj" \
"CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj"
"CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj" \
"CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj"
# External object files for target ppPlace
ppPlace_EXTERNAL_OBJECTS =
......@@ -159,11 +175,12 @@ ppPlace.exe: CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj
ppPlace.exe: CMakeFiles/ppPlace.dir/src/Database.cpp.obj
ppPlace.exe: CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj
ppPlace.exe: CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj
ppPlace.exe: CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj
ppPlace.exe: CMakeFiles/ppPlace.dir/build.make
ppPlace.exe: CMakeFiles/ppPlace.dir/linklibs.rsp
ppPlace.exe: CMakeFiles/ppPlace.dir/objects1.rsp
ppPlace.exe: CMakeFiles/ppPlace.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=E:\iccad2023\ppp\build\CMakeFiles --progress-num=$(CMAKE_PROGRESS_6) "Linking CXX executable ppPlace.exe"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=E:\iccad2023\ppp\build\CMakeFiles --progress-num=$(CMAKE_PROGRESS_7) "Linking CXX executable ppPlace.exe"
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles\ppPlace.dir\link.txt --verbose=$(VERBOSE)
# Rule to build all files generated by this target.
......
......@@ -9,6 +9,8 @@ file(REMOVE_RECURSE
"CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj.d"
"CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj"
"CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj.d"
"CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj"
"CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj.d"
"libppPlace.dll.a"
"ppPlace.exe"
"ppPlace.exe.manifest"
......
......@@ -383,4 +383,10 @@ CMakeFiles/ppPlace.dir/main.cpp.obj: E:\iccad2023\ppp\main.cpp \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/sherrors.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/io.h \
E:/iccad2023/ppp/include/FFTBin.h E:/iccad2023/ppp/include/param.h \
E:/iccad2023/ppp/include/FFT_calculator.h
E:/iccad2023/ppp/include/FFT_calculator.h \
E:/iccad2023/ppp/include/Legalizer.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/list \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/stl_list.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/allocated_ptr.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/list.tcc \
E:/iccad2023/ppp/include/Terminal.h
CMakeFiles/ppPlace.dir/main.cpp.obj CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj CMakeFiles/ppPlace.dir/src/Database.cpp.obj CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj
CMakeFiles/ppPlace.dir/main.cpp.obj CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj CMakeFiles/ppPlace.dir/src/Database.cpp.obj CMakeFiles/ppPlace.dir/src/FFTBin.cpp.obj CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.obj CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj
......@@ -4,4 +4,5 @@ CMAKE_PROGRESS_3 = 3
CMAKE_PROGRESS_4 = 4
CMAKE_PROGRESS_5 = 5
CMAKE_PROGRESS_6 = 6
CMAKE_PROGRESS_7 = 7
......@@ -383,4 +383,10 @@ CMakeFiles/ppPlace.dir/src/Circuit.cpp.obj: \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/sherrors.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/io.h \
E:/iccad2023/ppp/include/FFTBin.h E:/iccad2023/ppp/include/param.h \
E:/iccad2023/ppp/include/FFT_calculator.h
E:/iccad2023/ppp/include/FFT_calculator.h \
E:/iccad2023/ppp/include/Legalizer.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/list \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/stl_list.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/allocated_ptr.h \
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/list.tcc \
E:/iccad2023/ppp/include/Terminal.h
......@@ -248,6 +248,30 @@ src/FFT_calculator.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/FFT_calculator.cpp.s
.PHONY : src/FFT_calculator.cpp.s
src/Legalizer.obj: src/Legalizer.cpp.obj
.PHONY : src/Legalizer.obj
# target to build an object file
src/Legalizer.cpp.obj:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Legalizer.cpp.obj
.PHONY : src/Legalizer.cpp.obj
src/Legalizer.i: src/Legalizer.cpp.i
.PHONY : src/Legalizer.i
# target to preprocess a source file
src/Legalizer.cpp.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Legalizer.cpp.i
.PHONY : src/Legalizer.cpp.i
src/Legalizer.s: src/Legalizer.cpp.s
.PHONY : src/Legalizer.s
# target to generate assembly for a file
src/Legalizer.cpp.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles\ppPlace.dir\build.make CMakeFiles/ppPlace.dir/src/Legalizer.cpp.s
.PHONY : src/Legalizer.cpp.s
# Help Target
help:
@echo The following are some of the valid targets for this Makefile:
......@@ -272,6 +296,9 @@ help:
@echo ... src/FFT_calculator.obj
@echo ... src/FFT_calculator.i
@echo ... src/FFT_calculator.s
@echo ... src/Legalizer.obj
@echo ... src/Legalizer.i
@echo ... src/Legalizer.s
.PHONY : help
......
No preview for this file type
......@@ -1274,7 +1274,7 @@ Pin P60 4298 0
LibCell N MC221 50 33 1
Pin P1 25 16
DieSize 0 0 23000 38000
DieSize 0 0 23000 19000
TopDieMaxUtil 80
BottomDieMaxUtil 80
NumTechnologies 2
Tech TA 3
LibCell N MC1 400 300 1
LibCell N MC1 7 10 1
Pin P1 2 7
LibCell N MC2 14 10 2
Pin P1 10 4
......@@ -20,7 +20,7 @@ Pin P1 2 12
Pin P2 3 3
Pin P3 15 7
DieSize 0 0 800 600
DieSize 0 0 40 30
TopDieMaxUtil 80
BottomDieMaxUtil 90
......@@ -35,7 +35,36 @@ TerminalSize 6 6
TerminalSpacing 5
TerminalCost 10
NumInstances 1
NumInstances 8
Inst C1 MC1
Inst C2 MC3
Inst C3 MC3
Inst C4 MC2
Inst C5 MC2
Inst C6 MC3
Inst C7 MC2
Inst C8 MC1
NumNets 0
\ No newline at end of file
NumNets 6
Net N1 2
Pin C1/P1
Pin C2/P2
Net N2 3
Pin C2/P1
Pin C3/P1
Pin C7/P2
Net N3 2
Pin C2/P3
Pin C8/P1
Net N4 3
Pin C3/P3
Pin C6/P2
Pin C7/P1
Net N5 3
Pin C4/P2
Pin C6/P1
Pin C5/P1
Net N6 2
Pin C4/P1
Pin C5/P2
todo:
filler cell NumInstances
local smoothing
cur a pre a coeff
cellcenter
multithread
replace diff
macro
iccad2022
东南大学
1.partition
dual-objective partition model
2.global placement
eplace
3.legalization
overlap of cells +overlap of terminals
4.detailed placement
linyibo
鹏程实验室
1.wirelength & area-aware initial assignment
2. iterative improvement
die placement
terminal legalization
local search re-assignment
3.3d ligalization & detailed placement
#ifndef PPP_CIRCUIT_H
#define PPP_CIRCUIT_H
#include "Database.h"
#include "FFTBin.h"
#include "Legalizer.h"
#include "Terminal.h"
#include "Param.h"
class Circuit : public Database{
public:
int filler_num, allcell_num;
long long movecell_num[2];
long long stdcell_num[2];
long long filler_num[2];
long long allcell_num[2];
long long all;
//std::vector<std::vector<Bin>> bins;
fftBin* fftbin;
Terminal* term;
int binsize_x;
......@@ -17,6 +30,8 @@ public:
public:
void init(int);
void finish();
void makeCellList();
void setCellTechs();
void makeInstList();
......@@ -33,6 +48,10 @@ public:
void doFFT();
void updateDensity();
void legalize();
void terminalAssignment();
float calHPWL();
......@@ -44,8 +63,8 @@ public:
//cimg
#if VISUAL
void draw(std::string, int Scale=1);
void plotDensity(cimg_library::CImg<unsigned char>&);
void plotCells(cimg_library::CImg<unsigned char>&);
void plotDensity(cimg_library::CImg<unsigned char>&, int);
void plotCells(cimg_library::CImg<unsigned char>&, int);
void plotNets(cimg_library::CImg<unsigned char>&);
void drawLine(cimg_library::CImg<unsigned char>&, const int, const int, const int, const int, const unsigned int, const unsigned char[]);
//void drawBinDensity(cimg_library::CImg<unsigned char>& image, float opacity);
......@@ -56,3 +75,5 @@ public:
~Circuit() {delete fftbin;};
};
#endif //PPP_CIRCUIT_H
\ No newline at end of file
......@@ -12,17 +12,6 @@ class Net
};
*/
class Inst
{
public:
int w, h;
long area;
public:
Inst() = default;
Inst(int W, int H): w(W), h(H), area(W*H) {}
};
class Cell
{
......@@ -41,6 +30,21 @@ public:
Cell(int W, int H, bool IM): w(W), h(H), is_macro(IM), is_filler(false), area(W*H) {}
};
/*
class Inst
{
public:
int w, h;
long area;
int layer;
std::vector<std::pair<int, int>> pins;
public:
Inst() = default;
Inst(int W, int H): w(W), h(H), area(W*H), layer(0) {}
Inst(int W, int H, std::pair<int, int>* b, std::pair<int, int>* e): w(W), h(H), area(W*H), layer(0), pins(b, e) {}
};
*/
......@@ -58,17 +62,17 @@ public:
class Database
{
public:
std::vector<std::vector<Cell>> techs;
std::vector<std::vector<Cell*>> techs;
int h, w;
Die_infro die_infro[2];
int th, tw, tspaceing, tcost; //terminal information
int tech_num, cell_num, net_num;
std::vector<int> cells;
std::vector<int> layer;
std::vector<int> cell_die;
//std::vector<int> cell_die;
std::vector<int> mass;
std::vector<Inst> insts;
std::vector<Cell*> insts;
std::vector<std::vector<std::pair<int, int>>> nets;
std::vector<std::vector<std::pair<int, int>>> node_net;
......@@ -80,6 +84,8 @@ public:
std::vector<std::pair<float, float>> net_center;
std::vector<std::pair<int, int>> term_pos;
public:
void readcase(std::string);
......
......@@ -14,19 +14,32 @@ public:
//std::vector<std::vector<float>> llx, lly, urx, ury;
std::vector<float> coordx, coordy;
std::vector<float*> electricDensity;
std::vector<float*> electricPotential;
std::vector<float*> electricField_x;
std::vector<float*> electricField_y;
std::vector<float*> electricDensity_top;
std::vector<float*> electricPotential_top;
std::vector<float*> electricField_x_top;
std::vector<float*> electricField_y_top;
std::vector<std::vector<float>> stdArea, fillerArea;
std::vector<std::vector<std::vector<int>>> correspondCells;
std::vector<float*> electricDensity_bottom;
std::vector<float*> electricPotential_bottom;
std::vector<float*> electricField_x_bottom;
std::vector<float*> electricField_y_bottom;
std::vector<std::vector<float>> stdArea_top, fillerArea_top;
std::vector<std::vector<std::vector<int>>> correspondCells_top;
std::vector<std::vector<float>> stdArea_bottom, fillerArea_bottom;
std::vector<std::vector<std::vector<int>>> correspondCells_bottom;
//fft parts
std::vector<float> wx, wy;
std::vector<float> wx_sq, wy_sq;
std::vector<float> wx_top, wy_top;
std::vector<float> wx_sq_top, wy_sq_top;
std::vector<float> wx_bottom, wy_bottom;
std::vector<float> wx_sq_bottom, wy_sq_bottom;
std::vector<float> cosTable;
......
#ifndef ABACUS_HPP
#define ABACUS_HPP
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>
#include <climits>
struct node{
node(int x,int y,int w = -1,int h = -1 )
:origin_y{y},origin_x{x},width{w},height{h}{}
node(std::string n,int x,int y,int w ,int h )
:name{n},origin_y{y},origin_x{x},width{w},height{h}{}
void setShape(int w,int h){
width = w;
height = h;
}
int origin_x,origin_y;//global placement result
int width;
int height;
int weight = 1;
int x,y;
std::string name;
};
// abacus datastructure.
struct cluster{
int xc; // start x-position
// abacus dp
int ec; // ec <- ec + e(i)
int qc; // qc <- qc +e(i)[x'(i) -wc ]
int wc; // wc <- wc + w(i)
cluster(int x)
:xc{x},ec{0},qc{0},wc{0}{}
// if overlap with predecessor cluster, then do cluster.
// nodes for caculate each position x
std::list<node*>nodes;
void AddCell(node*n){
nodes.push_back(n);
ec += n->weight;
qc += n->weight * (n->origin_x - wc);
wc += n->width;
}
void AddCluster(cluster*other)
{
for(auto n:other->nodes)nodes.push_back(n);
ec += other->ec;
qc += (other->qc - other->ec * wc);
wc += other->wc;
}
};
struct subrow{
subrow(int startx,int width,int coordinate)
: x1{startx},x2{startx + width},y{coordinate}
{
remainSpace = x2-x1;
cost = 0;
clusterNum = BackupNum=0;
}
cluster& last(){
if(empty()){
std::cerr<<"error in cluster&last(),Clusters is empty\n";
exit(1);
}
return Clusters.at(clusterNum-1);
}
bool empty(){return clusterNum==0;}
void AppendCluster(int);
void Collapse();//Collapse start from last Cluster in Clusters, and update ClusterIdx.
void place(node*);//Place node to last Cluster in Clusters .
int getPos();//return the total Cost in Clusters.
std::vector<cluster>Clusters;
int x1,x2;
int remainSpace;
int y;
int cost;
int clusterNum;// point to last Cluster in Clusters.
void Backup()
{
if(clusterNum > ClustersBackup.size())//need allocate
ClustersBackup.push_back(Clusters.back());
if(clusterNum > ClustersBackup.size()){
std::cerr<<"Back up error,clusterNum > clusterBack.size()\n";
exit(1);
}
BackupNum = clusterNum;
ClustersBackup.at(BackupNum-1) = Clusters.at(clusterNum-1);
}
//each time after calling subrow::place(node*) , need recover .
void RecvoerClusters(){
if(clusterNum==BackupNum)//only need recover last cluster.
Clusters.at(clusterNum-1) = ClustersBackup.at(clusterNum-1);
else if(clusterNum < BackupNum) // clusters call collapse during place(node*)
{
if(Clusters.size() < BackupNum)
{
std::cerr<<"Clusters.size() not enough!\n";
exit(1);
}
for(int idx = clusterNum-1;idx < BackupNum;idx++)
Clusters.at(idx) = ClustersBackup.at(idx);
}
clusterNum = BackupNum;
}
private:
int BackupNum;// point to last Cluster in Backup
std::vector<cluster>ClustersBackup;
};
using fixed_node = node;
struct row{
row(int x,int coordinate,int w,int h)
:y{coordinate},height{h}{
subrows.push_back({x,w,coordinate});
}
int y;
int height;
std::vector<subrow> subrows;
//need sorted by x.
void block(fixed_node&terminal);
std::pair<subrow*,int> placeRow(node* n);
int getCost();
int getRemain();
std::vector<node*> RipUp(int threshold);//RipUp the width <= threshold
};
void placeTerminal(std::vector<fixed_node>&terminals,std::vector<row>&rows);
int abacus(std::vector<node*>nodes,std::vector<row>&rows);
#endif
......@@ -39,6 +39,11 @@ namespace Color {
}
const static int inf=0x7fffffff;
const static int mid_width = 10;
const static float densityScale = 1e-1; //1e-4; // variable for preventing the overflow of binDensity
const static float time_step = 0.02;
const static float wireLengthCoefficient = 10; //1e-1;
......
#ifndef PPP_TERMINAL_H
#define PPP_TERMINAL_H
#include "Param.h"
class Terminal{
public:
//const int maxn=10005;
const int inf=0x7fffffff;
int n, m;
std::vector<int> wx, wy, cx, cy, slack;
std::vector<bool> visx, visy;
//int Map[maxn][maxn];
//int minz;
std::vector<std::vector<int>> index;
std::vector<std::vector<int>> value;
Terminal(int x, int y): n(x), m(y) {
index.resize(n);
value.resize(m);
}
void add(int i, int x, int y) {
index[i].push_back(x);
value[i].push_back(y);
}
int BinarySearch(std::vector<int> array, int key)
{
int aSize = array.size();
if ( array.empty() || aSize == 0 )
return -1;
int low = 0;
int high = aSize - 1;
int mid = 0;
while ( low <= high )
{
mid = (low + high )/2;
if ( array[mid] < key)
low = mid + 1;
else if ( array[mid] > key )
high = mid - 1;
else
return mid;
}
return -1;
}
bool find(int u)
{
visx[u]=1;
int l = index[u].size();
for(int j = 0; j < l; ++j)
{
int v = index[u][j];
if(visy[v]) continue;
int t = wx[u] + wy[v] - value[u][j];
if(t == 0)
{
visy[v]=1;
if(cy[v]==-1||find(cy[v]))
{
cx[u]=v;
cy[v]=u;
return 1;
}
}
else if(t<0)
{
slack[v]=std::max(slack[v],t);
}
}
return false;
}
int run()
{
slack.resize(m, 0);
cx.resize(n, -1);
cy.resize(m, -1);
wx.resize(n, 0);
wy.resize(m, 0);
visx.resize(n);
visy.resize(m);
for(int i = 0; i < n; ++i)
{
int l = index[i].size();
for(int j = 0; j < l; ++j)
{
wx[i]=std::min(wx[i],value[i][j]);
}
std::cout << wx[i] << std::endl;
}
for(int i = 0; i < n; ++i)
{
for(;;)
{
//minz=-inf;
std::fill(slack.begin(), slack.end(), -inf);
std::fill(visx.begin(), visx.end(), 0);
std::fill(visy.begin(), visy.end(), 0);
if(find(i)) break;
int d = -inf;
for (int j = 0; j < m; ++j)
if (!visy[j]) d = std::max(d, slack[j]);
for(int j = 0; j < m; ++j)
{
if(visx[j]) wx[j]-=d;
if(visy[j]) wy[j]+=d;
else slack[j] -= d;
}
}
//for (int j = 0; j < cntx; ++j)
// std::cout << cx[j] << " " << cy[j] << " " << wx[j] << " " << wy[j] << " " << slack[j] << std::endl;
//return 1;
}
int ans=0;
for(int i = 0; i < n; ++i)
{
if(cx[i]!=-1)
{
int ind = BinarySearch(index[i], cx[i]);
ans+=value[i][ind];
}
}
return ans;
}
};
#endif //PPP_TERMINAL_H
\ No newline at end of file
......@@ -9,11 +9,15 @@ int main() {
Circuit* circuit = new Circuit();
circuit->readcase("../data/toy.txt");
circuit->readcase("../data/ProblemB_case2.txt");
std::cout << "Reading case..." << std::endl;
std::string picname;
circuit->init(0);
std::cout << "Initializing process..." << std::endl;
circuit->init(10);
std::cout << "Initialplacement done" << std::endl;
picname = "initial.bmp";
circuit->draw(picname);
......@@ -24,17 +28,19 @@ int main() {
std::cout << "Electric potential apply." << std::endl;
for (int i = 0; i < 1; ++i) {
for (int i = 0; i < 10; ++i) {
circuit->Iteration(i);
std::cout << "HPWL:" << circuit->calHPWL() << std::endl;
if ((i+1) % 1 == 0) {
if ((i+1) % 10 == 0) {
picname = "iter" + std::to_string(i) + ".bmp";
circuit->draw(picname);
}
}
circuit->finish();
picname = "after.bmp";
circuit->draw(picname);
......
......@@ -10,7 +10,10 @@ void Database::readcase(std::string inputfilename)
std::string temp;
ss >> temp >> tech_num;
techs.resize(tech_num);
//techs.resize(tech_num);
techs.resize(2);
if (tech_num == 1)
techs[1].resize(1);
for (int i = 0; i < tech_num; ++i) {
ss >> temp;
......@@ -24,8 +27,8 @@ void Database::readcase(std::string inputfilename)
ss >> is_macro;
ss >> cell_name;
int w, h;
ss >> w >> h;
techs[i][j+1] = Cell(w, h, is_macro=="Y");
ss >> h >> w;
techs[i][j+1] = new Cell(w, h, is_macro=="Y");
//ss >> techs[i][cell_name].w;
//ss >> techs[i][cell_name].h;
......@@ -33,14 +36,14 @@ void Database::readcase(std::string inputfilename)
int pin_num;
ss >> pin_num;
techs[i][j+1].pins.resize(pin_num);
techs[i][j+1]->pins.resize(pin_num);
for (int k = 0; k < pin_num; ++k) {
int x, y;
ss >> temp;
ss >> temp;
ss >> x;
ss >> y;
techs[i][j+1].pins[k] = std::make_pair(x, y);
techs[i][j+1]->pins[k] = std::make_pair(x, y);
}
}
......@@ -125,6 +128,7 @@ void Database::readcase(std::string inputfilename)
node_net[inst_idx].push_back(std::make_pair(i, pin_idx));
//std::cout << inst_idx << " " << pin_idx << std::endl;
//if (i > 10) break;
}
......
......@@ -32,35 +32,35 @@ void fftBin::doFFT() {
ddct2d(binsize_x,
binsize_y,
-1,
electricDensity.data(),
electricDensity_top.data(),
NULL,
workArea.data(),
cosTable.data()
);
for (int i = 0; i < binsize_x; ++i) {
electricDensity[i][0] *= 0.5;
electricDensity_top[i][0] *= 0.5;
}
for (int i = 0; i < binsize_y; ++i) {
electricDensity[0][i] *= 0.5;
electricDensity_top[0][i] *= 0.5;
}
for (int i = 0; i < binsize_x; ++i) {
for (int j = 0; j < binsize_y; ++j) {
electricDensity[i][j] *= 4.0 / binsize_x / binsize_y;
electricDensity_top[i][j] *= 4.0 / binsize_x / binsize_y;
}
}
for (int i = 0; i < binsize_x; ++i) {
float wwx = wx[i];
float wwx2 = wx_sq[i];
float wwx = wx_top[i];
float wwx2 = wx_sq_top[i];
for (int j = 0; j < binsize_y; ++j) {
float wwy = wy[j];
float wwy2 = wy_sq[j];
float wwy = wy_top[j];
float wwy2 = wy_sq_top[j];
float density = electricDensity[i][j];
float density = electricDensity_top[i][j];
float phi = 0;
float electroX = 0, electroY = 0;
if (i == 0 && j == 0) {
......@@ -72,16 +72,16 @@ void fftBin::doFFT() {
electroY = phi * wwy;
}
electricPotential[i][j] = phi;
electricField_x[i][j] = electroX;
electricField_y[i][j] = electroY;
electricPotential_top[i][j] = phi;
electricField_x_top[i][j] = electroX;
electricField_y_top[i][j] = electroY;
}
}
ddct2d(binsize_x,
binsize_y,
1,
electricPotential.data(),
electricPotential_top.data(),
NULL,
workArea.data(),
cosTable.data()
......@@ -89,7 +89,75 @@ void fftBin::doFFT() {
ddsct2d(binsize_x,
binsize_y,
1,
electricField_x.data(),
electricField_x_top.data(),
NULL,
workArea.data(),
cosTable.data()
);
ddcst2d(binsize_x,
binsize_y,
1,
electricField_y_top.data(),
NULL,
workArea.data(),
cosTable.data()
);
ddct2d(binsize_x,
binsize_y,
-1,
electricDensity_bottom.data(),
NULL,
workArea.data(),
cosTable.data()
);
for (int i = 0; i < binsize_x; ++i) {
electricDensity_bottom[i][0] *= 0.5;
}
for (int i = 0; i < binsize_y; ++i) {
electricDensity_bottom[0][i] *= 0.5;
}
for (int i = 0; i < binsize_x; ++i) {
for (int j = 0; j < binsize_y; ++j) {
electricDensity_bottom[i][j] *= 4.0 / binsize_x / binsize_y;
}
}
for (int i = 0; i < binsize_x; ++i) {
float wwx = wx_bottom[i];
float wwx2 = wx_sq_bottom[i];
for (int j = 0; j < binsize_y; ++j) {
float wwy = wy_bottom[j];
float wwy2 = wy_sq_bottom[j];
float density = electricDensity_bottom[i][j];
float phi = 0;
float electroX = 0, electroY = 0;
if (i == 0 && j == 0) {
phi = electroX = electroY = 0.0f;
}
else {
phi = density / (wwx2 + wwy2);
electroX = phi * wwx;
electroY = phi * wwy;
}
electricPotential_bottom[i][j] = phi;
electricField_x_bottom[i][j] = electroX;
electricField_y_bottom[i][j] = electroY;
}
}
ddct2d(binsize_x,
binsize_y,
1,
electricPotential_bottom.data(),
NULL,
workArea.data(),
cosTable.data()
......@@ -97,7 +165,15 @@ void fftBin::doFFT() {
ddsct2d(binsize_x,
binsize_y,
1,
electricField_y.data(),
electricField_x_bottom.data(),
NULL,
workArea.data(),
cosTable.data()
);
ddcst2d(binsize_x,
binsize_y,
1,
electricField_y_bottom.data(),
NULL,
workArea.data(),
cosTable.data()
......@@ -111,9 +187,14 @@ void fftBin::doFFT() {
fftBin::~fftBin() {
for (int i = 0; i < binsize_x; ++i) {
delete electricDensity[i];
delete electricPotential[i];
delete electricField_x[i];
delete electricField_y[i];
delete electricDensity_top[i];
delete electricPotential_top[i];
delete electricField_x_top[i];
delete electricField_y_top[i];
delete electricDensity_bottom[i];
delete electricPotential_bottom[i];
delete electricField_x_bottom[i];
delete electricField_y_bottom[i];
}
}
#include "Legalizer.h"
// user need to enter terminal with the increasing x order.
// the block function check the relative position between termianl node and place-row , and make the correction : split the subrows or boundary correction.
void row::block(fixed_node &terminal){
//pre-checking y range
if(terminal.origin_y + terminal.height <= y || terminal.origin_y >= y + height)return ;
subrow* last = &(*subrows.rbegin());// this is why user need to enter terminal with the increasing x.
int condition;//overlap condition
int t_x1 = terminal.origin_x;
int t_x2 = t_x1 + terminal.width;
if( (t_x2 <= last->x1 ) || ( t_x1 >= last->x2) )condition = 0;//not overlap in x.
else if(t_x1 <= last->x1 && t_x2 >=last->x2)condition = 1; // completely ovelap
else if(t_x1 <= last->x1 && t_x2 < last->x2)condition = 2; // x|xx---|
else if(t_x1 > last->x1 && t_x2 < last->x2)condition = 3;//|--xxx--| need split
else if(t_x1 > last->x1 && t_x2 >= last->x2)condition = 4; //|---xx|x
if(condition==1)
subrows.pop_back();//delete subrow
else if(condition==2)
last->x1 = t_x2;
else if(condition==3){//split new subrow
subrows.push_back({t_x2,last->x2-t_x2,y});
last = &subrows.at(subrows.size()-2);//push back may allocate new memory
last->x2 = t_x1;
}
else if(condition==4)
last->x2 = t_x1;
if(condition > 1) last->remainSpace = last->x2 - last->x1;
}
void subrow::Collapse(){
int c = clusterNum - 1;
// check if overlap happend.
for(;c >= 0 ;c--){
cluster&cur = Clusters.at(c);
cur.xc = cur.qc / cur.ec;
if(cur.xc < x1) cur.xc = x1;
if(cur.xc > x2 - cur.wc)cur.xc = x2 - cur.wc;
if(c > 0 && Clusters.at(c-1).xc + Clusters.at(c-1).wc > cur.xc)
Clusters.at(c-1).AddCluster(&cur);
else
break;//do not decrease c
}
clusterNum = c + 1;
}
// modified part : boundary fixed.
inline int modify_x(int x1,int x2,node*n){
if(n->origin_x < x1)
return x1;
if(n->origin_x + n->width > x2)
return x2 - n->width;
return n->origin_x;
}
void subrow::AppendCluster(int x){
if(Clusters.size()==clusterNum){//need allocate new memmory.
Clusters.push_back(cluster{x});
}
else if(Clusters.size() > clusterNum)//update clusterNum
Clusters.at(clusterNum) = cluster{x};
else{
std::cerr<<"subrow::AppendCluster error, clusterNum > clusters.size()\n";
exit(1);
}
clusterNum++;
}
void subrow::place(node*n){
int m_x = modify_x(x1,x2,n);// abacus fixed.
if(empty() || last().xc + last().wc <= m_x){//if do not need place compactly.
AppendCluster(m_x);//new cluster
last().AddCell(n);//new cluster add cell
}
else{
last().AddCell(n);
Collapse();//recursive Collapse
}
}
int subrow::getPos(){
int cost = 0;
for(int c = 0;c < clusterNum;c++){
cluster& clst = Clusters.at(c);
int x = clst.xc;
for(node*n : clst.nodes){
n->x = x;
n->y = y;
cost+=std::abs(n->x - n->origin_x);
cost+=std::abs(n->y - n->origin_y);
x += n->width;
}
}
return cost;//total cost
}
int SubRowPlace(subrow*r,node*n){
r->place(n);
return r->getPos();
}
int BsSub(std::vector<subrow>&subs,node*n){
int l = 0;
int r= subs.size()-1;
while(l<r)
{
int mid = (l+r)/2;
if(subs.at(mid).x1==n->origin_x)return mid;
else if(subs.at(mid).x1 > n->origin_x)r = mid-1;
else l = mid+1;
}
return std::max(0,l);
}
bool tryPlace(subrow&sub,node*n,int&bestCost,subrow*&bestp){
if(sub.remainSpace >= n->width){//still have space
sub.place(n);
int afterCost = sub.getPos();
int dCost = afterCost - sub.cost;//new - original : cost of placing one node.
sub.RecvoerClusters();
if(dCost < bestCost){
bestp = &sub;
bestCost = dCost;
return true;
}
else
return false;
}
return true;
}
//first : optimal subrow to place n
//second : delta_cost
std::pair<subrow*,int> row::placeRow(node* n){
//std::cout<<"placerow\n";
subrow* p = nullptr;//find a subrow to place p.
int bestCost = INT_MAX;
int start = BsSub(subrows,n);
for(int i = start-1;i<=start+1;i++){
if(i>=0&&i<subrows.size())
tryPlace(subrows.at(i),n,bestCost,p);
}
for(int i = start-2;i>=0;i--){
if(i>=0)
if(!tryPlace(subrows.at(i),n,bestCost,p))break;
}
for(int i = start+2;i<subrows.size();i++){
if(i<subrows.size())
if(!tryPlace(subrows.at(i),n,bestCost,p))break;
}
return {p,bestCost};
}
int row::getCost()
{
int cost = 0;
for(auto &sub:subrows)
cost += sub.getPos();// get final position
return cost;
}
int row::getRemain()
{
int space = 0;
for(auto sub:subrows)space+=sub.remainSpace;
return space;
}
int binarySearchRow(std::vector<row>&rows,node*n)
{
int l = 0;
int r = rows.size()-1;
while(l<r)
{
int mid = (l+r)/2;
if(rows.at(mid).y==n->origin_y)return mid;
else if(rows.at(mid).y > n->origin_y)r = mid-1;
else l = mid+1;
}
return std::max(0,l);
}
bool tryPlace2(std::vector<row>&rows,int i,node*n,int&bestCost,subrow*&bestPlace,int&bestRow)
{
row& r = rows.at(i);
auto place = r.placeRow(n);
if(place.first && place.second < bestCost){
bestCost = place.second;
bestPlace = place.first;
bestRow = i;
return true;
}
else if(place.first)
return false;
return true;
}
int abacus(std::vector<node*>nodes,std::vector<row>&rows){
//sort by x
std::sort(nodes.begin(),nodes.end(),[](node*n1,node*n2){
if(n1->origin_x==n2->origin_x)
return n1->width < n2->width;
return n1->origin_x < n2->origin_x;
}
);
bool succ = true;
for(auto n : nodes){
int bestCost = INT_MAX;
subrow* bestplace = nullptr;
int bestRow = -1;
int startRow = binarySearchRow(rows,n);
int range = 18;
for(int i = startRow-range;i<=startRow+range;i++){
if(i>=0 && i<rows.size())
tryPlace2(rows,i,n,bestCost,bestplace,bestRow);
}
for(int i = startRow-range-1;i>=0;i--)
if(!tryPlace2(rows,i,n,bestCost,bestplace,bestRow))break;
for(int i = startRow+range+1;i<rows.size();i++)
if(!tryPlace2(rows,i,n,bestCost,bestplace,bestRow))break;
if(bestplace){
bestplace->place(n);
bestplace->Backup();
bestplace->cost = bestplace->getPos();
bestplace->remainSpace-=n->width;
if(bestplace->remainSpace<0){
std::cerr<<"abacus remainspace<0!\n";
exit(1);
}
}
else{
succ = false;
break;
}
}
if(succ){
int cost = 0;
for(auto &r:rows)
cost+=r.getCost();
return cost;
}
else{
std::cout<<"abacus failed\n";
return -1;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment