Skip to content
Snippets Groups Projects
Commit 81aadd7c authored by Bram Veenboer's avatar Bram Veenboer
Browse files

Replace ParallelFor by StaticFor

parent 677b48c6
Branches
No related tags found
No related merge requests found
Pipeline #63725 failed
// Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) // Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include <aocommon/parallelfor.h> #include <aocommon/staticfor.h>
#include <fftw3.h> #include <fftw3.h>
#include <algorithm> #include <algorithm>
...@@ -108,7 +108,7 @@ void WeighVisibilities(size_t n_threads, ...@@ -108,7 +108,7 @@ void WeighVisibilities(size_t n_threads,
assert(uv_pixels.shape()[1] == n_baselines); assert(uv_pixels.shape()[1] == n_baselines);
assert(uv_pixels.shape()[2] == n_channels); assert(uv_pixels.shape()[2] == n_channels);
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
loop.Run(0, n_baselines, [&](size_t bl, size_t /*thread*/) { loop.Run(0, n_baselines, [&](size_t bl, size_t /*thread*/) {
for (size_t chan = 0; chan < n_channels; ++chan) { for (size_t chan = 0; chan < n_channels; ++chan) {
for (size_t cor = 0; cor < n_correlations; ++cor) { for (size_t cor = 0; cor < n_correlations; ++cor) {
...@@ -160,7 +160,7 @@ void VisibilitiesToSubgrids( ...@@ -160,7 +160,7 @@ void VisibilitiesToSubgrids(
const xt::xtensor<float, 1> wavenumbers = ComputeWavenumbers(frequencies); const xt::xtensor<float, 1> wavenumbers = ComputeWavenumbers(frequencies);
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
loop.Run(0, n_baselines, [&](size_t bl, size_t /*thread*/) { loop.Run(0, n_baselines, [&](size_t bl, size_t /*thread*/) {
// Load metadata // Load metadata
const SubgridMetadata m = metadata(bl); const SubgridMetadata m = metadata(bl);
...@@ -226,7 +226,7 @@ void ApplySubgridFFT(size_t n_threads, ...@@ -226,7 +226,7 @@ void ApplySubgridFFT(size_t n_threads,
fftwf_complex* out = in; fftwf_complex* out = in;
plan = fftwf_plan_dft_2d(size, size, in, out, sign, FFTW_ESTIMATE); plan = fftwf_plan_dft_2d(size, size, in, out, sign, FFTW_ESTIMATE);
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
loop.Run(0, n_subgrids, [&](size_t i, size_t /*thread*/) { loop.Run(0, n_subgrids, [&](size_t i, size_t /*thread*/) {
fftwf_complex* subgrid = fftwf_complex* subgrid =
reinterpret_cast<fftwf_complex*>(&subgrids(i, 0, 0)); reinterpret_cast<fftwf_complex*>(&subgrids(i, 0, 0));
...@@ -247,7 +247,7 @@ void SubgridsToGrid(size_t n_threads, size_t subgrid_size, size_t grid_size, ...@@ -247,7 +247,7 @@ void SubgridsToGrid(size_t n_threads, size_t subgrid_size, size_t grid_size,
const xt::xtensor<SubgridMetadata, 1>& metadata, const xt::xtensor<SubgridMetadata, 1>& metadata,
const xt::xtensor<std::complex<float>, 3>& subgrids, const xt::xtensor<std::complex<float>, 3>& subgrids,
xt::xtensor<std::complex<float>, 2>& grid) { xt::xtensor<std::complex<float>, 2>& grid) {
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
const size_t nr_subgrids = metadata.size(); const size_t nr_subgrids = metadata.size();
...@@ -279,7 +279,7 @@ void SubgridsToTiles(size_t n_threads, size_t tile_size, size_t grid_size, ...@@ -279,7 +279,7 @@ void SubgridsToTiles(size_t n_threads, size_t tile_size, size_t grid_size,
const size_t subgrid_size = subgrids.shape()[1]; const size_t subgrid_size = subgrids.shape()[1];
assert(subgrid_size == subgrids.shape()[2]); assert(subgrid_size == subgrids.shape()[2]);
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
// Precompute phasor // Precompute phasor
xt::xtensor<float, 2> phase({subgrid_size, subgrid_size}); xt::xtensor<float, 2> phase({subgrid_size, subgrid_size});
...@@ -440,7 +440,7 @@ void ApplyGridFFT(size_t n_threads, xt::xtensor<std::complex<float>, 2>& in, ...@@ -440,7 +440,7 @@ void ApplyGridFFT(size_t n_threads, xt::xtensor<std::complex<float>, 2>& in,
fftwf_plan plan = fftwf_plan plan =
fftwf_plan_dft_1d(size, nullptr, nullptr, sign, FFTW_ESTIMATE); fftwf_plan_dft_1d(size, nullptr, nullptr, sign, FFTW_ESTIMATE);
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
xt::xtensor<std::complex<float>, 2> temp({size, size}, 0); xt::xtensor<std::complex<float>, 2> temp({size, size}, 0);
...@@ -502,7 +502,7 @@ void ApplyPhasor(size_t tile_idx, float image_size, float w_step, float tile_z, ...@@ -502,7 +502,7 @@ void ApplyPhasor(size_t tile_idx, float image_size, float w_step, float tile_z,
} // end for y } // end for y
} // end ApplyPhasor } // end ApplyPhasor
void PaddedTilesToGrid(aocommon::ParallelFor<size_t>& loop, size_t n_tiles, void PaddedTilesToGrid(aocommon::StaticFor<size_t>& loop, size_t n_tiles,
size_t tile_offset, size_t tile_offset,
const xt::xtensor<TileMetadata, 1>& metadata, const xt::xtensor<TileMetadata, 1>& metadata,
const xt::xtensor<std::complex<float>, 3>& tiles, const xt::xtensor<std::complex<float>, 3>& tiles,
...@@ -554,7 +554,7 @@ void TilesToGrid(size_t n_threads, float image_size, float w_step, ...@@ -554,7 +554,7 @@ void TilesToGrid(size_t n_threads, float image_size, float w_step,
fftwf_plan plan_backward = fftwf_plan_dft_1d( fftwf_plan plan_backward = fftwf_plan_dft_1d(
padded_tile_size, nullptr, nullptr, FFTW_BACKWARD, FFTW_ESTIMATE); padded_tile_size, nullptr, nullptr, FFTW_BACKWARD, FFTW_ESTIMATE);
aocommon::ParallelFor<size_t> loop(n_threads); aocommon::StaticFor<size_t> loop(n_threads);
const size_t n_tiles = tiles.shape()[0]; const size_t n_tiles = tiles.shape()[0];
size_t current_n_tiles = 0; size_t current_n_tiles = 0;
...@@ -632,7 +632,7 @@ void Imager::Initialize(const xt::xtensor<double, 1>& frequencies, ...@@ -632,7 +632,7 @@ void Imager::Initialize(const xt::xtensor<double, 1>& frequencies,
// Initialize per baseline metadata // Initialize per baseline metadata
subgrid_metadata_.resize({n_baselines}); subgrid_metadata_.resize({n_baselines});
uv_pixels_.resize({2, n_baselines, n_channels}); uv_pixels_.resize({2, n_baselines, n_channels});
aocommon::ParallelFor<size_t> loop(1); aocommon::StaticFor<size_t> loop(1);
loop.Run(0, n_baselines, [&](size_t bl, size_t /*thread*/) { loop.Run(0, n_baselines, [&](size_t bl, size_t /*thread*/) {
const double u_meters = uvw(bl, 0); const double u_meters = uvw(bl, 0);
const double v_meters = uvw(bl, 1); const double v_meters = uvw(bl, 1);
...@@ -824,7 +824,7 @@ xt::xtensor<float, 2> Imager::GetImage() { ...@@ -824,7 +824,7 @@ xt::xtensor<float, 2> Imager::GetImage() {
const size_t x_start = y_start; const size_t x_start = y_start;
const size_t x_end = y_end; const size_t x_end = y_end;
aocommon::ParallelFor<size_t> loop(n_threads_); aocommon::StaticFor<size_t> loop(n_threads_);
loop.Run(y_start, y_end, [&](size_t y, size_t /*thread*/) { loop.Run(y_start, y_end, [&](size_t y, size_t /*thread*/) {
for (size_t x = x_start; x < x_end; ++x) { for (size_t x = x_start; x < x_end; ++x) {
const size_t y_src = (y + (padded_grid_size_ / 2)) % padded_grid_size_; const size_t y_src = (y + (padded_grid_size_ / 2)) % padded_grid_size_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment