From 4dd9609eab3e8e4bebeabbd02842da06472291f3 Mon Sep 17 00:00:00 2001 From: Simon Klix Date: Thu, 28 Sep 2023 17:34:56 +0200 Subject: [PATCH] commented out faulty edif parser and changed process generation in boolean influence (WIP) --- plugins/boolean_influence/CMakeLists.txt | 16 +------ .../src/plugin_boolean_influence.cpp | 46 ++++++++----------- plugins/edif_parser/src/edif_parser.cpp | 3 +- 3 files changed, 22 insertions(+), 43 deletions(-) diff --git a/plugins/boolean_influence/CMakeLists.txt b/plugins/boolean_influence/CMakeLists.txt index f1bb6beb6ab..3910c5ba1a4 100644 --- a/plugins/boolean_influence/CMakeLists.txt +++ b/plugins/boolean_influence/CMakeLists.txt @@ -1,28 +1,14 @@ option(PL_BOOLEAN_INFLUENCE "PL_BOOLEAN_INFLUENCE" OFF) if(PL_BOOLEAN_INFLUENCE OR BUILD_ALL_PLUGINS) - - if(APPLE AND CMAKE_HOST_APPLE AND NOT Qt5_DIR) - set (Qt5_DIR "/usr/local/opt/qt@5/lib/cmake" ) - endif() - - find_package(Qt5 COMPONENTS Core REQUIRED) - - if(Qt5Core_FOUND) - message(VERBOSE "Qt5Core_INCLUDE_DIRS: ${Qt5Core_INCLUDE_DIRS}") - elseif(NOT Qt5Core_FOUND) - message(STATUS "Qt5Core not found for boolean_influence") - endif(Qt5Core_FOUND) - file(GLOB_RECURSE BOOLEAN_INFLUENCE_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) file(GLOB_RECURSE BOOLEAN_INFLUENCE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) file(GLOB_RECURSE BOOLEAN_INFLUENCE_PYTHON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/python/*.cpp) - qt5_wrap_cpp(MOC_HDR ${BOOLEAN_INFLUENCE_INC}) hal_add_plugin(boolean_influence SHARED HEADER ${BOOLEAN_INFLUENCE_INC} SOURCES ${BOOLEAN_INFLUENCE_SRC} ${BOOLEAN_INFLUENCE_PYTHON_SRC} ${MOC_HDR} - LINK_LIBRARIES PUBLIC ${Z3_LIBRARIES} z3_utils OpenMP::OpenMP_CXX Qt5::Core + LINK_LIBRARIES PUBLIC ${Z3_LIBRARIES} z3_utils OpenMP::OpenMP_CXX subprocess::subprocess PYDOC SPHINX_DOC_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/documentation/boolean_influence.rst ) endif() diff --git a/plugins/boolean_influence/src/plugin_boolean_influence.cpp b/plugins/boolean_influence/src/plugin_boolean_influence.cpp index 0c419d35823..07aabb635a1 100644 --- a/plugins/boolean_influence/src/plugin_boolean_influence.cpp +++ b/plugins/boolean_influence/src/plugin_boolean_influence.cpp @@ -5,7 +5,6 @@ #include "hal_core/netlist/netlist_utils.h" #include "z3_utils/include/z3_utils.h" -#include #include #include @@ -285,29 +284,29 @@ int main(int argc, char *argv[]) { const auto idx = idx_res.get(); const std::string num_evaluations_str = deterministic ? "" : std::to_string(num_evaluations); + const std::string run_command = program_name + " " + std::to_string(idx) + " " + num_evaluations_str + " 2>&1"; - const std::string run_command = program_name + " " + std::to_string(idx) + " " + num_evaluations_str + " 2>&1"; + /* + auto p = subprocess::Popen( + {program_name, std::to_string(idx), num_evaluations_str}, subprocess::error{subprocess::PIPE}, subprocess::output{subprocess::PIPE}, subprocess::input{subprocess::PIPE}); - QStringList args; - args << QString::number(idx); - if (!deterministic) - { - args << QString::number(num_evaluations); - } + auto p_communication = p.communicate(); - QProcess proc; - proc.start(QString::fromStdString(program_name), args); - proc.waitForStarted(); - proc.waitForFinished(); - QByteArray output = proc.readAllStandardError(); - output += proc.readAllStandardOutput(); + const std::vector output_buf = p_communication.first.buf; + const std::string result = {output_buf.begin(), output_buf.end()}; - std::string result; - result = QString::fromUtf8(output).toStdString(); + // TODO: + // check whether process was terminated (i.e. killed) via the subprocess + // API to channel this to the caller + p.close_input(); + p.close_output(); + p.close_error(); + p.kill(); + */ - /* + std::string result; char buffer[129]; - memset(buffer,0,sizeof(buffer)); + memset(buffer, 0, sizeof(buffer)); FILE* pipe = popen(run_command.c_str(), "r"); if (!pipe) @@ -315,21 +314,14 @@ int main(int argc, char *argv[]) { return ERR("unable to generate Boolean influence: error during execution of compiled boolean program"); } - testMutex.lock(); - std::cerr << "run <" << run_command << ">" << (result.empty() ? " empty" : " filled") - << (feof(pipe) ? " feof" : " no-eof") << (ferror(pipe) ? " ferror" : " no-err") << std::endl; - testMutex.unlock(); - while (fgets(buffer, 128, pipe) != NULL) { result += buffer; - memset(buffer,0,sizeof(buffer)); + memset(buffer, 0, sizeof(buffer)); } pclose(pipe); -*/ - if (result.empty() || (result.find_first_not_of("0123456789") == std::string::npos)) { return ERR("unable to generate Boolean influence: result is empty or not a number, result: " + result); @@ -353,7 +345,7 @@ int main(int argc, char *argv[]) { std::remove(file_path.string().c_str()); std::remove(program_name.c_str()); - //std::filesystem::remove(directory); + std::filesystem::remove(directory); return OK(influences); } diff --git a/plugins/edif_parser/src/edif_parser.cpp b/plugins/edif_parser/src/edif_parser.cpp index fd05f117e70..6b403af0c2d 100644 --- a/plugins/edif_parser/src/edif_parser.cpp +++ b/plugins/edif_parser/src/edif_parser.cpp @@ -14,6 +14,7 @@ namespace hal { + /* Result EdifParser::parse(const std::filesystem::path& file_path) { m_path = file_path; @@ -1247,5 +1248,5 @@ namespace hal return unique_alias; } - + */ } // namespace hal