Skip to content

Commit

Permalink
feat(structure): updated output structure of the profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Oct 13, 2023
1 parent 618f61a commit eb256a5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
28 changes: 20 additions & 8 deletions DiscoPoP/DiscoPoP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ bool DiscoPoP::doInitialization(Module &M) {
errs() << "DiscoPoP | 190: init pass DiscoPoP \n";
}

// prepare .discopop directory if not present
struct stat st1 = {0};
if (stat(".discopop", &st1) == -1){
mkdir(".discopop", 0777);
}
// prepare profiler directory if not present
struct stat st2 = {0};
if (stat(".discopop/profiler", &st2) == -1){
mkdir(".discopop/profiler", 0777);
}


// CUGeneration
{
CUIDCounter = 0;
Expand Down Expand Up @@ -871,7 +883,7 @@ void DiscoPoP::fillStartEndLineNumbers(Node *root, LoopInfo &LI) {
}

void DiscoPoP::initializeCUIDCounter() {
std::string CUCounterFile = "DP_CUIDCounter.txt";
std::string CUCounterFile = ".discopop/profiler/DP_CUIDCounter.txt";
if (dputil::fexists(CUCounterFile)) {
std::fstream inCUIDCounter(CUCounterFile, std::ios_base::in);;
inCUIDCounter >> CUIDCounter;
Expand Down Expand Up @@ -1811,7 +1823,7 @@ void DiscoPoP::dp_reduction_insert_functions() {

// insert function calls to monitor loop iterations
std::ofstream loop_metadata_file;
loop_metadata_file.open("loop_meta.txt");
loop_metadata_file.open(".discopop/profiler/loop_meta.txt");
int loop_id = 1;
llvm::Type* loop_incr_fn_arg_type = llvm::Type::getInt32Ty(*ctx_);
llvm::ArrayRef<llvm::Type*> loop_incr_fn_args(loop_incr_fn_arg_type);
Expand Down Expand Up @@ -1999,10 +2011,10 @@ bool DiscoPoP::runOnModule(Module &M) {
ctx_ = &module_->getContext();

reduction_file = new std::ofstream();
reduction_file->open("reduction.txt", std::ios_base::app);
reduction_file->open(".discopop/profiler/reduction.txt", std::ios_base::app);

loop_counter_file = new std::ofstream();
loop_counter_file->open("loop_counter_output.txt", std::ios_base::app);
loop_counter_file->open(".discopop/profiler/loop_counter_output.txt", std::ios_base::app);

bool success = dp_reduction_init_util(FileMappingPath);
if (!success) {
Expand Down Expand Up @@ -2435,7 +2447,7 @@ bool DiscoPoP::runOnFunction(Function &F) {
// Report statically identified dependencies

staticDependencyFile = new std::ofstream();
staticDependencyFile->open("static_dependencies.txt", std::ios_base::app);
staticDependencyFile->open(".discopop/profiler/static_dependencies.txt", std::ios_base::app);

for (auto pair: conditionalBBDepMap) {
for (auto s: pair.second) {
Expand Down Expand Up @@ -2845,13 +2857,13 @@ string DiscoPoP::xmlEscape(string data) {

void DiscoPoP::secureStream() {
outOriginalVariables = new std::ofstream();
outOriginalVariables->open("OriginalVariables.txt", std::ios_base::app);
outOriginalVariables->open(".discopop/profiler/OriginalVariables.txt", std::ios_base::app);

outCUs = new std::ofstream();
outCUs->open("Data.xml", std::ios_base::app);
outCUs->open(".discopop/profiler/Data.xml", std::ios_base::app);

outCUIDCounter = new std::ofstream();
outCUIDCounter->open("DP_CUIDCounter.txt", std::ios_base::out);
outCUIDCounter->open(".discopop/profiler/DP_CUIDCounter.txt", std::ios_base::out);
}

string DiscoPoP::getLineNumbersString(set<int> LineNumbers) {
Expand Down
3 changes: 3 additions & 0 deletions DiscoPoP/DiscoPoP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
#include <string.h>
#include <utility>

#include <sys/stat.h>
#include <sys/types.h>

#define DP_DEBUG false

using namespace llvm;
Expand Down
5 changes: 3 additions & 2 deletions rtlib/iFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace __dp {

void outputAllocations() {
auto allocationsFileStream = new ofstream();
allocationsFileStream->open("memory_regions.txt", ios::out);
allocationsFileStream->open(".discopop/profiler/memory_regions.txt", ios::out);
for(auto memoryRegion : *allocatedMemoryRegions){
string position = decodeLID(get<0>(memoryRegion));
string id = get<1>(memoryRegion);
Expand Down Expand Up @@ -1084,7 +1084,8 @@ namespace __dp {
selfPath = nullptr;
out->open("Output.txt", ios::out);
}
out->open(string(selfPath) + "_dep.txt", ios::out);
//out->open(string(selfPath) + "_dep.txt", ios::out); # results in the old <prog>_dep.txt
out->open(".discopop/profiler/dynamic_dependencies.txt", ios::out);
}
#else
out->open("Output.txt", ios::out);
Expand Down
4 changes: 2 additions & 2 deletions rtlib/loop_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void loop_counter_output() {
// get meta information about the loops
std::vector <loop_info_t> loop_infos;
loop_infos.push_back(loop_info_t()); // dummy
ifile.open("loop_meta.txt");
ifile.open(".discopop/profiler/loop_meta.txt");
while (std::getline(ifile, line)) {
loop_info_t loop_info;
int cnt = sscanf(line.c_str(), "%d %d %d", &loop_info.file_id_,
Expand All @@ -69,7 +69,7 @@ void loop_counter_output() {
ifile.close();

// output information about the loops
ofile.open("loop_counter_output.txt");
ofile.open(".discopop/profiler/loop_counter_output.txt");
for (auto i = 1; i < lc.loop_counters_.size(); ++i) {
loop_info_t &loop_info = loop_infos[i];
ofile << loop_info.file_id_ << " ";
Expand Down

0 comments on commit eb256a5

Please sign in to comment.