/* * Copyright (c) 2010-2013 Michael Pippig * * This file is part of PFFT. * * PFFT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * PFFT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with PFFT. If not, see . * */ #include "pfft.h" #include "ipfft.h" #include "util.h" static void calculate_3dto2d_blocks( const INT *n, MPI_Comm comm_cart_3d, INT *iblk); INT PX(local_size_many_dft)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, MPI_Comm comm_cart, unsigned pfft_flags, INT *local_ni, INT *local_i_start, INT *local_no, INT *local_o_start ) { return PX(local_size_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, comm_cart, PFFTI_TRAFO_C2C, pfft_flags, local_ni, local_i_start, local_no, local_o_start); } INT PX(local_size_many_dft_r2c)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, MPI_Comm comm_cart, unsigned pfft_flags, INT *local_ni, INT *local_i_start, INT *local_no, INT *local_o_start ) { unsigned trafo_flag = (pfft_flags & PFFT_PADDED_R2C) ? PFFTI_TRAFO_R2C_PADDED : PFFTI_TRAFO_R2C; return PX(local_size_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, comm_cart, trafo_flag, pfft_flags, local_ni, local_i_start, local_no, local_o_start); } INT PX(local_size_many_dft_c2r)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, MPI_Comm comm_cart, unsigned pfft_flags, INT *local_ni, INT *local_i_start, INT *local_no, INT *local_o_start ) { unsigned trafo_flag = (pfft_flags & PFFT_PADDED_C2R) ? PFFTI_TRAFO_C2R_PADDED : PFFTI_TRAFO_C2R; return PX(local_size_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, comm_cart, trafo_flag, pfft_flags, local_ni, local_i_start, local_no, local_o_start); } INT PX(local_size_many_r2r)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, MPI_Comm comm_cart, unsigned pfft_flags, INT *local_ni, INT *local_i_start, INT *local_no, INT *local_o_start ) { return PX(local_size_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, comm_cart, PFFTI_TRAFO_R2R, pfft_flags, local_ni, local_i_start, local_no, local_o_start); } PX(plan) PX(plan_many_dft)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, C *in, C *out, MPI_Comm comm_cart, int sign, unsigned pfft_flags ) { X(r2r_kind) *kinds=NULL; int *skip_trafos=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, (R*) in, (R*) out, comm_cart, sign, kinds, skip_trafos, PFFTI_TRAFO_C2C, pfft_flags); } PX(plan) PX(plan_many_dft_r2c)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, R *in, C *out, MPI_Comm comm_cart, int sign, unsigned pfft_flags ) { unsigned trafo_flag = (pfft_flags & PFFT_PADDED_R2C) ? PFFTI_TRAFO_R2C_PADDED : PFFTI_TRAFO_R2C; X(r2r_kind) *kinds=NULL; int *skip_trafos=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, in, (R*) out, comm_cart, sign, kinds, skip_trafos, trafo_flag, pfft_flags); } PX(plan) PX(plan_many_dft_c2r)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, C *in, R *out, MPI_Comm comm_cart, int sign, unsigned pfft_flags ) { unsigned trafo_flag = (pfft_flags & PFFT_PADDED_C2R) ? PFFTI_TRAFO_C2R_PADDED : PFFTI_TRAFO_C2R; X(r2r_kind) *kinds=NULL; int *skip_trafos=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, (R*) in, out, comm_cart, sign, kinds, skip_trafos, trafo_flag, pfft_flags); } PX(plan) PX(plan_many_r2r)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, R *in, R *out, MPI_Comm comm_cart, const PX(r2r_kind) *kinds, unsigned pfft_flags ) { int sign=0; int *skip_trafos=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, in, out, comm_cart, sign, kinds, skip_trafos, PFFTI_TRAFO_R2R, pfft_flags); } PX(plan) PX(plan_many_dft_skipped)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, const int *skip_trafos, C *in, C *out, MPI_Comm comm_cart, int sign, unsigned pfft_flags ) { X(r2r_kind) *kinds=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, (R*) in, (R*) out, comm_cart, sign, kinds, skip_trafos, PFFTI_TRAFO_C2C, pfft_flags); } PX(plan) PX(plan_many_dft_r2c_skipped)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, const int *skip_trafos, R *in, C *out, MPI_Comm comm_cart, int sign, unsigned pfft_flags ) { unsigned trafo_flag = (pfft_flags & PFFT_PADDED_R2C) ? PFFTI_TRAFO_R2C_PADDED : PFFTI_TRAFO_R2C; X(r2r_kind) *kinds=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, in, (R*) out, comm_cart, sign, kinds, skip_trafos, trafo_flag, pfft_flags); } PX(plan) PX(plan_many_dft_c2r_skipped)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, const int *skip_trafos, C *in, R *out, MPI_Comm comm_cart, int sign, unsigned pfft_flags ) { unsigned trafo_flag = (pfft_flags & PFFT_PADDED_C2R) ? PFFTI_TRAFO_C2R_PADDED : PFFTI_TRAFO_C2R; X(r2r_kind) *kinds=NULL; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, (R*) in, out, comm_cart, sign, kinds, skip_trafos, trafo_flag, pfft_flags); } PX(plan) PX(plan_many_r2r_skipped)( int rnk_n, const INT *n, const INT *ni, const INT *no, INT howmany, const INT *iblock, const INT *oblock, const int *skip_trafos, R *in, R *out, MPI_Comm comm_cart, const PX(r2r_kind) *kinds, unsigned pfft_flags ) { int sign=0; return PX(plan_partrafo)( rnk_n, n, ni, no, howmany, iblock, oblock, in, out, comm_cart, sign, kinds, skip_trafos, PFFTI_TRAFO_R2R, pfft_flags); } INT PX(local_size_many_gc)( int rnk_n, const INT *local_n, const INT *local_start, INT howmany, const INT *gc_below, const INT *gc_above, INT *local_ngc, INT *local_gc_start ) { return PX(local_size_gc_internal)( rnk_n, local_n, local_start, howmany, gc_below, gc_above, local_ngc, local_gc_start); } PX(gcplan) PX(plan_many_rgc)( int rnk_n, const INT *n, INT howmany, const INT *block, const INT *gc_below, const INT *gc_above, R *data, MPI_Comm comm, unsigned gc_flags ) { int rnk_pm; INT blk_3dto2d[3]; MPI_Comm *comms_pm; PX(gcplan) ths; MPI_Comm comm_cart = PX(assure_cart_comm)(comm); INT *pn = PX(malloc_INT)(rnk_n); for(int t=0; t