SHAFFT 1.1.0-alpha
A Scalable High-dimensional Accelerated FFT Library
Loading...
Searching...
No Matches
C API

C interface for SHAFFT. More...

Classes

struct  shafft_nd_layout_t
 N-D layout state (initial or output). More...
 
struct  shafft_nd_config_t
 N-D configuration object (C POD struct). More...
 
struct  shafft_1d_layout_t
 1-D layout state (initial or output). More...
 
struct  shafft_1d_config_t
 1-D configuration object (C POD struct). More...
 

Typedefs

typedef struct shafft_nd_layout_t shafft_nd_layout_t
 N-D layout state (initial or output).
 
typedef struct shafft_nd_config_t shafft_nd_config_t
 N-D configuration object (C POD struct).
 
typedef struct shafft_1d_layout_t shafft_1d_layout_t
 1-D layout state (initial or output).
 
typedef struct shafft_1d_config_t shafft_1d_config_t
 1-D configuration object (C POD struct).
 

Enumerations

enum  shafft_t { SHAFFT_C2C , SHAFFT_Z2Z }
 C interface for SHAFFT. More...
 
enum  shafft_direction_t { SHAFFT_FORWARD , SHAFFT_BACKWARD }
 Transform direction. More...
 
enum  shafft_tensor_layout_t { SHAFFT_TENSOR_LAYOUT_CURRENT , SHAFFT_TENSOR_LAYOUT_INITIAL , SHAFFT_TENSOR_LAYOUT_REDISTRIBUTED }
 Tensor layout for querying local decomposition. More...
 
enum  shafft_transform_layout_t { SHAFFT_LAYOUT_REDISTRIBUTED = 0 , SHAFFT_LAYOUT_INITIAL = 1 }
 Forward transform output policy for planning. More...
 
enum  shafft_status_t {
  SHAFFT_SUCCESS = 0 , SHAFFT_ERR_NULLPTR = 1 , SHAFFT_ERR_INVALID_COMM = 2 , SHAFFT_ERR_NO_BUFFER = 3 ,
  SHAFFT_ERR_PLAN_NOT_INIT = 4 , SHAFFT_ERR_INVALID_DIM = 5 , SHAFFT_ERR_DIM_MISMATCH = 6 , SHAFFT_ERR_INVALID_DECOMP = 7 ,
  SHAFFT_ERR_INVALID_FFTTYPE = 8 , SHAFFT_ERR_ALLOC = 9 , SHAFFT_ERR_BACKEND = 10 , SHAFFT_ERR_MPI = 11 ,
  SHAFFT_ERR_INVALID_LAYOUT = 12 , SHAFFT_ERR_SIZE_OVERFLOW = 13 , SHAFFT_ERR_NOT_IMPL = 14 , SHAFFT_ERR_INVALID_STATE = 15 ,
  SHAFFT_ERR_INTERNAL = 16
}
 Status/error codes returned by SHAFFT functions (aligned with shafft::Status).0 indicates success; non-zero indicates an error condition. More...
 
enum  shafft_errsrc_t {
  SHAFFT_ERRSRC_NONE = 0 , SHAFFT_ERRSRC_MPI = 1 , SHAFFT_ERRSRC_HIP = 2 , SHAFFT_ERRSRC_HIPFFT = 3 ,
  SHAFFT_ERRSRC_FFTW = 4 , SHAFFT_ERRSRC_SYSTEM = 5
}
 Error source domain for detailed diagnostics. More...
 
enum  shafft_decomposition_strategy_t { SHAFFT_MAXIMIZE_NDA , SHAFFT_MINIMIZE_NDA }
 Decomposition strategy for automatic configuration. More...
 
enum  shafft_config_flags_t { SHAFFT_CONFIG_CHANGED_COMM_DIMS = (1 << 0) , SHAFFT_CONFIG_CHANGED_NDA = (1 << 1) , SHAFFT_CONFIG_INACTIVE_RANKS = (1 << 2) , SHAFFT_CONFIG_RESOLVED = (1 << 3) }
 Flags bitset for config object state. More...
 

Functions

int shafftLastErrorStatus (void)
 Get the SHAFFT status code from the last error on this thread.
 
int shafftLastErrorSource (void)
 Get the error source domain from the last error on this thread.
 
int shafftLastErrorDomainCode (void)
 Get the raw domain-specific error code from the last error.
 
