cufft

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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)
}

Index

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

func Estimate1d(nx int32, type_ Type, batch int32) (uint, error)

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:

Wraps cufftEstimate1d.

func Estimate2d

func Estimate2d(nx int32, ny int32, type_ Type) (uint, error)

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:

Wraps cufftEstimate2d.

func Estimate3d

func Estimate3d(nx int32, ny int32, nz int32, type_ Type) (uint, error)

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:

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:

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:

Wraps cufftGetProperty.

func GetVersion

func GetVersion() (int32, error)

GetVersion returns the version number of cuFFT.

A nil error means cuFFT successfully returned the version number.

Wraps cufftGetVersion.

func Has

func Has(symbol string) bool

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

func Load(path string) error

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.

func Loaded

func Loaded() bool

Loaded reports whether the library is currently loaded. It does not trigger a load.

func Path

func Path() string

Path returns the path or name the loaded library was opened from, or the empty string if no library is loaded.

Types

type BindFailure

type BindFailure struct {
	Symbol string
	Err    error
}

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

type CallError struct {
	Func   string // the C symbol called
	Result Result
}

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.

func (*CallError) Error

func (e *CallError) Error() string

Error reports the C symbol called and the result it returned.

func (*CallError) Unwrap

func (e *CallError) Unwrap() error

Unwrap returns the result the call reported.

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 Complex

type Complex struct {
	X float32
	Y float32
	// contains filtered or unexported fields
}

Complex represents a single-precision complex number.

type Direction

type Direction int32

Direction represents transform directions.

const (
	Forward Direction = -1
	Inverse Direction = 1
)

Transform directions.

func (Direction) String

func (v Direction) String() string

String returns the constant name, or a numeric representation for unknown values.

type DoubleComplex

type DoubleComplex struct {
	X float64
	Y float64
}

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 DoubleReal

type DoubleReal float64

DoubleReal is a double-precision real value.

type Handle

type Handle int32

Handle is an opaque plan handle for cuFFT operations.

func Create

func Create() (Handle, error)

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:

Wraps cufftCreate.

func Plan1d

func Plan1d(nx int32, type_ Type, batch int32) (Handle, error)

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:

Wraps cufftPlan1d.

func Plan2d

func Plan2d(nx int32, ny int32, type_ Type) (Handle, error)

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

func Plan3d(nx int32, ny int32, nz int32, type_ Type) (Handle, error)

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:

Wraps cufftPlanMany.

func (Handle) Destroy

func (h Handle) Destroy() error

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:

It is not named Close because Handle is not a pointer, so zero may name a live object.

Wraps cufftDestroy.

func (Handle) ExecC2C

func (h Handle) ExecC2C(idata driver.DevicePtr, odata driver.DevicePtr, direction Direction) error

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:

Wraps cufftExecC2C.

func (Handle) ExecC2R

func (h Handle) ExecC2R(idata driver.DevicePtr, odata driver.DevicePtr) error

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:

Wraps cufftExecC2R.

func (Handle) ExecD2Z

func (h Handle) ExecD2Z(idata driver.DevicePtr, odata driver.DevicePtr) error

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:

Wraps cufftExecD2Z.

func (Handle) ExecR2C

func (h Handle) ExecR2C(idata driver.DevicePtr, odata driver.DevicePtr) error

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:

Wraps cufftExecR2C.

func (Handle) ExecZ2D

func (h Handle) ExecZ2D(idata driver.DevicePtr, odata driver.DevicePtr) error

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:

Wraps cufftExecZ2D.

func (Handle) ExecZ2Z

func (h Handle) ExecZ2Z(idata driver.DevicePtr, odata driver.DevicePtr, direction Direction) error

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:

Wraps cufftExecZ2Z.

func (Handle) MakePlan1d

func (h Handle) MakePlan1d(nx int32, type_ Type, batch int32) (uint, error)

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

func (h Handle) MakePlan2d(nx int32, ny int32, type_ Type) (uint, error)

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:

Wraps cufftMakePlan2d.

func (Handle) MakePlan3d

func (h Handle) MakePlan3d(nx int32, ny int32, nz int32, type_ Type) (uint, error)

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:

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

func (h Handle) PlanPropertyInt64(property Property) (int64, error)

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:

Wraps cufftGetPlanPropertyInt64.

func (Handle) ResetPlanProperty

func (h Handle) ResetPlanProperty(property Property) error

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

func (h Handle) SetAutoAllocation(autoAllocate int32) error

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:

Wraps cufftSetAutoAllocation.

func (Handle) SetPlanPropertyInt64

func (h Handle) SetPlanPropertyInt64(property Property, inputValueInt int64) error

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

func (h Handle) SetStream(stream driver.Stream) error

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

func (h Handle) SetWorkArea(workArea driver.DevicePtr) error

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:

Wraps cufftSetWorkArea.

func (Handle) Size

func (h Handle) Size() (uint, error)

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:

Wraps cufftGetSize.

func (Handle) Size1d

func (h Handle) Size1d(nx int32, type_ Type, batch int32) (uint, error)

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:

Wraps cufftGetSize1d.

func (Handle) Size2d

func (h Handle) Size2d(nx int32, ny int32, type_ Type) (uint, error)

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:

Wraps cufftGetSize2d.

func (Handle) Size3d

func (h Handle) Size3d(nx int32, ny int32, nz int32, type_ Type) (uint, error)

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:

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:

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:

Wraps cufftGetSizeMany64.

type LibraryAttempt

type LibraryAttempt struct {
	Name string // path or soname passed to dlopen
	Err  error
}

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 Property

type Property int32

Property specifies the property (cufftProperty).

const (
	NvfftPlanPropertyInt64PatientJit        Property = 0x1
	NvfftPlanPropertyInt64MaxNumHostThreads Property = 0x2
	NvfftPlanPropertyInt64BluesteinOnly     Property = 0x3
	NvfftPlanPropertyInt64DisableFma        Property = 0x4
)

func (Property) String

func (e Property) String() string

String returns the constant name, or a numeric representation for unknown values.

type Real

type Real float32

Real is a single-precision real value.

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.

func (Result) Code

func (r Result) Code() int32

Code returns the underlying result code for programmatic error handling.

func (Result) Error

func (r Result) Error() string

Error implements the error interface. It returns the error name and description derived from the header documentation.

func (Result) String

func (r Result) String() string

String returns the Go constant name of the result.

type SymbolError

type SymbolError struct {
	Symbol string
	Err    error
}

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 Type

type Type int32

Type specifies the type (cufftType).

const (
	R2C Type = 0x2a // Real to Complex (interleaved)
	C2R Type = 0x2c // Complex (interleaved) to Real
	C2C Type = 0x29 // Complex to Complex, interleaved
	D2Z Type = 0x6a // Double to Double-Complex
	Z2D Type = 0x6c // Double-Complex to Double
	Z2Z Type = 0x69 // Double-Complex to Double-Complex
)

func (Type) String

func (e Type) String() string

String returns the constant name, or a numeric representation for unknown values.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL