### Complete hipFFT example: plan, execute, and cleanup Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/conceptual/overview.html Full example showing the entire hipFFT workflow: allocate device buffer, initialize data, copy to device, create plan, execute, synchronize, copy back, print results, free memory, and destroy plan. ```cpp #include #include #include "hip/hip_runtime_api.h" #include "hip/hip_vector_types.h" #include "hipfft/hipfft.h" int main() { hipfftHandle plan; size_t N = 16; size_t Nbytes = N * sizeof(hipfftComplex); // Create HIP device buffer hipfftComplex *x; hipMalloc(&x, Nbytes); // Initialize data std::vector cx(N); for (size_t i = 0; i < N; i++) { cx[i].x = 1; cx[i].y = -1; } // Copy data to device hipMemcpy(x, cx.data(), Nbytes, hipMemcpyHostToDevice); // Create hipFFT plan hipfftPlan1d(&plan, N, HIPFFT_C2C, 1); // Execute plan hipfftExecC2C(plan, x, x, HIPFFT_FORWARD); // Wait for execution to finish hipDeviceSynchronize(); // Copy result back to host std::vector y(N); hipMemcpy(y.data(), x, Nbytes, hipMemcpyDeviceToHost); // Print results for (size_t i = 0; i < N; i++) { std::cout << y[i].x << ", " << y[i].y << std::endl; } // Free device buffer hipFree(x); // Destroy plan hipfftDestroy(plan); return 0; } ``` -------------------------------- ### 2D real-to-complex transform using hipfftPlanMany() Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/conceptual/overview.html Complete C++ example showing how to set up and execute a batched 2D real-to-complex FFT using the hipFFT advanced interface. It defines the transform parameters (rank, dimensions, batch size), computes strides and distances for the input/output layouts, initializes input data, creates the plan with hipfftPlanMany(), and allocates GPU memory. The example prints the layout parameters and input data for clarity. ```cpp #include #include #include #include #include int main() { // Define the parameters for the 2D FFT int rank = 2; // Rank of the transform (2D FFT) int n[2] = {4, 5}; // Dimensions of the FFT (4 rows, 5 columns) int howmany = 3; // Number of transforms to compute (batch size) // Derived parameters for handling real-to-complex output int n1_complex_elements = n[1] / 2 + 1; // Number of complex elements in the last dimension int n1_padding_real_elements = n1_complex_elements * 2; // Adjusted real elements to account for padding // Strides and distances int istride = 1; // Stride between elements in input int ostride = istride; // Stride between elements in output int inembed[2] = {n[0], n1_padding_real_elements}; // Input layout int onembed[2] = {n[0], n1_complex_elements}; // Output layout int idist = istride * inembed[0] * inembed[1]; // Distance between batches in input int odist = ostride * onembed[0] * onembed[1]; // Distance between batches in output // Print the layout parameters std::cout << "n: " << n[0] << " " << n[1] << "\n" << "howmany: " << howmany << "\n" << "istride: " << istride << "\tostride: " << ostride << "\n" << "inembed: " << inembed[0] << " " << inembed[1] << "\n" << "onembed: " << onembed[0] << " " << onembed[1] << "\n" << "idist: " << idist << "\todist: " << odist << "\n" << std::endl; // Initialize input data std::vector data(howmany * idist); // Allocate space for batched input const auto total_bytes = data.size() * sizeof(decltype(data)::value_type); std::cout << "input:\n"; std::fill(data.begin(), data.end(), 0.0); // Fill data with zeros for(int ibatch = 0; ibatch < howmany; ++ibatch) { for(int i = 0; i < n[0]; i++) // Loop over rows { for(int j = 0; j < n[1]; j++) // Loop over columns { // Calculate the position in the input array const auto pos = ibatch * idist + istride * (i * inembed[1] + j); data[pos] = i + ibatch + j; // Populate data with unique values for clarity } } } // Print the input data for each batch for(int ibatch = 0; ibatch < howmany; ++ibatch) { std::cout << "batch: " << ibatch << "\n"; for(int i = 0; i < n[0]; i++) { for(int j = 0; j < n[1]; j++) { const auto pos = ibatch * idist + istride * (i * inembed[1] + j); std::cout << data[pos] << " "; } std::cout << "\n"; } std::cout << "\n"; } std::cout << std::endl; // Create the hipFFT plan for batched 2D real-to-complex transforms hipfftHandle hipForwardPlan; hipfftResult hipfft_rt = hipfftPlanMany(&hipForwardPlan, rank, n, inembed, istride, idist, onembed, ostride, odist, HIPFFT_R2C, // Transform type (real-to-complex) howmany); // Number of transforms in the batch if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("failed to create plan"); // Allocate GPU memory for input and output hipfftReal* gpu_data; hipError_t hip_rt = hipMalloc((void**)&gpu_data, total_bytes); if(hip_rt != hipSuccess) throw std::runtime_error("hipMalloc failed"); } ``` -------------------------------- ### Install amdrocm-fft-dev on Debian-based distros Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/install.html Installs the latest FFT development package on Debian-based distributions using apt. ```bash sudo apt install amdrocm-fft-dev ``` -------------------------------- ### Multi-GPU 2D FFT with hipFFT Xt API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/conceptual/overview.html Complete example of performing a 2D FFT on two GPUs using hipFFT's Xt API. It initializes input data, creates a plan, assigns GPUs with hipfftXtSetGPUs, allocates memory with hipfftXtMalloc, copies data with hipfftXtMemcpy, executes with hipfftXtExecDescriptor, and cleans up. Requires two GPUs (GPU 0 and GPU 1) and includes error checking for each hipFFT call. ```cpp #include #include #include #include #include #include int main() { // Define FFT dimensions const int Nx = 512; const int Ny = 512; int direction = HIPFFT_FORWARD; // forward = -1, backward = 1 // Initialize input data (complex numbers) for FFT computation int verbose = 0; std::vector> cinput(Nx * Ny); for(size_t i = 0; i < Nx * Ny; i++) { cinput[i] = i; // Initialize the data with some values } // Optionally, print the input data if(verbose) { std::cout << "Input:\n"; for(int i = 0; i < Nx; i++) { for(int j = 0; j < Ny; j++) { int pos = i * Ny + j; std::cout << cinput[pos] << " "; } std::cout << "\n"; } std::cout << std::endl; } // Specify the GPUs you want to use for multi-GPU setup std::vector gpus = {0, 1}; // Use GPU 0 and GPU 1 // Create a multi-GPU plan hipLibXtDesc* desc; // Input descriptor for the Xt format hipfftHandle plan; // Plan handle // Create the FFT plan if(hipfftCreate(&plan) != HIPFFT_SUCCESS) throw std::runtime_error("failed to create plan"); // Create a GPU stream and assign it to the plan for asynchronous operations hipStream_t stream{}; if(hipStreamCreate(&stream) != hipSuccess) throw std::runtime_error("hipStreamCreate failed."); if(hipfftSetStream(plan, stream) != HIPFFT_SUCCESS) throw std::runtime_error("hipfftSetStream failed."); // Assign GPUs to the plan (this is where multi-GPU is specified) hipfftResult hipfft_rt = hipfftXtSetGPUs(plan, gpus.size(), gpus.data()); if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("hipfftXtSetGPUs failed."); // Make the 2D plan for FFT (this defines the 2D FFT using the specified dimensions) std::vector workSize(gpus.size()); hipfft_rt = hipfftMakePlan2d(plan, Nx, Ny, HIPFFT_Z2Z, workSize.data()); if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("hipfftMakePlan2d failed."); // Allocate memory for input data on the GPUs (Xt format handles the data distribution) hipfftXtSubFormat_t format = HIPFFT_XT_FORMAT_INPLACE; hipfft_rt = hipfftXtMalloc(plan, &desc, format); // Allocate memory for the descriptor if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("hipfftXtMalloc failed."); // Copy the input data to the GPUs (device memory) hipfft_rt = hipfftXtMemcpy(plan, reinterpret_cast(desc), reinterpret_cast(cinput.data()), HIPFFT_COPY_HOST_TO_DEVICE); // Copy from host to device if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("hipfftXtMemcpy failed."); // Execute the FFT computation using the Xt descriptor hipfft_rt = hipfftXtExecDescriptor(plan, desc, desc, direction); if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("hipfftXtExecDescriptor failed."); // Optionally, print the output data (copy the results back to the host) if(verbose) { // Copy the output data back to the host hipfft_rt = hipfftXtMemcpy(plan, reinterpret_cast(cinput.data()), reinterpret_cast(desc), HIPFFT_COPY_DEVICE_TO_HOST); // Copy from device to host if(hipfft_rt != HIPFFT_SUCCESS) throw std::runtime_error("hipfftXtMemcpy D2H failed."); std::cout << "Output:\n"; for(size_t i = 0; i < Nx; i++) { for(size_t j = 0; j < Ny; j++) { auto pos = i * Ny + j; std::cout << cinput[pos] << " "; // Print the output FFT results } std::cout << "\n"; } std::cout << std::endl; } // Clean up memory and resources if(hipfftXtFree(desc) != HIPFFT_SUCCESS) throw std::runtime_error("hipfftXtFree failed."); if(hipfftDestroy(plan) != HIPFFT_SUCCESS) throw std::runtime_error("hipfftDestroy failed."); if(hipStreamDestroy(stream) != hipSuccess) throw std::runtime_error("hipStreamDestroy failed."); return 0; } ``` -------------------------------- ### Install amdrocm-fft-devel on RHEL-based distros Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/install.html Installs the latest FFT development package on RHEL-based distributions using dnf. ```bash sudo dnf install amdrocm-fft-devel ``` -------------------------------- ### Install amdrocm-fft-devel on SLES Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/install.html Installs the latest FFT development package on SLES using zypper. ```bash sudo zypper install amdrocm-fft-devel ``` -------------------------------- ### Build with standard host compiler Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/building-installing-hipfft-and-hipfftw.html Build a project using HIP language APIs and hipFFT (or hipFFTW) with the standard host compiler g++. ```bash cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -L .. ``` -------------------------------- ### hipfftXtMakePlanMany Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Initializes a batched rank-dimensional FFT plan with advanced data layout and specified input, output, and execution data types. The plan handle must already be created. Supports strided data layouts and batched transforms. ```APIDOC ## hipfftXtMakePlanMany ### Description Initializes a batched rank-dimensional FFT plan with advanced data layout and specified input, output, execution data types. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. The number of elements to transform in each direction of the input data in the FFT plan is specified in n. The batch parameter tells hipFFT how many transforms to perform. The distance between the first elements of two consecutive batches of the input and output data are specified with the idist and odist parameters. The inembed and onembed parameters define the input and output data layouts. The number of elements in the data is assumed to be larger than the number of elements in the transform. Strided data layouts are also supported. Strides along the fastest direction in the input and output data are specified via the istride and ostride parameters. If both inembed and onembed parameters are set to NULL, all the advanced data layout parameters are ignored and reverted to default values, i.e., the batched transform is performed with non-strided data access and the number of data/transform elements are assumed to be equivalent. The inputType, outputType, executionType parameters specify the data types (precision, and whether the data is real-valued or complex-valued) of the transform input, output, and internal representation respectively. Currently, the precision of all three parameters must match, and the execution type must always be complex-valued. At least one of inputType and outputType must be complex. A half-precision transform can be requested by using either the HIP_R_16F or HIP_C_16F types. ### Function Signature hipfftResult hipfftXtMakePlanMany(hipfftHandle plan, int rank, long long int *n, long long int *inembed, long long int istride, long long int idist, hipDataType inputType, long long int *onembed, long long int ostride, long long int odist, hipDataType outputType, long long int batch, size_t *workSize, hipDataType executionType) ### Parameters - **plan** (hipfftHandle) - [out] Pointer to the FFT plan handle. - **rank** (int) - [in] Dimension of transform (1, 2, or 3). - **n** (long long int*) - [in] Number of elements to transform in the x/y/z directions. - **inembed** (long long int*) - [in] Number of elements in the input data in the x/y/z directions. - **istride** (long long int) - [in] Distance between two successive elements in the input data. - **idist** (long long int) - [in] Distance between input batches. - **inputType** (hipDataType) - [in] Data type of the transform input. - **onembed** (long long int*) - [in] Number of elements in the output data in the x/y/z directions. - **ostride** (long long int) - [in] Distance between two successive elements in the output data. - **odist** (long long int) - [in] Distance between output batches. - **outputType** (hipDataType) - [in] Data type of the transform output. - **batch** (long long int) - [in] Number of batched transforms to perform. - **workSize** (size_t*) - [out] Pointer to work area size (returned value). - **executionType** (hipDataType) - [in] Data type for internal representation. ### Return Value hipfftResult - Result code indicating success or failure. ``` -------------------------------- ### hipFFT 2D batched C2C transform with overlapping input data Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/conceptual/overview.html Complete C++ example configuring inembed, istride, and idist in hipfftPlanMany() to create overlapping input batches. It sets inembed to {512, 2240} and idist to 432, which is smaller than the full input row size, enabling data reuse. The example performs a 2D 512x512 complex-to-complex FFT on 5 batches and prints the output. ```cpp #include #include #include #include #include #include #include int main() { std::cout << "hipFFT 2D batched complex-to-complex transform example\n"; // FFT configuration int rank = 2; int xformSz[2] = {512, 512}; // 2D FFT size: 512x512 int inEmbed[2] = {512, 2240}; // Input data layout int onEmbed[2] = {512, 512}; // Output data layout int istride = 1, ostride = 1; // Stride for input and output int idist = 432, odist = 262144; // Batch distance for input and output int batch = 5; // Number of FFTs to compute in parallel // Calculate input and output sizes in bytes // Input data sequences are all within an array of inEmbed[0] x inEmbed[1] complex // floating-point values (of elementary stride istride): size_t inSize = istride * inEmbed[0] * inEmbed[1] * sizeof(std::complex); // Output data sequences are made of odist complex floating-point values, stored // contiguously without overlap: size_t outSize = odist * batch * sizeof(std::complex); // Initialize HIP and hipFFT resources hipSetDevice(0); hipStream_t stream; hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); hipfftHandle handleF; if (hipfftPlanMany(&handleF, rank, xformSz, inEmbed, istride, idist, onEmbed, ostride, odist, HIPFFT_C2C, batch) != HIPFFT_SUCCESS) { std::cerr << "Failed to create hipFFT plan" << std::endl; return EXIT_FAILURE; } hipfftSetStream(handleF, stream); // Allocate device memory std::complex* miTD; // Input buffer std::complex* miFD; // Output buffer if (hipMalloc(&miTD, inSize) != hipSuccess || hipMalloc(&miFD, outSize) != hipSuccess) { std::cerr << "hipMalloc failed" << std::endl; return EXIT_FAILURE; } // Initialize input data on the host std::vector> inputData(istride * inEmbed[0] * inEmbed[1], {0.0f, 0.0f}); for (int ibatch = 0; ibatch < batch; ++ibatch) { for (int i = 0; i < xformSz[0]; ++i) { for (int j = 0; j < xformSz[1]; ++j) { int pos = ibatch * idist + istride * (i * inEmbed[1] + j); inputData[pos] = std::complex(i + j, ibatch); } } } // Copy input data to device if (hipMemcpy(miTD, inputData.data(), inSize, hipMemcpyHostToDevice) != hipSuccess) { std::cerr << "hipMemcpy failed" << std::endl; return EXIT_FAILURE; } // Execute FFT if (hipfftExecC2C(handleF, reinterpret_cast(miTD), reinterpret_cast(miFD), HIPFFT_FORWARD) != HIPFFT_SUCCESS) { std::cerr << "Failed to execute hipFFT" << std::endl; return EXIT_FAILURE; } // Synchronize stream hipStreamSynchronize(stream); // Copy results back to host std::vector> outputData(odist * batch); if (hipMemcpy(outputData.data(), miFD, outSize, hipMemcpyDeviceToHost) != hipSuccess) { std::cerr << "hipMemcpy failed" << std::endl; return EXIT_FAILURE; } // Display results std::cout << "Output data:\n"; for (int ibatch = 0; ibatch < batch; ++ibatch) { std::cout << "Batch " << ibatch << ":\n"; for (int i = 0; i < xformSz[0]; ++i) { for (int j = 0; j < xformSz[1]; ++j) { int pos = ibatch * odist + ostride * (i * onEmbed[1] + j); std::cout << outputData[pos] << " "; } std::cout << "\n"; } std::cout << "\n"; } // Clean up resources hipfftDestroy(handleF); hipStreamDestroy(stream); hipFree(miTD); hipFree(miFD); return EXIT_SUCCESS; } ``` -------------------------------- ### void fftwf_execute(const fftwf_plan plan) Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Single-precision equivalent of fftw_execute. ```APIDOC ## void fftwf_execute(const fftwf_plan plan) ### Description Single-precision equivalent of fftw_execute. ### Parameters - **plan** (fftwf_plan) - [in] the single-precision plan capturing the transform to compute. ``` -------------------------------- ### hipfftCreate Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Allocate a new plan. ```APIDOC ## hipfftCreate ### Description Allocate a new plan. ### Method hipfftCreate ### Endpoint hipfftResult hipfftCreate(hipfftHandle *plan) ### Parameters - **plan** (hipfftHandle*) - [out] Pointer to the FFT plan handle to be allocated. ### Returns hipfftResult ``` -------------------------------- ### amdrocm-fft package name format Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/install.html The package name format for ROCm FFT packages, used to specify development packages, ROCm version, and GPU architecture. For example, `amdrocm-fft-dev7.13-gfx950`. ```plaintext amdrocm-fft<-dev/-devel><-llvm_target> ``` -------------------------------- ### fftwf_plan_guru64_dft API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a single-precision plan using 64-bit layout descriptors. ```c fftwf_plan fftwf_plan_guru64_dft(int rank, const fftwf_iodim64 *dims, int howmany_rank, const fftwf_iodim64 *howmany_dims, fftwf_complex *in, fftwf_complex *out, int sign, unsigned flags) ``` -------------------------------- ### Build with HIP-Clang and clients Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/building-installing-hipfft-and-hipfftw.html Build a project using HIP language APIs, hipFFT (or hipFFTW), and device kernels with HIP-Clang. The -DBUILD_CLIENTS=ON option is only allowed with the amdclang++ or HIPCC compilers. ```bash cmake -DCMAKE_CXX_COMPILER=amdclang++ -DCMAKE_BUILD_TYPE=Release -DBUILD_CLIENTS=ON -L .. ``` -------------------------------- ### fftwf_plan_guru64_dft_r2c API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a single-precision real forward plan using 64-bit layout descriptors. ```c fftwf_plan fftwf_plan_guru64_dft_r2c(int rank, const fftwf_iodim64 *dims, int howmany_rank, const fftwf_iodim64 *howmany_dims, float *in, fftwf_complex *out, unsigned flags) ``` -------------------------------- ### hipfftMakePlan1d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Initialize a new one-dimensional FFT plan. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. ```APIDOC ## hipfftMakePlan1d ### Description Initialize a new one-dimensional FFT plan. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. ### Method hipfftMakePlan1d ### Endpoint hipfftResult hipfftMakePlan1d(hipfftHandle plan, int nx, hipfftType type, int batch, size_t *workSize) ### Parameters - **plan** (hipfftHandle) - [in] Handle of the FFT plan. - **nx** (int) - [in] FFT length. - **type** (hipfftType) - [in] FFT type. - **batch** (int) - [in] Number of batched transforms to compute. - **workSize** (size_t*) - [out] Pointer to work area size (returned value). ### Returns hipfftResult ``` -------------------------------- ### fftwf_plan_guru64_dft_c2r API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a single-precision real backward plan using 64-bit layout descriptors. ```c fftwf_plan fftwf_plan_guru64_dft_c2r(int rank, const fftwf_iodim64 *dims, int howmany_rank, const fftwf_iodim64 *howmany_dims, fftwf_complex *in, float *out, unsigned flags) ``` -------------------------------- ### hipfftMakePlanMany Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Initializes a new batched rank-dimensional FFT plan with advanced data layout. The plan handle must already be created. Supports strided data layouts and batched transforms. ```APIDOC ## hipfftMakePlanMany ### Description Initializes a new batched rank-dimensional FFT plan with advanced data layout. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. The number of elements to transform in each direction of the input data in the FFT plan is specified in n. The batch parameter tells hipFFT how many transforms to perform. The distance between the first elements of two consecutive batches of the input and output data are specified with the idist and odist parameters. The inembed and onembed parameters define the input and output data layouts. The number of elements in the data is assumed to be larger than the number of elements in the transform. Strided data layouts are also supported. Strides along the fastest direction in the input and output data are specified via the istride and ostride parameters. If both inembed and onembed parameters are set to NULL, all the advanced data layout parameters are ignored and reverted to default values, i.e., the batched transform is performed with non-strided data access and the number of data/transform elements are assumed to be equivalent. ### Function Signature hipfftResult hipfftMakePlanMany(hipfftHandle plan, int rank, int *n, int *inembed, int istride, int idist, int *onembed, int ostride, int odist, hipfftType type, int batch, size_t *workSize) ### Parameters - **plan** (hipfftHandle) - [out] Pointer to the FFT plan handle. - **rank** (int) - [in] Dimension of transform (1, 2, or 3). - **n** (int*) - [in] Number of elements to transform in the x/y/z directions. - **inembed** (int*) - [in] Number of elements in the input data in the x/y/z directions. - **istride** (int) - [in] Distance between two successive elements in the input data. - **idist** (int) - [in] Distance between input batches. - **onembed** (int*) - [in] Number of elements in the output data in the x/y/z directions. - **ostride** (int) - [in] Distance between two successive elements in the output data. - **odist** (int) - [in] Distance between output batches. - **type** (hipfftType) - [in] FFT type. - **batch** (int) - [in] Number of batched transforms to perform. - **workSize** (size_t*) - [out] Pointer to work area size (returned value). ### Return Value hipfftResult - Result code indicating success or failure. ``` -------------------------------- ### fftw_plan_guru_dft_r2c Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates an arbitrary plan for a multidimensional, double-precision, real forward (complex) discrete Fourier transform of lengths `dims[0].n x dims[1].n x ... x dims[rank-1].n` and batch sizes `howmany_dims[0].n x howmany_dims[1].n x ... x howmany_dims[howmany_rank-1].n`. ```APIDOC ## fftw_plan_guru_dft_r2c ### Description Creates an arbitrary plan for a multidimensional, double-precision, real forward (complex) discrete Fourier transform of lengths `dims[0].n x dims[1].n x ... x dims[rank-1].n` and batch sizes `howmany_dims[0].n x howmany_dims[1].n x ... x howmany_dims[howmany_rank-1].n`. ### Parameters - **rank** (int) - [in] strictly positive rank of the transform - **dims** (const fftw_iodim*) - [in] array of `rank` `fftw_iodim` values - **howmany_rank** (int) - [in] strictly positive rank of the transform's batch sizes - **howmany_dims** (const fftw_iodim*) - [in] array of `howmany_rank` `fftw_iodim` values - **in** (double*) - [in] pointer to the input buffer for the transform - **out** (fftw_complex*) - [in] pointer to the output buffer for the transform - **flags** (unsigned) - [in] bitwise OR (`|`) combination of zero or more constant flag values ### Returns A valid double-precision hipFFTW plan ready for execution upon success (`nullptr` otherwise). ``` -------------------------------- ### Show CMake build options Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/install/building-installing-hipfft-and-hipfftw.html Run from the rocm-libraries/projects/hipfft directory to show all build options for hipFFT and hipFFTW. ```bash mkdir build && cd build cmake -LH .. ``` -------------------------------- ### fftw_plan_guru_dft Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates an arbitrary plan for a multidimensional, double-precision, complex discrete Fourier transform of lengths `dims[0].n x dims[1].n x ... x dims[rank-1].n` and batch sizes `howmany_dims[0].n x howmany_dims[1].n x ... x howmany_dims[howmany_rank-1].n`. ```APIDOC ## fftw_plan_guru_dft ### Description Creates an arbitrary plan for a multidimensional, double-precision, complex discrete Fourier transform of lengths `dims[0].n x dims[1].n x ... x dims[rank-1].n` and batch sizes `howmany_dims[0].n x howmany_dims[1].n x ... x howmany_dims[howmany_rank-1].n`. ### Parameters - **rank** (int) - [in] strictly positive rank of the transform - **dims** (const fftw_iodim*) - [in] array of `rank` `fftw_iodim` values - **howmany_rank** (int) - [in] strictly positive rank of the transform's batch sizes - **howmany_dims** (const fftw_iodim*) - [in] array of `howmany_rank` `fftw_iodim` values - **in** (fftw_complex*) - [in] pointer to the input buffer for the transform - **out** (fftw_complex*) - [in] pointer to the output buffer for the transform - **sign** (int) - [in] exponent sign defining the desired complex transform (`FFTW_FORWARD` or `FFTW_BACKWARD`) - **flags** (unsigned) - [in] bitwise OR (`|`) combination of zero or more constant flag values ### Returns A valid double-precision hipFFTW plan ready for execution upon success (`nullptr` otherwise). ``` -------------------------------- ### hipfftMakePlan3d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Initialize a new two-dimensional FFT plan. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. Three-dimensional data should be stored in C ordering (row-major format), so that indexes in z-direction (k index) vary the fastest. ```APIDOC ## hipfftMakePlan3d ### Description Initialize a new two-dimensional FFT plan. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. Three-dimensional data should be stored in C ordering (row-major format), so that indexes in z-direction (k index) vary the fastest. ### Method hipfftMakePlan3d ### Endpoint hipfftResult hipfftMakePlan3d(hipfftHandle plan, int nx, int ny, int nz, hipfftType type, size_t *workSize) ### Parameters - **plan** (hipfftHandle) - [in] Handle of the FFT plan. - **nx** (int) - [in] Number of elements in the x-direction (slowest index). - **ny** (int) - [in] Number of elements in the y-direction. - **nz** (int) - [in] Number of elements in the z-direction (fastest index). - **type** (hipfftType) - [in] FFT type. - **workSize** (size_t*) - [out] Pointer to work area size (returned value). ### Returns hipfftResult ``` -------------------------------- ### void fftwf_execute_dft(const fftwf_plan plan, fftwf_complex *in, fftwf_complex *out) Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Single-precision equivalent of fftw_execute_dft. ```APIDOC ## void fftwf_execute_dft(const fftwf_plan plan, fftwf_complex *in, fftwf_complex *out) ### Description Single-precision equivalent of fftw_execute_dft. ### Parameters - **plan** (fftwf_plan) - [in] the single-precision plan capturing the complex transform to compute. - **in** (fftwf_complex*) - [in] pointer to a new input buffer for the transform. - **out** (fftwf_complex*) - [out] pointer to a new output buffer for the transform. ``` -------------------------------- ### fftw_plan_guru64_dft API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a double-precision plan using 64-bit layout descriptors. ```c fftw_plan fftw_plan_guru64_dft(int rank, const fftw_iodim64 *dims, int howmany_rank, const fftw_iodim64 *howmany_dims, fftw_complex *in, fftw_complex *out, int sign, unsigned flags) ``` -------------------------------- ### fftw_plan_guru64_dft_r2c API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a double-precision real forward plan using 64-bit layout descriptors. ```c fftw_plan fftw_plan_guru64_dft_r2c(int rank, const fftw_iodim64 *dims, int howmany_rank, const fftw_iodim64 *howmany_dims, double *in, fftw_complex *out, unsigned flags) ``` -------------------------------- ### fftw_plan_guru64_dft_c2r API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a double-precision real backward plan using 64-bit layout descriptors. ```c fftw_plan fftw_plan_guru64_dft_c2r(int rank, const fftw_iodim64 *dims, int howmany_rank, const fftw_iodim64 *howmany_dims, fftw_complex *in, double *out, unsigned flags) ``` -------------------------------- ### fftwf_plan_guru_dft_r2c API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a single-precision plan for a multidimensional real forward discrete Fourier transform. ```c fftwf_plan fftwf_plan_guru_dft_r2c(int rank, const fftwf_iodim *dims, int howmany_rank, const fftwf_iodim *howmany_dims, float *in, fftwf_complex *out, unsigned flags) ``` -------------------------------- ### hipfftMakePlan2d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Initialize a new two-dimensional FFT plan. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. Two-dimensional data should be stored in C ordering (row-major format), so that indexes in y-direction (j index) vary the fastest. ```APIDOC ## hipfftMakePlan2d ### Description Initialize a new two-dimensional FFT plan. Assumes that the plan has been created already, and modifies the plan associated with the plan handle. Two-dimensional data should be stored in C ordering (row-major format), so that indexes in y-direction (j index) vary the fastest. ### Method hipfftMakePlan2d ### Endpoint hipfftResult hipfftMakePlan2d(hipfftHandle plan, int nx, int ny, hipfftType type, size_t *workSize) ### Parameters - **plan** (hipfftHandle) - [in] Handle of the FFT plan. - **nx** (int) - [in] Number of elements in the x-direction (slow index). - **ny** (int) - [in] Number of elements in the y-direction (fast index). - **type** (hipfftType) - [in] FFT type. - **workSize** (size_t*) - [out] Pointer to work area size (returned value). ### Returns hipfftResult ``` -------------------------------- ### fftwf_plan_guru_dft_c2r API Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Creates a single-precision plan for a multidimensional real backward discrete Fourier transform. ```c fftwf_plan fftwf_plan_guru_dft_c2r(int rank, const fftwf_iodim *dims, int howmany_rank, const fftwf_iodim *howmany_dims, fftwf_complex *in, float *out, unsigned flags) ``` -------------------------------- ### void fftwf_execute_dft_c2r(const fftwf_plan plan, fftwf_complex *in, float *out) Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Single-precision equivalent of fftw_execute_dft_c2r. ```APIDOC ## void fftwf_execute_dft_c2r(const fftwf_plan plan, fftwf_complex *in, float *out) ### Description Single-precision equivalent of fftw_execute_dft_c2r. ### Parameters - **plan** (fftwf_plan) - [in] the single-precision plan capturing the real backward (inverse) transform to compute. - **in** (fftwf_complex*) - [in] pointer to a new input buffer for the transform. - **out** (float*) - [out] pointer to a new output buffer for the transform. ``` -------------------------------- ### void fftwf_execute_dft_r2c(const fftwf_plan plan, float *in, fftwf_complex *out) Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Single-precision equivalent of fftw_execute_dft_r2c. ```APIDOC ## void fftwf_execute_dft_r2c(const fftwf_plan plan, float *in, fftwf_complex *out) ### Description Single-precision equivalent of fftw_execute_dft_r2c. ### Parameters - **plan** (fftwf_plan) - [in] the single-precision plan capturing the real forward transform to compute. - **in** (float*) - [in] pointer to a new input buffer for the transform. - **out** (fftwf_complex*) - [out] pointer to a new output buffer for the transform. ``` -------------------------------- ### hipfftPlan3d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Create a new three-dimensional FFT plan. Allocate and initialize a new three-dimensional FFT plan. Three-dimensional data should be stored in C ordering (row-major format), so that indexes in z-direction (k index) vary the fastest. ```APIDOC ## hipfftPlan3d ### Description Create a new three-dimensional FFT plan. Allocate and initialize a new three-dimensional FFT plan. Three-dimensional data should be stored in C ordering (row-major format), so that indexes in z-direction (k index) vary the fastest. ### Method hipfftPlan3d ### Endpoint hipfftResult hipfftPlan3d(hipfftHandle *plan, int nx, int ny, int nz, hipfftType type) ### Parameters - **plan** (hipfftHandle*) - [out] Pointer to the FFT plan handle. - **nx** (int) - [in] Number of elements in the x-direction (slowest index). - **ny** (int) - [in] Number of elements in the y-direction. - **nz** (int) - [in] Number of elements in the z-direction (fastest index). - **type** (hipfftType) - [in] FFT type. ### Returns hipfftResult ``` -------------------------------- ### hipfftPlan1d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Create a new one-dimensional FFT plan. Allocate and initialize a new one-dimensional FFT plan. ```APIDOC ## hipfftPlan1d ### Description Create a new one-dimensional FFT plan. Allocate and initialize a new one-dimensional FFT plan. ### Method hipfftPlan1d ### Endpoint hipfftResult hipfftPlan1d(hipfftHandle *plan, int nx, hipfftType type, int batch) ### Parameters - **plan** (hipfftHandle*) - [out] Pointer to the FFT plan handle. - **nx** (int) - [in] FFT length. - **type** (hipfftType) - [in] FFT type. - **batch** (int) - [in] Number of batched transforms to compute. ### Returns hipfftResult ``` -------------------------------- ### fftwf_plan_guru64_dft_r2c Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html Equivalent of fftwf_plan_guru_dft_r2c using layout-describing values of type `fftwf_iodim64` instead of `fftwf_iodim`. ```APIDOC ## fftwf_plan_guru64_dft_r2c ### Description Equivalent of fftwf_plan_guru_dft_r2c using layout-describing values of type `fftwf_iodim64` instead of `fftwf_iodim`. ### Parameters - **rank** (int) - [in] strictly positive rank of the transform - **dims** (const fftwf_iodim64*) - [in] array of `rank` `fftwf_iodim64` values - **howmany_rank** (int) - [in] strictly positive rank of the transform's batch sizes - **howmany_dims** (const fftwf_iodim64*) - [in] array of `howmany_rank` `fftwf_iodim64` values - **in** (float*) - [in] pointer to the input buffer for the transform - **out** (fftwf_complex*) - [in] pointer to the output buffer for the transform - **flags** (unsigned) - [in] bitwise OR (`|`) combination of zero or more constant flag values ### Returns A valid single-precision hipFFTW plan ready for execution upon success (`nullptr` otherwise). ``` -------------------------------- ### Create a 1D hipFFT plan with hipfftPlan1d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/conceptual/overview.html Creates a 1D complex-to-complex FFT plan using hipfftPlan1d. The plan handle is passed by pointer, and the transform type is HIPFFT_C2C with a batch size of 1. ```cpp hipfftHandle plan; hipfftPlan1d(&plan, N, HIPFFT_C2C, 1); ``` -------------------------------- ### hipfftPlan2d Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfft-api-usage.html Create a new two-dimensional FFT plan. Allocate and initialize a new two-dimensional FFT plan. Two-dimensional data should be stored in C ordering (row-major format), so that indexes in y-direction (j index) vary the fastest. ```APIDOC ## hipfftPlan2d ### Description Create a new two-dimensional FFT plan. Allocate and initialize a new two-dimensional FFT plan. Two-dimensional data should be stored in C ordering (row-major format), so that indexes in y-direction (j index) vary the fastest. ### Method hipfftPlan2d ### Endpoint hipfftResult hipfftPlan2d(hipfftHandle *plan, int nx, int ny, hipfftType type) ### Parameters - **plan** (hipfftHandle*) - [out] Pointer to the FFT plan handle. - **nx** (int) - [in] Number of elements in the x-direction (slow index). - **ny** (int) - [in] Number of elements in the y-direction (fast index). - **type** (hipfftType) - [in] FFT type. ### Returns hipfftResult ``` -------------------------------- ### void fftwf_free(void *p) Source: https://rocm.docs.amd.com/projects/hipFFT/en/latest/reference/hipfftw-api-usage.html This function is strictly equivalent to fftw_free. ```APIDOC ## void fftwf_free(void *p) ### Description This function is strictly equivalent to fftw_free. ```