int shafftLastErrorMessage (char *buf, int buflen)
 Get a human-readable message for the last error.
 
void shafftClearLastError (void)
 Clear the last error state on this thread.
 
const char * shafftErrorSourceName (int source)
 Get the name of an error source as a string.
 
int shafftConfigNDInit (shafft_nd_config_t *cfg, int ndim, const size_t *globalShape, shafft_t precision, const int *commDims, int hintNda, shafft_decomposition_strategy_t strategy, shafft_transform_layout_t outputPolicy, size_t memLimit, MPI_Comm comm)
 Initialize and resolve an N-D configuration object.
 
void shafftConfigNDRelease (shafft_nd_config_t *cfg)
 Release internal resources of an N-D config object.
 
int shafftConfigNDResolve (shafft_nd_config_t *cfg)
 Re-resolve an N-D configuration.
 
int shafftNDInitFromConfig (void *planPtr, shafft_nd_config_t *cfg)
 Initialize an N-D plan from a resolved config object.
 
int shafftConfig1DInit (shafft_1d_config_t *cfg, size_t globalSize, shafft_t precision, MPI_Comm comm)
 Initialize and resolve a 1-D configuration object.
 
void shafftConfig1DRelease (shafft_1d_config_t *cfg)
 Release internal resources of a 1-D config object.
 
int shafftConfig1DResolve (shafft_1d_config_t *cfg)
 Re-resolve a 1-D configuration.
 
int shafft1DInitFromConfig (void *planPtr, shafft_1d_config_t *cfg)
 Initialize a 1-D plan from a resolved config object.
 
int shafftGetCommunicator (void *planPtr, MPI_Comm *outComm)
 Get a duplicated communicator from a plan.
 
int shafftConfigurationND (int ndim, int *size, shafft_t precision, int *commDims, int *nda, size_t *subsize, size_t *offset, int *commSize, shafft_decomposition_strategy_t strategy, size_t memLimit, MPI_Comm cComm)
 Compute local layout and process grid for N-D distributed FFT.
 
int shafftNDCreate (void **outPlan)
 Allocate uninitialized N-D plan object.
 
int shafftNDInit (void *planPtr, int ndim, int commDims[], int dimensions[], shafft_t precision, MPI_Comm cComm, shafft_transform_layout_t output_policy)
 Initialize N-D plan from process grid.
 
int shafftPlan (void *planPtr)
 Create backend FFT plans.
 
int shafftDestroy (void **planPtr)
 Release plan resources.
 
int shafftGetLayout (void *planPtr, size_t *subsize, size_t *offset, shafft_tensor_layout_t layout)
 Query local tensor layout.
 
int shafftGetAxes (void *planPtr, int *ca, int *da, shafft_tensor_layout_t layout)
 Query contiguous and distributed axis indices.
 
int shafftGetAllocSize (void *plan, size_t *localAllocSize)
 Get required buffer size in complex elements.
 
int shafftGetGlobalSize (void *plan, size_t *globalSize)
 Get global FFT size (product of all dimensions).
 
int shafftIsConfigured (void *plan, int *configured)
 Check if plan is configured (init succeeded).
 
int shafftIsActive (void *plan, int *active)
 Check if this rank participates in the plan.
 
int shafftSetBuffers (void *planPtr, void *data, void *work)
 Attach data and work buffers to a plan.
 
int shafftGetBuffers (void *planPtr, void **data, void **work)
 Retrieve current buffer pointers.
 
int shafftExecute (void *planPtr, shafft_direction_t direction)
 Execute FFT transform.
 
int shafftNormalize (void *planPtr)
 Apply normalization to data buffer.
 
int shafftConfiguration1D (size_t N, size_t *localN, size_t *localStart, size_t *localAllocSize, shafft_t precision, MPI_Comm cComm)
 Compute local layout for 1D distributed FFT.
 
int shafft1DCreate (void **outPlan)
 Allocate uninitialized 1D plan object.
 
int shafft1DInit (void *planPtr, size_t N, size_t localN, size_t localStart, shafft_t precision, MPI_Comm cComm)
 Initialize 1D distributed FFT plan.
 
int shafftAllocBufferF (size_t count, void **buf)
 Allocate single-precision complex buffer.
 
int shafftAllocBufferD (size_t count, void **buf)
 Allocate double-precision complex buffer.
 
