Compare commits
2 Commits
7bcc724d8e
...
6d1d360ec0
Author | SHA1 | Date | |
---|---|---|---|
6d1d360ec0 | |||
4c687844d3 |
23
main.cpp
23
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[]) {
|
||||||
@ -426,7 +421,6 @@ int main(int argc, char* argv[]) {
|
|||||||
Mode mode = Mode::SEQ;
|
Mode mode = Mode::SEQ;
|
||||||
bool use_gpu = false;
|
bool use_gpu = false;
|
||||||
int num_generations = 0;
|
int num_generations = 0;
|
||||||
int num_threads = 1;
|
|
||||||
bool measure = false;
|
bool measure = false;
|
||||||
|
|
||||||
if (argc < 8) {
|
if (argc < 8) {
|
||||||
@ -468,7 +462,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
} else if (std::string(argv[i]) == "--threads") {
|
} else if (std::string(argv[i]) == "--threads") {
|
||||||
if (i + 1 < argc) {
|
if (i + 1 < argc) {
|
||||||
num_threads = std::stoi(argv[i+1]);
|
omp_set_num_threads(std::stoi(argv[i+1]));
|
||||||
} else {
|
} else {
|
||||||
print_usage();
|
print_usage();
|
||||||
return 1;
|
return 1;
|
||||||
@ -502,13 +496,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