Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
- Replaced DTFFT_WITHOUT_FFTW with DTFFT_WITH_FFTW
- Added new error code: DTFFT_ERROR_INVALID_AUX
- Plan execution returns first detected error code, instead of last
- Fixed bug with 3d z-slab in-place transpose-only plan execution
  • Loading branch information
ShatrovOA committed Oct 13, 2024
1 parent 373f544 commit 1dfa52e
Show file tree
Hide file tree
Showing 37 changed files with 179 additions and 159 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(dtFFT VERSION 0.2.0
HOMEPAGE_URL "https://github.com/ShatrovOA/dtFFT"
LANGUAGES Fortran C CXX)

option(DTFFT_WITHOUT_FFTW "Build dtFFT without FFTW support" OFF)
option(DTFFT_WITH_FFTW "Build dtFFT with FFTW support" OFF)
option(DTFFT_WITH_MKL "Build dtFFT with MKL DFTI support" OFF)
option(DTFFT_WITH_CUFFT "Build dtFFT with cufft support" OFF)
# option(DTFFT_WITH_KFR "Build dtFFT with KFR support" OFF)
Expand Down Expand Up @@ -64,11 +64,11 @@ end program"
HAVE_BLOCK_STATEMENT
SRC_EXT .F90)

if( DTFFT_WITHOUT_FFTW
if( NOT DTFFT_WITH_FFTW
AND NOT DTFFT_WITH_MKL
# AND NOT DTFFT_WITH_KFR
AND NOT DTFFT_WITH_CUFFT
AND NOT DTFFT_WITH_VKFFT
# AND NOT DTFFT_WITH_CUFFT
# AND NOT DTFFT_WITH_VKFFT
)
set ( DTFFT_TRANSPOSE_ONLY ON )
endif()
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# dtFFT - DataTyped Fast Fourier Transform

[![Status](https://img.shields.io/badge/status-stable-brightgreen.svg)]()
![Build Status](https://github.com/ShatrovOA/dtFFT/actions/workflows/main.yml/badge.svg)
[![dtfft workflow](https://github.com/ShatrovOA/dtFFT/actions/workflows/main.yml/badge.svg)](https://github.com/ShatrovOA/dtFFT/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/ShatrovOA/dtFFT/graph/badge.svg?token=6BI4AQVH7Z)](https://codecov.io/gh/ShatrovOA/dtFFT)
[![License](https://img.shields.io/github/license/ShatrovOA/dtFFT?color=brightgreen&logo=License)]()

Expand Down Expand Up @@ -60,15 +60,15 @@ To build this library modern (2008+) Fortran compiler is required. This library

| Option | Possible values | Default value | Description |
| -------- | ------- | -------- | ------- |
| DTFFT_WITHOUT_FFTW | on / off | off | Build dtFFT without FFTW support. When `OFF` user need to set `FFTWDIR` environmental variable in order to find FFTW3. Both single and double precision versions are required |
| DTFFT_WITH_FFTW | on / off | off | Build dtFFT with FFTW support. When enabled user need to set `FFTWDIR` environmental variable in order to find FFTW3 located in custom directory. Both single and double precision versions of library are required |
| DTFFT_WITH_MKL | on / off | off | Build dtFFT with MKL DFTI support |
| DTFFT_BUILD_TESTS | on / off | off | Build tests |
| DTFFT_ENABLE_COVERAGE | on / off | off | Build coverage of library. Only possible with gfortran |
| DTFFT_BUILD_SHARED | on / off | on | Build shared library |
| DTFFT_USE_MPI | on / off | on | Use Fortran `mpi` module instead of `mpi_f08` |
| DTFFT_BUILD_C_CXX_API | on / off | on | Build C/C++ API |
| DTFFT_ENABLE_PERSISTENT_COMM | on / off | off | In case you are planning to execute plan multiple times then it can be very beneficial to use persistent communications. But user must aware that such communications are created at first call to `execute` or `transpose` subroutines and pointers are saved internally inside MPI. All other plan executions will use those pointers. Take care not to free them. |
| DTFFT_WITH_CALIPER | on / off | off | Enable library profiler via Caliper. Additional parameter is required to find caliper: `Dcaliper_DIR` |
| DTFFT_WITH_CALIPER | on / off | off | Enable library profiler via Caliper. Additional parameter is required to find caliper: `caliper_DIR` |
| DTFFT_MEASURE_ITERS | positive integer | 2 | Number of iterations to run in order to find best plan when passing `DTFFT_MEASURE` or `DTFFT_PATIENT` to effort_flag parameter during plan creation |
| DTFFT_FORWARD_X_Y | 1 / 2 | 2 | Default id of transposition plan for X -> Y transpose which will be used if plan created with `DTFFT_ESTIMATE` and `DTFFT_MEASURE` effort_flags |
| DTFFT_BACKWARD_X_Y | 1 / 2 | 2 | Default id of transposition plan for Y -> X transpose which will be used if plan created with `DTFFT_ESTIMATE` and `DTFFT_MEASURE` effort_flags |
Expand Down
15 changes: 6 additions & 9 deletions include/dtfft.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct dtfft_plan_t *dtfft_plan;
#define DTFFT_ERROR_INVALID_R2R_KINDS CONF_DTFFT_ERROR_INVALID_R2R_KINDS
#define DTFFT_ERROR_R2C_TRANSPOSE_PLAN CONF_DTFFT_ERROR_R2C_TRANSPOSE_PLAN
#define DTFFT_ERROR_INPLACE_TRANSPOSE CONF_DTFFT_ERROR_INPLACE_TRANSPOSE
#define DTFFT_ERROR_INVALID_AUX CONF_DTFFT_ERROR_INVALID_AUX
#define DTFFT_ERROR_R2R_FFT_NOT_SUPPORTED CONF_DTFFT_ERROR_R2R_FFT_NOT_SUPPORTED
#define DTFFT_ERROR_CUFFTMP_2D_PLAN CONF_DTFFT_ERROR_CUFFTMP_2D_PLAN

Expand All @@ -82,9 +83,9 @@ do { \

// dtFFT transpose_type flags

// Perform XYZ --> YXZ --> ZXY transposition
// Perform XYZ --> YXZ --> ZXY plan execution
#define DTFFT_TRANSPOSE_OUT CONF_DTFFT_TRANSPOSE_OUT
// Perform ZXY --> YXZ --> XYZ transposition
// Perform ZXY --> YXZ --> XYZ plan execution
#define DTFFT_TRANSPOSE_IN CONF_DTFFT_TRANSPOSE_IN

// Flags for transpose only plans
Expand Down Expand Up @@ -128,7 +129,7 @@ do { \
*/
// Create transpose only plan, no executor needed
#define DTFFT_EXECUTOR_NONE CONF_DTFFT_EXECUTOR_NONE
#ifndef DTFFT_WITHOUT_FFTW
#ifdef DTFFT_WITH_FFTW
// Use FFTW3
#define DTFFT_EXECUTOR_FFTW3 CONF_DTFFT_EXECUTOR_FFTW3
#endif
Expand Down Expand Up @@ -279,6 +280,8 @@ dtfft_execute(dtfft_plan plan, void *in, void *out, const int transpose_type, vo
* - `DTFFT_TRANSPOSE_Y_TO_X`
* - `DTFFT_TRANSPOSE_Y_TO_Z` (3d plan only)
* - `DTFFT_TRANSPOSE_Z_TO_Y` (3d plan only)
* - `DTFFT_TRANSPOSE_X_TO_Z` (3d plan only)
* - `DTFFT_TRANSPOSE_Z_TO_X` (3d plan only)
*
* \return `DTFFT_SUCCESS` if plan was executed, error code otherwise
*/
Expand Down Expand Up @@ -309,11 +312,8 @@ dtfft_destroy(dtfft_plan *plan);
* \param[out] out_starts Starts of local portion of data in 'fourier' space in reversed order
* \param[out] out_counts Sizes of local portion of data in 'fourier' space in reversed order
* \param[out] alloc_size Minimum number of elements needs to be allocated for `in`, `out` or `aux` buffers:
*
* - C2C plan: 2 * `alloc_size` * sizeof(double/float) or `alloc_size` * sizeof(dtfft_complex/dtfftf_complex)
*
* - R2R plan: `alloc_size` * sizeof(double/float)
*
* - R2C plan: `alloc_size` * sizeof(double/float)
* \return `DTFFT_SUCCESS` if call was successfull, error code otherwise
*/
Expand All @@ -328,11 +328,8 @@ dtfft_get_local_sizes(dtfft_plan plan, int *in_starts, int *in_counts, int *out_
*
* \param[in] plan Plan handle
* \param[out] alloc_size Minimum number of elements needs to be allocated for `in`, `out` or `aux` buffers:
*
* - C2C plan: 2 * `alloc_size` * sizeof(double/float) or `alloc_size` * sizeof(dtfft_complex/dtfftf_complex)
*
* - R2R plan: `alloc_size` * sizeof(double/float)
*
* - R2C plan: `alloc_size` * sizeof(double/float)
* \return `DTFFT_SUCCESS` if call was successfull, error code otherwise
*/
Expand Down
21 changes: 8 additions & 13 deletions include/dtfft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ namespace dtfft
* \param[in] transpose_type Type of transpose:
* - `DTFFT_TRANSPOSE_X_TO_Y`
* - `DTFFT_TRANSPOSE_Y_TO_X`
* - `DTFFT_TRANSPOSE_Y_TO_Z`
* - `DTFFT_TRANSPOSE_Z_TO_Y`
* - `DTFFT_TRANSPOSE_Y_TO_Z` (3d plan only)
* - `DTFFT_TRANSPOSE_Z_TO_Y` (3d plan only)
* - `DTFFT_TRANSPOSE_X_TO_Z` (3d plan only)
* - `DTFFT_TRANSPOSE_Z_TO_X` (3d plan only)
*
* \return Status code of method execution
*/
Expand All @@ -139,8 +141,10 @@ namespace dtfft
* \param[in] transpose_type Type of transpose:
* - `DTFFT_TRANSPOSE_X_TO_Y`
* - `DTFFT_TRANSPOSE_Y_TO_X`
* - `DTFFT_TRANSPOSE_Y_TO_Z`
* - `DTFFT_TRANSPOSE_Z_TO_Y`
* - `DTFFT_TRANSPOSE_Y_TO_Z` (3d plan only)
* - `DTFFT_TRANSPOSE_Z_TO_Y` (3d plan only)
* - `DTFFT_TRANSPOSE_X_TO_Z` (3d plan only)
* - `DTFFT_TRANSPOSE_Z_TO_X` (3d plan only)
*
* \return Status code of method execution
*/
Expand All @@ -153,11 +157,8 @@ namespace dtfft
/** \brief Wrapper around `get_local_sizes`
*
* \param[out] alloc_size Minimum number of elements needs to be allocated for `in`, `out` or `aux` buffers:
*
* - C2C plan: 2 * `alloc_size` * sizeof(double/float) or `alloc_size` * sizeof(dtfft_complex/dtfftf_complex)
*
* - R2R plan: `alloc_size` * sizeof(double/float)
*
* - R2C plan: `alloc_size` * sizeof(double/float)
*
* \return Status code of method execution
Expand All @@ -175,11 +176,8 @@ namespace dtfft
* \param[out] out_starts Starts of local portion of data in 'fourier' space in reversed order
* \param[out] out_counts Sizes of local portion of data in 'fourier' space in reversed order
* \param[out] alloc_size Minimum number of elements needs to be allocated for `in`, `out` or `aux` buffers:
*
* - C2C plan: 2 * `alloc_size` * sizeof(double/float) or `alloc_size` * sizeof(dtfft_complex/dtfftf_complex)
*
* - R2R plan: `alloc_size` * sizeof(double/float)
*
* - R2C plan: `alloc_size` * sizeof(double/float)
*
* \return Status code of method execution
Expand All @@ -197,11 +195,8 @@ namespace dtfft
* \param[out] out_starts Starts of local portion of data in 'fourier' space in reversed order
* \param[out] out_counts Sizes of local portion of data in 'fourier' space in reversed order
* \param[out] alloc_size Minimum number of elements needs to be allocated for `in`, `out` or `aux` buffers:
*
* - C2C plan: 2 * `alloc_size` * sizeof(double/float) or `alloc_size` * sizeof(dtfft_complex/dtfftf_complex)
*
* - R2R plan: `alloc_size` * sizeof(double/float)
*
* - R2C plan: `alloc_size` * sizeof(double/float)
*
* \return Status code of method execution
Expand Down
13 changes: 7 additions & 6 deletions include/dtfft_config.h.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef DTFFT_CONFIG_H
#define DTFFT_CONFIG_H

#cmakedefine DTFFT_WITHOUT_FFTW
#cmakedefine DTFFT_WITH_FFTW
#cmakedefine DTFFT_WITH_MKL
#cmakedefine DTFFT_WITH_CUFFT
#cmakedefine DTFFT_WITH_KFR
// #cmakedefine DTFFT_WITH_VKFFT
/* #cmakedefine DTFFT_WITH_CUFFT */
/* #cmakedefine DTFFT_WITH_KFR */
/* #cmakedefine DTFFT_WITH_VKFFT */
#cmakedefine DTFFT_TRANSPOSE_ONLY


Expand Down Expand Up @@ -40,9 +40,9 @@
#define CONF_DTFFT_EXECUTOR_NONE 0
#define CONF_DTFFT_EXECUTOR_FFTW3 +1
#define CONF_DTFFT_EXECUTOR_MKL +2
#define CONF_DTFFT_EXECUTOR_CUFFT +3
/* #define CONF_DTFFT_EXECUTOR_CUFFT +3 */
/* #define CONF_DTFFT_EXECUTOR_KFR +4 */
#define CONF_DTFFT_EXECUTOR_VKFFT +5
/* #define CONF_DTFFT_EXECUTOR_VKFFT +5 */

#define CONF_DTFFT_SUCCESS 0
#define CONF_DTFFT_ERROR_MPI_FINALIZED (-1)
Expand All @@ -60,6 +60,7 @@
#define CONF_DTFFT_ERROR_INVALID_R2R_KINDS 12
#define CONF_DTFFT_ERROR_R2C_TRANSPOSE_PLAN 13
#define CONF_DTFFT_ERROR_INPLACE_TRANSPOSE 14
#define CONF_DTFFT_ERROR_INVALID_AUX 15
#define CONF_DTFFT_ERROR_R2R_FFT_NOT_SUPPORTED 101
#define CONF_DTFFT_ERROR_CUFFTMP_2D_PLAN 200

Expand Down
2 changes: 1 addition & 1 deletion src/dtfft.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module dtfft

! 1d FFT External Executor types
public :: DTFFT_EXECUTOR_NONE
#ifndef DTFFT_WITHOUT_FFTW
#ifdef DTFFT_WITH_FFTW
public :: DTFFT_EXECUTOR_FFTW3
#endif
#ifdef DTFFT_WITH_MKL
Expand Down
Loading

0 comments on commit 1dfa52e

Please sign in to comment.