Skip to content

Commit a744c63

Browse files
author
Anudeep Kambapu
authored
Merge pull request #31 from oneapi-src/quicksilver/input_file_check
[Quicksilver][SYCL][CUDA][HIP] Return -1 from main when input file path is bad
2 parents bc59be6 + 9784295 commit a744c63

File tree

9 files changed

+28
-6
lines changed

9 files changed

+28
-6
lines changed

QuickSilver/CUDA/src/.depend

Whitespace-only changes.

QuickSilver/CUDA/src/Parameters.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ namespace
320320
if (!in.good())
321321
{
322322
std::cerr << "ERROR : Input file '" << filename << "' does not exist " << std::endl;
323-
exit(-1);
323+
return;
324324
}
325325
string line;
326326
getline(in, line);

QuickSilver/CUDA/src/git_hash.hh

Lines changed: 0 additions & 1 deletion
This file was deleted.

QuickSilver/CUDA/src/git_vers.hh

Lines changed: 0 additions & 1 deletion
This file was deleted.

QuickSilver/CUDA/src/main.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
4545

4646
#include <cuda_profiler_api.h>
4747
#include <iostream>
48+
#include <fstream>
49+
#include <string>
4850
#include "utils.hh"
4951
#include "Parameters.hh"
5052
#include "utilsMpi.hh"
@@ -106,6 +108,12 @@ int main(int argc, char **argv)
106108
printBanner(GIT_VERS, GIT_HASH);
107109

108110
Parameters params = getParameters(argc, argv);
111+
const string &filename = params.simulationParams.inputFile;
112+
ifstream inp_file(filename.c_str());
113+
if (!inp_file.good())
114+
{
115+
return -1;
116+
}
109117
printParameters(params, cout);
110118

111119
setGPU();
@@ -376,7 +384,7 @@ void cycleTracking(MonteCarlo *monteCarlo, uint64_cu *tallies, uint64_cu *tallie
376384
processingVault->getBaseParticleComm(mcb_particle, sendQueueT._particleIndex);
377385

378386
int buffer = monteCarlo->particle_buffer->Choose_Buffer(sendQueueT._neighbor);
379-
if(buffer >= 0)
387+
if (buffer >= 0)
380388
monteCarlo->particle_buffer->Buffer_Particle(mcb_particle, buffer);
381389
}
382390

QuickSilver/HIP/src/Parameters.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ namespace
320320
if (!in.good())
321321
{
322322
std::cerr << "ERROR : Input file '" << filename << "' does not exist " << std::endl;
323-
exit(-1);
323+
return;
324324
}
325325
string line;
326326
getline(in, line);

QuickSilver/HIP/src/main.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
4545

4646
#include "hip/hip_runtime.h"
4747
#include <iostream>
48+
#include <fstream>
49+
#include <string>
4850
#include "utils.hh"
4951
#include "Parameters.hh"
5052
#include "utilsMpi.hh"
@@ -107,6 +109,12 @@ int main(int argc, char **argv)
107109
printBanner(GIT_VERS, GIT_HASH);
108110

109111
Parameters params = getParameters(argc, argv);
112+
const string &filename = params.simulationParams.inputFile;
113+
ifstream inp_file(filename.c_str());
114+
if (!inp_file.good())
115+
{
116+
return -1;
117+
}
110118
printParameters(params, cout);
111119

112120
setGPU();

QuickSilver/SYCL/src/Parameters.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ namespace
318318
if (!in.good())
319319
{
320320
std::cerr << "ERROR : Input file '" << filename << "' does not exist " << std::endl;
321-
exit(-1);
321+
return;
322322
}
323323
string line;
324324
getline(in, line);

QuickSilver/SYCL/src/main.cc.dp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
4545

4646
#include <sycl/sycl.hpp>
4747
#include <iostream>
48+
#include <fstream>
49+
#include <string>
4850
#include "utils.hh"
4951
#include "Parameters.hh"
5052
#include "utilsMpi.hh"
@@ -109,6 +111,12 @@ int main(int argc, char **argv)
109111
printBanner(GIT_VERS, GIT_HASH);
110112
std::cout << "Loading params" << std::endl;
111113
Parameters params = getParameters(argc, argv);
114+
const string &filename = params.simulationParams.inputFile;
115+
ifstream inp_file(filename.c_str());
116+
if (!inp_file.good())
117+
{
118+
return -1;
119+
}
112120
std::cout << "Finished loading params" << std::endl;
113121
printParameters(params, cout);
114122
std::cout << "setting GPU" << std::endl;

0 commit comments

Comments
 (0)