Skip to content

Reduce number of exported symbols in shared library #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions fortran/finufftfort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern "C" {
#endif

// --------------------- guru interface from fortran ------------------------
FINUFFT_EXPORT
void finufft_makeplan_(int *type, int *n_dims, i64 *n_modes, int *iflag, int *n_transf,
f64 *tol, finufft_plan *plan, finufft_opts *o, int *ier) {
if (!plan)
Expand All @@ -45,6 +46,7 @@ void finufft_makeplan_(int *type, int *n_dims, i64 *n_modes, int *iflag, int *n_
}
}

FINUFFT_EXPORT
void finufft_setpts_(finufft_plan *plan, i64 *M, f64 *xj, f64 *yj, f64 *zj, i64 *nk,
f64 *s, f64 *t, f64 *u, int *ier) {
if (!*plan) {
Expand All @@ -56,13 +58,15 @@ void finufft_setpts_(finufft_plan *plan, i64 *M, f64 *xj, f64 *yj, f64 *zj, i64
*ier = finufft_setpts(*plan, *M, xj, yj, zj, nk_safe, s, t, u);
}

FINUFFT_EXPORT
void finufft_execute_(finufft_plan *plan, c128 *weights, c128 *result, int *ier) {
if (!plan)
fprintf(stderr, "%s fortran: finufft_plan unallocated!", __func__);
else
*ier = finufft_execute(*plan, weights, result);
}

FINUFFT_EXPORT
void finufft_destroy_(finufft_plan *plan, int *ier) {
if (!plan)
fprintf(stderr, "%s fortran: finufft_plan unallocated!", __func__);
Expand All @@ -72,6 +76,7 @@ void finufft_destroy_(finufft_plan *plan, int *ier) {

// ------------ use FINUFFT to set the default options ---------------------
// (Note the finufft_opts is created in f90-style derived types, not here)
FINUFFT_EXPORT
void finufft_default_opts_(finufft_opts *o) {
if (!o)
fprintf(stderr, "%s fortran: opts must be allocated!\n", __func__);
Expand All @@ -82,102 +87,121 @@ void finufft_default_opts_(finufft_opts *o) {

// -------------- simple and many-vector interfaces --------------------
// --- 1D ---
FINUFFT_EXPORT
void finufft1d1_(i64 *nj, f64 *xj, c128 *cj, int *iflag, f64 *eps, i64 *ms, c128 *fk,
finufft_opts *o, int *ier) {
*ier = finufft1d1(*nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufft1d1many_(int *ntransf, i64 *nj, f64 *xj, c128 *cj, int *iflag, f64 *eps,
i64 *ms, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft1d1many(*ntransf, *nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufft1d2_(i64 *nj, f64 *xj, c128 *cj, int *iflag, f64 *eps, i64 *ms, c128 *fk,
finufft_opts *o, int *ier) {
*ier = finufft1d2(*nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufft1d2many_(int *ntransf, i64 *nj, f64 *xj, c128 *cj, int *iflag, f64 *eps,
i64 *ms, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft1d2many(*ntransf, *nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufft1d3_(i64 *nj, f64 *x, c128 *c, int *iflag, f64 *eps, i64 *nk, f64 *s, c128 *f,
finufft_opts *o, int *ier) {
*ier = finufft1d3(*nj, x, c, *iflag, *eps, *nk, s, f, o);
}

FINUFFT_EXPORT
void finufft1d3many_(int *ntransf, i64 *nj, f64 *x, c128 *c, int *iflag, f64 *eps,
i64 *nk, f64 *s, c128 *f, finufft_opts *o, int *ier) {
*ier = finufft1d3many(*ntransf, *nj, x, c, *iflag, *eps, *nk, s, f, o);
}

// --- 2D ---
FINUFFT_EXPORT
void finufft2d1_(i64 *nj, f64 *xj, f64 *yj, c128 *cj, int *iflag, f64 *eps, i64 *ms,
i64 *mt, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft2d1(*nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}
FINUFFT_EXPORT
void finufft2d1many_(int *ntransf, i64 *nj, f64 *xj, f64 *yj, c128 *cj, int *iflag,
f64 *eps, i64 *ms, i64 *mt, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft2d1many(*ntransf, *nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}

FINUFFT_EXPORT
void finufft2d2_(i64 *nj, f64 *xj, f64 *yj, c128 *cj, int *iflag, f64 *eps, i64 *ms,
i64 *mt, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft2d2(*nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}
FINUFFT_EXPORT
void finufft2d2many_(int *ntransf, i64 *nj, f64 *xj, f64 *yj, c128 *cj, int *iflag,
f64 *eps, i64 *ms, i64 *mt, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft2d2many(*ntransf, *nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}

FINUFFT_EXPORT
void finufft2d3_(i64 *nj, f64 *x, f64 *y, c128 *c, int *iflag, f64 *eps, i64 *nk, f64 *s,
f64 *t, c128 *f, finufft_opts *o, int *ier) {
*ier = finufft2d3(*nj, x, y, c, *iflag, *eps, *nk, s, t, f, o);
}

FINUFFT_EXPORT
void finufft2d3many_(int *ntransf, i64 *nj, f64 *x, f64 *y, c128 *c, int *iflag, f64 *eps,
i64 *nk, f64 *s, f64 *t, c128 *f, finufft_opts *o, int *ier) {
*ier = finufft2d3many(*ntransf, *nj, x, y, c, *iflag, *eps, *nk, s, t, f, o);
}

// --- 3D ---
FINUFFT_EXPORT
void finufft3d1_(i64 *nj, f64 *xj, f64 *yj, f64 *zj, c128 *cj, int *iflag, f64 *eps,
i64 *ms, i64 *mt, i64 *mu, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft3d1(*nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufft3d1many_(int *ntransf, i64 *nj, f64 *xj, f64 *yj, f64 *zj, c128 *cj,
int *iflag, f64 *eps, i64 *ms, i64 *mt, i64 *mu, c128 *fk,
finufft_opts *o, int *ier) {
*ier =
finufft3d1many(*ntransf, *nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufft3d2_(i64 *nj, f64 *xj, f64 *yj, f64 *zj, c128 *cj, int *iflag, f64 *eps,
i64 *ms, i64 *mt, i64 *mu, c128 *fk, finufft_opts *o, int *ier) {
*ier = finufft3d2(*nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufft3d2many_(int *ntransf, i64 *nj, f64 *xj, f64 *yj, f64 *zj, c128 *cj,
int *iflag, f64 *eps, i64 *ms, i64 *mt, i64 *mu, c128 *fk,
finufft_opts *o, int *ier) {
*ier =
finufft3d2many(*ntransf, *nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufft3d3_(i64 *nj, f64 *x, f64 *y, f64 *z, c128 *c, int *iflag, f64 *eps, i64 *nk,
f64 *s, f64 *t, f64 *u, c128 *f, finufft_opts *o, int *ier) {
*ier = finufft3d3(*nj, x, y, z, c, *iflag, *eps, *nk, s, t, u, f, o);
}

FINUFFT_EXPORT
void finufft3d3many_(int *ntransf, i64 *nj, f64 *x, f64 *y, f64 *z, c128 *c, int *iflag,
f64 *eps, i64 *nk, f64 *s, f64 *t, f64 *u, c128 *f, finufft_opts *o,
int *ier) {
*ier = finufft3d3many(*ntransf, *nj, x, y, z, c, *iflag, *eps, *nk, s, t, u, f, o);
}

// --------------------- guru interface from fortran ------------------------
FINUFFT_EXPORT
void finufftf_makeplan_(int *type, int *n_dims, i64 *n_modes, int *iflag, int *n_transf,
f32 *tol, finufftf_plan *plan, finufft_opts *o, int *ier) {
if (!plan)
Expand All @@ -191,6 +215,7 @@ void finufftf_makeplan_(int *type, int *n_dims, i64 *n_modes, int *iflag, int *n
}
}

FINUFFT_EXPORT
void finufftf_setpts_(finufftf_plan *plan, i64 *M, f32 *xj, f32 *yj, f32 *zj, i64 *nk,
f32 *s, f32 *t, f32 *u, int *ier) {
if (!*plan) {
Expand All @@ -202,13 +227,15 @@ void finufftf_setpts_(finufftf_plan *plan, i64 *M, f32 *xj, f32 *yj, f32 *zj, i6
*ier = finufftf_setpts(*plan, *M, xj, yj, zj, nk_safe, s, t, u);
}

FINUFFT_EXPORT
void finufftf_execute_(finufftf_plan *plan, c64 *weights, c64 *result, int *ier) {
if (!plan)
fprintf(stderr, "%s fortran: finufft_plan unallocated!", __func__);
else
*ier = finufftf_execute(*plan, weights, result);
}

FINUFFT_EXPORT
void finufftf_destroy_(finufftf_plan *plan, int *ier) {
if (!plan)
fprintf(stderr, "%s fortran: finufft_plan unallocated!", __func__);
Expand All @@ -218,6 +245,7 @@ void finufftf_destroy_(finufftf_plan *plan, int *ier) {

// ------------ use FINUFFT to set the default options ---------------------
// (Note the finufft_opts is created in f90-style derived types, not here)
FINUFFT_EXPORT
void finufftf_default_opts_(finufft_opts *o) {
if (!o)
fprintf(stderr, "%s fortran: opts must be allocated!\n", __func__);
Expand All @@ -228,95 +256,113 @@ void finufftf_default_opts_(finufft_opts *o) {

// -------------- simple and many-vector interfaces --------------------
// --- 1D ---
FINUFFT_EXPORT
void finufftf1d1_(i64 *nj, f32 *xj, c64 *cj, int *iflag, f32 *eps, i64 *ms, c64 *fk,
finufft_opts *o, int *ier) {
*ier = finufftf1d1(*nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufftf1d1many_(int *ntransf, i64 *nj, f32 *xj, c64 *cj, int *iflag, f32 *eps,
i64 *ms, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf1d1many(*ntransf, *nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufftf1d2_(i64 *nj, f32 *xj, c64 *cj, int *iflag, f32 *eps, i64 *ms, c64 *fk,
finufft_opts *o, int *ier) {
*ier = finufftf1d2(*nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufftf1d2many_(int *ntransf, i64 *nj, f32 *xj, c64 *cj, int *iflag, f32 *eps,
i64 *ms, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf1d2many(*ntransf, *nj, xj, cj, *iflag, *eps, *ms, fk, o);
}

FINUFFT_EXPORT
void finufftf1d3_(i64 *nj, f32 *x, c64 *c, int *iflag, f32 *eps, i64 *nk, f32 *s, c64 *f,
finufft_opts *o, int *ier) {
*ier = finufftf1d3(*nj, x, c, *iflag, *eps, *nk, s, f, o);
}

FINUFFT_EXPORT
void finufftf1d3many_(int *ntransf, i64 *nj, f32 *x, c64 *c, int *iflag, f32 *eps,
i64 *nk, f32 *s, c64 *f, finufft_opts *o, int *ier) {
*ier = finufftf1d3many(*ntransf, *nj, x, c, *iflag, *eps, *nk, s, f, o);
}

// --- 2D ---
FINUFFT_EXPORT
void finufftf2d1_(i64 *nj, f32 *xj, f32 *yj, c64 *cj, int *iflag, f32 *eps, i64 *ms,
i64 *mt, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf2d1(*nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}
FINUFFT_EXPORT
void finufftf2d1many_(int *ntransf, i64 *nj, f32 *xj, f32 *yj, c64 *cj, int *iflag,
f32 *eps, i64 *ms, i64 *mt, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf2d1many(*ntransf, *nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}

FINUFFT_EXPORT
void finufftf2d2_(i64 *nj, f32 *xj, f32 *yj, c64 *cj, int *iflag, f32 *eps, i64 *ms,
i64 *mt, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf2d2(*nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}
FINUFFT_EXPORT
void finufftf2d2many_(int *ntransf, i64 *nj, f32 *xj, f32 *yj, c64 *cj, int *iflag,
f32 *eps, i64 *ms, i64 *mt, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf2d2many(*ntransf, *nj, xj, yj, cj, *iflag, *eps, *ms, *mt, fk, o);
}

FINUFFT_EXPORT
void finufftf2d3_(i64 *nj, f32 *x, f32 *y, c64 *c, int *iflag, f32 *eps, i64 *nk, f32 *s,
f32 *t, c64 *f, finufft_opts *o, int *ier) {
*ier = finufftf2d3(*nj, x, y, c, *iflag, *eps, *nk, s, t, f, o);
}

FINUFFT_EXPORT
void finufftf2d3many_(int *ntransf, i64 *nj, f32 *x, f32 *y, c64 *c, int *iflag, f32 *eps,
i64 *nk, f32 *s, f32 *t, c64 *f, finufft_opts *o, int *ier) {
*ier = finufftf2d3many(*ntransf, *nj, x, y, c, *iflag, *eps, *nk, s, t, f, o);
}

// --- 3D ---
FINUFFT_EXPORT
void finufftf3d1_(i64 *nj, f32 *xj, f32 *yj, f32 *zj, c64 *cj, int *iflag, f32 *eps,
i64 *ms, i64 *mt, i64 *mu, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf3d1(*nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufftf3d1many_(int *ntransf, i64 *nj, f32 *xj, f32 *yj, f32 *zj, c64 *cj,
int *iflag, f32 *eps, i64 *ms, i64 *mt, i64 *mu, c64 *fk,
finufft_opts *o, int *ier) {
*ier =
finufftf3d1many(*ntransf, *nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufftf3d2_(i64 *nj, f32 *xj, f32 *yj, f32 *zj, c64 *cj, int *iflag, f32 *eps,
i64 *ms, i64 *mt, i64 *mu, c64 *fk, finufft_opts *o, int *ier) {
*ier = finufftf3d2(*nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufftf3d2many_(int *ntransf, i64 *nj, f32 *xj, f32 *yj, f32 *zj, c64 *cj,
int *iflag, f32 *eps, i64 *ms, i64 *mt, i64 *mu, c64 *fk,
finufft_opts *o, int *ier) {
*ier =
finufftf3d2many(*ntransf, *nj, xj, yj, zj, cj, *iflag, *eps, *ms, *mt, *mu, fk, o);
}

FINUFFT_EXPORT
void finufftf3d3_(i64 *nj, f32 *x, f32 *y, f32 *z, c64 *c, int *iflag, f32 *eps, i64 *nk,
f32 *s, f32 *t, f32 *u, c64 *f, finufft_opts *o, int *ier) {
*ier = finufftf3d3(*nj, x, y, z, c, *iflag, *eps, *nk, s, t, u, f, o);
}

FINUFFT_EXPORT
void finufftf3d3many_(int *ntransf, i64 *nj, f32 *x, f32 *y, f32 *z, c64 *c, int *iflag,
f32 *eps, i64 *nk, f32 *s, f32 *t, f32 *u, c64 *f, finufft_opts *o,
int *ier) {
Expand Down
6 changes: 5 additions & 1 deletion include/finufft/finufft_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
these defines.The main reason is that if msvc changes the way it deals
with it in the future we just need to update cmake for it to work
instead of having a check on the msvc version. */
#if defined(FINUFFT_DLL) && (defined(_WIN32) || defined(__WIN32__))
#if defined(FINUFFT_DLL)
#if (defined(_WIN32) || defined(__WIN32__))
#if defined(dll_EXPORTS)
#define FINUFFT_EXPORT __declspec(dllexport)
#else
#define FINUFFT_EXPORT __declspec(dllimport)
#endif
#else
#define FINUFFT_EXPORT __attribute__((visibility("default")))
#endif
#else
#define FINUFFT_EXPORT
#endif

Expand Down
6 changes: 5 additions & 1 deletion include/finufft_eitherprec.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
these defines.The main reason is that if msvc changes the way it deals
with it in the future we just need to update cmake for it to work
instead of having a check on the msvc version. */
#if defined(FINUFFT_DLL) && (defined(_WIN32) || defined(__WIN32__))
#if defined(FINUFFT_DLL)
#if (defined(_WIN32) || defined(__WIN32__))
#if defined(dll_EXPORTS)
#define FINUFFT_EXPORT __declspec(dllexport)
#else
#define FINUFFT_EXPORT __declspec(dllimport)
#endif
#else
#define FINUFFT_EXPORT __attribute__((visibility("default")))
#endif
#else
#define FINUFFT_EXPORT
#endif

Expand Down
6 changes: 5 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PYTHON = python3
# they allow gcc to vectorize the code more effectively
CFLAGS := -O3 -funroll-loops -march=native -fcx-limited-range -ffp-contract=fast\
-fno-math-errno -fno-signed-zeros -fno-trapping-math -fassociative-math\
-freciprocal-math -fmerge-all-constants -ftree-vectorize $(CFLAGS) -Wfatal-errors
-freciprocal-math -fmerge-all-constants -ftree-vectorize $(CFLAGS) -Wfatal-errors -fvisibility=hidden
FFLAGS := $(CFLAGS) $(FFLAGS)
CXXFLAGS := $(CFLAGS) $(CXXFLAGS)
# FFTW base name, and math linking...
Expand Down Expand Up @@ -179,6 +179,10 @@ HEADERS = $(wildcard include/*.h include/finufft/*.h)
# implicit rules for objects (note -o ensures writes to correct dir)
%.o: %.cpp $(HEADERS)
$(CXX) -c $(CXXFLAGS) $< -o $@
src/%.o: src/%.cpp $(HEADERS)
$(CXX) -DFINUFFT_DLL -Ddll_EXPORTS -c $(CXXFLAGS) $< -o $@
fortran/%.o: fortran/%.cpp $(HEADERS)
$(CXX) -DFINUFFT_DLL -Ddll_EXPORTS -c $(CXXFLAGS) $< -o $@
%.o: %.c $(HEADERS)
$(CC) -c $(CFLAGS) $< -o $@
%.o: %.f
Expand Down
Loading