int shafftFreeBufferF (void *buf)
 Free single-precision buffer from shafftAllocBufferF().
 
int shafftFreeBufferD (void *buf)
 Free double-precision buffer from shafftAllocBufferD().
 
int shafftCopyToBufferF (void *dst, const void *src, size_t count)
 Copy single-precision data from host to SHAFFT buffer.
 
int shafftCopyToBufferD (void *dst, const void *src, size_t count)
 Copy double-precision data from host to SHAFFT buffer.
 
int shafftCopyFromBufferF (void *dst, const void *src, size_t count)
 Copy single-precision data from SHAFFT buffer to host.
 
int shafftCopyFromBufferD (void *dst, const void *src, size_t count)
 Copy double-precision data from SHAFFT buffer to host.
 
const char * shafftGetBackendName (void)
 Get the name of the FFT backend used at compile time.
 
void shafftGetVersion (int *major, int *minor, int *patch)
 Get the library version as major, minor, patch components.
 
const char * shafftGetVersionString (void)
 Get the library version as a string.
 
int shafftFinalize (void)
 Finalize library and release backend resources.
 

Detailed Description

Procedural functions for plan creation, execution, and resource management.

See also
shafft.h for the complete API

Typedef Documentation

◆ shafft_nd_layout_t

Contains per-axis arrays describing the local block for one layout state. All pointer fields are config-owned and populated by resolve.

◆ shafft_nd_config_t

The authoritative data store for all language APIs. Caller-owned (stack/heap); internal arrays are config-owned. Do NOT copy by value (owning pointers — double-free hazard). Use shafftConfigNDInit/shafftConfigNDRelease to manage lifecycle.

◆ shafft_1d_layout_t

◆ shafft_1d_config_t

Simpler than N-D: no adjustable hints, no strategy/policy. Do NOT copy by value (owning pointers — double-free hazard).

Enumeration Type Documentation

◆ shafft_t

enum shafft_t

Conventions:

  • Axis indices are 0-based.
  • Arrays noted as "length = ndim" must have at least ndim elements.
  • "ca" = indices of locally contiguous (non-distributed) axes, ordered innermost to outermost stride for the reported stage/layout.
  • Buffers may be swapped internally during execution; call shafftGetBuffers() after shafftExecute() to obtain the buffer that currently holds the most recent execution result.

FFT type.

  • SHAFFT_C2C : single-precision complex-to-complex.
  • SHAFFT_Z2Z : double-precision complex-to-complex.
Enumerator
SHAFFT_C2C 
SHAFFT_Z2Z 

◆ shafft_direction_t

  • SHAFFT_FORWARD : forward transform.
  • SHAFFT_BACKWARD : backward transform.
Enumerator
SHAFFT_FORWARD 

Forward transform.

SHAFFT_BACKWARD 

Backward transform.

◆ shafft_tensor_layout_t

  • SHAFFT_TENSOR_LAYOUT_CURRENT : layout associated with the last executed transform direction.
  • SHAFFT_TENSOR_LAYOUT_INITIAL : layout before any transforms have been executed.
  • SHAFFT_TENSOR_LAYOUT_REDISTRIBUTED : user-visible post-forward redistributed layout (policy-dependent).
Enumerator
SHAFFT_TENSOR_LAYOUT_CURRENT 

Current layout (forward or backward, depending on last execution).

SHAFFT_TENSOR_LAYOUT_INITIAL 

Initial layout (before any transforms).

SHAFFT_TENSOR_LAYOUT_REDISTRIBUTED 

User-visible redistributed layout state.

◆ shafft_transform_layout_t

Controls the data layout after a forward transform for N-D plans. Used by shafftNDInit(); not applicable to shafft1DInit().

Enumerator
SHAFFT_LAYOUT_REDISTRIBUTED 

Keep post-forward redistributed layout.

SHAFFT_LAYOUT_INITIAL 

Restore initial layout after forward transform.

◆ shafft_status_t

Enumerator
SHAFFT_SUCCESS 

Operation completed successfully.

SHAFFT_ERR_NULLPTR 

Null pointer argument.

SHAFFT_ERR_INVALID_COMM 

Invalid MPI communicator.

SHAFFT_ERR_NO_BUFFER 

Required data/work buffer was not set.

SHAFFT_ERR_PLAN_NOT_INIT 

Plan or subplan not initialized.

SHAFFT_ERR_INVALID_DIM 

Invalid dimension parameter.

