Commit ac91426c authored by Bram Veenboer's avatar Bram Veenboer

CPU W-Tiling: Apply clang formatting

parent 1843809e
Pipeline #12682 failed with stages
in 18 minutes and 21 seconds
......@@ -18,12 +18,9 @@
extern "C" {
void kernel_apply_phasor(int w_padded_tile_size, float image_size,
float w_step, const float *shift,
idg::Coordinate& coordinate,
idg::float2 *tile,
int sign)
{
void kernel_apply_phasor(int w_padded_tile_size, float image_size, float w_step,
const float *shift, idg::Coordinate &coordinate,
idg::float2 *tile, int sign) {
float cell_size = image_size / w_padded_tile_size;
int N = w_padded_tile_size * w_padded_tile_size;
float w = (coordinate.z + 0.5f) * w_step;
......@@ -33,8 +30,7 @@ void kernel_apply_phasor(int w_padded_tile_size, float image_size,
int x_ = x;
int y_ = x;
// Inline FFT shift
if (sign == -1)
{
if (sign == -1) {
x_ = (x + (w_padded_tile_size / 2)) % w_padded_tile_size;
y_ = (y + (w_padded_tile_size / 2)) % w_padded_tile_size;
}
......@@ -55,20 +51,15 @@ void kernel_apply_phasor(int w_padded_tile_size, float image_size,
}
}
}
} // end kernel_apply_phasor
inline void kernel_tile_from_grid(int wtile_size,
int w_padded_tile_size,
int grid_size,
idg::Coordinate& coordinate,
idg::float2 *tile,
const idg::float2 *grid)
{
int x0 = coordinate.x * wtile_size -
(w_padded_tile_size - wtile_size) / 2 + grid_size / 2;
int y0 = coordinate.y * wtile_size -
(w_padded_tile_size - wtile_size) / 2 + grid_size / 2;
} // end kernel_apply_phasor
inline void kernel_tile_from_grid(int wtile_size, int w_padded_tile_size,
int grid_size, idg::Coordinate &coordinate,
idg::float2 *tile, const idg::float2 *grid) {
int x0 = coordinate.x * wtile_size - (w_padded_tile_size - wtile_size) / 2 +
grid_size / 2;
int y0 = coordinate.y * wtile_size - (w_padded_tile_size - wtile_size) / 2 +
grid_size / 2;
int x_start = std::max(0, x0);
int y_start = std::max(0, y0);
int x_end = std::min(x0 + w_padded_tile_size, grid_size);
......@@ -85,32 +76,23 @@ inline void kernel_tile_from_grid(int wtile_size,
}
}
void kernel_tiles_from_grid(int nr_tiles,
int wtile_size,
int w_padded_tile_size,
int grid_size,
idg::Coordinate *coordinates,
idg::float2 *tiles,
const idg::float2 *grid)
{
void kernel_tiles_from_grid(int nr_tiles, int wtile_size,
int w_padded_tile_size, int grid_size,
idg::Coordinate *coordinates, idg::float2 *tiles,
const idg::float2 *grid) {
#pragma omp parallel for
for (int i = 0; i < nr_tiles; i++)
{
size_t sizeof_w_padded_tile = NR_POLARIZATIONS * w_padded_tile_size * w_padded_tile_size;
for (int i = 0; i < nr_tiles; i++) {
size_t sizeof_w_padded_tile =
NR_POLARIZATIONS * w_padded_tile_size * w_padded_tile_size;
idg::float2 *tile = &tiles[i * sizeof_w_padded_tile];
kernel_tile_from_grid(wtile_size, w_padded_tile_size, grid_size,
coordinates[i], tile, grid);
}
}
void kernel_tiles_to_grid(int nr_tiles,
int wtile_size,
int w_padded_tile_size,
int grid_size,
idg::Coordinate *coordinates,
const idg::float2 *tiles,
idg::float2 *grid)
{
void kernel_tiles_to_grid(int nr_tiles, int wtile_size, int w_padded_tile_size,
int grid_size, idg::Coordinate *coordinates,
const idg::float2 *tiles, idg::float2 *grid) {
#pragma omp parallel for
for (int y = 0; y < w_padded_tile_size; y++) {
for (int i = 0; i < nr_tiles; i++) {
......@@ -132,13 +114,8 @@ void kernel_tiles_to_grid(int nr_tiles,
}
}
inline void kernel_copy_tile(
int src_tile_size,
int dst_tile_size,
idg::float2 *src_tile,
idg::float2 *dst_tile)
{
inline void kernel_copy_tile(int src_tile_size, int dst_tile_size,
idg::float2 *src_tile, idg::float2 *dst_tile) {
const int index_pol_transposed[NR_POLARIZATIONS] = {0, 2, 1, 3};
int padding = dst_tile_size - src_tile_size;
int padding2 = padding / 2;
......@@ -152,8 +129,7 @@ inline void kernel_copy_tile(
int src_x = x;
int dst_x = x;
if (padding > 0)
{
if (padding > 0) {
dst_y += padding2;
dst_x += padding2;
} else if (padding < 0) {
......@@ -305,9 +281,10 @@ void kernel_adder_wtiles_to_grid(int grid_size, int subgrid_size,
idg::Coordinate &coordinate = tile_coordinates[tile_idx];
// Copy tile
size_t src_idx = index_grid(padded_tile_size, tile_ids[tile_idx], 0, 0, 0);
kernel_copy_tile(padded_tile_size, w_padded_tile_size,
&tiles[src_idx], tile_buffers.data(i, 0, 0, 0));
size_t src_idx =
index_grid(padded_tile_size, tile_ids[tile_idx], 0, 0, 0);
kernel_copy_tile(padded_tile_size, w_padded_tile_size, &tiles[src_idx],
tile_buffers.data(i, 0, 0, 0));
// Reset tile to zero
std::fill(
......@@ -481,7 +458,6 @@ void kernel_splitter_wtiles_from_grid(int grid_size, int subgrid_size,
reinterpret_cast<fftwf_complex *>(tile_buffers.data(i, 0, 0, 0));
fftwf_execute_dft(plan_backward, tile_ptr, tile_ptr);
// Multiply w term
kernel_apply_phasor(w_padded_tile_size, image_size, w_step, shift,
coordinate, tile_buffers.data(i, 0, 0, 0), 1);
......@@ -490,7 +466,8 @@ void kernel_splitter_wtiles_from_grid(int grid_size, int subgrid_size,
fftwf_execute_dft(plan_forward, tile_ptr, tile_ptr);
// Copy tile
size_t dst_idx = index_grid(padded_tile_size, tile_ids[tile_idx], 0, 0, 0);
size_t dst_idx =
index_grid(padded_tile_size, tile_ids[tile_idx], 0, 0, 0);
kernel_copy_tile(w_padded_tile_size, padded_tile_size,
tile_buffers.data(i, 0, 0, 0), &tiles[dst_idx]);
} // end for current_nr_tiles
......
......@@ -221,7 +221,8 @@ void InstanceCPU::load_kernel_funcions() {
idg::Coordinate *tile_coordinates, idg::float2 *tiles, \
idg::float2 *grid))
#define sig_tiles_to_grid (void (*)(int, int, int, int, void *, void *, void *))
#define sig_tiles_from_grid (void (*)(int, int, int, int, void *, void *, void *))
#define sig_tiles_from_grid \
(void (*)(int, int, int, int, void *, void *, void *))
#define sig_average_beam \
(void (*)(int, int, int, int, int, int, void *, void *, void *, void *, \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment