Skip to content

Add kokkos-fft blog post #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yasahi-hpc
Copy link

This PR adds a blog post on kokkos-fft.

  • featuring some technical details and a real world example
  • links are valid

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall


* wishing to integrate in-situ signal and image processing with FFTs. E.g., spectral analyses, low pass filtering, etc.

* __NOT__ willing to go through the documentation of de facto standard FFT libraries. They want to benefit from powerful vendor FFT libraries while working with a simple API like that of [`numpy.fft`](https://numpy.org/doc/stable/reference/routines.fft.html).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get that point.
Is that about saying that the kokkos-fft API is easier to use than other C++ alternatives and inspired from numpy.fft?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes
I would like to say that the kokkos-fft API is easier to use than those of vendor libraries and inspired from numpy.fft?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that "easier" point is kind of subjective. It is certainly more intuitive to use for Python users, but I am not sure it is the case for hardcore fftw Fortran users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "intuitive" then :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cedricchevalier19 I understand your point. Actually, what I am claiming here is that our API is as simple as numpy.fft. As you may say, fftw experts could only prefer fftw APIs

Comment on lines 76 to 137
# Prerequisites

To use kokkos-fft, we need the following:

* `CMake 3.22+`
* `Kokkos 4.4+`

Depending on your backend, you also need at least one of the following compilers (for the latest requirements, see [README](https://github.com/kokkos/kokkos-fft)):

* `gcc 8.3.0+` (CPUs)
* `IntelLLVM 2023.0.0+` (CPUs, Intel GPUs)
* `nvcc 11.0.0+` (NVIDIA GPUs)
* `rocm 5.3.0+` (AMD GPUs)

# Using kokkos-fft in your CMake project

For the moment, there are two ways to use kokkos-fft: include as a subdirectory in your CMake project or install as a library. Since kokkos-fft is a header-only library, it is easy to add it as a subdirectory in a CMake project. We will see how to do it.

It is assumed that both Kokkos and kokkos-fft are placed under `<project_directory>/tpls`. Here is the structure of a simple CMake project.

```
---/
|
└──<project_directory>/
|──tpls/
| |──kokkos/
| └──kokkos-fft/
|──CMakeLists.txt
└──hello.cpp
```

See [here](https://kokkos.org/kokkos-core-wiki/get-started/integrating-kokkos-into-your-cmake-project.html#embedded-kokkos-via-add-subdirectory-and-git-submodules) about embedding Kokkos via `add_subdirectory()` and Git Submodules in your CMake project. Then, you need to clone the repo of kokkos-fft into `<project_directory>/tpls/kokkos-fft`.

```bash
git clone --recursive https://github.com/kokkos/kokkos-fft.git
```

The `CMakeLists.txt` file of the project would be

```CMake
cmake_minimum_required(VERSION 3.23)
project(kokkos-fft-as-subdirectory LANGUAGES CXX)

add_subdirectory(tpls/kokkos)
add_subdirectory(tpls/kokkos-fft)

add_executable(hello-kokkos-fft hello.cpp)
target_link_libraries(hello-kokkos-fft PUBLIC Kokkos::kokkos KokkosFFT::fft)
```

To build the project, we basically rely on the CMake options for Kokkos. For example, the build steps for an A100 GPU based backend are as follows:

```bash
cmake -B build \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release \
-DKokkos_ENABLE_CUDA=ON \
-DKokkos_ARCH_AMPERE80=ON
cmake --build build -j 8
```

This way, all the FFT functionalities will be executed on the A100 GPU. For installation as a library, details are provided in the [documentation](https://kokkosfft.readthedocs.io/en/latest/intro/building.html#install-kokkosfft-as-a-library).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would drop these two sections and defer to the kokkos-fft documentation.
You could say that the code for the following example can be found in the kokkos-fft repo and post a link.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I just tried to make this blog post self-contained. If it is not necessary, I can drop this part

@yasahi-hpc
Copy link
Author

@dalg24 Thanks a lot for your comments.
I will try to fix as soon as possible.
Is there any deadline to merge this?

@dalg24
Copy link
Member

dalg24 commented Mar 14, 2025

@dalg24 Thanks a lot for your comments.

I will try to fix as soon as possible.

Is there any deadline to merge this?

No hard deadline. But obviously we don't want to unnecessarily drag it too much.

@yasahi-hpc
Copy link
Author

@dalg24 Thanks a lot for your comments.
I will try to fix as soon as possible.
Is there any deadline to merge this?

No hard deadline. But obviously we don't want to unnecessarily drag it too much.

Good. I think we can safely make it before the end of next week

@yasahi-hpc yasahi-hpc requested a review from dalg24 March 19, 2025 14:50
@yasahi-hpc
Copy link
Author

Hi @dalg24
May I have another review.

Since I have largely modified the source code, I made a benchmark again.
Surprisingly, with the new python, there is a factor of 2 speed up.
I added the compiler/version in the table for reproducibility.

@dalg24 dalg24 requested a review from lucbv March 20, 2025 07:39
@yasahi-hpc yasahi-hpc force-pushed the add-kokkos-fft-blog branch from 1e4dbca to 96238dc Compare April 1, 2025 11:25
@yasahi-hpc
Copy link
Author

@dalg24
I have added the performance result on PVC as we have discussed yesterday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants