From f2d2e36b9295be1ca053a31e93bd365c3cc01c29 Mon Sep 17 00:00:00 2001 From: ricardoypeng Date: Mon, 4 Aug 2025 21:29:54 +0800 Subject: [PATCH] feat: Add support for darwin_arm64 (Apple Silicon) architecture --- CMakeLists.txt | 1 - build.sh | 55 +++++++------ cmake/third_party.cmake | 38 +++++++++ src/database/data/design/db_layout/IdbLayer.h | 3 + .../manager/parser/liberty/LibClassifyCell.cc | 2 +- .../source/data_manager/advance/DRCHeader.hpp | 4 + .../iDRC/source/toolkit/logger/Logger.hpp | 6 +- .../ops/annotate_toggle_sp/AnnotateData.hh | 55 +++++++++---- .../ops/annotate_toggle_sp/CMakeLists.txt | 13 ++- .../module/detail_placer/database/DPBin.hh | 6 +- .../module/detail_placer/database/DPRow.hh | 7 +- .../detail_placer/database/DPSegment.hh | 4 +- .../detail_placer/operation/NFSpread.cc | 78 +++++++++++++----- .../detail_placer/operation/NFSpread.hh | 9 ++- .../source/solver/partition/CMakeLists.txt | 6 +- src/operation/iPNP/source/CMakeLists.txt | 53 ++++++++---- .../source/data_manager/advance/RTHeader.hpp | 4 + .../iRT/source/toolkit/logger/Logger.hpp | 6 +- .../iRT/source/toolkit/utility/Utility.hpp | 1 + src/operation/iSTA/CMakeLists.txt | 80 +++++++++++++------ .../source/module/delay/ReduceDelayCal.hh | 15 +++- .../iSTA/source/module/sta/CMakeLists.txt | 50 ++++++++---- src/operation/iSTA/test/CMakeLists.txt | 78 ++++++++++++------ src/third_party/ThreadPool/ThreadPool.h | 24 ++++-- src/third_party/lemon/binomial_heap.h | 2 +- src/third_party/lemon/color.h | 2 +- src/third_party/lemon/cost_scaling.h | 2 +- src/third_party/lemon/cycle_canceling.h | 2 +- src/third_party/lemon/fib_heap.h | 2 +- src/third_party/lemon/graph_to_eps.h | 2 +- src/third_party/lemon/lp_base.h | 2 +- src/third_party/lemon/{math.h => math1.h} | 0 src/third_party/lemon/network_simplex.h | 2 +- src/third_party/lemon/pairing_heap.h | 2 +- src/third_party/lemon/random.h | 2 +- src/third_party/lemon/time_measure.h | 2 +- src/third_party/pybind11/tests/CMakeLists.txt | 16 ++-- .../googletest/cmake/internal_utils.cmake | 12 ++- src/utility/log/CMakeLists.txt | 28 +++++-- src/utility/log/Log.cc | 2 +- src/utility/tcl/CMakeLists.txt | 18 ++++- src/utility/tcl/ScriptEngine.hh | 4 + 42 files changed, 508 insertions(+), 192 deletions(-) rename src/third_party/lemon/{math.h => math1.h} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecc5c03b4..3df0277e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,6 @@ endif() if (BUILD_STATIC_LIB) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Disable shared libs" FORCE) set(CMAKE_POSITION_INDEPENDENT_CODE OFF) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc") endif() if(NOT COMPATIBILITY_MODE) diff --git a/build.sh b/build.sh index 53b97bbde..2af843b4e 100755 --- a/build.sh +++ b/build.sh @@ -18,20 +18,27 @@ set -e +OS=$(uname -s) # variables IEDA_WORKSPACE=$(cd "$(dirname "$0")";pwd) BINARY_TARGET="iEDA" BINARY_DIR="${IEDA_WORKSPACE}/bin" BUILD_DIR="${IEDA_WORKSPACE}/build" -CPP_COMPILER_PATH="g++-10" -C_COMPILER_PATH="gcc-10" +if [[ "$OS" == "Darwin" ]]; then + CPP_COMPILER_PATH="g++" + C_COMPILER_PATH="gcc" + BUILD_THREADS="$(sysctl -n hw.logicalcpu)" +else + CPP_COMPILER_PATH="g++-10" + C_COMPILER_PATH="gcc-10" + BUILD_THREADS="$(nproc)" +fi DRY_RUN="OFF" RUN_IEDA="OFF" NO_BUILD="OFF" DEL_BUILD="OFF" INSTALL_DEP="OFF" NON_INTERACTIVE="OFF" -BUILD_THREADS="$(nproc)" CMAKE_OPTIONS=( "-DCMAKE_BUILD_TYPE=Release" @@ -134,26 +141,28 @@ check_compiler_version() { exit 1 fi - local version_str=$("$compiler_path" --version | grep -E -m1 '(gcc|g\+\+)' | head -1) - local version_num=$(echo "$version_str" | - grep -oP '(?<= )\d+\.\d+(?=\.)?' | - head -1) - - if ! [[ "$version_num" =~ ^[0-9]+\.[0-9]+$ ]]; then - echo -e "${red}ERROR: Failed to detect $compiler_name version from:${clear}" - echo " $version_str" - exit 1 - fi - - local major=$(echo "$version_num" | cut -d. -f1) - local minor=$(echo "$version_num" | cut -d. -f2) - - if (( major > min_major )) || \ - (( major == min_major && minor >= min_minor )); then - echo -e "${green}Validated $compiler_name version: ${version_num}${clear}" - else - echo -e "${red}ERROR: Minimum required $compiler_name version: ${min_major}.${min_minor} (found ${version_num})${clear}" - exit 1 + if [[ "$OS" != "Darwin" ]]; then + local version_str=$("$compiler_path" --version | grep -E -m1 '(gcc|g\+\+)' | head -1) + local version_num=$(echo "$version_str" | + grep -oP '(?<= )\d+\.\d+(?=\.)?' | + head -1) + + if ! [[ "$version_num" =~ ^[0-9]+\.[0-9]+$ ]]; then + echo -e "${red}ERROR: Failed to detect $compiler_name version from:${clear}" + echo " $version_str" + exit 1 + fi + + local major=$(echo "$version_num" | cut -d. -f1) + local minor=$(echo "$version_num" | cut -d. -f2) + + if (( major > min_major )) || \ + (( major == min_major && minor >= min_minor )); then + echo -e "${green}Validated $compiler_name version: ${version_num}${clear}" + else + echo -e "${red}ERROR: Minimum required $compiler_name version: ${min_major}.${min_minor} (found ${version_num})${clear}" + exit 1 + fi fi } diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index d49a4c56b..689189a3d 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -9,6 +9,44 @@ include_directories(SYSTEM ${THIRD_PARTY_HOME}/json ) +if (APPLE) + set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) + message(STATUS "Homebrew Prefix: ${HOMEBREW_PREFIX}") + + set(OpenMP_C_LIB_NAMES "omp") + set(OpenMP_CXX_LIB_NAMES "omp") + set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include") + set(OpenMP_omp_LIBRARY "${HOMEBREW_PREFIX}/opt/libomp/lib/libomp.dylib") + set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${HOMEBREW_PREFIX}/opt/libomp/include") + set(OpenMP_CXX_LIBRARY "${HOMEBREW_PREFIX}/opt/libomp/lib/libomp.dylib") + + set(ZLIB_ROOT "${HOMEBREW_PREFIX}/opt/zlib") + set(ZLIB_INCLUDE_DIRS "${ZLIB_ROOT}/include") + set(ZLIB_LIBRARY "${ZLIB_ROOT}/lib/libz.dylib") + + set(BOOST_ROOT "${HOMEBREW_PREFIX}/opt/boost") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${BOOST_ROOT}/include") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${BOOST_ROOT}/include") + + set(GLOG_ROOT_DIR "${HOMEBREW_PREFIX}/opt/glog") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${GLOG_ROOT_DIR}/include") + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I${GLOG_ROOT_DIR}/include") + set(GLOG_LIBRARIES "${GLOG_ROOT_DIR}/lib/libglog.dylib") + + set(GFLAGS_ROOT_DIR "${HOMEBREW_PREFIX}/opt/gflags") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${GFLAGS_ROOT_DIR}/include") + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I${GFLAGS_ROOT_DIR}/include") + + set(TCL_ROOT_DIR "${HOMEBREW_PREFIX}/opt/tcl-tk@8") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TCL_ROOT_DIR}/include") + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I${TCL_ROOT_DIR}/include") + + set(GMP_ROOT_DIR "${HOMEBREW_PREFIX}/opt/gmp") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${GMP_ROOT_DIR}/include") + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I${GMP_ROOT_DIR}/include") + set(GMP_LIBRARIES "${GMP_ROOT_DIR}/lib/libgmp.dylib") +endif() + find_package(OpenMP REQUIRED) if (OPENMP_CXX_FOUND) message("OPENMP FOUND") diff --git a/src/database/data/design/db_layout/IdbLayer.h b/src/database/data/design/db_layout/IdbLayer.h index 00239857a..17813b597 100644 --- a/src/database/data/design/db_layout/IdbLayer.h +++ b/src/database/data/design/db_layout/IdbLayer.h @@ -769,6 +769,9 @@ class IdbLayerImplant : public IdbLayer if (_spacing_list->get_num() == 1) { return _spacing_list->get_min_spacing(0)->get_min_spacing(); } + else { + return -1; + } } IdbLayerImplantSpacingList* get_min_spacing_list() { return _spacing_list; } int32_t get_min_width() { return _min_width; } diff --git a/src/database/manager/parser/liberty/LibClassifyCell.cc b/src/database/manager/parser/liberty/LibClassifyCell.cc index 7c0aea1f8..3bbe7de0b 100644 --- a/src/database/manager/parser/liberty/LibClassifyCell.cc +++ b/src/database/manager/parser/liberty/LibClassifyCell.cc @@ -278,7 +278,7 @@ bool LibClassifyCell::compareFunction(LibCell* the_cell1, LibCell* the_cell2) * @param the_lib * @param hash_to_cells */ -void LibClassifyCell::classifyOneLibCell(LibLibrary* the_lib, std::unordered_map>& hash_to_cells) +void LibClassifyCell::classifyOneLibCell(LibLibrary* the_lib, std::unordered_map>& hash_to_cells) { LibCell* cell; FOREACH_LIB_CELL(the_lib, cell) diff --git a/src/operation/iDRC/source/data_manager/advance/DRCHeader.hpp b/src/operation/iDRC/source/data_manager/advance/DRCHeader.hpp index dca5848c1..37600d40f 100644 --- a/src/operation/iDRC/source/data_manager/advance/DRCHeader.hpp +++ b/src/operation/iDRC/source/data_manager/advance/DRCHeader.hpp @@ -38,7 +38,11 @@ #include #include #include +#if defined(__APPLE__) && defined(__MACH__) +#include +#else #include +#endif #include #include #include diff --git a/src/operation/iDRC/source/toolkit/logger/Logger.hpp b/src/operation/iDRC/source/toolkit/logger/Logger.hpp index a762c5516..e1b2e7a1e 100644 --- a/src/operation/iDRC/source/toolkit/logger/Logger.hpp +++ b/src/operation/iDRC/source/toolkit/logger/Logger.hpp @@ -23,7 +23,11 @@ namespace idrc { -using Loc = std::experimental::source_location; +#if defined(__APPLE__) && defined(__MACH__) + using Loc = std::source_location; +#else + using Loc = std::experimental::source_location; +#endif #define DRCLOG (idrc::Logger::getInst()) diff --git a/src/operation/iPA/source/module/ops/annotate_toggle_sp/AnnotateData.hh b/src/operation/iPA/source/module/ops/annotate_toggle_sp/AnnotateData.hh index aeee2665f..e3c56bb41 100644 --- a/src/operation/iPA/source/module/ops/annotate_toggle_sp/AnnotateData.hh +++ b/src/operation/iPA/source/module/ops/annotate_toggle_sp/AnnotateData.hh @@ -44,18 +44,37 @@ namespace ipower { */ class AnnotateTime { public: - AnnotateTime(int64_t t0, int64_t t1, int64_t tx, int64_t tz) - : _T0(t0), _T1(t1), _TX(tx), _TZ(tz) {} - AnnotateTime() = default; - ~AnnotateTime() = default; - auto& get_T0() { return _T0; } - void incrT0(int64_t duration) { _T0 += duration; } - auto& get_T1() { return _T1; } - void incrT1(int64_t duration) { _T1 += duration; } - auto& get_TX() { return _TX; } - void incrTX(int64_t duration) { _TX += duration; } - auto& get_TZ() { return _TZ; } - void incrTZ(int64_t duration) { _TZ += duration; } + #if defined(__APPLE__) && defined(__MACH__) + AnnotateTime(int64_t t0, int64_t t1, int64_t tx, int64_t tz) + // : _T0(t0), _T1(t1), _TX(tx), _TZ(tz) {} + : _T0(static_cast(t0)), + _T1(static_cast(t1)), + _TX(static_cast(tx)), + _TZ(static_cast(tz)) {} + AnnotateTime() = default; + ~AnnotateTime() = default; + auto& get_T0() { return _T0; } + void incrT0(int64_t duration) { _T0 += static_cast(duration); } + auto& get_T1() { return _T1; } + void incrT1(int64_t duration) { _T1 += static_cast(duration); } + auto& get_TX() { return _TX; } + void incrTX(int64_t duration) { _TX += static_cast(duration); } + auto& get_TZ() { return _TZ; } + void incrTZ(int64_t duration) { _TZ += static_cast(duration); } + #else + AnnotateTime(int64_t t0, int64_t t1, int64_t tx, int64_t tz) + : _T0(t0), _T1(t1), _TX(tx), _TZ(tz) {} + AnnotateTime() = default; + ~AnnotateTime() = default; + auto& get_T0() { return _T0; } + void incrT0(int64_t duration) { _T0 += duration; } + auto& get_T1() { return _T1; } + void incrT1(int64_t duration) { _T1 += duration; } + auto& get_TX() { return _TX; } + void incrTX(int64_t duration) { _TX += duration; } + auto& get_TZ() { return _TZ; } + void incrTZ(int64_t duration) { _TZ += duration; } + #endif void printAnnotateTime(std::ostream& out); double get_SP() { @@ -241,7 +260,11 @@ class AnnotateInstance { class AnnotateTimeScale { public: void set_annotate_time_scale(int64_t scale, int8_t unit_num) { - _scale = scale; + #if defined(__APPLE__) && defined(__MACH__) + _scale = static_cast(scale); + #else + _scale = scale; + #endif _unit = (ScaleUnit)unit_num; }; @@ -271,12 +294,14 @@ class AnnotateDB { auto* get_top_instance() { return _top_instance.get(); } void set_simulation_start_time(int64_t simulation_start_time) { - _simulation_start_time = simulation_start_time; + // _simulation_start_time = simulation_start_time; + _simulation_start_time = static_cast(simulation_start_time); } auto get_simulation_sart_time() { return _simulation_start_time.get_ui(); } void set_simulation_duration(int64_t simulation_duration) { - _simulation_duration = simulation_duration; + // _simulation_duration = simulation_duration; + _simulation_duration = static_cast(simulation_duration); } auto get_simulation_duration() { return _simulation_duration.get_ui(); } diff --git a/src/operation/iPA/source/module/ops/annotate_toggle_sp/CMakeLists.txt b/src/operation/iPA/source/module/ops/annotate_toggle_sp/CMakeLists.txt index 4007c2795..c3f256194 100644 --- a/src/operation/iPA/source/module/ops/annotate_toggle_sp/CMakeLists.txt +++ b/src/operation/iPA/source/module/ops/annotate_toggle_sp/CMakeLists.txt @@ -5,12 +5,21 @@ set (CMAKE_CXX_STANDARD 20) aux_source_directory(./ SRC) add_library(annotate ${SRC}) -set(LIBGMP "gmp") +if (APPLE) + set(LIBGMP "${HOMEBREW_PREFIX}/opt/gmp/lib/libgmp.dylib") + set(LIBGMP "${HOMEBREW_PREFIX}/opt/gmp/lib/libgmp.a") +else() + set(LIBGMP "gmp") +endif() if(BUILD_STATIC_LIB) find_library(GMP_STATIC_LIB NAMES libgmp.a - PATHS /usr/lib/x86_64-linux-gnu + if (APPLE) + PATHS ${HOMEBREW_PREFIX}/opt/gmp/lib + else() + PATHS /usr/lib/x86_64-linux-gnu + endif() NO_DEFAULT_PATH ) if(GMP_STATIC_LIB) diff --git a/src/operation/iPL/source/module/detail_placer/database/DPBin.hh b/src/operation/iPL/source/module/detail_placer/database/DPBin.hh index 90ba779c3..7f3a4beac 100644 --- a/src/operation/iPL/source/module/detail_placer/database/DPBin.hh +++ b/src/operation/iPL/source/module/detail_placer/database/DPBin.hh @@ -21,8 +21,12 @@ #include #include "DPNode.hh" -#include "DPSegment.hh" #include "data/Rectangle.hh" +#if defined(__APPLE__) && defined(__MACH__) +class DPSegment; +#else +#include "DPSegment.hh" +#endif namespace ipl{ class DPSegment; diff --git a/src/operation/iPL/source/module/detail_placer/database/DPRow.hh b/src/operation/iPL/source/module/detail_placer/database/DPRow.hh index d51ebe109..049a533de 100644 --- a/src/operation/iPL/source/module/detail_placer/database/DPRow.hh +++ b/src/operation/iPL/source/module/detail_placer/database/DPRow.hh @@ -36,6 +36,10 @@ */ #ifndef IPL_DPROW_H #define IPL_DPROW_H +#if defined(__APPLE__) && defined(__MACH__) +#include "DPSegment.hh" +#include "DPBin.hh" +#endif #include #include @@ -48,8 +52,9 @@ namespace ipl { class DPSegment; class DPNode; +#if not (defined(__APPLE__) && defined(__MACH__)) class DPBin; - +#endif class DPSite { public: diff --git a/src/operation/iPL/source/module/detail_placer/database/DPSegment.hh b/src/operation/iPL/source/module/detail_placer/database/DPSegment.hh index 34108a636..ff59f5a12 100644 --- a/src/operation/iPL/source/module/detail_placer/database/DPSegment.hh +++ b/src/operation/iPL/source/module/detail_placer/database/DPSegment.hh @@ -21,7 +21,9 @@ #include #include "DPNode.hh" - +#if defined(__APPLE__) && defined(__MACH__) +#include "DPBin.hh" +#endif namespace ipl{ class DPRow; diff --git a/src/operation/iPL/source/module/detail_placer/operation/NFSpread.cc b/src/operation/iPL/source/module/detail_placer/operation/NFSpread.cc index 2273c181c..6ed6861e2 100644 --- a/src/operation/iPL/source/module/detail_placer/operation/NFSpread.cc +++ b/src/operation/iPL/source/module/detail_placer/operation/NFSpread.cc @@ -32,6 +32,11 @@ NFSpread::NFSpread(DPConfig* config, DPDatabase* database, DPOperator* dp_operat NFSpread::~NFSpread() { + #if defined(__APPLE__) && defined(__MACH__) + for (TNode* node : _tNodeStorage) { + delete node; + } + #endif } void NFSpread::runNFSpread() @@ -792,7 +797,11 @@ TNode* NFSpread::pathAugmentationBranchBound(TNode * root, std::deque &p DPBin * src = parent->_bin; visited_bins.insert(src); - std::deque & children = parent->_children; + #if defined(__APPLE__) && defined(__MACH__) + std::vector & children = parent->_children; + #else + std::deque & children = parent->_children; + #endif for (DPBin * sink : src->get_neighbor_list()) { if (visited_bins.find(sink) != visited_bins.end()) { @@ -807,28 +816,55 @@ TNode* NFSpread::pathAugmentationBranchBound(TNode * root, std::deque &p continue; } - children.push_back(TNode()); - TNode & sink_node = children.back(); - sink_node._bin = sink; - sink_node._cost = cost + parent->_cost; - sink_node._flow = out_supply; - sink_node._parent = parent; + #if defined(__APPLE__) && defined(__MACH__) + TNode* sink_node = new TNode(); + sink_node->_bin = sink; + sink_node->_cost = cost + parent->_cost; + sink_node->_flow = out_supply; + sink_node->_parent = parent; + + children.push_back(sink_node); + _tNodeStorage.push_back(sink_node); + #else + children.push_back(TNode()); + TNode & sink_node = children.back(); + sink_node._bin = sink; + sink_node._cost = cost + parent->_cost; + sink_node._flow = out_supply; + sink_node._parent = parent; + #endif } - for (size_t i = 0; i < children.size(); ++i) { - TNode * nd = &children[i]; - if (nd->_flow <= nd->_bin->getDemand()) { - paths.push_back(nd); - if (best_path && (best_path->_cost > nd->_cost)) { - best_path = nd; - } - if (!best_path) { - best_path = nd; - } - } else { - nodes.push(nd); - } - } + #if defined(__APPLE__) && defined(__MACH__) + for (TNode* child : children) { + if (child->_flow <= child->_bin->getDemand()) { + paths.push_back(child); + if (best_path && (best_path->_cost > child->_cost)) { + best_path = child; + } + if (!best_path) { + best_path = child; + } + } else { + nodes.push(child); + } + } + #else + for (size_t i = 0; i < children.size(); ++i) { + TNode * nd = &children[i]; + if (nd->_flow <= nd->_bin->getDemand()) { + paths.push_back(nd); + if (best_path && (best_path->_cost > nd->_cost)) { + best_path = nd; + } + if (!best_path) { + best_path = nd; + } + } else { + nodes.push(nd); + } + } + #endif } while (!nodes.empty()); diff --git a/src/operation/iPL/source/module/detail_placer/operation/NFSpread.hh b/src/operation/iPL/source/module/detail_placer/operation/NFSpread.hh index 213e29afc..932435f88 100644 --- a/src/operation/iPL/source/module/detail_placer/operation/NFSpread.hh +++ b/src/operation/iPL/source/module/detail_placer/operation/NFSpread.hh @@ -35,7 +35,11 @@ struct TNode { double _cost = 0.0; DPBin * _bin = nullptr; TNode * _parent = nullptr; - std::deque _children; + #if defined(__APPLE__) && defined(__MACH__) + std::vector _children; + #else + std::deque _children; + #endif }; struct NodeFlow { @@ -134,6 +138,9 @@ private: void moveNode(DPNode* node, DPSegment* src, DPSegment* sink ,int64_t target_pos_x, int64_t target_pos_y); void insertNode(DPSegment* segment, DPNode* inst){ segment->insertNode(inst);} void removeNode(DPSegment* segment, DPNode* inst){ segment->removeNode(inst);} + #if defined(__APPLE__) && defined(__MACH__) + std::vector _tNodeStorage; + #endif }; } diff --git a/src/operation/iPL/source/solver/partition/CMakeLists.txt b/src/operation/iPL/source/solver/partition/CMakeLists.txt index 17314d4a9..b7b7b6ee4 100644 --- a/src/operation/iPL/source/solver/partition/CMakeLists.txt +++ b/src/operation/iPL/source/solver/partition/CMakeLists.txt @@ -1,3 +1,7 @@ add_library(ipl-solver-partition Metis.cc Hmetis.cc) target_include_directories(ipl-solver-partition PUBLIC ${HOME_THIRDPARTY}/metis) -target_link_libraries(ipl-solver-partition ${HOME_THIRDPARTY}/hmetis/libmetis.a) +if(APPLE) + target_link_libraries(ipl-solver-partition ${HOMEBREW_PREFIX}/opt/metis/lib/libmetis.dylib) +else() + target_link_libraries(ipl-solver-partition ${HOME_THIRDPARTY}/hmetis/libmetis.a) +endif() diff --git a/src/operation/iPNP/source/CMakeLists.txt b/src/operation/iPNP/source/CMakeLists.txt index 6a4b38c93..5a6d7267f 100644 --- a/src/operation/iPNP/source/CMakeLists.txt +++ b/src/operation/iPNP/source/CMakeLists.txt @@ -4,20 +4,39 @@ add_subdirectory(module) add_library(pnp iPNP.cpp) -target_link_libraries( - pnp - pnp-cmd - optimizer - evaluator - synthesis - data_manager - config - idb - tcl - log - usage - pthread - stdc++fs - IdbBuilder - def_service - lef_service) +if(APPLE) + target_link_libraries( + pnp + pnp-cmd + optimizer + evaluator + synthesis + data_manager + config + idb + tcl + log + usage + pthread + IdbBuilder + def_service + lef_service) +else() + target_link_libraries( + pnp + pnp-cmd + optimizer + evaluator + synthesis + data_manager + config + idb + tcl + log + usage + pthread + stdc++fs + IdbBuilder + def_service + lef_service) +endif() diff --git a/src/operation/iRT/source/data_manager/advance/RTHeader.hpp b/src/operation/iRT/source/data_manager/advance/RTHeader.hpp index 1dee56a22..3f409ac1f 100644 --- a/src/operation/iRT/source/data_manager/advance/RTHeader.hpp +++ b/src/operation/iRT/source/data_manager/advance/RTHeader.hpp @@ -38,7 +38,11 @@ #include #include #include +#if defined(__APPLE__) && defined(__MACH__) +#include +#else #include +#endif #include #include #include diff --git a/src/operation/iRT/source/toolkit/logger/Logger.hpp b/src/operation/iRT/source/toolkit/logger/Logger.hpp index ac0d87479..232aba2a2 100644 --- a/src/operation/iRT/source/toolkit/logger/Logger.hpp +++ b/src/operation/iRT/source/toolkit/logger/Logger.hpp @@ -23,7 +23,11 @@ namespace irt { -using Loc = std::experimental::source_location; +#if defined(__APPLE__) && defined(__MACH__) + using Loc = std::source_location; +#else + using Loc = std::experimental::source_location; +#endif #define RTLOG (irt::Logger::getInst()) diff --git a/src/operation/iRT/source/toolkit/utility/Utility.hpp b/src/operation/iRT/source/toolkit/utility/Utility.hpp index 909945b9e..f6c99f571 100644 --- a/src/operation/iRT/source/toolkit/utility/Utility.hpp +++ b/src/operation/iRT/source/toolkit/utility/Utility.hpp @@ -492,6 +492,7 @@ class Utility { if (coord_list.empty()) { RTLOG.error(Loc::current(), "The coord list is empty!"); + return false; } else if (coord_list.size() <= 2) { return true; } else { diff --git a/src/operation/iSTA/CMakeLists.txt b/src/operation/iSTA/CMakeLists.txt index d5648c2c6..825ee38b0 100644 --- a/src/operation/iSTA/CMakeLists.txt +++ b/src/operation/iSTA/CMakeLists.txt @@ -80,29 +80,57 @@ add_subdirectory(test) add_executable(iSTA main.cc) -target_link_libraries( - iSTA - sdc - ista-engine - inference - sdc-cmd - shell-cmd - sta - log - str - time - netlist - liberty - delay - ista_utility - sta-solver - verilog - graph - idb - tcl - usage - pthread - stdc++fs - IdbBuilder - def_service - lef_service) +if(APPLE) + target_link_libraries( + iSTA + sdc + ista-engine + inference + sdc-cmd + shell-cmd + sta + log + str + time + netlist + liberty + delay + ista_utility + sta-solver + verilog + graph + idb + tcl + usage + pthread + IdbBuilder + def_service + lef_service) +else() + target_link_libraries( + iSTA + sdc + ista-engine + inference + sdc-cmd + shell-cmd + sta + log + str + time + netlist + liberty + delay + ista_utility + sta-solver + verilog + graph + idb + tcl + usage + pthread + stdc++fs + IdbBuilder + def_service + lef_service) +endif() diff --git a/src/operation/iSTA/source/module/delay/ReduceDelayCal.hh b/src/operation/iSTA/source/module/delay/ReduceDelayCal.hh index dea566706..cbe3eeb61 100644 --- a/src/operation/iSTA/source/module/delay/ReduceDelayCal.hh +++ b/src/operation/iSTA/source/module/delay/ReduceDelayCal.hh @@ -105,12 +105,21 @@ class ArnoldiNet : public RcNet { LibArc* get_lib_arc() { return _lib_arc; } void set_lib_arc(LibArc* lib_arc) { _lib_arc = lib_arc; } - std::optional calcDelay(const VectorXd& driver_waveform, - const VectorXd& load_waveform, + #if defined(__APPLE__) && defined(__MACH__) + std::optional calcDelay(const Eigen::VectorXd& driver_waveform, + const Eigen::VectorXd& load_waveform, double step_time_ns, DesignObject* pin); - std::optional calcSlew(const VectorXd& waveform, double step_time_ns, + std::optional calcSlew(const Eigen::VectorXd& waveform, double step_time_ns, DesignObject* pin); + #else + std::optional calcDelay(const VectorXd& driver_waveform, + const VectorXd& load_waveform, + double step_time_ns, DesignObject* pin); + + std::optional calcSlew(const VectorXd& waveform, double step_time_ns, + DesignObject* pin); + #endif std::optional delay(Waveform& driver_waveform, Waveform& node_waveform, DesignObject* pin); diff --git a/src/operation/iSTA/source/module/sta/CMakeLists.txt b/src/operation/iSTA/source/module/sta/CMakeLists.txt index 7b4ff0567..eb6392378 100644 --- a/src/operation/iSTA/source/module/sta/CMakeLists.txt +++ b/src/operation/iSTA/source/module/sta/CMakeLists.txt @@ -9,22 +9,40 @@ endif() aux_source_directory(./ SRC) add_library(sta ${SRC}) -target_link_libraries(sta - liberty - delay - spef - sdc - sdc-cmd - verilog - aocv-parser - graph sdc - absl::btree - tcl - time - report_table - stdc++fs - log - yaml-cpp) +if(APPLE) + target_link_libraries(sta + liberty + delay + spef + sdc + sdc-cmd + verilog + aocv-parser + graph sdc + absl::btree + tcl + time + report_table + log + yaml-cpp) +else() + target_link_libraries(sta + liberty + delay + spef + sdc + sdc-cmd + verilog + aocv-parser + graph sdc + absl::btree + tcl + time + report_table + stdc++fs + log + yaml-cpp) +endif() if (USE_CUDA_MODE) target_link_libraries(sta diff --git a/src/operation/iSTA/test/CMakeLists.txt b/src/operation/iSTA/test/CMakeLists.txt index 84274f53f..d66e0b9c3 100644 --- a/src/operation/iSTA/test/CMakeLists.txt +++ b/src/operation/iSTA/test/CMakeLists.txt @@ -11,32 +11,60 @@ find_package(GTest REQUIRED) aux_source_directory(. SourceFiles) add_executable(iSTATest ${SourceFiles}) +if(APPLE) target_link_libraries( - iSTATest - ista-engine - inference - sdc-cmd - shell-cmd - sta - log - str - time - netlist - liberty - delay - ista_utility - sta-solver - verilog - graph - idb - tcl - usage - pthread - stdc++fs - IdbBuilder - def_service - lef_service - gtest) + iSTATest + ista-engine + inference + sdc-cmd + shell-cmd + sta + log + str + time + netlist + liberty + delay + ista_utility + sta-solver + verilog + graph + idb + tcl + usage + pthread + IdbBuilder + def_service + lef_service + gtest) +else() + target_link_libraries( + iSTATest + ista-engine + inference + sdc-cmd + shell-cmd + sta + log + str + time + netlist + liberty + delay + ista_utility + sta-solver + verilog + graph + idb + tcl + usage + pthread + stdc++fs + IdbBuilder + def_service + lef_service + gtest) +endif() if(USE_CUDA_MODE) target_link_libraries(iSTATest delay-gpu propagation-gpu) diff --git a/src/third_party/ThreadPool/ThreadPool.h b/src/third_party/ThreadPool/ThreadPool.h index 418320307..bde4021e7 100644 --- a/src/third_party/ThreadPool/ThreadPool.h +++ b/src/third_party/ThreadPool/ThreadPool.h @@ -14,9 +14,15 @@ class ThreadPool { public: ThreadPool(size_t); - template - auto enqueue(F&& f, Args&&... args) - -> std::future::type>; + #if defined(__APPLE__) && defined(__MACH__) + template + auto enqueue(F&& f, Args&&... args) + -> std::future>; + #else + template + auto enqueue(F&& f, Args&&... args) + -> std::future::type>; + #endif ~ThreadPool(); private: // need to keep track of threads so we can join them @@ -61,9 +67,17 @@ inline ThreadPool::ThreadPool(size_t threads) // add new work item to the pool template auto ThreadPool::enqueue(F&& f, Args&&... args) +#if defined(__APPLE__) && defined(__MACH__) + -> std::future> +#else -> std::future::type> -{ - using return_type = typename std::result_of::type; +#endif +{ + #if defined(__APPLE__) && defined(__MACH__) + using return_type = typename std::invoke_result_t; + #else + using return_type = typename std::result_of::type; + #endif auto task = std::make_shared< std::packaged_task >( std::bind(std::forward(f), std::forward(args)...) diff --git a/src/third_party/lemon/binomial_heap.h b/src/third_party/lemon/binomial_heap.h index 5bc137870..c4f2467ae 100644 --- a/src/third_party/lemon/binomial_heap.h +++ b/src/third_party/lemon/binomial_heap.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include namespace lemon { diff --git a/src/third_party/lemon/color.h b/src/third_party/lemon/color.h index 02357910f..96f7cd24c 100644 --- a/src/third_party/lemon/color.h +++ b/src/third_party/lemon/color.h @@ -20,7 +20,7 @@ #define LEMON_COLOR_H #include -#include +#include #include diff --git a/src/third_party/lemon/cost_scaling.h b/src/third_party/lemon/cost_scaling.h index efecdfe77..4661ea2da 100644 --- a/src/third_party/lemon/cost_scaling.h +++ b/src/third_party/lemon/cost_scaling.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/third_party/lemon/cycle_canceling.h b/src/third_party/lemon/cycle_canceling.h index 646d299e3..7802b21ce 100644 --- a/src/third_party/lemon/cycle_canceling.h +++ b/src/third_party/lemon/cycle_canceling.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/third_party/lemon/fib_heap.h b/src/third_party/lemon/fib_heap.h index 3441722a0..19650b92f 100644 --- a/src/third_party/lemon/fib_heap.h +++ b/src/third_party/lemon/fib_heap.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace lemon { diff --git a/src/third_party/lemon/graph_to_eps.h b/src/third_party/lemon/graph_to_eps.h index 29ba83693..46ad16a15 100644 --- a/src/third_party/lemon/graph_to_eps.h +++ b/src/third_party/lemon/graph_to_eps.h @@ -32,7 +32,7 @@ #include #endif -#include +#include #include #include #include diff --git a/src/third_party/lemon/lp_base.h b/src/third_party/lemon/lp_base.h index 22d3e4899..41f733947 100644 --- a/src/third_party/lemon/lp_base.h +++ b/src/third_party/lemon/lp_base.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/third_party/lemon/math.h b/src/third_party/lemon/math1.h similarity index 100% rename from src/third_party/lemon/math.h rename to src/third_party/lemon/math1.h diff --git a/src/third_party/lemon/network_simplex.h b/src/third_party/lemon/network_simplex.h index 6ccad33e6..5d4643dff 100644 --- a/src/third_party/lemon/network_simplex.h +++ b/src/third_party/lemon/network_simplex.h @@ -29,7 +29,7 @@ #include #include -#include +#include namespace lemon { diff --git a/src/third_party/lemon/pairing_heap.h b/src/third_party/lemon/pairing_heap.h index da6ebcb15..e3a38569e 100644 --- a/src/third_party/lemon/pairing_heap.h +++ b/src/third_party/lemon/pairing_heap.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace lemon { diff --git a/src/third_party/lemon/random.h b/src/third_party/lemon/random.h index 8de74ede8..22b53a031 100644 --- a/src/third_party/lemon/random.h +++ b/src/third_party/lemon/random.h @@ -68,7 +68,7 @@ #include #include -#include +#include #include #ifndef WIN32 diff --git a/src/third_party/lemon/time_measure.h b/src/third_party/lemon/time_measure.h index 3f7f07789..76be34988 100644 --- a/src/third_party/lemon/time_measure.h +++ b/src/third_party/lemon/time_measure.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include namespace lemon { diff --git a/src/third_party/pybind11/tests/CMakeLists.txt b/src/third_party/pybind11/tests/CMakeLists.txt index 9beb268ed..075c7c38e 100644 --- a/src/third_party/pybind11/tests/CMakeLists.txt +++ b/src/third_party/pybind11/tests/CMakeLists.txt @@ -351,11 +351,13 @@ else() STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COMPILE_DEFINITIONS -std=c++17) - try_compile( - STD_FS_NEEDS_STDCXXFS ${CMAKE_CURRENT_BINARY_DIR} - SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - COMPILE_DEFINITIONS -std=c++17 - LINK_LIBRARIES stdc++fs) + if(NOT APPLE) + try_compile( + STD_FS_NEEDS_STDCXXFS ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMPILE_DEFINITIONS -std=c++17 + LINK_LIBRARIES stdc++fs) + endif() try_compile( STD_FS_NEEDS_CXXFS ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp @@ -364,7 +366,9 @@ else() endif() if(${STD_FS_NEEDS_STDCXXFS}) - set(STD_FS_LIB stdc++fs) + if(NOT APPLE) + set(STD_FS_LIB stdc++fs) + endif() elseif(${STD_FS_NEEDS_CXXFS}) set(STD_FS_LIB c++fs) elseif(${STD_FS_NO_LIB_NEEDED}) diff --git a/src/third_party/yaml-cpp/test/gtest-1.10.0/googletest/cmake/internal_utils.cmake b/src/third_party/yaml-cpp/test/gtest-1.10.0/googletest/cmake/internal_utils.cmake index 2f70f0b08..19d32c8f1 100644 --- a/src/third_party/yaml-cpp/test/gtest-1.10.0/googletest/cmake/internal_utils.cmake +++ b/src/third_party/yaml-cpp/test/gtest-1.10.0/googletest/cmake/internal_utils.cmake @@ -62,10 +62,16 @@ macro(config_compiler_and_linker) unset(GTEST_HAS_PTHREAD) if (NOT gtest_disable_pthreads AND NOT MINGW) # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT. - find_package(Threads) - if (CMAKE_USE_PTHREADS_INIT) + if(APPLE) + set(CMAKE_USE_PTHREADS_INIT ON) + set(CMAKE_THREAD_LIBS_INIT "-pthread") set(GTEST_HAS_PTHREAD ON) - endif() + else() + find_package(Threads) + if (CMAKE_USE_PTHREADS_INIT) + set(GTEST_HAS_PTHREAD ON) + endif() + endif endif() fix_default_compiler_settings_() diff --git a/src/utility/log/CMakeLists.txt b/src/utility/log/CMakeLists.txt index ce40213de..c97fadc70 100644 --- a/src/utility/log/CMakeLists.txt +++ b/src/utility/log/CMakeLists.txt @@ -3,19 +3,35 @@ SET (CMAKE_CXX_STANDARD 20) AUX_SOURCE_DIRECTORY(./ SRC) -SET(LINK_unwind "unwind") +if (NOT APPLE) + SET(LINK_unwind "unwind") +endif() # Define GLOG_USE_GLOG_EXPORT for glog 0.7.1+ compatibility add_definitions(-DGLOG_USE_GLOG_EXPORT) if(BUILD_STATIC_LIB) - SET(LINK_glog "libglog.a") - SET(LINK_gflags "libgflags.a") + if (APPLE) + SET(LINK_glog "${HOMEBREW_PREFIX}/opt/glog/lib/libglog.dylib") + SET(LINK_gflags "${HOMEBREW_PREFIX}/opt/gflags/lib/libgflags.dylib") + else() + SET(LINK_glog "libglog.a") + SET(LINK_gflags "libgflags.a") + endif() ADD_LIBRARY(log STATIC ${SRC}) else() - SET(LINK_glog "glog") - SET(LINK_gflags "gflags") + if (APPLE) + SET(LINK_glog "${HOMEBREW_PREFIX}/opt/glog/lib/libglog.dylib") + SET(LINK_gflags "${HOMEBREW_PREFIX}/opt/gflags/lib/libgflags.dylib") + else() + SET(LINK_glog "glog") + SET(LINK_gflags "gflags") + endif() ADD_LIBRARY(log SHARED ${SRC}) endif() -TARGET_LINK_LIBRARIES(log PUBLIC ${LINK_glog} ${LINK_gflags} ${LINK_unwind}) +if (APPLE) + TARGET_LINK_LIBRARIES(log PUBLIC ${LINK_glog} ${LINK_gflags}) +else() + TARGET_LINK_LIBRARIES(log PUBLIC ${LINK_glog} ${LINK_gflags} ${LINK_unwind}) +endif() diff --git a/src/utility/log/Log.cc b/src/utility/log/Log.cc index b4ea89149..a293dc4b3 100644 --- a/src/utility/log/Log.cc +++ b/src/utility/log/Log.cc @@ -43,7 +43,7 @@ bool Log::_is_init = false; * @param data * @param size */ -void SignalHandle(const char* data, int size) +void SignalHandle(const char* data, size_t size) { std::ofstream fs("glog_dump.log", std::ios::app); std::string str = std::string(data, size); diff --git a/src/utility/tcl/CMakeLists.txt b/src/utility/tcl/CMakeLists.txt index 32dc67ee4..ff5812d2d 100644 --- a/src/utility/tcl/CMakeLists.txt +++ b/src/utility/tcl/CMakeLists.txt @@ -10,15 +10,27 @@ else(TCL_FOUND) endif(TCL_FOUND) aux_source_directory(./ SRC) -set(LINK_tcl "tcl8.6") +if (APPLE) + set(LINK_tcl "${HOMEBREW_PREFIX}/opt/tcl-tk@8/lib/libtcl8.6.dylib") +else() + set(LINK_tcl "tcl8.6") +endif() find_library(TCL_STATIC_LIB NAMES libtcl8.6.a - PATHS /usr/lib/x86_64-linux-gnu + if (APPLE) + PATHS ${HOMEBREW_PREFIX}/opt/tcl-tk@8/lib + else() + PATHS /usr/lib/x86_64-linux-gnu + endif() NO_DEFAULT_PATH ) if(BUILD_STATIC_LIB AND TCL_STATIC_LIB) - set(LINK_tcl ${TCL_STATIC_LIB}) + if (APPLE) + set(LINK_tcl "${HOMEBREW_PREFIX}/opt/tcl-tk@8/lib/libtcl8.6.a") + else() + set(LINK_tcl ${TCL_STATIC_LIB}) + endif() add_library(tcl STATIC ${SRC}) else() add_library(tcl SHARED ${SRC}) diff --git a/src/utility/tcl/ScriptEngine.hh b/src/utility/tcl/ScriptEngine.hh index 3489507a2..7d99cf77b 100644 --- a/src/utility/tcl/ScriptEngine.hh +++ b/src/utility/tcl/ScriptEngine.hh @@ -24,7 +24,11 @@ #pragma once +#if defined(__APPLE__) && defined(__MACH__) +#include +#else #include +#endif #include #include -- Gitee