Skip to content

Commit

Permalink
fixes so that MPI code compiles when MPICC is a C++ compiler, even if…
Browse files Browse the repository at this point in the history
… the serial code is compiled with a C compiler; thanks to Kyle Spyksma for the bug report
  • Loading branch information
stevengj committed Aug 5, 2011
1 parent d7feb2d commit 6fbb063
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 10 deletions.
12 changes: 12 additions & 0 deletions api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@

#include "fftw3.h"
#include "ifftw.h"
#include "rdft.h"

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

/* the API ``plan'' contains both the kernel plan and problem */
struct X(plan_s) {
Expand Down Expand Up @@ -95,4 +101,10 @@ void X(mapflags)(planner *, unsigned);

apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb);

rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind);

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* __API_H__ */
2 changes: 0 additions & 2 deletions api/plan-guru-r2r.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "api.h"
#include "rdft.h"

rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind);

X(plan) XGURU(r2r)(int rank, const IODIM *dims,
int howmany_rank,
const IODIM *howmany_dims,
Expand Down
2 changes: 0 additions & 2 deletions api/plan-many-r2r.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "api.h"
#include "rdft.h"

rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind);

#define N0(nembed)((nembed) ? (nembed) : n)

X(plan) X(plan_many_r2r)(int rank, const int *n,
Expand Down
9 changes: 9 additions & 0 deletions dft/dft.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "ifftw.h"
#include "codelet-dft.h"

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

/* problem.c: */
typedef struct {
problem super;
Expand Down Expand Up @@ -76,4 +81,8 @@ void X(ct_genericbuf_register)(planner *p);
/* configurations */
void X(dft_conf_standard)(planner *p);

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* __DFT_H__ */
9 changes: 9 additions & 0 deletions kernel/ifftw.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
# include <inttypes.h> /* uintptr_t, maybe */
#endif

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

/* Windows annoyances -- since tests/hook.c uses some internal
FFTW functions, we need to given them the dllexport attribute
under Windows when compiling as a DLL (see api/fftw3.h). */
Expand Down Expand Up @@ -1120,4 +1125,8 @@ static __inline__ E FNMS(E a, E b, E c)
#define FNMS(a, b, c) ((c) - ((a) * (b)))
#endif

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* __IFFTW_H__ */
4 changes: 1 addition & 3 deletions mpi/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static dtensor *default_sz(int rnk, const XM(ddim) *dims0, int n_pes,
block sizes weren't specified (i.e. 0), then set the
unspecified blocks so as to use as many processes as
possible with as few distributed dimensions as possible. */
for (k = IB; k <= OB; ++k) {
FORALL_BLOCK_KIND(k) {
INT nb = XM(num_blocks_total)(sz, k);
INT np = n_pes / nb;
for (i = 0; i < rnk && np > 1; ++i)
Expand Down Expand Up @@ -635,8 +635,6 @@ X(plan) XM(plan_dft_3d)(ptrdiff_t nx, ptrdiff_t ny, ptrdiff_t nz,
/*************************************************************************/
/* R2R API */

extern rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind);

X(plan) XM(plan_guru_r2r)(int rnk, const XM(ddim) *dims0,
ptrdiff_t howmany,
R *in, R *out,
Expand Down
2 changes: 1 addition & 1 deletion mpi/dtensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dtensor *XM(dtensor_canonical)(const dtensor *sz, int compress)
for (i = rnk = 0; i < sz->rnk; ++i) {
if (!compress || sz->dims[i].n > 1) {
x->dims[rnk].n = sz->dims[i].n;
for (k = IB; k <= OB; ++k) {
FORALL_BLOCK_KIND(k) {
if (XM(num_blocks)(sz->dims[i].n, sz->dims[i].b[k]) == 1)
x->dims[rnk].b[k] = sz->dims[i].n;
else
Expand Down
5 changes: 4 additions & 1 deletion mpi/ifftw-mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ typedef struct {
INT b[2]; /* b[IB], b[OB] */
} ddim;

/* Loop over k in {IB, OB}. Note: need explicit casts for C++. */
#define FORALL_BLOCK_KIND(k) for (k = IB; k <= OB; k = (block_kind) (((int) k) + 1))

/* unlike tensors in the serial FFTW, the ordering of the dtensor
dimensions matters - both the array and the block layout are
row-major order. */
Expand Down Expand Up @@ -136,7 +139,7 @@ typedef enum {

/* skipping SQUARE_AFTER since it doesn't seem to offer any advantage
over SQUARE_BEFORE */
#define FORALL_REARRANGE(rearrange) for (rearrange = CONTIG; rearrange <= SQUARE_MIDDLE; ++rearrange)
#define FORALL_REARRANGE(rearrange) for (rearrange = CONTIG; rearrange <= SQUARE_MIDDLE; rearrange = (rearrangement) (((int) rearrange) + 1))

int XM(rearrange_applicable)(rearrangement rearrange,
ddim dim0, INT vn, int n_pes);
Expand Down
2 changes: 1 addition & 1 deletion mpi/mpi-bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "fftw-bench.h"
#include "fftw3-mpi.h"
#include "fftw-bench.h"

#if defined(BENCHFFT_SINGLE)
# define BENCH_MPI_TYPE MPI_FLOAT
Expand Down
9 changes: 9 additions & 0 deletions rdft/rdft.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include "ifftw.h"
#include "codelet-rdft.h"

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

/* problem.c: */
typedef struct {
problem super;
Expand Down Expand Up @@ -164,4 +169,8 @@ void X(rdft2_rank_geq2_register)(planner *p);
/* configurations */
void X(rdft_conf_standard)(planner *p);

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* __RDFT_H__ */

0 comments on commit 6fbb063

Please sign in to comment.