SHAFFT_ERR_DIM_MISMATCH 

Dimension mismatch between arrays.

SHAFFT_ERR_INVALID_DECOMP 

Invalid or unsupported slab decomposition.

SHAFFT_ERR_INVALID_FFTTYPE 

Invalid FFT type.

SHAFFT_ERR_ALLOC 

Memory allocation failed.

SHAFFT_ERR_BACKEND 

Backend (FFTW/hipFFT/HIP) failure.

SHAFFT_ERR_MPI 

MPI failure.

SHAFFT_ERR_INVALID_LAYOUT 

Layout parameters don't match expected distribution.

SHAFFT_ERR_SIZE_OVERFLOW 

Size exceeds INT_MAX.

SHAFFT_ERR_NOT_IMPL 

Feature not yet implemented.

SHAFFT_ERR_INVALID_STATE 

Operation not valid in current plan state.

SHAFFT_ERR_INTERNAL 

Uncategorized internal error.

◆ shafft_errsrc_t

When a SHAFFT function returns an error, call shafftLastErrorSource() to determine which subsystem caused the failure.

Enumerator
SHAFFT_ERRSRC_NONE 

No error or SHAFFT-internal error

SHAFFT_ERRSRC_MPI 

MPI library error (use MPI_Error_string)

SHAFFT_ERRSRC_HIP 

HIP runtime error (hipError_t)

SHAFFT_ERRSRC_HIPFFT 

hipFFT library error (hipfftResult_t)

SHAFFT_ERRSRC_FFTW 

FFTW library error

SHAFFT_ERRSRC_SYSTEM 

OS / allocation / errno-like errors

◆ shafft_decomposition_strategy_t

Enumerator
SHAFFT_MAXIMIZE_NDA 

Maximize number of distributed axes (better parallelism)

SHAFFT_MINIMIZE_NDA 

Minimize number of distributed axes (fewer communication phases)

◆ shafft_config_flags_t

Enumerator
SHAFFT_CONFIG_CHANGED_COMM_DIMS 

commDims was adjusted by resolve.

SHAFFT_CONFIG_CHANGED_NDA 

nda was adjusted by resolve.

SHAFFT_CONFIG_INACTIVE_RANKS 

Some ranks are inactive.

SHAFFT_CONFIG_RESOLVED 

Config has been resolved.

Function Documentation

◆ shafftLastErrorStatus()

int shafftLastErrorStatus ( void  )
Returns
Status code (one of shafft_status_t values).

◆ shafftLastErrorSource()

int shafftLastErrorSource ( void  )
Returns
Error source (one of shafft_errsrc_t values).

◆ shafftLastErrorDomainCode()

int shafftLastErrorDomainCode ( void  )

The meaning of this code depends on shafftLastErrorSource():

  • SHAFFT_ERRSRC_MPI: MPI error code (use MPI_Error_string)
  • SHAFFT_ERRSRC_HIP: hipError_t value
  • SHAFFT_ERRSRC_HIPFFT: hipfftResult_t value
  • SHAFFT_ERRSRC_FFTW: (not used, FFTW has no error codes)
  • SHAFFT_ERRSRC_SYSTEM: errno or similar
Returns
Raw error code from the underlying subsystem.

◆ shafftLastErrorMessage()

int shafftLastErrorMessage ( char *  buf,
int  buflen 
)
Parameters
bufBuffer to receive the null-terminated message.
buflenSize of the buffer in bytes.
Returns
Number of characters written (excluding null terminator).

◆ shafftClearLastError()

void shafftClearLastError ( void  )
Returns
void.

◆ shafftErrorSourceName()

const char * shafftErrorSourceName ( int  source)
Parameters
sourceError source value from shafftLastErrorSource().
Returns
String name (e.g., "MPI", "HIP", "hipFFT", "FFTW").

◆ shafftConfigNDInit()

int shafftConfigNDInit ( shafft_nd_config_t cfg,
int  ndim,
const size_t *  globalShape,
shafft_t  precision,
const int *  commDims,
int  hintNda,
shafft_decomposition_strategy_t  strategy,
shafft_transform_layout_t  outputPolicy,
size_t  memLimit,
MPI_Comm  comm 
)

Allocates internal arrays, copies inputs, resolves decomposition, populates layouts and metadata, stores worldComm (dup of comm), and creates activeComm via MPI_Comm_split. The struct must be zero-initialized before this call. Collective on comm.

