-
Notifications
You must be signed in to change notification settings - Fork 6
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
Cleanup over empty #10
Changes from all commits
16f76f9
2b28474
1e33763
fdee139
a6c3507
e40bcfa
83ebcec
5015701
d54923b
51c1adc
b214033
caa1193
5823af0
8d2f31c
48352b4
9a8a3e6
243ba49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: CMake | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: RelWithDebInfo | ||
|
||
jobs: | ||
|
||
build_nvidia: | ||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | ||
# You can convert this to a matrix build if you need cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
backends: OPENMP CUDA | ||
CUDA_ARCHITECTURES: AMPERE80 | ||
CMAKE_CXX_COMPILER: /work/tpls/kokkos/bin/nvcc_wrapper | ||
container: nvidia_env | ||
|
||
steps: | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/[email protected] | ||
with: { tool-cache: true, large-packages: false } | ||
|
||
- name: Checkout built branch | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Update submodules | ||
run: git submodule update --remote --recursive | ||
|
||
- name: Build docker | ||
run: docker build -t ${{ env.container }} docker/nvidia | ||
|
||
- name: Configure CMake for OpenMP backend | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_OPENMP \ | ||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=g++ \ | ||
-DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_OPENMP=ON -DBUILD_TESTING=ON | ||
|
||
- name: Configure CMake for CUDA backend | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_CUDA \ | ||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{env.CMAKE_CXX_COMPILER}} \ | ||
-DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_${{env.CUDA_ARCHITECTURES}}=ON -DBUILD_TESTING=ON | ||
|
||
- name: Build | ||
# Build your program with the given configuration | ||
run: | | ||
for backend in ${{ env.backends }}; do | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${backend} --config ${{env.BUILD_TYPE}} -j 2 | ||
done | ||
|
||
- name: Test on CPUs | ||
# Execute tests defined by the CMake configuration. Testing on CPUs only | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} ctest --output-on-failure --test-dir build_OPENMP -C ${{env.BUILD_TYPE}} | ||
|
||
build_amd: | ||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | ||
# You can convert this to a matrix build if you need cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
backend: HIP | ||
architecture: VEGA90A | ||
CMAKE_CXX_COMPILER: hipcc | ||
container: amd_env | ||
|
||
steps: | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/[email protected] | ||
with: { tool-cache: true, large-packages: false } | ||
|
||
- name: Checkout built branch | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Update submodules | ||
run: git submodule update --remote --recursive | ||
|
||
- name: Build docker | ||
run: docker build -t ${{ env.container }} docker/amd | ||
|
||
- name: Configure CMake for HIP backend | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_${{env.backend}} \ | ||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{env.CMAKE_CXX_COMPILER}} \ | ||
-DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_${{env.architecture}}=ON -DBUILD_TESTING=ON | ||
|
||
- name: Build | ||
# Build your program with the given configuration | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${{env.backend}} --config ${{env.BUILD_TYPE}} -j 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "tpls/googletest"] | ||
path = tpls/googletest | ||
url = https://github.com/google/googletest | ||
[submodule "tpls/kokkos"] | ||
path = tpls/kokkos | ||
url = https://github.com/kokkos/kokkos.git |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||||||||
cmake_minimum_required(VERSION 3.23) | ||||||||||||||
project(kokkos-fft LANGUAGES CXX) | ||||||||||||||
|
||||||||||||||
# Add cmake helpers for FFTW | ||||||||||||||
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") | ||||||||||||||
|
||||||||||||||
# Options | ||||||||||||||
option(BUILD_EXAMPLES "Build kokkos-fft examples" ON) | ||||||||||||||
|
||||||||||||||
find_package(Kokkos CONFIG) | ||||||||||||||
if(NOT kokkos_FOUND) | ||||||||||||||
add_subdirectory(tpls/kokkos) | ||||||||||||||
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Ideally, we should have a flag to turn off in source Kokkos to help packaging. It is important to fail if Kokkos is not found in the case of Spack. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, this point is not very clear to me. I would appreciate if you could show me examples |
||||||||||||||
endif() | ||||||||||||||
|
||||||||||||||
# Googletest | ||||||||||||||
include(CTest) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We do not need CTest here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the end, we need this for execute testing of examples in actions? |
||||||||||||||
if(BUILD_TESTING) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Option is not previously defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This options would be needed for production, build with |
||||||||||||||
find_package(GTest CONFIG) | ||||||||||||||
if(NOT GTest_FOUND) | ||||||||||||||
add_subdirectory(tpls/googletest) | ||||||||||||||
Comment on lines
+18
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as for Kokkos |
||||||||||||||
endif() | ||||||||||||||
endif() | ||||||||||||||
|
||||||||||||||
add_subdirectory(common) | ||||||||||||||
add_subdirectory(fft) | ||||||||||||||
if(BUILD_EXAMPLES) | ||||||||||||||
add_subdirectory(examples) | ||||||||||||||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# kokkos-fft | ||
|
||
UNOFFICIAL FFT interfaces for Kokkos C++ Performance Portability Programming EcoSystem | ||
|
||
KokkosFFT implements local interfaces Kokkos and de facto standard FFT libraries, including fftw, cufft and hipfft. | ||
"Local" means not using MPI, or running within a | ||
single MPI process without knowing about MPI. We are inclined to implement the numpy FFT interfaces based on Kokkos. | ||
Here is the example for 1D case in python and KokkosFFT. | ||
```python3 | ||
import numpy as np | ||
x = np.random.rand(4) | ||
x_hat = np.fft.rfft(x) | ||
``` | ||
|
||
```C++ | ||
#include <Kokkos_Core.hpp> | ||
#include <Kokkos_Complex.hpp> | ||
#include <Kokkos_Random.hpp> | ||
#include <KokkosFFT.hpp> | ||
using execution_space = Kokkos::DefaultExecutionSpace; | ||
template <typename T> using View1D = Kokkos::View<T*, execution_space>; | ||
constexpr int n = 4; | ||
|
||
View1D<double> x("x", n); | ||
View1D<Kokkos::complex<double> > x_hat("x_hat", n/2+1); | ||
|
||
Kokkos::Random_XorShift64_Pool<> random_pool(12345); | ||
Kokkos::fill_random(x, random_pool, 1); | ||
Kokkos::fence(); | ||
|
||
KokkosFFT::rfft(x, x_hat); | ||
``` | ||
|
||
Depending on the View dimension, it automatically uses the batched plans as follows | ||
```python3 | ||
import numpy as np | ||
x = np.random.rand(4, 8) | ||
x_hat = np.fft.rfft(x, axis=-1) | ||
``` | ||
|
||
```C++ | ||
#include <Kokkos_Core.hpp> | ||
#include <Kokkos_Complex.hpp> | ||
#include <Kokkos_Random.hpp> | ||
#include <KokkosFFT.hpp> | ||
using execution_space = Kokkos::DefaultExecutionSpace; | ||
template <typename T> using View2D = Kokkos::View<T**, execution_space>; | ||
constexpr int n0 = 4, n1 = 8; | ||
|
||
View2D<double> x("x", n0, n1); | ||
View2D<Kokkos::complex<double> > x_hat("x_hat", n0, n1/2+1); | ||
|
||
Kokkos::Random_XorShift64_Pool<> random_pool(12345); | ||
Kokkos::fill_random(x, random_pool, 1); | ||
Kokkos::fence(); | ||
|
||
int axis = -1; | ||
KokkosFFT::rfft(x, x_hat, KokkosFFT::FFT_Normalization::BACKWARD, axis); // FFT along -1 axis and batched along 0th axis | ||
``` | ||
|
||
## Building KokkosFFT | ||
|
||
### CMake | ||
Up to now, we just rely on the CMake options for Kokkos. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a good idea to add a version number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure