Skip to content

Commit

Permalink
fft: remove use of dynamically sized arrays (not c++ std), use std::v…
Browse files Browse the repository at this point in the history
…ector instead
  • Loading branch information
KariRummukainen committed Sep 2, 2024
1 parent beea88f commit 9423558
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions libraries/plumbing/backend_gpu/fft_gpu_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ void hila_fft<cmplx_t>::gather_data() {
// post receive and send
int n_comms = hila_pencil_comms[dir].size() - 1;

MPI_Request sendreq[n_comms], recreq[n_comms];
MPI_Status stat[n_comms];
std::vector<MPI_Request> sendreq(n_comms), recreq(n_comms);
std::vector<MPI_Status> stat(n_comms);

#ifndef GPU_AWARE_MPI
cmplx_t *send_p[n_comms];
cmplx_t *receive_p[n_comms];
std::vector<cmplx_t *> send_p(n_comms);
std::vector<cmplx_t *> receive_p(n_comms);
#endif

int i = 0;
Expand Down Expand Up @@ -364,8 +364,8 @@ void hila_fft<cmplx_t>::gather_data() {

// and wait for the send and receive to complete
if (n_comms > 0) {
MPI_Waitall(n_comms, recreq, stat);
MPI_Waitall(n_comms, sendreq, stat);
MPI_Waitall(n_comms, recreq.data(), stat.data());
MPI_Waitall(n_comms, sendreq.data(), stat.data());

#ifndef GPU_AWARE_MPI
i = j = 0;
Expand Down Expand Up @@ -403,12 +403,12 @@ void hila_fft<cmplx_t>::scatter_data() {

int n_comms = hila_pencil_comms[dir].size() - 1;

MPI_Request sendreq[n_comms], recreq[n_comms];
MPI_Status stat[n_comms];
std::vector<MPI_Request> sendreq(n_comms), recreq(n_comms);
std::vector<MPI_Status> stat(n_comms);

#ifndef GPU_AWARE_MPI
cmplx_t *send_p[n_comms];
cmplx_t *receive_p[n_comms];
std::vector<cmplx_t *> send_p(n_comms);
std::vector<cmplx_t *> receive_p(n_comms);
#endif

int i = 0;
Expand Down Expand Up @@ -458,8 +458,8 @@ void hila_fft<cmplx_t>::scatter_data() {

// and wait for the send and receive to complete
if (n_comms > 0) {
MPI_Waitall(n_comms, recreq, stat);
MPI_Waitall(n_comms, sendreq, stat);
MPI_Waitall(n_comms, recreq.data(), stat.data());
MPI_Waitall(n_comms, sendreq.data(), stat.data());

#ifndef GPU_AWARE_MPI
i = 0;
Expand Down
16 changes: 8 additions & 8 deletions libraries/plumbing/fft_fftw_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ void hila_fft<cmplx_t>::gather_data() {
// post receive and send
int n_comms = hila_pencil_comms[dir].size() - 1;

MPI_Request sendreq[n_comms], recreq[n_comms];
MPI_Status stat[n_comms];
std::vector<MPI_Request> sendreq(n_comms), recreq(n_comms);
std::vector<MPI_Status> stat(n_comms);

int i = 0;
int j = 0;
Expand Down Expand Up @@ -180,8 +180,8 @@ void hila_fft<cmplx_t>::gather_data() {

// and wait for the send and receive to complete
if (n_comms > 0) {
MPI_Waitall(n_comms, recreq, stat);
MPI_Waitall(n_comms, sendreq, stat);
MPI_Waitall(n_comms, recreq.data(), stat.data());
MPI_Waitall(n_comms, sendreq.data(), stat.data());
}

pencil_MPI_timer.stop();
Expand All @@ -200,8 +200,8 @@ void hila_fft<cmplx_t>::scatter_data() {

int n_comms = hila_pencil_comms[dir].size() - 1;

MPI_Request sendreq[n_comms], recreq[n_comms];
MPI_Status stat[n_comms];
std::vector<MPI_Request> sendreq(n_comms), recreq(n_comms);
std::vector<MPI_Status> stat(n_comms);

int i = 0;

Expand Down Expand Up @@ -232,8 +232,8 @@ void hila_fft<cmplx_t>::scatter_data() {

// and wait for the send and receive to complete
if (n_comms > 0) {
MPI_Waitall(n_comms, recreq, stat);
MPI_Waitall(n_comms, sendreq, stat);
MPI_Waitall(n_comms, recreq.data(), stat.data());
MPI_Waitall(n_comms, sendreq.data(), stat.data());
}

pencil_MPI_timer.stop();
Expand Down

0 comments on commit 9423558

Please sign in to comment.