Parameters
cfg[in,out] Config struct (caller-owned, zero-initialized).
ndimNumber of tensor dimensions (>= 1).
globalShapeGlobal extents per axis (length = ndim).
precisionFFT type (SHAFFT_C2C or SHAFFT_Z2Z).
commDimsProcess grid hint (length = ndim; NULL = auto).
hintNdaNumber of distributed axes hint (0 = auto).
strategyDecomposition strategy.
outputPolicyForward output-layout policy (0 = REDISTRIBUTED default).
memLimitPer-rank memory limit in bytes (0 = no limit).
commMPI communicator.
Returns
0 on success, non-zero on error.
Examples
example_portable_config.c.

◆ shafftConfigNDRelease()

void shafftConfigNDRelease ( shafft_nd_config_t cfg)

Frees config-owned arrays/strings and owned communicators (worldComm, activeComm), then zero-fills the struct. Must be called before MPI_Finalize. Does not free the struct itself. Idempotent; safe after failed init.

Parameters
cfgConfig struct.
Examples
example_portable_config.c.

◆ shafftConfigNDResolve()

int shafftConfigNDResolve ( shafft_nd_config_t cfg)

Uses stored worldComm (no comm parameter). Frees old activeComm and creates a new one. For advanced use after modifying struct fields.

Parameters
cfg[in,out] Initialized config struct.
Returns
0 on success, non-zero on error.

◆ shafftNDInitFromConfig()

int shafftNDInitFromConfig ( void *  planPtr,
shafft_nd_config_t cfg 
)

Auto-resolves if SHAFFT_CONFIG_RESOLVED is not set. Communicator is read from the config struct (worldComm).

Parameters
planPtrPlan from shafftNDCreate().
cfg[in,out] Config struct (resolved or will be auto-resolved).
Returns
0 on success, non-zero on error.
Examples
example_portable_config.c.

◆ shafftConfig1DInit()

int shafftConfig1DInit ( shafft_1d_config_t cfg,
size_t  globalSize,
shafft_t  precision,
MPI_Comm  comm 
)

Allocates internals, copies inputs, resolves layout, stores worldComm (dup of comm), and creates activeComm. Collective on comm.

Parameters
cfg[in,out] Config struct (caller-owned, zero-initialized).
globalSizeGlobal FFT length (> 0).
precisionFFT type (SHAFFT_C2C or SHAFFT_Z2Z).
commMPI communicator.
Returns
0 on success, non-zero on error.

◆ shafftConfig1DRelease()

void shafftConfig1DRelease ( shafft_1d_config_t cfg)

Frees config-owned strings and owned communicators (worldComm, activeComm), then zero-fills the struct. Must be called before MPI_Finalize.

Parameters
cfgConfig struct.

◆ shafftConfig1DResolve()

int shafftConfig1DResolve ( shafft_1d_config_t cfg)

Uses stored worldComm (no comm parameter). Frees old activeComm and creates a new one.

Parameters
cfg[in,out] Initialized config struct.
Returns
0 on success, non-zero on error.

◆ shafft1DInitFromConfig()

int shafft1DInitFromConfig ( void *  planPtr,
shafft_1d_config_t cfg 
)

Auto-resolves if SHAFFT_CONFIG_RESOLVED is not set. Communicator is read from the config struct (worldComm).

Parameters
planPtrPlan from shafft1DCreate().
cfg[in,out] Config struct (resolved or will be auto-resolved).
Returns
0 on success, non-zero on error.

◆ shafftGetCommunicator()

int shafftGetCommunicator ( void *  planPtr,
MPI_Comm *  outComm 
)

Returns MPI_COMM_NULL on inactive ranks. The caller is responsible for MPI_Comm_free() on the returned non-null communicator. Valid only after planning stage (shafftPlan).

Parameters
planPtrPlan pointer (N-D or 1D).
outComm[out] Receives duplicated communicator.
Returns
0 on success, non-zero on error.

◆ shafftConfigurationND()

int shafftConfigurationND ( int  ndim,
int *  size,
shafft_t  precision,
int *  commDims,
int *  nda,
size_t *  subsize,
size_t *  offset,
int *  commSize,
shafft_decomposition_strategy_t  strategy,
size_t  memLimit,
MPI_Comm  cComm 
)

Attempts configuration using the fallback chain: commDims -> nda -> strategy.

