Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laplacian equation challenge

Performance comparison of the 3D Laplacian stencil computation

About The Project

The goal is to test multiple implementation of the Laplacian equation, for different programming languages and different libraries, with CPU and GPU, and various compilation options.

Currently, we implemented:

  • Native C++ (CPU)
  • C++ with the Kokkos library (CPU and GPU)
  • Python with Numba (CPU)
  • Python with Taichi (CPU and GPU)

Laplacian Equation

The Laplacian operator is defined as the sum of second partial derivatives

Laplacian equation

Discretized Form (Finite Difference)

In 1D, using a grid spacing h:

Laplacian equation 1d

In 3D, for a regular cubic grid:

Laplacian equation 1d

(back to top)

Installation

Clone the repository

git clone --recurse-submodules https://github.com/mianbreton/laplacian_challenge.git

The C++ and Python tests are independent.

C++

# Build native and Kokkos CPU executables
cd cpp/
mkdir -p build/openmp; cd build/openmp
cmake ../../ -DKokkos_ENABLE_OPENMP=ON
make -j $NCPU

# Build Kokkos GPU executables with CUDA
cd cpp/
mkdir -p build/cuda; cd build/cuda
cmake ../../ -DKokkos_ENABLE_OPENMP=ON -DKokkos_ENABLE_CUDA=ON
make -j $NCPU

Configuration options ( cmake -D arguments ) include :

# The following GPU backends are available
DKokkos_ENABLE_CUDA=ON/OFF
DKokkos_ENABLE_HIP=ON/OFF
DKokkos_ENABLE_SYCL=ON/OFF
# Debug, adds the -g compilation flag
-DDEBUG=ON/OFF
# Enable unit testing
-DENABLE_UNIT_TESTING=ON/OFF

If unit tests are enabled, run ctest in the build directory to test the build.

Python

To install all the dependencies

cd python/
python -m pip install -e .

⚠️ Currently, it seems that Taichi does not support Python 3.11 and above

To test the installation, first install pytest and run the tests

python -m pip install pytest
# Then, in the python/ directory
pytest

Run

You can run the C++ executables with

cd cpp/
./run_all.sh

To run the Python implementations

cd python/
python run.py # Which by defaults runs as 'python run.py --ncells 32 64 128 256 --ncpus 1 2 4 8 16 --runs 10'

Both runs will produce runtime files in ./timings/

Contributing

If you with to contribute to this project with other implementations of the Laplacian equation, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

About

Various implementations of the 3D Laplacian equation for CPU and GPU

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages