Skip to content

Commit

Permalink
commented out faulty edif parser and changed process generation in bo…
Browse files Browse the repository at this point in the history
…olean influence (WIP)
  • Loading branch information
Simon Klix committed Sep 28, 2023
1 parent 890bc6e commit 4dd9609
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 43 deletions.
16 changes: 1 addition & 15 deletions plugins/boolean_influence/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
46 changes: 19 additions & 27 deletions plugins/boolean_influence/src/plugin_boolean_influence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "hal_core/netlist/netlist_utils.h"
#include "z3_utils/include/z3_utils.h"

#include <QProcess>
#include <filesystem>
#include <fstream>

Expand Down Expand Up @@ -285,51 +284,44 @@ 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<char> 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)
{
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);
Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/edif_parser/src/edif_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace hal
{
/*
Result<std::monostate> EdifParser::parse(const std::filesystem::path& file_path)
{
m_path = file_path;
Expand Down Expand Up @@ -1247,5 +1248,5 @@ namespace hal
return unique_alias;
}

*/
} // namespace hal

0 comments on commit 4dd9609

Please sign in to comment.