Parameters
ndimNumber of tensor dimensions.
sizeGlobal extents per axis (length = ndim).
precisionFFT type (SHAFFT_C2C or SHAFFT_Z2Z).
commDims[in,out] Process grid preference (0 = no preference); updated on output.
nda[in,out] Distributed axes preference (0 = no preference); updated on output.
subsize[out] Local extents per axis (length = ndim).
offset[out] Global starting indices per axis (length = ndim).
commSize[out] Number of active ranks.
strategyFallback strategy (SHAFFT_MAXIMIZE_NDA or SHAFFT_MINIMIZE_NDA).
memLimitPer-rank memory limit in bytes (0 = no limit).
cCommMPI communicator.
Returns
0 on success, non-zero on error.
Examples
example_portable.c.

◆ shafftNDCreate()

int shafftNDCreate ( void **  outPlan)
Parameters
outPlan[out] Receives plan pointer (NULL on failure).
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftNDInit()

int shafftNDInit ( void *  planPtr,
int  ndim,
int  commDims[],
int  dimensions[],
shafft_t  precision,
MPI_Comm  cComm,
shafft_transform_layout_t  output_policy 
)
Parameters
planPtrPlan from shafftNDCreate().
ndimNumber of dimensions.
commDimsProcess grid dimensions (length = ndim).
dimensionsGlobal tensor extents (length = ndim).
precisionFFT type (SHAFFT_C2C or SHAFFT_Z2Z).
cCommMPI communicator.
output_policyForward output-layout policy.
Returns
0 on success, non-zero on error.
Examples
example_portable.c.

◆ shafftPlan()

int shafftPlan ( void *  planPtr)

Must be called after init completes. Works on N-D and 1D plans. Calling plan() more than once is an error.

Parameters
planPtrPlan pointer (N-D or 1D).
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftDestroy()

int shafftDestroy ( void **  planPtr)

Works on N-D and 1D plans. Does not free user-provided buffers.

Parameters
planPtr[in,out] Pointer to plan; set to NULL on return.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftGetLayout()

int shafftGetLayout ( void *  planPtr,
size_t *  subsize,
size_t *  offset,
shafft_tensor_layout_t  layout 
)
Parameters
planPtrPlan pointer (N-D or 1D).
subsize[out] Local extents per axis.
offset[out] Global starting indices per axis.
layoutWhich layout to query.
Returns
0 on success, non-zero on error.

◆ shafftGetAxes()

int shafftGetAxes ( void *  planPtr,
int *  ca,
int *  da,
shafft_tensor_layout_t  layout 
)
Parameters
planPtrPlan pointer (N-D or 1D).
ca[out] Contiguous axis indices (innermost to outermost stride).
da[out] Distributed axis indices (innermost to outermost stride).
layoutWhich layout to query.
Returns
0 on success, non-zero on error.

◆ shafftGetAllocSize()

int shafftGetAllocSize ( void *  plan,
size_t *  localAllocSize 
)
Parameters
planPlan pointer (N-D or 1D).
localAllocSize[out] Required element count.
Returns
0 on success, non-zero on error.
Examples
example_portable.c.

◆ shafftGetGlobalSize()

int shafftGetGlobalSize ( void *  plan,
size_t *  globalSize 
)
Parameters
planPlan pointer (N-D or 1D).
globalSize[out] Total element count.
Returns
0 on success, non-zero on error.

◆ shafftIsConfigured()

int shafftIsConfigured ( void *  plan,
int *  configured 
)
Parameters
planPlan pointer (N-D or 1D).
configured[out] 1 if configured, 0 otherwise.
Returns
0 on success, non-zero on error.

◆ shafftIsActive()

int shafftIsActive ( void *  plan,
int *  active 
)
Parameters
planPlan pointer (N-D or 1D).
active[out] 1 if active, 0 otherwise.
Returns
0 on success, non-zero on error.

◆ shafftSetBuffers()

int shafftSetBuffers ( void *  planPtr,
void *  data,
void *  work 
)

Buffers must remain valid until plan destruction or new buffers are set.

Parameters
planPtrPlan pointer (N-D or 1D).
dataMain data buffer.
workWork/scratch buffer.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftGetBuffers()

int shafftGetBuffers ( void *  planPtr,
void **  data,
void **  work 
)

Buffers may be swapped during execution; call after shafftExecute() to locate the most recent execution result.

