Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes souffleprof and enable build on Windows #2423

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,15 @@ endif ()
# Souffle's profiler binary
# --------------------------------------------------

if (NOT WIN32)
add_executable(souffleprof
souffle_prof.cpp)
target_include_directories(souffleprof PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
install(TARGETS souffleprof DESTINATION bin)

# Set C++ standard to C++17
target_compile_features(souffleprof
PUBLIC cxx_std_17)
endif()

add_executable(souffleprof
souffle_prof.cpp)
target_include_directories(souffleprof PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
install(TARGETS souffleprof DESTINATION bin)

# Set C++ standard to C++17
target_compile_features(souffleprof
PUBLIC cxx_std_17)

if (MSVC)
target_compile_options(libsouffle PUBLIC /bigobj)
Expand All @@ -403,12 +402,15 @@ if (MSVC)

target_compile_options(libsouffle PUBLIC /Zc:preprocessor)
target_compile_options(compiled PUBLIC /Zc:preprocessor)
target_compile_options(souffleprof PUBLIC /Zc:preprocessor)

target_compile_options(libsouffle PUBLIC /EHsc)
target_compile_options(compiled PUBLIC /EHsc)
target_compile_options(souffleprof PUBLIC /EHsc)

target_compile_definitions(libsouffle PUBLIC USE_CUSTOM_GETOPTLONG)
target_compile_definitions(compiled PUBLIC USE_CUSTOM_GETOPTLONG)
target_compile_definitions(souffleprof PUBLIC USE_CUSTOM_GETOPTLONG)
endif (MSVC)


Expand Down
31 changes: 19 additions & 12 deletions src/LogStatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,59 +21,66 @@
namespace souffle {

class LogStatement {
private:
static std::string str(const SrcLocation& loc) {
return loc.getReportedPath() + " [" + std::to_string(loc.start.line) + ":" +
std::to_string(loc.start.column) + "-" + std::to_string(loc.end.line) + ":" +
std::to_string(loc.end.column) + "]";
}

public:
static const std::string tNonrecursiveRelation(
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@t-nonrecursive-relation";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";";
return line.str();
}
static const std::string tRelationLoadTime(
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@t-relation-loadtime";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";loadtime;";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";loadtime;";
return line.str();
}

static const std::string tRelationSaveTime(
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@t-relation-savetime";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";savetime;";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";savetime;";
return line.str();
}

static const std::string nNonrecursiveRelation(
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@n-nonrecursive-relation";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";";
return line.str();
}

static const std::string tNonrecursiveRule(
const std::string& relationName, const SrcLocation& srcLocation, const std::string& datalogText) {
const char* messageType = "@t-nonrecursive-rule";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";" << datalogText << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";" << datalogText << ";";
return line.str();
}

static const std::string nNonrecursiveRule(
const std::string& relationName, const SrcLocation& srcLocation, const std::string& datalogText) {
const char* messageType = "@n-nonrecursive-rule";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";" << datalogText << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";" << datalogText << ";";
return line.str();
}

static const std::string tRecursiveRule(const std::string& relationName, const std::size_t version,
const SrcLocation& srcLocation, const std::string& datalogText) {
const char* messageType = "@t-recursive-rule";
std::stringstream line;
line << messageType << ";" << relationName << ";" << version << ";" << srcLocation << ";"
line << messageType << ";" << relationName << ";" << version << ";" << str(srcLocation) << ";"
<< datalogText << ";";
return line.str();
}
Expand All @@ -82,7 +89,7 @@ class LogStatement {
const SrcLocation& srcLocation, const std::string& datalogText) {
const char* messageType = "@n-recursive-rule";
std::stringstream line;
line << messageType << ";" << relationName << ";" << version << ";" << srcLocation << ";"
line << messageType << ";" << relationName << ";" << version << ";" << str(srcLocation) << ";"
<< datalogText << ";";
return line.str();
}
Expand All @@ -91,23 +98,23 @@ class LogStatement {
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@t-recursive-relation";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";";
return line.str();
}

static const std::string nRecursiveRelation(
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@n-recursive-relation";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";";
return line.str();
}

static const std::string cRecursiveRelation(
const std::string& relationName, const SrcLocation& srcLocation) {
const char* messageType = "@c-recursive-relation";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";";
return line.str();
}

Expand All @@ -117,7 +124,7 @@ class LogStatement {
// messages are ignored
const char* messageType = "#p-proof-counter";
std::stringstream line;
line << messageType << ";" << relationName << ";" << srcLocation << ";" << datalogText << ";";
line << messageType << ";" << relationName << ";" << str(srcLocation) << ";" << datalogText << ";";
// TODO (#590): the additional semicolon is added to maintain backwards compatibility and should
// eventually be removed
line << ";";
Expand Down
1 change: 1 addition & 0 deletions src/ast/QualifiedName.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <cstdint>
#include <iosfwd>
#include <string>
#include <vector>
Expand Down
5 changes: 1 addition & 4 deletions src/ast/Term.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ class Term : public Argument {

template <typename... Operands>
static VecOwn<Argument> asVec(Operands... ops) {
Own<Argument> ary[] = {std::move(ops)...};
VecOwn<Argument> xs;
for (auto&& x : ary) {
xs.push_back(std::move(x));
}
(xs.emplace_back(std::move(std::forward<Operands>(ops))), ...);
return xs;
}

Expand Down
16 changes: 8 additions & 8 deletions src/include/souffle/profile/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Cell<std::chrono::microseconds> : public CellInterface {
double getDoubleVal() const override {
return value.count() / 1000000.0;
}
long getLongVal() const override {
int64_t getLongVal() const override {
std::cerr << "getting long on time cell\n";
throw this;
}
Expand All @@ -62,7 +62,7 @@ class Cell<double> : public CellInterface {
double getDoubleVal() const override {
return value;
}
long getLongVal() const override {
int64_t getLongVal() const override {
std::cerr << "getting long on double cell\n";
throw this;
}
Expand All @@ -89,7 +89,7 @@ class Cell<std::string> : public CellInterface {
std::cerr << "getting double on string cell\n";
throw this;
}
long getLongVal() const override {
int64_t getLongVal() const override {
std::cerr << "getting long on string cell\n";
throw this;
}
Expand All @@ -106,11 +106,11 @@ class Cell<std::string> : public CellInterface {
};

template <>
class Cell<long> : public CellInterface {
const long value;
class Cell<int64_t> : public CellInterface {
const int64_t value;

public:
Cell(long value) : value(value){};
Cell(int64_t value) : value(value){};
double getDoubleVal() const override {
std::cerr << "getting double on long cell\n";
throw this;
Expand All @@ -119,7 +119,7 @@ class Cell<long> : public CellInterface {
std::cerr << "getting string on long cell\n";
throw this;
}
long getLongVal() const override {
int64_t getLongVal() const override {
return value;
}
std::chrono::microseconds getTimeVal() const override {
Expand All @@ -139,7 +139,7 @@ class Cell<void> : public CellInterface, std::false_type {
std::cerr << "getting double on void cell";
throw this;
}
long getLongVal() const override {
int64_t getLongVal() const override {
std::cerr << "getting long on void cell";
throw this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/souffle/profile/CellInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CellInterface {

virtual double getDoubleVal() const = 0;

virtual long getLongVal() const = 0;
virtual int64_t getLongVal() const = 0;

virtual std::string getStringVal() const = 0;

Expand Down
17 changes: 12 additions & 5 deletions src/include/souffle/profile/Cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
#include <map>
#include <string>
#include <vector>

#ifdef USE_CUSTOM_GETOPTLONG
#include "souffle/utility/GetOptLongImpl.h"
#else
#include <getopt.h>
#endif

namespace souffle {
namespace profile {
Expand Down Expand Up @@ -52,10 +57,10 @@ class Cli {
}
}

void parse() {
int parse() {
if (args.size() == 0) {
std::cout << "No arguments provided.\nTry souffleprof -h for help.\n";
exit(EXIT_FAILURE);
return (EXIT_FAILURE);
}

if (args.count('h') != 0 || args.count('f') == 0) {
Expand All @@ -70,7 +75,7 @@ class Cli {
<< std::endl
<< " Default filename is profiler_html/[num].html" << std::endl
<< "-h Print this help message." << std::endl;
exit(0);
return (0);
}
std::string filename = args['f'];

Expand All @@ -81,13 +86,15 @@ class Cli {
}
} else if (args.count('j') != 0) {
if (args['j'] == "j") {
Tui(filename, false, true).outputHtml();
return Tui(filename, false, true).outputHtml();
} else {
Tui(filename, false, true).outputHtml(args['j']);
return Tui(filename, false, true).outputHtml(args['j']);
}
} else {
Tui(filename, true, false).runProf();
}

return 0;
}
};

Expand Down
Loading