Skip to content

Commit

Permalink
Merge branch 'feat/90' into 'devel'
Browse files Browse the repository at this point in the history
[PGIS] Towards better option handling (#90)

See merge request tuda-sc/projects/metacg!120
  • Loading branch information
jplehr committed Aug 14, 2023
2 parents de00a32 + 79b7852 commit 3cb8d31
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 103 deletions.
3 changes: 2 additions & 1 deletion pgis/lib/include/ErrorCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum ErrorCode : int {
UnknownFileFormat,
ErroneousOverheadConfiguration,
CouldNotGetCWD,
TooFewProgramArguments = 1024,
FileDoesNotExist,
TooFewProgramArguments = 1024
};
} // namespace pgis

Expand Down
9 changes: 5 additions & 4 deletions pgis/lib/include/ExtrapConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "cxxabi.h"

#include <filesystem>
#include <map>
#include <numeric>
#include <string>
Expand Down Expand Up @@ -87,11 +88,11 @@ class ExtrapExtrapolator {
};

/* Utility functions to read in configuration and print it */
ExtrapConfig getExtrapConfigFromJSON(std::string filePath);
ExtrapConfig getExtrapConfigFromJSON(const std::filesystem::path &filePath);

void printConfig(ExtrapConfig &cfg);

inline std::string demangle(std::string &input) {
inline std::string demangle(std::string input) {
char *res;
int st;
res = abi::__cxa_demangle(input.c_str(), nullptr, nullptr, &st);
Expand Down Expand Up @@ -193,7 +194,7 @@ class ExtrapModelProvider {
}
}
// Needs to be defined in header, so deduction works correctly in usages.
auto getModelFor(std::string functionName) {
auto getModelFor(const std::string &functionName) {
if (models.empty()) {
buildModels();
}
Expand All @@ -213,7 +214,7 @@ class ExtrapModelProvider {

std::vector<EXTRAP::Parameter> getParameterList();

std::vector<double> getConfigValues(std::string key) {
std::vector<double> getConfigValues(const std::string &key) {
std::vector<double> vals;
vals.reserve(config.params.size());
// FIXME for now we assume only a single parameter!!
Expand Down
2 changes: 1 addition & 1 deletion pgis/lib/include/MetaData/CgNodeMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class PiraTwoData : public metacg::MetaData::Registrar<PiraTwoData> {
auto &gOpts = ::pgis::config::GlobalConfig::get();
auto rtOnly = gOpts.getAs<bool>("runtime-only");

auto rtAndParams = valTup(getRuntimeVec(), getExtrapParameters(), getNumReps());
auto rtAndParams = utils::valTup(getRuntimeVec(), getExtrapParameters(), getNumReps());
nlohmann::json experiments;
for (auto elem : rtAndParams) {
nlohmann::json exp{};
Expand Down
12 changes: 10 additions & 2 deletions pgis/lib/include/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
#include <string>
#include <unistd.h>

namespace {
namespace utils {
namespace string {

inline bool stringEndsWith(const std::string &s, const std::string &suffix) {
return s.size() >= suffix.size() && s.compare(s.size() - suffix.size(), suffix.size(), suffix) == 0;
}

} // namespace string

inline std::string getHostname() {
char *cName = (char *)malloc(255 * sizeof(char));
if (!gethostname(cName, 255)) {
Expand Down Expand Up @@ -63,7 +71,7 @@ auto valTup(C1 co, C2 ct, int numReps) {
return res;
}

} // namespace
} // namespace utils

inline bool isEligibleForPathInstrumentation(metacg::CgNode *node, metacg::Callgraph *graph,
std::vector<metacg::CgNode *> parents = {}) {
Expand Down
2 changes: 1 addition & 1 deletion pgis/lib/src/ExtrapConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void printConfig(ExtrapConfig &cfg) {
cfg.directory, cfg.repetitions, cfg.prefix, cfg.postfix, cfg.iteration, parameterStr);
}

ExtrapConfig getExtrapConfigFromJSON(std::string filePath) {
ExtrapConfig getExtrapConfigFromJSON(const std::filesystem::path &filePath) {
using json = nlohmann::json;

json j;
Expand Down
Loading

0 comments on commit 3cb8d31

Please sign in to comment.