Compare commits
No commits in common. "6d1d360ec04d6d8aca7c3ff1881ee997a337f145" and "7bcc724d8ec16640854ece50dc690bd0b91f2638" have entirely different histories.
6d1d360ec0
...
7bcc724d8e
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;
|
||||
}
|
||||
|
||||
void main_opencl(std::string infile, std::string outfile, int num_generations, bool measure, bool use_gpu) {
|
||||
void main_opencl(std::string infile, std::string outfile, int num_generations, bool measure) {
|
||||
Timing *timing = Timing::getInstance();
|
||||
|
||||
// Get Nvidia CUDA platform
|
||||
@ -324,10 +324,11 @@ void main_opencl(std::string infile, std::string outfile, int num_generations, b
|
||||
|
||||
result_file.close();
|
||||
|
||||
delete[] world;
|
||||
delete[] result;
|
||||
|
||||
timing->stopFinalization();
|
||||
|
||||
if (measure) {
|
||||
std::cout << timing->getResults() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void main_classic(std::string infile, std::string outfile, int num_generations, bool measure, Mode mode) {
|
||||
@ -407,6 +408,10 @@ void main_classic(std::string infile, std::string outfile, int num_generations,
|
||||
delete neighbor_counts;
|
||||
|
||||
timing->stopFinalization();
|
||||
|
||||
if (measure) {
|
||||
std::cout << timing->getResults() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
@ -421,6 +426,7 @@ int main(int argc, char* argv[]) {
|
||||
Mode mode = Mode::SEQ;
|
||||
bool use_gpu = false;
|
||||
int num_generations = 0;
|
||||
int num_threads = 1;
|
||||
bool measure = false;
|
||||
|
||||
if (argc < 8) {
|
||||
@ -462,7 +468,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
} else if (std::string(argv[i]) == "--threads") {
|
||||
if (i + 1 < argc) {
|
||||
omp_set_num_threads(std::stoi(argv[i+1]));
|
||||
num_threads = std::stoi(argv[i+1]);
|
||||
} else {
|
||||
print_usage();
|
||||
return 1;
|
||||
@ -496,14 +502,13 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// If OpenCL was demanded, run that function.
|
||||
if (mode == Mode::OCL) {
|
||||
main_opencl(infile, outfile, num_generations, measure, use_gpu);
|
||||
main_opencl(infile, outfile, num_generations, measure);
|
||||
return 0;
|
||||
} else {
|
||||
main_classic(infile, outfile, num_generations, measure, mode);
|
||||
}
|
||||
|
||||
if (measure) {
|
||||
std::cout << timing->getResults() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user