Documentation
¶
Overview ¶
Package cufft provides low-level Go bindings for cuFFT (CUDA Fast Fourier Transform).
cuFFT computes discrete Fourier transforms (DFTs) on NVIDIA GPUs, supporting 1D, 2D, and 3D transforms in single and double precision for real-to-complex, complex-to-real, and complex-to-complex transforms.
The central type is Handle, which represents a cuFFT plan. Create plans with Plan1d, Plan2d, Plan3d, or PlanMany, execute with the Exec* methods (e.g., Handle.ExecC2C), and clean up with Handle.Destroy.
This package provides bindings generated from cufft.h using github.com/ebitengine/purego for cgo-free dynamic loading of libcufft. Functions returning a C status report errors wrapping cufftResult.
Plan Creation ¶
- Create: Creates only an opaque handle, and allocates small data structures on the host.
- Handle.MakePlan1d: Following a call to Create makes a 1D FFT plan configuration for a specified signal size and data type.
- Handle.MakePlan2d: Following a call to Create makes a 2D FFT plan configuration according to specified signal sizes and data type.
- Handle.MakePlan3d: Following a call to Create makes a 3D FFT plan configuration according to specified signal sizes and data type.
- Handle.MakePlanMany: Following a call to Create makes a FFT plan configuration of dimension rank, with sizes specified in the array n.
- Handle.MakePlanMany64: Following a call to Create makes a FFT plan configuration of dimension rank, with sizes specified in the array n.
- Plan1d: Creates a 1D FFT plan configuration for a specified signal size and data type.
- Plan2d: Creates a 2D FFT plan configuration according to specified signal sizes and data type.
- Plan3d: Creates a 3D FFT plan configuration according to specified signal sizes and data type.
- PlanMany: Creates a FFT plan configuration of dimension rank, with sizes specified in the array n.
Plan Lifecycle ¶
- Handle.Destroy: Frees all GPU resources associated with a cuFFT plan and destroys the internal plan data structure.
Execution ¶
- Handle.ExecC2C: Handle.ExecC2C ( Handle.ExecZ2Z) executes a single-precision (double-precision) complex-to-complex transform plan in the transform direction as specified by direction parameter.
- Handle.ExecC2R: Handle.ExecC2R ( Handle.ExecZ2D) executes a single-precision (double-precision) complex-to-real, implicitly inverse, cuFFT transform plan.
- Handle.ExecD2Z: Handle.ExecR2C ( Handle.ExecD2Z) executes a single-precision (double-precision) real-to-complex, implicitly forward, cuFFT transform plan.
- Handle.ExecR2C: Handle.ExecR2C ( Handle.ExecD2Z) executes a single-precision (double-precision) real-to-complex, implicitly forward, cuFFT transform plan.
- Handle.ExecZ2D: Handle.ExecC2R ( Handle.ExecZ2D) executes a single-precision (double-precision) complex-to-real, implicitly inverse, cuFFT transform plan.
- Handle.ExecZ2Z: Handle.ExecC2C ( Handle.ExecZ2Z) executes a single-precision (double-precision) complex-to-complex transform plan in the transform direction as specified by direction parameter.
Version Queries ¶
- GetProperty: Return in *value the number for the property described by type of the dynamically linked CUFFT library.
- GetVersion: Returns the version number of cuFFT.
Configuration ¶
- Handle.SetAutoAllocation: Handle.SetAutoAllocation indicates that the caller intends to allocate and manage work areas for plans that have been generated.
- Handle.SetStream: Associates a CUDA stream with a cuFFT plan.
- Handle.SetWorkArea: Handle.SetWorkArea overrides the work area pointer associated with a plan.
Other ¶
- Estimate1d: During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
- Estimate2d: During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
- Estimate3d: During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
- EstimateMany: During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
- Handle.PlanPropertyInt64: Retrieves the property value identified by the key property associated with the cuFFT plan plan.
- Handle.Size: Once plan generation has been done, either with the original API or the extensible API, this call returns the actual size of the work area required to support the plan.
- Handle.Size1d: This call gives a more accurate estimate of the work area size required for a plan than Estimate1d, given the specified parameters, and taking into account any plan settings that may have been made.
- Handle.Size2d: This call gives a more accurate estimate of the work area size required for a plan than Estimate2d, given the specified parameters, and taking into account any plan settings that may have been made.
- Handle.Size3d: This call gives a more accurate estimate of the work area size required for a plan than Estimate3d, given the specified parameters, and taking into account any plan settings that may have been made.
- Handle.SizeMany: This call gives a more accurate estimate of the work area size required for a plan than cufftEstimateSizeMany(), given the specified parameters, and taking into account any plan settings that may have been made.
- Handle.SizeMany64: This call gives a more accurate estimate of the work area size required for a plan than cufftEstimateSizeMany(), given the specified parameters, and taking into account any plan settings that may have been made.
- Handle.ResetPlanProperty: Resets the value of the property identified by the key property, associated with the cuFFT plan plan, to its default value.
- Handle.SetPlanPropertyInt64: Associates a cuFFT plan with a property identified by the key property.
Example ¶
Example transforms a four-point complex impulse in place on the first CUDA device. The transform of an impulse is 1+0i at every point. It returns early when the CUDA driver or cuFFT is not available. It has no Output comment, so it is compiled but not run: it needs a CUDA device.
package main
import (
"fmt"
"runtime"
"unsafe"
"github.com/tmc/lib/nvidia/cufft"
"github.com/tmc/lib/nvidia/driver"
)
func main() {
version, err := cufft.GetVersion()
if err != nil {
fmt.Println("cuFFT unavailable:", err)
return
}
fmt.Println("cuFFT version:", version)
// A CUDA context is current on an OS thread, not on a goroutine.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := driver.Init(0); err != nil {
fmt.Println("CUDA driver unavailable:", err)
return
}
dev, err := driver.DeviceGet(0)
if err != nil {
fmt.Println("device:", err)
return
}
ctx, err := dev.PrimaryCtxRetain()
if err != nil {
fmt.Println("context:", err)
return
}
defer dev.PrimaryCtxRelease()
if err := ctx.SetCurrent(); err != nil {
fmt.Println("set context:", err)
return
}
values := []cufft.Complex{{X: 1}, {}, {}, {}}
size := uint(len(values)) * uint(unsafe.Sizeof(values[0]))
p, err := driver.MemAllocBytes(size)
if err != nil {
fmt.Println("alloc:", err)
return
}
defer p.Free()
if err := p.CopyFromHost(values); err != nil {
fmt.Println("copy in:", err)
return
}
plan, err := cufft.Plan1d(int32(len(values)), cufft.C2C, 1)
if err != nil {
fmt.Println("plan:", err)
return
}
defer plan.Destroy()
if err := plan.ExecC2C(p, p, cufft.Forward); err != nil {
fmt.Println("exec:", err)
return
}
if err := p.CopyToHost(values); err != nil {
fmt.Println("copy out:", err)
return
}
fmt.Println("FFT(impulse) =", values)
}
Output:
Index ¶
- func Close() error
- func Estimate1d(nx int32, type_ Type, batch int32) (uint, error)
- func Estimate2d(nx int32, ny int32, type_ Type) (uint, error)
- func Estimate3d(nx int32, ny int32, nz int32, type_ Type) (uint, error)
- func EstimateMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, ...) (uint, error)
- func GetProperty(type_ LibraryPropertyType) (int32, error)
- func GetVersion() (int32, error)
- func Has(symbol string) bool
- func HasCreate() bool
- func HasDestroy() bool
- func HasEstimate1d() bool
- func HasEstimate2d() bool
- func HasEstimate3d() bool
- func HasEstimateMany() bool
- func HasExecC2C() bool
- func HasExecC2R() bool
- func HasExecD2Z() bool
- func HasExecR2C() bool
- func HasExecZ2D() bool
- func HasExecZ2Z() bool
- func HasGetPlanPropertyInt64() bool
- func HasGetProperty() bool
- func HasGetSize() bool
- func HasGetSize1d() bool
- func HasGetSize2d() bool
- func HasGetSize3d() bool
- func HasGetSizeMany() bool
- func HasGetSizeMany64() bool
- func HasGetVersion() bool
- func HasMakePlan1d() bool
- func HasMakePlan2d() bool
- func HasMakePlan3d() bool
- func HasMakePlanMany() bool
- func HasMakePlanMany64() bool
- func HasPlan1d() bool
- func HasPlan2d() bool
- func HasPlan3d() bool
- func HasPlanMany() bool
- func HasResetPlanProperty() bool
- func HasSetAutoAllocation() bool
- func HasSetPlanPropertyInt64() bool
- func HasSetStream() bool
- func HasSetWorkArea() bool
- func Load(path string) error
- func Loaded() bool
- func Path() string
- type BindFailure
- type CallError
- type Compatibility
- type Complex
- type Direction
- type DoubleComplex
- type DoubleReal
- type Handle
- func Create() (Handle, error)
- func Plan1d(nx int32, type_ Type, batch int32) (Handle, error)
- func Plan2d(nx int32, ny int32, type_ Type) (Handle, error)
- func Plan3d(nx int32, ny int32, nz int32, type_ Type) (Handle, error)
- func PlanMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, ...) (Handle, error)
- func (h Handle) Destroy() error
- func (h Handle) ExecC2C(idata driver.DevicePtr, odata driver.DevicePtr, direction Direction) error
- func (h Handle) ExecC2R(idata driver.DevicePtr, odata driver.DevicePtr) error
- func (h Handle) ExecD2Z(idata driver.DevicePtr, odata driver.DevicePtr) error
- func (h Handle) ExecR2C(idata driver.DevicePtr, odata driver.DevicePtr) error
- func (h Handle) ExecZ2D(idata driver.DevicePtr, odata driver.DevicePtr) error
- func (h Handle) ExecZ2Z(idata driver.DevicePtr, odata driver.DevicePtr, direction Direction) error
- func (h Handle) MakePlan1d(nx int32, type_ Type, batch int32) (uint, error)
- func (h Handle) MakePlan2d(nx int32, ny int32, type_ Type) (uint, error)
- func (h Handle) MakePlan3d(nx int32, ny int32, nz int32, type_ Type) (uint, error)
- func (h Handle) MakePlanMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, ...) (uint, error)
- func (h Handle) MakePlanMany64(rank int32, n *int64, inembed *int64, istride int64, idist int64, ...) (uint, error)
- func (h Handle) PlanPropertyInt64(property Property) (int64, error)
- func (h Handle) ResetPlanProperty(property Property) error
- func (h Handle) SetAutoAllocation(autoAllocate int32) error
- func (h Handle) SetPlanPropertyInt64(property Property, inputValueInt int64) error
- func (h Handle) SetStream(stream driver.Stream) error
- func (h Handle) SetWorkArea(workArea driver.DevicePtr) error
- func (h Handle) Size() (uint, error)
- func (h Handle) Size1d(nx int32, type_ Type, batch int32) (uint, error)
- func (h Handle) Size2d(nx int32, ny int32, type_ Type) (uint, error)
- func (h Handle) Size3d(nx int32, ny int32, nz int32, type_ Type) (uint, error)
- func (h Handle) SizeMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, ...) (uint, error)
- func (h Handle) SizeMany64(rank int32, n *int64, inembed *int64, istride int64, idist int64, ...) (uint, error)
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type LibraryPropertyType
- type Property
- type Real
- type Result
- type SymbolError
- type Type
- type VersionMismatchError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close() error
Close unloads the library and clears all bound function pointers.
The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.
func Estimate1d ¶
Estimate1d returns an estimate of the work area size a 1D plan requires, assuming default plan settings.
During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
This call returns an estimate for the size of the work area required, given the specified parameters, and assuming default plan settings.
- nx: The transform size (e.g. 256 for a 256-point FFT)
- type_: The transform data type (e.g., C2C for single precision complex to complex)
- batch: Number of transforms of size nx. Please consider using EstimateMany for multiple transforms
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidSize: The nx parameter is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftEstimate1d.
func Estimate2d ¶
Estimate2d returns an estimate of the work area size a 2D plan requires, assuming default plan settings.
During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
This call returns an estimate for the size of the work area required, given the specified parameters, and assuming default plan settings. If a work area size of 0 is returned it means no temporary storage is needed for evaluation.
- nx: The transform size in the x dimension (number of rows)
- ny: The transform size in the y dimension (number of columns)
- type_: The transform data type (e.g., C2R for single precision complex to real)
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidSize: Either or both of the nx or ny parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftEstimate2d.
func Estimate3d ¶
Estimate3d returns an estimate of the work area size a 3D plan requires, assuming default plan settings.
During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
This call returns an estimate for the size of the work area required, given the specified parameters, and assuming default plan settings. If a work area size of 0 is returned it means no temporary storage is needed for evaluation.
- nx: The transform size in the x dimension
- ny: The transform size in the y dimension
- nz: The transform size in the z dimension
- type_: The transform data type (e.g., R2C for single precision real to complex)
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidSize: One or more of the nx, ny, or nz parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftEstimate3d.
func EstimateMany ¶
func EstimateMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, onembed *int32, ostride int32, odist int32, type_ Type, batch int32) (uint, error)
EstimateMany returns an estimate of the work area size a plan of dimension rank requires, assuming default plan settings.
During plan execution, cuFFT requires a work area for temporary storage of intermediate results.
This call returns an estimate for the size of the work area required, given the specified parameters, and assuming default plan settings. If a work area size of 0 is returned it means no temporary storage is needed for evaluation. The EstimateMany API supports more complicated input and output data layouts via the advanced data layout parameters: inembed, istride, idist, onembed, ostride, and odist. All arrays are assumed to be in CPU memory.
- rank: Dimensionality of the transform (1, 2, or 3)
- n: Array of size rank, describing the size of each dimension
- inembed: Pointer of size rank that indicates the storage dimensions of the input data in memory. If set to NULL all other advanced data layout parameters are ignored
- istride: Indicates the distance between two successive input elements in the least significant (i.e., innermost) dimension
- idist: Indicates the distance between the first element of two consecutive signals in a batch of the input data
- onembed: Pointer of size rank that indicates the storage dimensions of the output data in memory. If set to NULL all other advanced data layout parameters are ignored
- ostride: Indicates the distance between two successive output elements in the output array in the least significant (i.e., innermost) dimension
- odist: Indicates the distance between the first element of two consecutive signals in a batch of the output data
- type_: The transform data type (e.g., R2C for single precision real to complex)
- batch: Batch size for this transform
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidSize: One or more of the parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftEstimateMany.
func GetProperty ¶
func GetProperty(type_ LibraryPropertyType) (int32, error)
GetProperty returns the number for the property described by type of the dynamically linked CUFFT library.
- type_: CUDA library property
A nil error means the property value was successfully returned.
Errors:
- ErrInvalidType: The property type is not recognized.
- ErrInvalidValue: value is NULL.
Wraps cufftGetProperty.
func GetVersion ¶
GetVersion returns the version number of cuFFT.
A nil error means cuFFT successfully returned the version number.
Wraps cufftGetVersion.
func Has ¶
Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.
func HasCreate ¶
func HasCreate() bool
HasCreate reports whether cufftCreate resolved in the loaded library.
func HasDestroy ¶
func HasDestroy() bool
HasDestroy reports whether cufftDestroy resolved in the loaded library.
func HasEstimate1d ¶
func HasEstimate1d() bool
HasEstimate1d reports whether cufftEstimate1d resolved in the loaded library.
func HasEstimate2d ¶
func HasEstimate2d() bool
HasEstimate2d reports whether cufftEstimate2d resolved in the loaded library.
func HasEstimate3d ¶
func HasEstimate3d() bool
HasEstimate3d reports whether cufftEstimate3d resolved in the loaded library.
func HasEstimateMany ¶
func HasEstimateMany() bool
HasEstimateMany reports whether cufftEstimateMany resolved in the loaded library.
func HasExecC2C ¶
func HasExecC2C() bool
HasExecC2C reports whether cufftExecC2C resolved in the loaded library.
func HasExecC2R ¶
func HasExecC2R() bool
HasExecC2R reports whether cufftExecC2R resolved in the loaded library.
func HasExecD2Z ¶
func HasExecD2Z() bool
HasExecD2Z reports whether cufftExecD2Z resolved in the loaded library.
func HasExecR2C ¶
func HasExecR2C() bool
HasExecR2C reports whether cufftExecR2C resolved in the loaded library.
func HasExecZ2D ¶
func HasExecZ2D() bool
HasExecZ2D reports whether cufftExecZ2D resolved in the loaded library.
func HasExecZ2Z ¶
func HasExecZ2Z() bool
HasExecZ2Z reports whether cufftExecZ2Z resolved in the loaded library.
func HasGetPlanPropertyInt64 ¶
func HasGetPlanPropertyInt64() bool
HasGetPlanPropertyInt64 reports whether cufftGetPlanPropertyInt64 resolved in the loaded library.
func HasGetProperty ¶
func HasGetProperty() bool
HasGetProperty reports whether cufftGetProperty resolved in the loaded library.
func HasGetSize ¶
func HasGetSize() bool
HasGetSize reports whether cufftGetSize resolved in the loaded library.
func HasGetSize1d ¶
func HasGetSize1d() bool
HasGetSize1d reports whether cufftGetSize1d resolved in the loaded library.
func HasGetSize2d ¶
func HasGetSize2d() bool
HasGetSize2d reports whether cufftGetSize2d resolved in the loaded library.
func HasGetSize3d ¶
func HasGetSize3d() bool
HasGetSize3d reports whether cufftGetSize3d resolved in the loaded library.
func HasGetSizeMany ¶
func HasGetSizeMany() bool
HasGetSizeMany reports whether cufftGetSizeMany resolved in the loaded library.
func HasGetSizeMany64 ¶
func HasGetSizeMany64() bool
HasGetSizeMany64 reports whether cufftGetSizeMany64 resolved in the loaded library.
func HasGetVersion ¶
func HasGetVersion() bool
HasGetVersion reports whether cufftGetVersion resolved in the loaded library.
func HasMakePlan1d ¶
func HasMakePlan1d() bool
HasMakePlan1d reports whether cufftMakePlan1d resolved in the loaded library.
func HasMakePlan2d ¶
func HasMakePlan2d() bool
HasMakePlan2d reports whether cufftMakePlan2d resolved in the loaded library.
func HasMakePlan3d ¶
func HasMakePlan3d() bool
HasMakePlan3d reports whether cufftMakePlan3d resolved in the loaded library.
func HasMakePlanMany ¶
func HasMakePlanMany() bool
HasMakePlanMany reports whether cufftMakePlanMany resolved in the loaded library.
func HasMakePlanMany64 ¶
func HasMakePlanMany64() bool
HasMakePlanMany64 reports whether cufftMakePlanMany64 resolved in the loaded library.
func HasPlan1d ¶
func HasPlan1d() bool
HasPlan1d reports whether cufftPlan1d resolved in the loaded library.
func HasPlan2d ¶
func HasPlan2d() bool
HasPlan2d reports whether cufftPlan2d resolved in the loaded library.
func HasPlan3d ¶
func HasPlan3d() bool
HasPlan3d reports whether cufftPlan3d resolved in the loaded library.
func HasPlanMany ¶
func HasPlanMany() bool
HasPlanMany reports whether cufftPlanMany resolved in the loaded library.
func HasResetPlanProperty ¶
func HasResetPlanProperty() bool
HasResetPlanProperty reports whether cufftResetPlanProperty resolved in the loaded library.
func HasSetAutoAllocation ¶
func HasSetAutoAllocation() bool
HasSetAutoAllocation reports whether cufftSetAutoAllocation resolved in the loaded library.
func HasSetPlanPropertyInt64 ¶
func HasSetPlanPropertyInt64() bool
HasSetPlanPropertyInt64 reports whether cufftSetPlanPropertyInt64 resolved in the loaded library.
func HasSetStream ¶
func HasSetStream() bool
HasSetStream reports whether cufftSetStream resolved in the loaded library.
func HasSetWorkArea ¶
func HasSetWorkArea() bool
HasSetWorkArea reports whether cufftSetWorkArea resolved in the loaded library.
func Load ¶
Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.
Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.
Types ¶
type BindFailure ¶
BindFailure names a symbol the loaded library exports but that could not be bound, and why.
func BindFailures ¶
func BindFailures() []BindFailure
BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.
A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.
type CallError ¶
CallError reports that a library call returned a failure result.
Unwrap returns Result, so errors.Is(err, c) reports whether the call returned the Result constant c, and errors.As(err, &r) with r of type Result recovers the code.
type Compatibility ¶
type Compatibility int32
Compatibility specifies the compatibility (cufftCompatibility).
const (
CompatibilityFftwPadding Compatibility = 0x01 // The default value
)
func (Compatibility) String ¶
func (e Compatibility) String() string
String returns the constant name, or a numeric representation for unknown values.
type DoubleComplex ¶
DoubleComplex holds 16-byte complex elements for host staging with Go alignment 8; Handle.ExecZ2Z, Handle.ExecD2Z, and Handle.ExecZ2D require device-accessible input and output addresses aligned to 16 bytes, which Go allocations and slice offsets do not guarantee.
type Handle ¶
type Handle int32
Handle is an opaque plan handle for cuFFT operations.
func Create ¶
Create creates only an opaque handle, and allocates small data structures on the host.
The cufftMakePlan*() calls actually do the plan generation.
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftCreate.
func Plan1d ¶
Plan1d creates a 1D FFT plan configuration for a specified signal size and data type.
The batch input parameter tells cuFFT how many 1D transforms to configure. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call.
- nx: The transform size (e.g. 256 for a 256-point FFT)
- type_: The transform data type (e.g., C2C for single precision complex to complex)
- batch: Number of transforms of size nx. Please consider using PlanMany for multiple transforms
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked.
- ErrInvalidSize: The nx or batch parameter is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftPlan1d.
func Plan2d ¶
Plan2d creates a 2D FFT plan configuration according to specified signal sizes and data type.
This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call.
- nx: The transform size in the x dimension This is slowest changing dimension of a transform (strided in memory)
- ny: The transform size in the y dimension. This is fastest changing dimension of a transform (contiguous in memory)
- type_: The transform data type (e.g., C2R for single precision complex to real)
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked.
- ErrInvalidSize: Either or both of the nx or ny parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftPlan2d.
func Plan3d ¶
Plan3d creates a 3D FFT plan configuration according to specified signal sizes and data type.
This function is the same as Plan2d except that it takes a third size parameter nz. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call.
- nx: The transform size in the x dimension. This is slowest changing dimension of a transform (strided in memory)
- ny: The transform size in the y dimension
- nz: The transform size in the z dimension. This is fastest changing dimension of a transform (contiguous in memory)
- type_: The transform data type (e.g., R2C for single precision real to complex)
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked.
- ErrInvalidSize: One or more of the nx, ny, or nz parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftPlan3d.
func PlanMany ¶
func PlanMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, onembed *int32, ostride int32, odist int32, type_ Type, batch int32) (Handle, error)
PlanMany creates a FFT plan configuration of dimension rank, with sizes specified in the array n.
The batch input parameter tells cuFFT how many transforms to configure. With this function, batched plans of 1, 2, or 3 dimensions may be created. The PlanMany API supports more complicated input and output data layouts via the advanced data layout parameters: inembed, istride, idist, onembed, ostride, and odist. If inembed and onembed are set to NULL, all other stride information is ignored, and default strides are used. The default assumes contiguous data arrays. All arrays are assumed to be in CPU memory. Please note that behavior of PlanMany function when inembed and onembed is NULL is different than corresponding function in FFTW library fftw_plan_many_dft. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call.
- rank: Dimensionality of the transform (1, 2, or 3)
- n: Array of size rank, describing the size of each dimension, n[0] being the size of the outermost and n[rank-1] innermost (contiguous) dimension of a transform
- inembed: Pointer of size rank that indicates the storage dimensions of the input data in memory. If set to NULL all other advanced data layout parameters are ignored
- istride: Indicates the distance between two successive input elements in the least significant (i.e., innermost) dimension
- idist: Indicates the distance between the first element of two consecutive signals in a batch of the input data
- onembed: Pointer of size rank that indicates the storage dimensions of the output data in memory. If set to NULL all other advanced data layout parameters are ignored
- ostride: Indicates the distance between two successive output elements in the output array in the least significant (i.e., innermost) dimension
- odist: Indicates the distance between the first element of two consecutive signals in a batch of the output data
- type_: The transform data type (e.g., R2C for single precision real to complex)
- batch: Batch size for this transform
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked.
- ErrInvalidSize: One or more of the parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftPlanMany.
func (Handle) Destroy ¶
Destroy frees all GPU resources associated with a cuFFT plan and destroys the internal plan data structure.
This function should be called once a plan is no longer needed, to avoid wasting GPU memory. In the case of multi-GPU plans, the plan created first should be destroyed last.
A nil error means cuFFT successfully destroyed the FFT plan.
Errors:
- ErrInvalidPlan: The plan parameter is not a valid handle.
It is not named Close because Handle is not a pointer, so zero may name a live object.
Wraps cufftDestroy.
func (Handle) ExecC2C ¶
ExecC2C Handle.ExecC2C ( Handle.ExecZ2Z) executes a single-precision (double-precision) complex-to-complex transform plan in the transform direction as specified by direction parameter.
cuFFT uses the GPU memory pointed to by the idata parameter as input data. This function stores the Fourier coefficients in the odata array. If idata and odata are the same, this method does an in-place transform.
- idata: Pointer to the complex input data (in GPU memory) to transform
- odata: Contains the complex Fourier coefficients
- direction: The transform direction: CUFFT_FORWARD or CUFFT_INVERSE
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrExecFailed: cuFFT failed to execute the transform on the GPU.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: At least one of the parameters idata, odata, and direction is not valid, or the work area provided in Handle.SetWorkArea is not valid.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftExecC2C.
func (Handle) ExecC2R ¶
ExecC2R Handle.ExecC2R ( Handle.ExecZ2D) executes a single-precision (double-precision) complex-to-real, implicitly inverse, cuFFT transform plan.
cuFFT uses as input data the GPU memory pointed to by the idata parameter. The input array holds only the nonredundant complex Fourier coefficients. This function stores the real output values in the odata array. and pointers are both required to be aligned to Complex data type in single-precision transforms and DoubleComplex type in double-precision transforms. If idata and odata are the same, this method does an in-place transform.
- idata: Pointer to the complex input data (in GPU memory) to transform
- odata: Contains the real output data
A nil error means cuFFT successfully executed the FFT plan.
Errors:
- ErrExecFailed: cuFFT failed to execute the transform on the GPU.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: At least one of the parameters idata and odata is not valid, or the work area provided in Handle.SetWorkArea is not valid.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftExecC2R.
func (Handle) ExecD2Z ¶
ExecD2Z Handle.ExecR2C ( Handle.ExecD2Z) executes a single-precision (double-precision) real-to-complex, implicitly forward, cuFFT transform plan.
cuFFT uses as input data the GPU memory pointed to by the idata parameter. This function stores the nonredundant Fourier coefficients in the odata array. Pointers to idata and odata are both required to be aligned to Complex data type in single-precision transforms and DoubleComplex data type in double-precision transforms. If idata and odata are the same, this method does an in-place transform. Note the data layout differences between in-place and out-of-place transforms as described in Parameter Type.
- idata: Pointer to the real input data (in GPU memory) to transform
- odata: Contains the complex Fourier coefficients
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrExecFailed: cuFFT failed to execute the transform on the GPU.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: At least one of the parameters idata and odata is not valid, or the work area provided in Handle.SetWorkArea is not valid.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftExecD2Z.
func (Handle) ExecR2C ¶
ExecR2C Handle.ExecR2C ( Handle.ExecD2Z) executes a single-precision (double-precision) real-to-complex, implicitly forward, cuFFT transform plan.
cuFFT uses as input data the GPU memory pointed to by the idata parameter. This function stores the nonredundant Fourier coefficients in the odata array. Pointers to idata and odata are both required to be aligned to Complex data type in single-precision transforms and DoubleComplex data type in double-precision transforms. If idata and odata are the same, this method does an in-place transform. Note the data layout differences between in-place and out-of-place transforms as described in Parameter Type.
- idata: Pointer to the real input data (in GPU memory) to transform
- odata: Contains the complex Fourier coefficients
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrExecFailed: cuFFT failed to execute the transform on the GPU.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: At least one of the parameters idata and odata is not valid, or the work area provided in Handle.SetWorkArea is not valid.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftExecR2C.
func (Handle) ExecZ2D ¶
ExecZ2D Handle.ExecC2R ( Handle.ExecZ2D) executes a single-precision (double-precision) complex-to-real, implicitly inverse, cuFFT transform plan.
cuFFT uses as input data the GPU memory pointed to by the idata parameter. The input array holds only the nonredundant complex Fourier coefficients. This function stores the real output values in the odata array. and pointers are both required to be aligned to Complex data type in single-precision transforms and DoubleComplex type in double-precision transforms. If idata and odata are the same, this method does an in-place transform.
- idata: Pointer to the complex input data (in GPU memory) to transform
- odata: Contains the real output data
A nil error means cuFFT successfully executed the FFT plan.
Errors:
- ErrExecFailed: cuFFT failed to execute the transform on the GPU.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: At least one of the parameters idata and odata is not valid, or the work area provided in Handle.SetWorkArea is not valid.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftExecZ2D.
func (Handle) ExecZ2Z ¶
ExecZ2Z Handle.ExecC2C ( Handle.ExecZ2Z) executes a single-precision (double-precision) complex-to-complex transform plan in the transform direction as specified by direction parameter.
cuFFT uses the GPU memory pointed to by the idata parameter as input data. This function stores the Fourier coefficients in the odata array. If idata and odata are the same, this method does an in-place transform.
- idata: Pointer to the complex input data (in GPU memory) to transform
- odata: Contains the complex Fourier coefficients
- direction: The transform direction: CUFFT_FORWARD or CUFFT_INVERSE
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrExecFailed: cuFFT failed to execute the transform on the GPU.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: At least one of the parameters idata, odata, and direction is not valid, or the work area provided in Handle.SetWorkArea is not valid.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftExecZ2Z.
func (Handle) MakePlan1d ¶
MakePlan1d configures the plan as a 1D FFT of the given signal size and data type.
Following a call to Create makes a 1D FFT plan configuration for a specified signal size and data type.
The batch input parameter tells cuFFT how many 1D transforms to configure. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call. If cufftXtSetGPUs() was called prior to this call with multiple GPUs, then workSize will contain multiple sizes. See sections on multiple GPUs for more details.
- nx: The transform size (e.g. 256 for a 256-point FFT). For multiple GPUs, this must be a power of 2
- type_: The transform data type (e.g., C2C for single precision complex to complex). For multiple GPUs this must be a complex to complex transform
- batch: Number of transforms of size nx. Please consider using Handle.MakePlanMany for multiple transforms
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked or multi-GPU restrictions are not met.
- ErrInvalidSize: The nx or batch parameter is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- [ErrSetupFailed]`: The cuFFT library failed to initialize.
Wraps cufftMakePlan1d.
func (Handle) MakePlan2d ¶
MakePlan2d configures the plan as a 2D FFT of the given signal sizes and data type.
Following a call to Create makes a 2D FFT plan configuration according to specified signal sizes and data type.
This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call. If cufftXtSetGPUs() was called prior to this call with multiple GPUs, then workSize will contain multiple sizes. See sections on multiple GPUs for more details.
- nx: The transform size in the x dimension. This is slowest changing dimension of a transform (strided in memory). For multiple GPUs, this must be factorable into primes less than or equal to 127
- ny: The transform size in the y dimension. This is fastest changing dimension of a transform (contiguous in memory). For 2 GPUs, this must be factorable into primes less than or equal to 127
- type_: The transform data type (e.g., C2R for single precision complex to real)
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: Either or both of the nx or ny parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftMakePlan2d.
func (Handle) MakePlan3d ¶
MakePlan3d configures the plan as a 3D FFT of the given signal sizes and data type.
Following a call to Create makes a 3D FFT plan configuration according to specified signal sizes and data type.
This function is the same as Plan2d except that it takes a third size parameter nz. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call. If cufftXtSetGPUs() was called prior to this call with multiple GPUs, then workSize will contain multiple sizes. See sections on multiple GPUs for more details.
- nx: The transform size in the x dimension. This is slowest changing dimension of a transform (strided in memory). For multiple GPUs, this must be factorable into primes less than or equal to 127
- ny: The transform size in the y dimension. For multiple GPUs, this must be factorable into primes less than or equal to 127
- nz: The transform size in the z dimension. This is fastest changing dimension of a transform (contiguous in memory). For multiple GPUs, this must be factorable into primes less than or equal to 127
- type_: The transform data type (e.g., R2C for single precision real to complex)
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: One or more of the nx, ny, or nz parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftMakePlan3d.
func (Handle) MakePlanMany ¶
func (h Handle) MakePlanMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, onembed *int32, ostride int32, odist int32, type_ Type, batch int32) (uint, error)
MakePlanMany configures the plan as an FFT of dimension rank, with the sizes in n.
Following a call to Create makes a FFT plan configuration of dimension rank, with sizes specified in the array n.
The batch input parameter tells cuFFT how many transforms to configure. With this function, batched plans of 1, 2, or 3 dimensions may be created. The PlanMany API supports more complicated input and output data layouts via the advanced data layout parameters: inembed, istride, idist, onembed, ostride, and odist. If inembed and onembed are set to NULL, all other stride information is ignored, and default strides are used. The default assumes contiguous data arrays. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call. If cufftXtSetGPUs() was called prior to this call with multiple GPUs, then workSize will contain multiple sizes. See sections on multiple GPUs for more details. All arrays are assumed to be in CPU memory.
- rank: Dimensionality of the transform (1, 2, or 3)
- n: Array of size rank, describing the size of each dimension, n[0] being the size of the outermost and n[rank-1] innermost (contiguous) dimension of a transform. For multiple GPUs and rank equal to 1, the sizes must be a power of 2. For multiple GPUs and rank equal to 2 or 3, the sizes must be factorable into primes less than or equal to 127
- inembed: Pointer of size rank that indicates the storage dimensions of the input data in memory, inembed[0] being the storage dimension of the outermost dimension. If set to NULL all other advanced data layout parameters are ignored
- istride: Indicates the distance between two successive input elements in the least significant (i.e., innermost) dimension
- idist: Indicates the distance between the first element of two consecutive signals in a batch of the input data
- onembed: Pointer of size rank that indicates the storage dimensions of the output data in memory, onembed[0] being the storage dimension of the outermost dimension. If set to NULL all other advanced data layout parameters are ignored
- ostride: Indicates the distance between two successive output elements in the output array in the least significant (i.e., innermost) dimension
- odist: Indicates the distance between the first element of two consecutive signals in a batch of the output data
- type_: The transform data type (e.g., R2C for single precision real to complex). For 2 GPUs this must be a complex to complex transform
- batch: Batch size for this transform
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked or multi-GPU restrictions are not met.
- ErrInvalidSize: One or more of the parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftMakePlanMany.
func (Handle) MakePlanMany64 ¶
func (h Handle) MakePlanMany64(rank int32, n *int64, inembed *int64, istride int64, idist int64, onembed *int64, ostride int64, odist int64, type_ Type, batch int64) (uint, error)
MakePlanMany64 configures the plan as an FFT of dimension rank, with 64-bit sizes and strides.
Following a call to Create makes a FFT plan configuration of dimension rank, with sizes specified in the array n.
The batch input parameter tells cuFFT how many transforms to configure. With this function, batched plans of 1, 2, or 3 dimensions may be created. This API is identical to Handle.MakePlanMany except that the arguments specifying sizes and strides are 64 bit integers. This API makes very large transforms possible. cuFFT includes kernels that use 32 bit indexes, and kernels that use 64 bit indexes. cuFFT planning selects 32 bit kernels whenever possible to avoid any overhead due to 64 bit arithmetic. All sizes and types of transform are supported by this interface, with two exceptions. For transforms whose size exceeds 4G elements, the dimensions specified in the array n must be factorable into primes that are less than or equal to 127. For real to complex and complex to real transforms whose size exceeds 4G elements, the fastest changing dimension must be even. The cufftPlanMany64() API supports more complicated input and output data layouts via the advanced data layout parameters: inembed, istride, idist, onembed, ostride, and odist. If inembed and onembed are set to NULL, all other stride information is ignored, and default strides are used. The default assumes contiguous data arrays. This call can only be used once for a given handle. It will fail and return ErrInvalidPlan if the plan is locked, i.e. the handle was previously used with a different cufftPlan or cufftMakePlan call. If cufftXtSetGPUs() was called prior to this call with multiple GPUs, then workSize will contain multiple sizes. See sections on multiple GPUs for more details. All arrays are assumed to be in CPU memory.
- rank: Dimensionality of the transform (1, 2, or 3)
- n: Array of size rank, describing the size of each dimension. For multiple GPUs and rank equal to 1, the sizes must be a power of 2. For multiple GPUs and rank equal to 2 or 3, the sizes must be factorable into primes less than or equal to 127
- inembed: Pointer of size rank that indicates the storage dimensions of the input data in memory. If set to NULL all other advanced data layout parameters are ignored
- istride: Indicates the distance between two successive input elements in the least significant (i.e., innermost) dimension
- idist: Indicates the distance between the first element of two consecutive signals in a batch of the input data
- onembed: Pointer of size rank that indicates the storage dimensions of the output data in memory. If set to NULL all other advanced data layout parameters are ignored
- ostride: Indicates the distance between two successive output elements in the output array in the least significant (i.e., innermost) dimension
- odist: Indicates the distance between the first element of two consecutive signals in a batch of the output data
- type_: The transform data type (e.g., R2C for single precision real to complex). For 2 GPUs this must be a complex to complex transform
- batch: Batch size for this transform
A nil error means cuFFT successfully created the FFT plan.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle. Handle is not valid when the plan is locked or multi-GPU restrictions are not met.
- ErrInvalidSize: One or more of the parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrMissingDependency: The cuFFT library was unable to find a dependency either because it is missing or the version found is incompatible
- ErrNvjitlinkFailure: nvJitLink encountered an error during planning
- ErrNvrtcFailure: NVRTC encountered an error during planning
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftMakePlanMany64.
func (Handle) PlanPropertyInt64 ¶
PlanPropertyInt64 retrieves the property value identified by the key property associated with the cuFFT plan plan.
The value for the property, which is a signed long long integer, is set in the address space pointed by propertyValueInt64.
Requires CUDA 12.4 or later; see HasGetPlanPropertyInt64.
- property: The property identifier, of type Property
A nil error means cuFFT successfully retrieved the property value.
Errors:
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: Invalid property, or pointer propertyValueInt64 is null
- ErrNotSupported: The property is not supported.
Wraps cufftGetPlanPropertyInt64.
func (Handle) ResetPlanProperty ¶
ResetPlanProperty resets the value of the property identified by the key property, associated with the cuFFT plan plan, to its default value.
Requires CUDA 12.4 or later; see HasResetPlanProperty.
- property: The property identifier, of type Property
A nil error means cuFFT successfully reset the property value.
Errors:
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: Invalid property
- ErrNotSupported: The property is not supported for plan, or cannot be reset at present time (see Behavior column on cuFFT Plan Properties).
Wraps cufftResetPlanProperty.
func (Handle) SetAutoAllocation ¶
SetAutoAllocation indicates that the caller intends to allocate and manage work areas for plans that have been generated.
cuFFT default behavior is to allocate the work area at plan generation time. If Handle.SetAutoAllocation has been called with autoAllocate set to 0 (“false”) prior to one of the cufftMakePlan*() calls, cuFFT does not allocate the work area. This is the preferred sequence for callers wishing to manage work area allocation.
- autoAllocate: Indicates whether to allocate work area
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
Wraps cufftSetAutoAllocation.
func (Handle) SetPlanPropertyInt64 ¶
SetPlanPropertyInt64 associates a cuFFT plan with a property identified by the key property.
The value for the property is given by value propertyValueInt64, which is a signed long long integer.
Requires CUDA 12.4 or later; see HasSetPlanPropertyInt64.
- property: The property identifier, of type Property
A nil error means cuFFT successfully set the property.
Errors:
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidValue: Invalid property or value with which to set the property
- ErrNotSupported: The property is not supported, or it cannot be set at the time (e.g. some properties cannot be set after calling a planning routine for the plan, see cuFFT Plan Properties).
Wraps cufftSetPlanPropertyInt64.
func (Handle) SetStream ¶
SetStream associates a CUDA stream with a cuFFT plan.
All kernel launches made during plan execution are now done through the associated stream, enabling overlap with activity in other streams (e.g. data copying). The association remains until the plan is destroyed or the stream is changed with another call to Handle.SetStream. Note that starting from CUDA 11.2 (cuFFT 10.4.0), Handle.SetStream is supported on multi-GPU plans. When associating a stream with a plan, cufftXtMemcpy() remains synchronous across the multiple GPUs. For previous versions of cuFFT, Handle.SetStream will return an error in multiple GPU plans. Note that starting from CUDA 12.2 (cuFFT 11.0.8), on multi-GPU plans, stream can be associated with any context on any GPU. However, repeated calls to Handle.SetStream with streams from different contexts incur a small time penalty. Optimal performance is obtained when repeated calls to Handle.SetStream use streams from the same CUDA context.
- stream: A valid CUDA stream created with cudaStreamCreate(); 0 for the default stream
A nil error means the stream was associated with the plan.
Errors:
- ErrInvalidPlan: The plan parameter is not a valid handle, or plan is multi-gpu in cuFFT version prior to 10.4.0.
Wraps cufftSetStream.
func (Handle) SetWorkArea ¶
SetWorkArea overrides the work area pointer associated with a plan.
If the work area was auto-allocated, cuFFT frees the auto-allocated space. The cufftExec*() calls assume that the work area pointer is valid, aligned to the complex type of the plan ( Complex for single precision and DoubleComplex for double precision transforms), and that it points to a contiguous region in device memory that does not overlap with any other work area. If the work area is misaligned, cufftExec*() fails with ErrInvalidValue. Other assumption violations yield indeterminate results.
- workArea: Pointer to workArea. For multiple GPUs, multiple work area pointers must be given
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftSetWorkArea.
func (Handle) Size ¶
Size returns the size of the work area the plan requires.
Once plan generation has been done, either with the original API or the extensible API, this call returns the actual size of the work area required to support the plan.
Callers who choose to manage work area allocation within their application must use this call after plan generation, and after any cufftSet*() calls subsequent to plan generation, if those calls might alter the required work space size.
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
Wraps cufftGetSize.
func (Handle) Size1d ¶
Size1d gives a more accurate estimate of the work area size required for a plan than Estimate1d, given the specified parameters, and taking into account any plan settings that may have been made.
If a work area size of 0 is returned it means no temporary storage is needed for evaluation.
- nx: The transform size (e.g. 256 for a 256-point FFT)
- type_: The transform data type (e.g., C2C for single precision complex to complex)
- batch: Number of transforms of size nx. Please consider using Handle.SizeMany for multiple transforms
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: The nx parameter is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftGetSize1d.
func (Handle) Size2d ¶
Size2d gives a more accurate estimate of the work area size required for a plan than Estimate2d, given the specified parameters, and taking into account any plan settings that may have been made.
If a work area size of 0 is returned it means no temporary storage is needed for evaluation.
- nx: The transform size in the x dimension (number of rows)
- ny: The transform size in the y dimension (number of columns)
- type_: The transform data type (e.g., C2R for single precision complex to real)
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: Either or both of the nx or ny parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftGetSize2d.
func (Handle) Size3d ¶
Size3d gives a more accurate estimate of the work area size required for a plan than Estimate3d, given the specified parameters, and taking into account any plan settings that may have been made.
If a work area size of 0 is returned it means no temporary storage is needed for evaluation.
- nx: The transform size in the x dimension
- ny: The transform size in the y dimension
- nz: The transform size in the z dimension
- type_: The transform data type (e.g., R2C for single precision real to complex)
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: One or more of the nx, ny, or nz parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftGetSize3d.
func (Handle) SizeMany ¶
func (h Handle) SizeMany(rank int32, n *int32, inembed *int32, istride int32, idist int32, onembed *int32, ostride int32, odist int32, type_ Type, batch int32) (uint, error)
SizeMany gives a more accurate estimate of the work area size required for a plan than cufftEstimateSizeMany(), given the specified parameters, and taking into account any plan settings that may have been made.
If a work area size of 0 is returned it means no temporary storage is needed for evaluation.
- rank: Dimensionality of the transform (1, 2, or 3)
- n: Array of size rank, describing the size of each dimension
- inembed: Pointer of size rank that indicates the storage dimensions of the input data in memory. If set to NULL all other advanced data layout parameters are ignored
- istride: Indicates the distance between two successive input elements in the least significant (i.e., innermost) dimension
- idist: Indicates the distance between the first element of two consecutive signals in a batch of the input data
- onembed: Pointer of size rank that indicates the storage dimensions of the output data in memory. If set to NULL all other advanced data layout parameters are ignored
- ostride: Indicates the distance between two successive output elements in the output array in the least significant (i.e., innermost) dimension
- odist: Indicates the distance between the first element of two consecutive signals in a batch of the output data
- type_: The transform data type (e.g., R2C for single precision real to complex)
- batch: Batch size for this transform
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: One or more of the parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftGetSizeMany.
func (Handle) SizeMany64 ¶
func (h Handle) SizeMany64(rank int32, n *int64, inembed *int64, istride int64, idist int64, onembed *int64, ostride int64, odist int64, type_ Type, batch int64) (uint, error)
SizeMany64 gives a more accurate estimate of the work area size required for a plan than cufftEstimateSizeMany(), given the specified parameters, and taking into account any plan settings that may have been made.
If a work area size of 0 is returned it means no temporary storage is needed for evaluation. This API is identical to Handle.MakePlanMany except that the arguments specifying sizes and strides are 64 bit integers. This API makes very large transforms possible. cuFFT includes kernels that use 32 bit indexes, and kernels that use 64 bit indexes. cuFFT planning selects 32 bit kernels whenever possible to avoid any overhead due to 64 bit arithmetic. All sizes and types of transform are supported by this interface, with two exceptions. For transforms whose total size exceeds 4G elements, the dimensions specified in the array n must be factorable into primes that are less than or equal to 127. For real to complex and complex to real transforms whose total size exceeds 4G elements, the fastest changing dimension must be even.
- rank: Dimensionality of the transform (1, 2, or 3)
- n: Array of size rank, describing the size of each dimension
- inembed: Pointer of size rank that indicates the storage dimensions of the input data in memory. If set to NULL all other advanced data layout parameters are ignored
- istride: Indicates the distance between two successive input elements in the least significant (i.e., innermost) dimension
- idist: Indicates the distance between the first element of two consecutive signals in a batch of the input data
- onembed: Pointer of size rank that indicates the storage dimensions of the output data in memory. If set to NULL all other advanced data layout parameters are ignored
- ostride: Indicates the distance between two successive output elements in the output array in the least significant (i.e., innermost) dimension
- odist: Indicates the distance between the first element of two consecutive signals in a batch of the output data
- type_: The transform data type (e.g., R2C for single precision real to complex)
- batch: Batch size for this transform
A nil error means cuFFT successfully returned the size of the work space.
Errors:
- ErrAllocFailed: The allocation of GPU resources for the plan failed.
- ErrInternalError: An internal driver error was detected.
- ErrInvalidPlan: The plan parameter is not a valid handle.
- ErrInvalidSize: One or more of the parameters is not a supported size.
- ErrInvalidValue: One or more invalid parameters were passed to the API.
- ErrSetupFailed: The cuFFT library failed to initialize.
Wraps cufftGetSizeMany64.
type LibraryAttempt ¶
LibraryAttempt records one failed attempt to open the shared library.
type LibraryConflictError ¶
type LibraryConflictError struct {
Loaded string
Requested string
// Implicit reports that the loaded library was opened lazily and no
// successful Load has since acknowledged it. A
// caller that sees this called some
// other function first, and that call took the default search list.
Implicit bool
}
LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.
func (*LibraryConflictError) Error ¶
func (e *LibraryConflictError) Error() string
Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.
type LibraryError ¶
type LibraryError struct {
Library string
Env string
Path string
Attempts []LibraryAttempt
Hint string
}
LibraryError reports that libcufft could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or CUFFT_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
Error describes the library load attempts and their errors.
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() []error
Unwrap returns the error from each attempt.
type LibraryPropertyType ¶
type LibraryPropertyType int32
LibraryPropertyType identifies a library property to query.
const ( // The major version number. MajorVersion LibraryPropertyType = 0 // The minor version number. MinorVersion LibraryPropertyType = 1 // The patch level. PatchLevel LibraryPropertyType = 2 )
LibraryPropertyType constants.
type Result ¶
type Result int32
Result represents a cufft API error code (cufftResult).
const ( Success Result = 0x0 ErrInvalidPlan Result = 0x1 ErrAllocFailed Result = 0x2 ErrInvalidType Result = 0x3 ErrInvalidValue Result = 0x4 ErrInternalError Result = 0x5 ErrExecFailed Result = 0x6 ErrSetupFailed Result = 0x7 ErrInvalidSize Result = 0x8 ErrUnalignedData Result = 0x9 ErrInvalidDevice Result = 0xB ErrNoWorkspace Result = 0xD ErrNotImplemented Result = 0xE ErrNotSupported Result = 0x10 ErrMissingDependency Result = 0x11 ErrNvrtcFailure Result = 0x12 ErrNvjitlinkFailure Result = 0x13 ErrNvshmemFailure Result = 0x14 )
cufft error codes from cufft.h.
type SymbolError ¶
SymbolError reports that a symbol is not callable.
Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.
func (*SymbolError) Error ¶
func (e *SymbolError) Error() string
Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.
func (*SymbolError) Unwrap ¶
func (e *SymbolError) Unwrap() error
Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.
type VersionMismatchError ¶
type VersionMismatchError struct {
Path string // the library that was opened
Want int // major version these bindings were generated for
Got int // major version the library reports
Raw int // the version value the library reported, undecoded
}
VersionMismatchError reports that the shared library that opened is not from the version train cufft was generated for. dlsym matches on name alone, so a library from a neighbouring train opens and resolves nearly every symbol; asking it its own version is what tells the two apart.
func (*VersionMismatchError) Error ¶
func (e *VersionMismatchError) Error() string
Error reports which library was opened and the two majors that disagree.
A decoder is only a decoder for the version schemes it was measured against, and a library from a train that predates the scheme can report a value it does not decode. Naming a major of 0 in that case would attribute to the library a claim it never made, so the raw value is reported instead.