Skip to content

Commit 396c94a

Browse files
committed
GPU Standalone: Add --absoluteEventsDir option
1 parent f9c073b commit 396c94a

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ AddOption(nEvents, int32_t, -1, "", 'n', "Number of events to process (-1; all)"
556556
AddOption(runs, int32_t, 1, "runs", 'r', "Number of iterations to perform (repeat each event)", min(0))
557557
AddOption(runs2, int32_t, 1, "runsExternal", 0, "Number of iterations to perform (repeat full processing)", min(1))
558558
AddOption(runsInit, int32_t, 1, "", 0, "Number of initial iterations excluded from average", min(0))
559-
AddOption(eventsDir, const char*, "pp", "events", 'e', "Directory with events to process", message("Reading events from Directory events/%s"))
559+
AddOption(eventsDir, const char*, "pp", "events", 'e', "Directory with events to process", message("Reading events from Directory %s"))
560+
AddOption(absoluteEventsDir, bool, false, "", 0, "Events directory is absolute, and not inside './events/'")
560561
AddOption(noEvents, bool, false, "", 0, "Run without data (e.g. for field visualization)")
561562
AddOption(eventDisplay, int32_t, 0, "display", 'd', "Show standalone event display", def(1))
562563
AddOption(eventGenerator, bool, false, "", 0, "Run event generator")

GPU/GPUTracking/Standalone/Benchmark/standalone.cxx

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ extern GPUSettingsStandalone configStandalone;
7474
GPUReconstruction *rec, *recAsync, *recPipeline;
7575
GPUChainTracking *chainTracking, *chainTrackingAsync, *chainTrackingPipeline;
7676
GPUChainITS *chainITS, *chainITSAsync, *chainITSPipeline;
77+
std::string eventsDir;
7778
void unique_ptr_aligned_delete(char* v)
7879
{
7980
operator delete(v, std::align_val_t(GPUCA_BUFFER_ALIGNMENT));
@@ -277,21 +278,19 @@ int32_t ReadConfiguration(int argc, char** argv)
277278
int32_t SetupReconstruction()
278279
{
279280
if (!configStandalone.eventGenerator) {
280-
char filename[256];
281-
snprintf(filename, 256, "events/%s/", configStandalone.eventsDir);
282281
if (configStandalone.noEvents) {
283-
configStandalone.eventsDir = "NON_EXISTING";
282+
eventsDir = "NON_EXISTING";
284283
configStandalone.rundEdx = false;
285-
} else if (rec->ReadSettings(filename)) {
284+
} else if (rec->ReadSettings(eventsDir.c_str())) {
286285
printf("Error reading event config file\n");
287286
return 1;
288287
}
289-
printf("Read event settings from dir %s (solenoidBz: %f, constBz %d, maxTimeBin %d)\n", filename, rec->GetGRPSettings().solenoidBzNominalGPU, (int32_t)rec->GetGRPSettings().constBz, rec->GetGRPSettings().grpContinuousMaxTimeBin);
288+
printf("Read event settings from dir %s (solenoidBz: %f, constBz %d, maxTimeBin %d)\n", eventsDir.c_str(), rec->GetGRPSettings().solenoidBzNominalGPU, (int32_t)rec->GetGRPSettings().constBz, rec->GetGRPSettings().grpContinuousMaxTimeBin);
290289
if (configStandalone.testSyncAsync) {
291-
recAsync->ReadSettings(filename);
290+
recAsync->ReadSettings(eventsDir.c_str());
292291
}
293292
if (configStandalone.proc.doublePipeline) {
294-
recPipeline->ReadSettings(filename);
293+
recPipeline->ReadSettings(eventsDir.c_str());
295294
}
296295
}
297296

@@ -504,23 +503,19 @@ int32_t SetupReconstruction()
504503

505504
int32_t ReadEvent(int32_t n)
506505
{
507-
char filename[256];
508-
snprintf(filename, 256, "events/%s/" GPUCA_EVDUMP_FILE ".%d.dump", configStandalone.eventsDir, n);
509506
if (configStandalone.inputcontrolmem && !configStandalone.preloadEvents) {
510507
rec->SetInputControl(inputmemory.get(), configStandalone.inputcontrolmem);
511508
}
512-
int32_t r = chainTracking->ReadData(filename);
509+
int32_t r = chainTracking->ReadData((eventsDir + GPUCA_EVDUMP_FILE "." + std::to_string(n) + ".dump").c_str());
513510
if (r) {
514511
return r;
515512
}
516513
#if defined(GPUCA_TPC_GEOMETRY_O2) && defined(GPUCA_BUILD_QA) && !defined(GPUCA_O2_LIB)
517514
if ((configStandalone.proc.runQA || configStandalone.eventDisplay) && !configStandalone.QA.noMC) {
518515
chainTracking->ForceInitQA();
519-
snprintf(filename, 256, "events/%s/mc.%d.dump", configStandalone.eventsDir, n);
520516
chainTracking->GetQA()->UpdateChain(chainTracking);
521-
if (chainTracking->GetQA()->ReadO2MCData(filename)) {
522-
snprintf(filename, 256, "events/%s/mc.%d.dump", configStandalone.eventsDir, 0);
523-
if (chainTracking->GetQA()->ReadO2MCData(filename) && configStandalone.proc.runQA) {
517+
if (chainTracking->GetQA()->ReadO2MCData((eventsDir + "mc." + std::to_string(n) + ".dump").c_str())) {
518+
if (chainTracking->GetQA()->ReadO2MCData((eventsDir + "mc.0.dump").c_str()) && configStandalone.proc.runQA) {
524519
throw std::runtime_error("Error reading O2 MC dump");
525520
}
526521
}
@@ -725,6 +720,7 @@ int32_t main(int argc, char** argv)
725720
if (ReadConfiguration(argc, argv)) {
726721
return 1;
727722
}
723+
eventsDir = std::string(configStandalone.absoluteEventsDir ? "" : "events/") + configStandalone.eventsDir + "/";
728724

729725
GPUSettingsDeviceBackend deviceSet;
730726
deviceSet.deviceType = configStandalone.runGPU ? GPUDataTypes::GetDeviceType(configStandalone.gpuType.c_str()) : GPUDataTypes::DeviceType::CPU;
@@ -787,9 +783,7 @@ int32_t main(int argc, char** argv)
787783

788784
for (nEventsInDirectory = 0; true; nEventsInDirectory++) {
789785
std::ifstream in;
790-
char filename[256];
791-
snprintf(filename, 256, "events/%s/" GPUCA_EVDUMP_FILE ".%d.dump", configStandalone.eventsDir, nEventsInDirectory);
792-
in.open(filename, std::ifstream::binary);
786+
in.open((eventsDir + GPUCA_EVDUMP_FILE "." + std::to_string(nEventsInDirectory) + ".dump").c_str(), std::ifstream::binary);
793787
if (in.fail()) {
794788
break;
795789
}
@@ -801,7 +795,7 @@ int32_t main(int argc, char** argv)
801795
}
802796

803797
if (configStandalone.eventGenerator) {
804-
genEvents::RunEventGenerator(chainTracking);
798+
genEvents::RunEventGenerator(chainTracking, eventsDir);
805799
return 0;
806800
}
807801

@@ -811,7 +805,7 @@ int32_t main(int argc, char** argv)
811805
} else {
812806
if (nEvents == -1 || nEvents > nEventsInDirectory) {
813807
if (nEvents >= 0) {
814-
printf("Only %d events available in directors %s (%d events requested)\n", nEventsInDirectory, configStandalone.eventsDir, nEvents);
808+
printf("Only %d events available in directory %s (%d events requested)\n", nEventsInDirectory, eventsDir.c_str(), nEvents);
815809
}
816810
nEvents = nEventsInDirectory;
817811
}

GPU/GPUTracking/qa/genEvents.cxx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void genEvents::FinishEventGenerator()
149149
}
150150
}
151151

152-
int32_t genEvents::GenerateEvent(const GPUParam& param, char* filename)
152+
int32_t genEvents::GenerateEvent(const GPUParam& param, const char* filename)
153153
{
154154
mRec->ClearIOPointers();
155155
static int32_t iEvent = -1;
@@ -354,20 +354,17 @@ int32_t genEvents::GenerateEvent(const GPUParam& param, char* filename)
354354
return (0);
355355
}
356356

357-
void genEvents::RunEventGenerator(GPUChainTracking* rec)
357+
void genEvents::RunEventGenerator(GPUChainTracking* rec, const std::string& dir)
358358
{
359359
std::unique_ptr<genEvents> gen(new genEvents(rec));
360-
char dirname[256];
361-
snprintf(dirname, 256, "events/%s/", configStandalone.eventsDir);
362-
mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
363-
rec->DumpSettings(dirname);
360+
mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
361+
rec->DumpSettings(dir.c_str());
364362

365363
gen->InitEventGenerator();
366364

367365
for (int32_t i = 0; i < (configStandalone.nEvents == -1 ? 10 : configStandalone.nEvents); i++) {
368366
GPUInfo("Generating event %d/%d", i, configStandalone.nEvents == -1 ? 10 : configStandalone.nEvents);
369-
snprintf(dirname, 256, "events/%s/" GPUCA_EVDUMP_FILE ".%d.dump", configStandalone.eventsDir, i);
370-
gen->GenerateEvent(rec->GetParam(), dirname);
367+
gen->GenerateEvent(rec->GetParam(), (dir + GPUCA_EVDUMP_FILE "." + std::to_string(i) + ".dump").c_str());
371368
}
372369
gen->FinishEventGenerator();
373370
}

GPU/GPUTracking/qa/genEvents.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class genEvents
2828
public:
2929
genEvents(GPUChainTracking* rec) {}
3030
void InitEventGenerator() {}
31-
int32_t GenerateEvent(const GPUParam& sectorParam, char* filename) { return 1; }
31+
int32_t GenerateEvent(const GPUParam& sectorParam, const char* filename) { return 1; }
3232
void FinishEventGenerator() {}
3333

34-
static void RunEventGenerator(GPUChainTracking* rec) {};
34+
static void RunEventGenerator(GPUChainTracking* rec, const std::string& dir) {};
3535
};
3636

3737
#else
@@ -41,10 +41,10 @@ class genEvents
4141
public:
4242
genEvents(GPUChainTracking* rec) : mRec(rec) {}
4343
void InitEventGenerator();
44-
int32_t GenerateEvent(const GPUParam& sectorParam, char* filename);
44+
int32_t GenerateEvent(const GPUParam& sectorParam, const char* filename);
4545
void FinishEventGenerator();
4646

47-
static void RunEventGenerator(GPUChainTracking* rec);
47+
static void RunEventGenerator(GPUChainTracking* rec, const std::string& dir);
4848

4949
private:
5050
int32_t GetSector(double GlobalPhi);

0 commit comments

Comments
 (0)