Parameters
planPtrPlan pointer (N-D or 1D).
data[out] Current data buffer.
work[out] Current work buffer.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftExecute()

int shafftExecute ( void *  planPtr,
shafft_direction_t  direction 
)
Parameters
planPtrPlan pointer (N-D or 1D).
directionSHAFFT_FORWARD or SHAFFT_BACKWARD.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftNormalize()

int shafftNormalize ( void *  planPtr)
Parameters
planPtrPlan pointer (N-D or 1D).
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftConfiguration1D()

int shafftConfiguration1D ( size_t  N,
size_t *  localN,
size_t *  localStart,
size_t *  localAllocSize,
shafft_t  precision,
MPI_Comm  cComm 
)
Parameters
NGlobal FFT size.
localN[out] Elements for this rank.
localStart[out] This rank's offset in global array.
localAllocSize[out] Required buffer size.
precisionFFT type (SHAFFT_C2C or SHAFFT_Z2Z).
cCommMPI communicator.
Returns
0 on success, non-zero on error.

◆ shafft1DCreate()

int shafft1DCreate ( void **  outPlan)
Parameters
outPlan[out] Receives plan pointer.
Returns
0 on success, non-zero on error.

◆ shafft1DInit()

int shafft1DInit ( void *  planPtr,
size_t  N,
size_t  localN,
size_t  localStart,
shafft_t  precision,
MPI_Comm  cComm 
)
Parameters
planPtrPlan from shafft1DCreate().
NGlobal FFT size.
localNElements for this rank.
localStartThis rank's offset.
precisionFFT type (SHAFFT_C2C or SHAFFT_Z2Z).
cCommMPI communicator.
Returns
0 on success, non-zero on error.

◆ shafftAllocBufferF()

int shafftAllocBufferF ( size_t  count,
void **  buf 
)

Uses device memory on GPU, host memory on CPU. Free with shafftFreeBufferF().

Parameters
countNumber of complex elements.
buf[out] Allocated buffer.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftAllocBufferD()

int shafftAllocBufferD ( size_t  count,
void **  buf 
)

Uses device memory on GPU, host memory on CPU. Free with shafftFreeBufferD().

Parameters
countNumber of complex elements.
buf[out] Allocated buffer.
Returns
0 on success, non-zero on error.

◆ shafftFreeBufferF()

int shafftFreeBufferF ( void *  buf)
Parameters
bufBuffer to free (NULL safe).
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftFreeBufferD()

int shafftFreeBufferD ( void *  buf)
Parameters
bufBuffer to free (NULL safe).
Returns
0 on success, non-zero on error.

◆ shafftCopyToBufferF()

int shafftCopyToBufferF ( void *  dst,
const void *  src,
size_t  count 
)
Parameters
dstDestination buffer.
srcSource host memory.
countNumber of complex elements.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftCopyToBufferD()

int shafftCopyToBufferD ( void *  dst,
const void *  src,
size_t  count 
)
Parameters
dstDestination buffer.
srcSource host memory.
countNumber of complex elements.
Returns
0 on success, non-zero on error.

◆ shafftCopyFromBufferF()

int shafftCopyFromBufferF ( void *  dst,
const void *  src,
size_t  count 
)
Parameters
dstDestination host memory.
srcSource buffer.
countNumber of complex elements.
Returns
0 on success, non-zero on error.
Examples
example_portable.c, and example_portable_config.c.

◆ shafftCopyFromBufferD()

int shafftCopyFromBufferD ( void *  dst,
const void *  src,
size_t  count 
)
Parameters
dstDestination host memory.
srcSource buffer.
countNumber of complex elements.
Returns
0 on success, non-zero on error.

◆ shafftGetBackendName()

const char * shafftGetBackendName ( void  )
Returns
"FFTW" or "hipFFT".

◆ shafftGetVersion()

void shafftGetVersion ( int *  major,
int *  minor,
int *  patch 
)
Parameters
major[out] Receives major version.
minor[out] Receives minor version.
patch[out] Receives patch version.

◆ shafftGetVersionString()

const char * shafftGetVersionString ( void  )
Returns
Version string.

◆ shafftFinalize()

int shafftFinalize ( void  )

Call after all plans are destroyed. Must be called before MPI_Finalize() for FFTW backend. Safe to call multiple times.

Returns
0 on success, non-zero on error.