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

Add sim.outputDir to specify an alternative directory for zsim output files. #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ void SimInit(const char* configFile, const char* outputDir, uint32_t shmid) {
config.get<uint32_t>("sim.gmMBytes", (1 << 10));
if (!zinfo->attachDebugger) config.get<bool>("sim.deadlockDetection", true);
config.get<bool>("sim.aslr", false);
config.get<const char*>("sim.outputDir", nullptr);

//Write config out
bool strictConfig = config.get<bool>("sim.strictConfig", true); //if true, panic on unused variables
Expand Down
15 changes: 10 additions & 5 deletions src/zsim_harness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static time_t startTime;
static time_t lastHeartbeatTime;
static uint64_t lastCycles = 0;

static void printHeartbeat(GlobSimInfo* zinfo) {
static void printHeartbeat(GlobSimInfo* zinfo, const char* outputDir) {
uint64_t cycles = zinfo->numPhases*zinfo->phaseLength;
time_t curTime = time(nullptr);
time_t elapsedSecs = curTime - startTime;
Expand All @@ -214,7 +214,9 @@ static void printHeartbeat(GlobSimInfo* zinfo) {
char hostname[256];
gethostname(hostname, 256);

std::ofstream hb("heartbeat");
std::string hbPath(outputDir);
hbPath += "/heartbeat";
std::ofstream hb(hbPath);
hb << "Running on: " << hostname << std::endl;
hb << "Start time: " << ctime_r(&startTime, time);
hb << "Heartbeat time: " << ctime_r(&curTime, time);
Expand Down Expand Up @@ -323,10 +325,13 @@ int main(int argc, char *argv[]) {

//Canonicalize paths --- because we change dirs, we deal in absolute paths
const char* configFile = realpath(argv[1], nullptr);
const char* outputDir = getcwd(nullptr, 0); //already absolute
const char* cwd = getcwd(nullptr, 0); //already absolute

Config conf(configFile);

//The output directory may be set in the config file
const char* outputDir = realpath(conf.get<const char*>("sim.outputDir", cwd), nullptr);

if (atexit(exitHandler)) panic("Could not register exit handler");

signal(SIGSEGV, sigHandler);
Expand Down Expand Up @@ -416,7 +421,7 @@ int main(int argc, char *argv[]) {
info("Attached to global heap");
}

printHeartbeat(zinfo); // ensure we dump hostname etc on early crashes
printHeartbeat(zinfo, outputDir); // ensure we dump hostname etc on early crashes

int left = sleep(sleepLength);
int secsSlept = sleepLength - left;
Expand Down Expand Up @@ -448,7 +453,7 @@ int main(int argc, char *argv[]) {
} //otherwise, activeProcs == 0; we're done
}

printHeartbeat(zinfo);
printHeartbeat(zinfo, outputDir);

//This solves a weird race in multiprocess where SIGCHLD does not always fire...
int cpid = -1;
Expand Down