### Basic FINUFFT Build, Test, and Install Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt A quick start guide for building FINUFFT from source, running tests, and installing it to a specified prefix. This process creates a static library by default. ```bash git clone https://github.com/flatironinstitute/finufft.git cd finufft cmake -S . -B build -DFINUFFT_BUILD_TESTS=ON --install-prefix /path/to/install cmake --build build --parallel ctest --test-dir build cmake --install build ``` -------------------------------- ### Install FINUFFT with pip Source: https://finufft.readthedocs.io/en/latest/python.html Installs the latest precompiled binaries of FINUFFT from PyPI. This is the easiest way to get started. ```bash pip install finufft ``` -------------------------------- ### Build and Test cufinufft on GPU Source: https://finufft.readthedocs.io/en/latest/devnotes.html This script outlines the steps to set up a GPU environment, load necessary modules, build the cufinufft library with CUDA support, and run tests. It includes Python environment setup and installation. ```bash srun -p gpu -C v100 -c 10 -n 1 --gpus=1 --pty bash cd path/to/finufft CUDAARCH=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader|head -n 1| sed 's/\.//') module -q purge module -q load gcc python cmake fftw cuda python -m venv venv --system-site-packages source venv/bin/activate pip install --upgrade pip mkdir -p build && cd build cmake -DFINUFFT_BUILD_TESTS=on -DFINUFFT_BUILD_EXAMPLES=on -DFINUFFT_USE_CUDA=on \ -DCMAKE_CUDA_ARCHITECTURES=$CUDAARCH -DCMAKE_BUILD_TYPE=RelWithDebInfo .. make -j 10 ctest LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD pip install -e ../python/cufinufft LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD python -m pytest --framework=numba ../python/cufinufft ``` -------------------------------- ### CMake Package Consumption Example Source: https://finufft.readthedocs.io/en/latest/changelog.html Demonstrates how to consume a FINUFFT installation using CMake's find_package. Ensures correct header inclusion and target resolution for consumers. ```cmake find_package(finufft REQUIRED) ``` -------------------------------- ### Build FINUFFT Examples Source: https://finufft.readthedocs.io/en/latest/install.html Compiles the example programs for FINUFFT. Does not require WSL or 64-bit gnu-make. ```bash make examples ``` -------------------------------- ### Install cufinufft with pip Source: https://finufft.readthedocs.io/en/latest/python_gpu.html Use this command to install the Python interface for cuFINUFFT. Ensure you have the necessary CUDA toolkit installed. ```bash pip install cufinufft ``` -------------------------------- ### Fortran Compilation with Dynamic Library Source: https://finufft.readthedocs.io/en/latest/_sources/fortran.rst.txt Example compilation command linking against the FINUFFT dynamic library. Uses rpath for easier execution from different directories. Replace $FINUFFT with the actual install path. ```bash gfortran -I../../include simple1d1.f -o simple1d1 -L../../lib -Wl,-rpath=$FINUFFT/lib -lfinufft ``` -------------------------------- ### Install Language Interfaces on Ubuntu Source: https://finufft.readthedocs.io/en/latest/install.html Installs Fortran, Python, and Octave language interfaces using apt-get. ```bash sudo apt-get gfortran python3 python3-pip octave liboctave-dev ``` -------------------------------- ### Install Python Interface from Source Source: https://finufft.readthedocs.io/en/latest/install_gpu.html Install the Python interface of cuFINUFFT from its source directory after building the shared library. ```bash pip install python/cufinufft ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://finufft.readthedocs.io/en/latest/install.html Installs essential command-line tools for development on macOS. Run this if you don't have Xcode installed. ```bash xcode-select --install ``` -------------------------------- ### Example Platform-Specific make.inc Files Source: https://finufft.readthedocs.io/en/latest/install.html These are examples of platform-specific make.inc files available in the make-platforms directory. Users can choose one as their make.inc for macOS or Windows. ```bash make-platforms/make.inc.macosx_clang ``` ```bash make-platforms/make.inc.macosx_gcc-14 ``` ```bash make-platforms/make.inc.windows_msys ``` -------------------------------- ### Install cuFINUFFT Python Interface from Source Source: https://finufft.readthedocs.io/en/latest/_sources/install_gpu.rst.txt Install the Python interface for cuFINUFFT after building the shared library. Ensure a compatible GPU framework (CuPy, Numba, PyTorch, PyCuda) is installed separately. ```bash pip install python/cufinufft ``` -------------------------------- ### Build cuFINUFFT with Testing Enabled Source: https://finufft.readthedocs.io/en/latest/_sources/install_gpu.rst.txt Configure and build cuFINUFFT with testing enabled to verify the installation and functionality of the GPU library. ```bash cmake -D FINUFFT_USE_CUDA=ON -D BUILD_TESTING=ON -D FINUFFT_BUILD_TESTS=ON .. cmake --build . --parallel ``` -------------------------------- ### Install Language Interfaces on Fedora/CentOS Source: https://finufft.readthedocs.io/en/latest/install.html Installs Fortran and Octave language interfaces using yum. ```bash sudo yum install gcc-gfortran octave octave-devel ``` -------------------------------- ### Linux Dependency Installation (Ubuntu) Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Installs base dependencies including FFTW3 on Ubuntu systems using apt-get. ```bash sudo apt-get install make build-essential libfftw3-dev ``` -------------------------------- ### Install Base Dependencies on Fedora/CentOS Source: https://finufft.readthedocs.io/en/latest/install.html Installs essential build tools and the FFTW3 library on Fedora/CentOS systems using yum. ```bash sudo yum install make gcc gcc-c++ fftw-devel libgomp ``` -------------------------------- ### Install Octave and Compile Octave Interface Source: https://finufft.readthedocs.io/en/latest/install.html Installs Octave using Homebrew and compiles the Octave interface for FINUFFT. This also runs a self-test for the Octave interface. ```bash brew install octave make octave ``` -------------------------------- ### Run FINUFFT Tests Source: https://finufft.readthedocs.io/en/latest/install.html Executes the test suite for FINUFFT to verify the installation. Requires WSL and 64-bit gnu-make. ```bash make test ``` -------------------------------- ### Install Python and FINUFFT (Python-only) Source: https://finufft.readthedocs.io/en/latest/install.html Installs Python 3 and the FINUFFT Python package using pip. Use this if you only need the Python interface. ```bash brew install python3 pip3 install finufft ``` -------------------------------- ### Build cuFINUFFT with CMake Source: https://finufft.readthedocs.io/en/latest/_sources/install_gpu.rst.txt Use this command to build the cuFINUFFT library with CUDA support. Ensure the Nvidia CUDA toolchain is installed. ```bash mkdir build cd build cmake -D FINUFFT_USE_CUDA=ON .. cmake --build . --parallel ``` -------------------------------- ### Install FINUFFT Python module from source Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Compile and install the FINUFFT Python module locally to achieve better performance by exploiting CPU capabilities. This uses the modern pyproject.toml build system. ```shell pip install python/finufft ``` -------------------------------- ### Clone and Compile FINUFFT for PowerPC Source: https://finufft.readthedocs.io/en/latest/install.html Clone the FINUFFT repository, copy a platform-specific make.inc file, and compile the library. This is an example for a PowerPC architecture. ```bash git clone https://github.com/flatironinstitute/finufft.git cd finufft cp make-platforms/make.inc.powerpc make.inc make test -j ``` -------------------------------- ### Fortran Example File List Source: https://finufft.readthedocs.io/en/latest/fortran.html Lists the available Fortran demo files for NUFFT transforms, categorized by dimension and interface type. Includes notes on precision and modifications from CMCL codes. ```text simple1d1.f - 1D type 1, simple interface, default and various opts guru1d1.f - 1D type 1, guru interface, default and various opts guru1d1_adjoint.f - adjoint of 1D type 1, guru interface, default opts guru1d2_adjoint.f - adjoint of 1D type 2, guru interface, default and various opts nufft1d_demo.f - 1D types 1,2,3, minimally changed from CMCL demo codes nufft2d_demo.f - 2D " nufft3d_demo.f - 3D " nufft2dmany_demo.f - 2D types 1,2,3, vectorized (many strengths) interface simple1d1.f90 - modern Fortran90 version of simple1d1 using module ``` -------------------------------- ### GNU Make Build for PowerPC Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Illustrates the classic GNU Make build process. Clone the repository, copy the appropriate platform-specific make.inc file, and then run 'make test'. ```bash git clone https://github.com/flatironinstitute/finufft.git cd finufft cp make-platforms/make.inc.powerpc make.inc make test -j ``` -------------------------------- ### Linking FINUFFT Shared Library (Linux/macOS) Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Example of linking the FINUFFT shared library to a C++ executable. Adjust include and library paths based on your installation prefix. The '-Wl,-rpath' flag is crucial for shared library loading. ```bash g++ -o simple1d1 ../examples/simple1d1.cpp -I$HOME/local/include -L$HOME/local/lib64 -Wl,-rpath $HOME/local/lib64 -lfinufft -O2 ``` -------------------------------- ### Compile FINUFFT from source Source: https://finufft.readthedocs.io/en/latest/python.html Installs FINUFFT by compiling from source, using the --no-binary option. This allows for custom compilation flags like -march=native for potential performance improvements. ```bash pip install --no-binary finufft finufft ``` -------------------------------- ### Install Python and FINUFFT on macOS Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Install Python 3 and the finufft Python package using pip on macOS. This is a simplified installation for Python-only users. ```bash brew install python3 pip3 install finufft ``` -------------------------------- ### Link to Installed FINUFFT Package Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Consume an already installed FINUFFT package by finding it with find_package and linking it to your executable. Ensure CMake can locate the installation prefix. ```cmake find_package(finufft REQUIRED) target_link_libraries(your_executable [PUBLIC|PRIVATE|INTERFACE] finufft::finufft) ``` -------------------------------- ### Install Homebrew and Dependencies on macOS Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Install Homebrew package manager and essential libraries like libomp and fftw on macOS. This command assumes Homebrew is already installed. ```bash brew install libomp fftw ``` -------------------------------- ### Interactive GPU Shell Setup and Finufft Build Source: https://finufft.readthedocs.io/en/latest/_sources/devnotes.rst.txt This snippet outlines the steps to acquire an interactive GPU shell, load necessary modules, build a Python virtual environment, and compile Finufft with CUDA support. It includes setting up build configurations and running standard tests. ```sh # to grab an interactive GPU shell -- here with 10 cores for building and a v100 for # testing. You could just as easily try this on your workstation srun -p gpu -C v100 -c 10 -n 1 --gpus=1 --pty bash cd path/to/finufft # get the local card to this machine's compute capability. If you know it you can obviously type it yourself CUDAARCH=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader|head -n 1| sed 's/\.//') # Load modules and build a venv. We typically recommend using venvs that fall back our our # default packages with the python module (--system-site-packages) module -q purge module -q load gcc python cmake fftw cuda python -m venv venv --system-site-packages source venv/bin/activate pip install --upgrade pip # building. Feel free to tweak whatever mkdir -p build && cd build cmake -DFINUFFT_BUILD_TESTS=on -DFINUFFT_BUILD_EXAMPLES=on -DFINUFFT_USE_CUDA=on \ -DCMAKE_CUDA_ARCHITECTURES=$CUDAARCH -DCMAKE_BUILD_TYPE=RelWithDebInfo .. make -j 10 # for standard tests ctest # python install. Needs build from before since installer searches for libcufinufft.so in # LD_LIBRARY_PATH (and default path) LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD pip install -e ../python/cufinufft # python tests. we have other GPU framework support, but you need to make sure they're # installed (numba, pycuda, torch, cupy). This LD_LIBRARY_PATH may or may not be necessary, # depending on if an RPATHing issue appears. Fix upstream at time of writing LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD python -m pytest --framework=numba ../python/cufinufft ``` -------------------------------- ### Set Points and Execute cuFINUFFT Plan Source: https://finufft.readthedocs.io/en/latest/c_gpu.html Configure the plan with the input points and then execute the plan to compute the NUDFT. The results are stored in d_f. ```c cufinufftf_setpts(plan, M, d_x, NULL, NULL, 0, NULL, NULL, NULL); cufinufftf_execute(plan, d_c, d_f); ``` -------------------------------- ### Install Homebrew Dependencies Source: https://finufft.readthedocs.io/en/latest/install.html Installs OpenMP and FFTW libraries using Homebrew. These are common dependencies for scientific computing. ```bash brew install libomp fftw ``` -------------------------------- ### Initialize CUFINUFFT Options Structure Source: https://finufft.readthedocs.io/en/latest/c_gpu.html This snippet shows how to initialize the options structure for GPU computations. You must create this structure and then pass its address to the plan creation functions. ```c cufinufft_opts opts; cufinufft_default_opts(&opts); ``` -------------------------------- ### Create and Execute a FINUFFT Plan Source: https://finufft.readthedocs.io/en/latest/python.html This snippet demonstrates how to initialize a FINUFFT plan for a type 1 transform, set non-uniform points, and execute the transform on source strengths. Ensure NumPy and FINUFFT are imported. ```python import numpy as np import finufft # set up parameters n_modes = (1000, 2000) n_pts = 100000 nufft_type = 1 n_trans = 4 # generate nonuniform points x = 2 * np.pi * np.random.uniform(size=n_pts) y = 2 * np.pi * np.random.uniform(size=n_pts) # generate source strengths c = (np.random.standard_normal(size=(n_trans, n_pts)) + 1J * np.random.standard_normal(size=(n_trans, n_pts))) # initialize the plan plan = finufft.Plan(nufft_type, n_modes, n_trans) # set the nonuniform points plan.setpts(x, y) # execute the plan f = plan.execute(c) ``` -------------------------------- ### C++ Finufft Plan Creation with Options Source: https://finufft.readthedocs.io/en/latest/changelog.html Demonstrates the C++/C interface for Finufft where 'opts' is passed as a pointer, a change from previous versions where it was passed by reference. ```cpp // C++/C interface struct nufft_opts opts; // ... initialize opts ... finufft_plan plan = finufft_makeplan(..., &opts, ...); ``` -------------------------------- ### Build and test FINUFFT with MSYS/MinGW on Windows Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt For users on Windows with MSYS and MinGW compilers, copy the appropriate make.inc file and then run the build and test commands. This setup is for local compilation. ```shell cp make-platforms/make.inc.windows_msys make.inc make test -j ``` -------------------------------- ### cuFINUFFT C API Overview Source: https://finufft.readthedocs.io/en/latest/_sources/c_gpu.rst.txt This section outlines the general workflow and available functions for using the cuFINUFFT C interface. It covers the steps for creating, executing, and destroying plans, along with notes on precision and version compatibility. ```APIDOC ## cuFINUFFT C API This API closely matches the plan interface to FINUFFT and is modeled after FFTW and NFFT. It offers both double (`cufinufft`) and single (`cufinufftf`) precision versions. ### Workflow 1. **Make a plan**: `cufinufftf_makeplan` or `cufinufft_makeplan` 2. **Set nonuniform points**: `cufinufftf_setpts` or `cufinufft_setpts` 3. **Execute transform**: `cufinufftf_execute` or `cufinufft_execute` 4. **Destroy plan**: `cufinufftf_destroy` or `cufinufft_destroy` ### Functions * `cufinufftf_makeplan(int type, int dim, int *nmodes, int sign, int ntrans, REAL eps, cufinufftf_plan *plan, void *options)` * `cufinufftf_setpts(cufinufftf_plan plan, int M, REAL *x, int xstd, REAL *y, int ystd, REAL *z, int zstd)` * `cufinufftf_execute(cufinufftf_plan plan, void *c, void *f)` * `cufinufftf_destroy(cufinufftf_plan plan)` (Double precision versions use `cufinufft_` prefix and `DOUBLE` type for `REAL`.) ### Example Usage (Single Precision) ```c #include #include #include #include #include #include int main() { const int M = 100000, N = 10000; int64_t modes[1] = {N}; float *x; float _Complex *c, *f; float *d_x; cuFloatComplex *d_c, *d_f; cufinufftf_plan plan; // Allocate host arrays x = (float *) malloc(M * sizeof(float)); c = (float _Complex *) malloc(M * sizeof(float _Complex)); f = (float _Complex *) malloc(N * sizeof(float _Complex)); // Fill host arrays with data srand(0); for(int j = 0; j < M; ++j) { x[j] = 2 * M_PI * (((float) rand()) / RAND_MAX - 1); c[j] = (2 * ((float) rand()) / RAND_MAX - 1) + I * (2 * ((float) rand()) / RAND_MAX - 1); } // Allocate device arrays and copy data cudaMalloc(&d_x, M * sizeof(float)); cudaMalloc(&d_c, M * sizeof(float _Complex)); cudaMalloc(&d_f, N * sizeof(float _Complex)); cudaMemcpy(d_x, x, M * sizeof(float), cudaMemcpyHostToDevice); cudaMemcpy(d_c, c, M * sizeof(float _Complex), cudaMemcpyHostToDevice); // Create plan cufinufftf_makeplan(1, 1, modes, 1, 1, 1e-6, &plan, NULL); // Set points and execute transform (example) // cufinufftf_setpts(plan, M, d_x, 0, NULL, 0, NULL, 0); // cufinufftf_execute(plan, d_c, d_f); // Destroy plan // cufinufftf_destroy(plan); // Free host memory free(x); free(c); free(f); // Free device memory (omitted for brevity) return 0; } ``` ``` -------------------------------- ### Install CuPy for CUDA 11.x Source: https://finufft.readthedocs.io/en/latest/install_gpu.html Install the CuPy library, a dependency for the Python interface, specifically for CUDA 11.x versions. ```bash pip install cupy-cuda11x ``` -------------------------------- ### Install CuPy for CUDA 11.x Source: https://finufft.readthedocs.io/en/latest/_sources/install_gpu.rst.txt Install the CuPy library, a dependency for the cuFINUFFT Python interface, specifying the CUDA version. ```bash pip install cupy-cuda11x ``` -------------------------------- ### Linux Dependency Installation (Fedora/CentOS) Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Installs base dependencies including FFTW3 and OpenMP support on Fedora/CentOS systems using yum. ```bash sudo yum install make gcc gcc-c++ fftw-devel libgomp ``` -------------------------------- ### Configure cuFINUFFT with GPU and Testing Enabled Source: https://finufft.readthedocs.io/en/latest/install_gpu.html Use this CMake command to configure the build with CUDA support and enable testing flags. ```bash cmake -D FINUFFT_USE_CUDA=ON -D BUILD_TESTING=ON -D FINUFFT_BUILD_TESTS=ON .. ``` -------------------------------- ### Install FINUFFT Python requirements Source: https://finufft.readthedocs.io/en/latest/_sources/install.rst.txt Install the necessary Python packages listed in the requirements.txt file for FINUFFT. This should be done after activating a virtual environment. ```shell pip install -r python/requirements.txt ```