More minor code improvements
This commit is contained in:
parent
7bcc724d8e
commit
4c687844d3
20
main.cpp
20
main.cpp
@ -173,7 +173,7 @@ void print_usage() {
|
|||||||
std::cerr << "Usage: gol --mode seq|omp|ocl [--threads number] [--device cpu|gpu] --load infile.gol --save outfile.gol --generations number [--measure]" << std::endl;
|
std::cerr << "Usage: gol --mode seq|omp|ocl [--threads number] [--device cpu|gpu] --load infile.gol --save outfile.gol --generations number [--measure]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_opencl(std::string infile, std::string outfile, int num_generations, bool measure) {
|
void main_opencl(std::string infile, std::string outfile, int num_generations, bool measure, bool use_gpu) {
|
||||||
Timing *timing = Timing::getInstance();
|
Timing *timing = Timing::getInstance();
|
||||||
|
|
||||||
// Get Nvidia CUDA platform
|
// Get Nvidia CUDA platform
|
||||||
@ -324,11 +324,10 @@ void main_opencl(std::string infile, std::string outfile, int num_generations, b
|
|||||||
|
|
||||||
result_file.close();
|
result_file.close();
|
||||||
|
|
||||||
timing->stopFinalization();
|
delete[] world;
|
||||||
|
delete[] result;
|
||||||
|
|
||||||
if (measure) {
|
timing->stopFinalization();
|
||||||
std::cout << timing->getResults() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_classic(std::string infile, std::string outfile, int num_generations, bool measure, Mode mode) {
|
void main_classic(std::string infile, std::string outfile, int num_generations, bool measure, Mode mode) {
|
||||||
@ -408,10 +407,6 @@ void main_classic(std::string infile, std::string outfile, int num_generations,
|
|||||||
delete neighbor_counts;
|
delete neighbor_counts;
|
||||||
|
|
||||||
timing->stopFinalization();
|
timing->stopFinalization();
|
||||||
|
|
||||||
if (measure) {
|
|
||||||
std::cout << timing->getResults() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
@ -502,13 +497,14 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// If OpenCL was demanded, run that function.
|
// If OpenCL was demanded, run that function.
|
||||||
if (mode == Mode::OCL) {
|
if (mode == Mode::OCL) {
|
||||||
main_opencl(infile, outfile, num_generations, measure);
|
main_opencl(infile, outfile, num_generations, measure, use_gpu);
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
main_classic(infile, outfile, num_generations, measure, mode);
|
main_classic(infile, outfile, num_generations, measure, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (measure) {
|
||||||
|
std::cout << timing->getResults() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user