Increase column limit in format

This commit is contained in:
karl 2020-12-16 20:05:39 +01:00
parent f90d9f6e24
commit fabc2daba9
2 changed files with 21 additions and 34 deletions

View File

@ -8,5 +8,6 @@ AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakBeforeMultilineStrings: 'true'
IndentWidth: '4'
ColumnLimit: 100
...

View File

@ -49,11 +49,9 @@ struct World {
inline void set(int x, int y, bool val) { data[y][x] = val; }
inline int get_num_neighbors(int left, int right, int up, int down, int x,
int y) {
return get_value(left, down) + get_value(x, down) +
get_value(right, down) + get_value(left, y) +
get_value(right, y) + get_value(left, up) + get_value(x, up) +
inline int get_num_neighbors(int left, int right, int up, int down, int x, int y) {
return get_value(left, down) + get_value(x, down) + get_value(right, down) +
get_value(left, y) + get_value(right, y) + get_value(left, up) + get_value(x, up) +
get_value(right, up);
}
@ -76,8 +74,7 @@ void generation_omp(World &world, int *neighbor_counts) {
for (int y = 0; y < size_y; y++) {
// Wrap y
// This happens rarely enough that this if isn't a huge problem, and it
// would be tedious
// to handle both this and x manually.
// would be tedious to handle both this and x manually.
int up = y - 1;
int down = y + 1;
@ -87,13 +84,11 @@ void generation_omp(World &world, int *neighbor_counts) {
down -= size_y;
// Handle x == 0
neighbor_counts[y * size_x + 0] =
world.get_num_neighbors(loop_x, 1, up, down, 0, y);
neighbor_counts[y * size_x + 0] = world.get_num_neighbors(loop_x, 1, up, down, 0, y);
// Handle 'normal' x
for (int x = 1; x < loop_x; x++) {
neighbor_counts[y * size_x + x] =
world.get_num_neighbors(x - 1, x + 1, up, down, x, y);
neighbor_counts[y * size_x + x] = world.get_num_neighbors(x - 1, x + 1, up, down, x, y);
}
// Handle x == loop_x (== size_x - 1, we're just re-using the variable
@ -127,8 +122,7 @@ void generation_seq(World &world, int *neighbor_counts) {
for (int y = 0; y < size_y; y++) {
// Wrap y
// This happens rarely enough that this if isn't a huge problem, and it
// would be tedious
// to handle both this and x manually.
// would be tedious to handle both this and x manually.
int up = y - 1;
int down = y + 1;
@ -138,13 +132,11 @@ void generation_seq(World &world, int *neighbor_counts) {
down -= size_y;
// Handle x == 0
neighbor_counts[y * size_x + 0] =
world.get_num_neighbors(loop_x, 1, up, down, 0, y);
neighbor_counts[y * size_x + 0] = world.get_num_neighbors(loop_x, 1, up, down, 0, y);
// Handle 'normal' x
for (int x = 1; x < loop_x; x++) {
neighbor_counts[y * size_x + x] =
world.get_num_neighbors(x - 1, x + 1, up, down, x, y);
neighbor_counts[y * size_x + x] = world.get_num_neighbors(x - 1, x + 1, up, down, x, y);
}
// Handle x == loop_x (== size_x - 1, we're just re-using the variable
@ -170,8 +162,8 @@ void print_usage() {
<< 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,
bool use_gpu) {
Timing *timing = Timing::getInstance();
// Get Nvidia CUDA platform
@ -215,8 +207,7 @@ void main_opencl(std::string infile, std::string outfile, int num_generations,
cl::Program program(context, sources);
if (program.build({default_device}) != CL_SUCCESS) {
std::cout << "Error building: "
<< program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(default_device)
<< std::endl;
<< program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(default_device) << std::endl;
exit(1);
}
@ -267,8 +258,7 @@ void main_opencl(std::string infile, std::string outfile, int num_generations,
cl::CommandQueue queue(context, default_device);
// Push write commands to queue
queue.enqueueWriteBuffer(buffer_previous, CL_TRUE, 0, sizeof(bool) * n,
world);
queue.enqueueWriteBuffer(buffer_previous, CL_TRUE, 0, sizeof(bool) * n, world);
queue.enqueueWriteBuffer(buffer_new, CL_TRUE, 0, sizeof(bool) * n, result);
queue.enqueueWriteBuffer(buffer_size, CL_TRUE, 0, sizeof(int) * 2, size);
@ -287,14 +277,12 @@ void main_opencl(std::string infile, std::string outfile, int num_generations,
gol_kernel.setArg(2, buffer_size);
// Run it
queue.enqueueNDRangeKernel(gol_kernel, cl::NullRange, cl::NDRange(n),
cl::NullRange);
queue.enqueueNDRangeKernel(gol_kernel, cl::NullRange, cl::NDRange(n), cl::NullRange);
queue.finish();
// Swap the previous buffer with the new buffer, as we will want to use
// our result from this loop
// as the input of the next loop (overwriting the previous result,
// which is not needed anymore)
// our result from this loop as the input of the next loop (overwriting the previous result,
// which is not needed anymore)
std::swap(buffer_previous, buffer_new);
}
queue.finish();
@ -306,11 +294,9 @@ void main_opencl(std::string infile, std::string outfile, int num_generations,
// depending on
// whether we're in swapped mode or not at the moment
if (num_generations % 2 == 0) {
queue.enqueueReadBuffer(buffer_previous, CL_TRUE, 0, sizeof(bool) * n,
result);
queue.enqueueReadBuffer(buffer_previous, CL_TRUE, 0, sizeof(bool) * n, result);
} else {
queue.enqueueReadBuffer(buffer_new, CL_TRUE, 0, sizeof(bool) * n,
result);
queue.enqueueReadBuffer(buffer_new, CL_TRUE, 0, sizeof(bool) * n, result);
}
// Write the result
@ -338,8 +324,8 @@ void main_opencl(std::string infile, std::string outfile, int num_generations,
timing->stopFinalization();
}
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) {
Timing *timing = Timing::getInstance();
// Read in the start state