diff --git a/CMakeLists.txt b/CMakeLists.txt index ecc5c03b46270401c7e60880dd2ed0f50aebe888..3df0277e2a4826ac61a72af24fcea058aa81968f 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 53b97bbdeefdddc8975522031537733d32bb3868..2af843b4e0f478d3b825179ac2152eb8a69c1a32 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 d49a4c56b59e4a1989fcd3071b4e0c861ef71abb..689189a3df5ee40dc9e16731d5f04cacb643ed9f 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 00239857ab94dfd751f66b660261336fbc426d7a..17813b597e22b02d732b43b5d12efe60031b2bfa 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 7c0aea1f8e979c7f318ff9070d098852804e9d91..3bbe7de0beb4e96dedf661ab1becc209ad4ca352 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 dca5848c1c2d9c7a052b3f51666aeffd7729852a..37600d40f010d0641cc70cf4facee559855cd46e 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 a762c5516c715b70453f8227b335578c65ac1ff8..e1b2e7a1e440dc399451ae700d798980ffc56e65 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 aeee2665f654957d12ba2e667b3c50b61987d6db..e3c56bb41f1a14078e606faa0cf1caee46d5cdae 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 4007c279565f05f019a660c98bbeb2debf36e4e3..c3f256194abe14e014ddf46d1bf356b0978d0edc 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 90ba779c3629e4afc2d86a990d4b28b0cf225e31..7f3a4beac76efbab3bb7661a5be6a5e18d6fa352 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 d51ebe109c4750e008346a77da61405d2e70b63e..049a533de3ae9c68c85b089b98c613d743640bf1 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 34108a636fbc133df19fb962bee52b5b016b07ad..ff59f5a124b8d727a68d1c68d74f2b25825b3486 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 2273c181c8e157152ea314b819da4cd7ed3246fc..6ed6861e2e29710a3e8b25c39458aec408caeba0 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 213e29afcef160c474522fc66f6c1aaae1737739..932435f88a43e7015dbd48f5dc962538541309c3 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 17314d4a98d539e385820ac36210cbdae896c439..b7b7b6ee45f2d310a73f8f06986c6290d85a3383 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 6a4b38c936d15f80263912da4d2809496bb9b3d3..5a6d7267facc89fef607124abf6fc1bfd1e337d5 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 1dee56a22c681f74b2af60a8a531d85acb81e4d3..3f409ac1f17209a779ae96d71b3c2983bc6484f6 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 ac0d8747900726b59a1d52f0cbad6ee955d828ec..232aba2a2d3a8c617dcd1f138d3c16ef1c4edb72 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 909945b9e9bd111f455e8bb5794c7b2243b550ff..f6c99f5717f0950a7bb27000dbe0722e8ca9fec9 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 d5648c2c64cb6ec72761417c45dbf08c7212840b..825ee38b086d85aee9343ee362739f3ac014a33f 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 dea5667064558c593fc04d67edd7d03c24484cd1..cbe3eeb616cc588467b3e755f1ff9fdf91fc1821 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 7b4ff0567fb56a6b808804108916b5200f9e9ba4..eb639237827d563d30bef250ed222a2a74f0d687 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 84274f53fafc52abc294df1c5778add43359ee1c..d66e0b9c3b9ad7c161940e205bfa62de6ac7ad0e 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 418320307885dc26efb07ee39cc159aa72b13f0d..bde4021e797d4db24e292d9aae4a0f6e84cfc44e 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 5bc1378705870fee500ca125fe4365fab798f932..c4f2467ae98fea5f843520889459a49c3613a340 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 02357910ff7e25c309b39b699d03ebf829e0c65b..96f7cd24c066bb563ca9c254a3ad80452503d30c 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 efecdfe77c73ec1f9d69a1013a1e9afd58c26edf..4661ea2da3bd0bd91b4c8d2016e2b439b36c566d 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 646d299e3ecdfbc63f4cf94a7f9e97aeee551d3f..7802b21ce779873af3a8fb862767e971cf19bd51 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 3441722a034d1a7f2c6c71a040cd9c1d2be97326..19650b92f84804a9814f53849ca7d2575a364570 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 29ba836937d009112eae984744a70155351b6fd3..46ad16a15fdc05ba36d26ddf7547cdc4030ee5cd 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 22d3e4899fe7f3f95200287fc949d420425dceae..41f733947f0447ea3da269a4cf46e075ba725a41 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 6ccad33e68e228d5ceecb9fb79d541a463db5a71..5d4643dfffe3588fb69c78f2cbbe529e92ec8cc3 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 da6ebcb1552baf3c9adbc53be61da4805cb48273..e3a38569e2f5be2b1ccec7622cc3d8193a2452be 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 8de74ede8a9e209a81d5f0c0d126f7d90fd27950..22b53a0310bb2477fbdc1db69e74269b6cf81cf6 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 3f7f0778999331ba78d07d5b9e764f97cfeb5d9d..76be3498872cc770852b466919a2e334de51c004 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 9beb268ed783d19aa97f2c0068af128a2cbd6b32..075c7c38eec7249dfa549fdc5a2ee76a30c4d057 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 2f70f0b084b99e3a231e3d01593c0dee9c7228b6..19d32c8f1d5306a709334f4b08b9490ca447555a 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 ce40213dee52a4c23946a00adca56ceb1b75ec88..c97fadc7060787844f79c1afabe41103004d4e11 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 b4ea89149766ee6d9667909edfa5c4053b385b0b..a293dc4b31c9ec5f4d482e1e010c62737afde187 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 32dc67ee42ea5f20bb07baea9eebd28ecfcb51b8..ff5812d2d1ca232cffebc7cfec61e17c79b2c634 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 3489507a255a017fdaed68abe89f284bc09a2d87..7d99cf77b3bd59bf8dbe83b67b223cf7b2405efb 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