Git Product home page Git Product logo

exasim's Introduction

Generating Discontinuous Galerkin Codes For Extreme Scalable Simulations

Exasim is an open-source software for generating high-order discontinuous Galerkin (DG) codes to numerically solve parametrized partial differential equations (PDEs) on different computing platforms with distributed memory. It combines high-level languages and low-level languages to easily construct parametrized PDE models and automatically produce high-performance C++ codes. The construction of parametrized PDE models and the generation of the stand-alone C++ production code are handled by high-level languages, while the production code itself can run on various machines, from laptops to the largest supercomputers, with both CPU and Nvidia GPU processors.

What make Exasim unique are the following distinctive features:

  • Solve a wide variety of PDEs in fluid and solid mechanics, and electromagnetism
  • Generate stand-alone C++ production code via the mathematical expressions of the PDEs
  • Implement local DG and hybridized DG methods for spatial discretization
  • Implement diagonally implicit Runge-Kutta methods for temporal discretization
  • Implement parallel Newton-GMRES solvers and scalable preconditioners using reduced basis method and polynomial preconditioners.
  • Employ Kokkos to provide full GPU functionality for all code components from discretization schemes to iterative solvers
  • Leverage Enzyme for automatic differentiation and Mutation++ for thermodynamic, transport, chemistry, and energy transfer properties.
  • Provide interfaces to Julia, Python, and Matlab.

After downloading the source code, please make sure that the name of the folder is Exasim. If it has a different name, please rename it to Exasim. See the documentation for more details.

Installation

Exasim needs Kokkos (required), Blas/Lapack libaries (required), MPI library (required), Gmesh for mesh generation (optional), METIS for mesh partitioning (optional), Paraview for visualization (optional), and CUDA Toolkit (optional) to run on Nvidia GPUs. These external packages can be installed by running install.jl in Julia, install.py in Python, or install.m in Matlab.

As Exasim generates and compiles stand-alone C++ code on the fly, Exasim does not require installation. However, since Exasim uses Kokkos to target various computing platforms, you must build Kokkos libraries before using Exasim. To build Kokkos serial library for CPU platform, please follow the below steps

  $ cd Exasim/kokkos   
  $ mkdir buildserial
  $ cd buildserial
  $ cmake .. -DCMAKE_INSTALL_PREFIX=../buildserial
  $ make install   

To build Kokkos CUDA library for Nvidia GPU platform, please follow the below steps

  $ cd Exasim/kokkos
  $ mkdir buildcuda
  $ cd buildcuda
  $ cmake .. -DCMAKE_CXX_COMPILER=clang++ -DKokkos_ENABLE_CUDA=ON -DCMAKE_INSTALL_PREFIX=../buildcuda
  $ make install   

Once Kokkos libraries are successfully built, you can start using Exasim. To try out any of the provided examples, please go to any folder in the directory Exasim/examples and run pdeapp.jl in Julia, pdeapp.py in Python, or pdeapp.m in Matlab.

Examples

Exasim produces C++ Code to solve a wide variety of parametrized partial differential equations from first-order, second-order elliptic, parabolic, hyperbolic PDEs, to higher-order PDEs. Many examples are provided in Exasim/examples to illustrate how to use Exasim for solving Poisson equation, wave equation, heat equation, advection, convection-diffusion, Euler equations, Navier-Stokes equations, and MHD equations. See the Bickley Jet example for simulation results.

To run any example with Julia, type the following line and hit return

   julia> include("pdeapp.jl")

To run any example with Python, type the following line and hit return

   > > > exec(open("pdeapp.py").read())

To run any example with Matlab, type the following line and hit return

   > >  pdeapp

If successful, Exasim produces an executable application and three new folders in the build folder. The build/model folder contains the Kokkos source code generated by Exasim, the build/datain folder contains input files for the executable application, and the build/dataout folder contains the output files produced by running the executable application, which stores the numerical solution of the PDE model defined in the pdeapp script. The name of the executable application is cpuEXASIM for CPU platform on one processor, cpumpiEXASIM for CPU platform on many processors, gpuEXASIM for CUDA platform on one GPU, and gpumpiEXASIM for CUDA platform on many GPUs.

Publications

[1] Vila-Pérez, J., Van Heyningen, R. L., Nguyen, N.-C., & Peraire, J. (2022). Exasim: Generating discontinuous Galerkin codes for numerical solutions of partial differential equations on graphics processors. SoftwareX, 20, 101212. https://doi.org/10.1016/j.softx.2022.101212

[2] Hoskin, D. S., Van Heyningen, R. L., Nguyen, N. C., Vila-Pérez, J., Harris, W. L., & Peraire, J. (2024). Discontinuous Galerkin methods for hypersonic flows. Progress in Aerospace Sciences, 146, 100999. https://doi.org/10.1016/j.paerosci.2024.100999

[3] Nguyen, N. C., Terrana, S., & Peraire, J. (2022). Large-Eddy Simulation of Transonic Buffet Using Matrix-Free Discontinuous Galerkin Method. AIAA Journal, 60(5), 3060–3077. https://doi.org/10.2514/1.j060459

[4] Nguyen, N. C., & Peraire, J. (2012). Hybridizable discontinuous Galerkin methods for partial differential equations in continuum mechanics. Journal of Computational Physics, 231(18), 5955–5988. https://doi.org/10.1016/j.jcp.2012.02.033

exasim's People

Contributors

e-dinesh avatar exapde avatar jvilaperez avatar peraire avatar rloekvh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

exasim's Issues

Compile flags to App files and core libraries

Right now the app.cpuflags and app.gpuflags fields allow the user to add flags to the compilation of main.cpp. I think it would also be helpful to let the user add flags to compile opuApp/gpuApp and the opuCore/gpuCore libs.

The first case is helpful when using a GPU compiler that is not the default, for example using LLVM Clang. Compiling the App files requires specifying --cuda-path and --cuda-gpu-arch. We could add these to the app object, or we could just let the user specify them by something like gpuappflags.

Allowing libraries to be added to Core compilations is helpful when developing on an M1 Mac, for example. To use MPI on my machine, I've only had luck specifying everything to work on an x86 architecture. This means adding the flag "-arch x86_64" to every compilation string, including those in genlib.

Modification to Version0.3/Kernel/Main/main.cpp

It seems the following modifications are required for successful generation of production codes in v0.3

Line 61:
printf("Usage: ./cppfile nomodels InputFile OutputFile\n");
and
Line 303:
string filename = pdemodel[i]->disc.common.fileout [i] + "_np" + NumberToString(pdemodel[i]->disc.common.mpiRank) + ".bin";

Also, the following code snippets in Sec 6.2 of ExaSim0.3 manual requires update.
mpirun -np mpiprocs ./mpiapp nomodels ../datain/ ../dataout/out
mpirun -gpu -np mpiprocs ./gpumpiapp nomodels ../datain/ ../dataout/out

non-reflecting boundary condition in Application/NS/naca0012 case

Hello.

First of all, Thank you for your works.

I want to get some guidance about non-reflecting boundary condition.

When running naca0012 examples, which you provide at Application/NS, it showed like boundary-induced oscillating, ended up going to divergence.

Could you check the above case to make it converged.

On the other hand, from references mentioned on the paper, i guess the kind of characteristic terms, which is in (ubou) , need to be within flux (fbou) in the form of boundary flux.

Can i get any indicates or references regarding why you put "A" (jacobian) in the (ubou) not (fbou)

Thank you.

P.S I found some tiny bug at execution on gpu, after i tested i am going to post issue about that.

Create CONTRIBUTING.md

We should establish some rules for the core development team and any outside contributors. We'll follow standard GitHub Flow procedures, but it'll still be helpful to have the process for updating code written out.

macos m1 arm64: ERROR: LoadError: TypeError: non-boolean (Int64) used in boolean context

==> Exasim ...
[ Info: Precompiling Preprocessing [top-level]
[ Info: Precompiling Mesh [top-level]
[ Info: Precompiling Postprocessing [top-level]
Using g++ compiler for CPU source code
Generating CPU core libraries.ar: creating archive commonCore.a
a - commonCore.o
ERROR: LoadError: TypeError: non-boolean (Int64) used in boolean context
Stacktrace:
[1] genlib(cpucompiler::String, gpucompiler::String, coredir::String, cpulibflags::String, gpulibflags::String)
@ Gencode ~/Documents/WJQ_DATA/2_Skill/19_Exaim/Exasim/src/Julia/Gencode/genlib.jl:19
[2] genlib
@ ~/Documents/WJQ_DATA/2_Skill/19_Exaim/Exasim/src/Julia/Gencode/genlib.jl:5 [inlined]
[3] setcompilers(app::Preprocessing.PDEStruct)
@ Gencode ~/Documents/WJQ_DATA/2_Skill/19_Exaim/Exasim/src/Julia/Gencode/setcompilers.jl:136
[4] exasim(pde::Preprocessing.PDEStruct, mesh::Preprocessing.MESHStruct)
@ Postprocessing ~/Documents/WJQ_DATA/2_Skill/19_Exaim/Exasim/src/Julia/Postprocessing/exasim.jl:11
[5] top-level scope
@ ~/Documents/WJQ_DATA/2_Skill/19_Exaim/Exasim/Applications/Euler/EulerVortex/pdeapp.jl:44
[6] include(fname::String)
@ Base.MainInclude ./client.jl:476
[7] top-level scope
@ REPL[16]:1
in expression starting at /Users/wjq/Documents/WJQ_DATA/2_Skill/19_Exaim/Exasim/Applications/Euler/EulerVortex/pdeapp.jl:44

AD matvec MPI

MPI functionality still needed for exact Jacobian-vector multiplication using automatic differentiation

Julia and Python apps fail GPU compilation

There are a few issues compiling GPU code with Julia or Python apps.

  1. Compilation will fail with 4 errors of the form
gpuFbou.cu(32): error: identifier "gpuFbou1" is undefined

In the generated file gpuUbou.cu in the app folder, the function is called kernelgpuFbou1, not gpuFbou1. These functions are generated in Gencode/gencodeface files. They are generated correctly in the matlab version, but not in Julia or Python for versions 0.1-0.3

  1. After that, an error appears that opuApp.a does not exist. This is due to missing lines in compilecode.jl and compilecode.py. Line 110-113 in the Julia code is
elseif app.platform == "gpu"
    run(string2cmd(compilerstr[3]));
    run(string2cmd(compilerstr[4]));
    if app.mpiprocs==1
        run(string2cmd(compilerstr[7]));
    else
        run(string2cmd(compilerstr[8]));
    end
end

while the same code block in matlab is

elseif app.platform == "gpu"
   eval(char("!" + compilerstr{1}));
   eval(char("!" + compilerstr{2}));       
   eval(char("!" + compilerstr{3}));
   eval(char("!" + compilerstr{4}));
   if app.mpiprocs==1
       eval(char("!" + compilerstr{7}));
   else
       eval(char("!" + compilerstr{8}));
   end
end

The Julia code also needs to run compilestr(1) and compilestr(2). Same holds for Python

Implementing Other DG Methods

Hello,
I'm trying to implement my numerical flux but as soon as I define it in the model file, two problems arise:

  1. the following error appear:
opuFhat.cpp: In function ‘void opuFhat(T*, T*, T*, T*, T*, T*, T*, T*, T*, T*, T*, T*, T*, T, int, int, int, int, int, int, int, int)’:
opuFhat.cpp:15:27: error: ‘udgp’ was not declared in this scope; did you mean ‘udgp1’?
   15 |                 T udgp1 = udgp[0*ng+i];
      |                           ^~~~
      |                           udgp1
opuFhat.cpp:27:27: error: ‘udgm’ was not declared in this scope; did you mean ‘udgm1’?
   27 |                 T udgm1 = udgm[0*ng+i];
      |                           ^~~~
      |                           udgm1
  1. any flux I enter the result remains the same, wrong (after a few iterations NaN and a non-physical field are generated)

I inserted the correct flag in the app file, I tried to define also the numerical trace but still the result does not change. I’m using the naca0012 profile test case (Euler model) to make sure the rest of the code is well written.

Thanks for reading.

Error "no method matching *(::Char, ::Tuple{String,Int64})" in install.jl

Trying to install Exasim on macOS (10.15.7). Running julia 1.5.3.

My first attempt to run

julia> include("install.jl")

failed because

Error: Cannot install mpich because conflicting formulae are installed.
  open-mpi: because both install MPI compiler wrappers

Please `brew unlink open-mpi` before continuing.

After running

$ brew unlink open-mpi

installation seemed to proceed more smoothly, until I hit

ERROR: LoadError: MethodError: no method matching *(::Char, ::Tuple{String,Int64})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:538
  *(::Union{AbstractChar, AbstractString}, ::Union{AbstractChar, AbstractString}...) at strings/basic.jl:251
  *(::Union{Regex, AbstractChar, AbstractString}, ::Union{Regex, AbstractChar, AbstractString}...) at regex.jl:656
Stacktrace:
 [1] *(::Char, ::Tuple{String,Int64}, ::Char) at ./operators.jl:538
 [2] top-level scope at /Users/gregorywagner/Projects/Exasim/Installation/install.jl:94
 [3] include(::String) at ./client.jl:457
 [4] top-level scope at REPL[1]:1
in expression starting at /Users/gregorywagner/Projects/Exasim/Installation/install.jl:94

This comes from

p = q * mpi * q;

I guess mpi is a tuple:

julia> mpi
("", 1)

and q is a char:

julia> q
'"': ASCII/Unicode U+0022 (category Po: Punctuation, other)

I'm not sure if mpi is meant to be Tuple, but the reason is because findinstallexec here:

mpi = findinstallexec("mpicxx", "openmpi", brew, 0);

returns a tuple:

return dirname, appinstall;

Julia GPU compilation warnings NavierStokes/naca

warning message pops up in Julia/python versions, not in Matlab. [#26]
resulted in the warnings (below) but seems the simulation is not affected (to be verified).
<<<
compile code...
ar: creating opuApp.a
a - opuApp.o
gpuInitu.cu(11): warning: variable "xdg1" was declared but never referenced
detected during:
instantiation of "void kernelgpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=double]"
(26): here
instantiation of "void gpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=double]"
(29): here

gpuInitu.cu(12): warning: variable "xdg2" was declared but never referenced
detected during:
instantiation of "void kernelgpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=double]"
(26): here
instantiation of "void gpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=double]"
(29): here

gpuInitu.cu(11): warning: variable "xdg1" was declared but never referenced
detected during:
instantiation of "void kernelgpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=float]"
(26): here
instantiation of "void gpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=float]"
(30): here

gpuInitu.cu(12): warning: variable "xdg2" was declared but never referenced
detected during:
instantiation of "void kernelgpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=float]"
(26): here
instantiation of "void gpuInitu(T *, T *, T *, T *, int, int, int, int, int, int) [with T=float]"
(30): here

GPU compilation error and Possible solution: Applications/Poisson/MuiltipleEquations/pdeapp.jl

Error:
In file included from gpuApp.cu:4:
gpuFlux.cu:1:10: fatal error: gpuFlux1.cpp: No such file or directory
 #include "gpuFlux1.cpp"
          ^~~~~~~~~~~~~~
compilation terminated.
ERROR: LoadError: failed process: Process(`nvcc -D_FORCE_INLINES -O3 -c --compiler-options "'-fPIC'" gpuApp.cu`, ProcessExited(1)) [1]

Suggested Solution @exapde
After the line

strgpu = replace(stropu, "opu" => "gpu");

I included the following line by replacing cpp by cu for proper compilation
strgpu = replace(strgpu, "cpp" => "cu");

And it worked. But not sure how it affects the other examples.
Any other examples for multiple equation models?

AD Matvec GPU

Exact Jacobian-vector multiplications with autodiff on GPU

Missing flags leading to wrong solutions for Python and Julia interfaces

Python and Julia app structs are missing flags for external Fhat, Uhat, and Stab terms

This leads to incorrect solutions for time-dependent problems when using Python or Julia to generate GPU code specifically. Bug was discovered for 2D Euler but most likely applies to other problems. It does not show up when using Matlab, using Python or Julia for CPU code, or solving steady problems

gmshcall.py to output physical groups if present in .geo specification

Regarding Exasim/src/Python/Mesh/gmshcall.py:

The current gmshcall function doesn't read in physical groups that are specified in the input .geo file. Physical groups are collections of model entities that are used to alias domains and boundaries, preventing having to manually enter them using logical operations on the coordinate values in the pdeapp script. If the geometry is specified using Gmsh, being able to read in the physical groups from the .geo file will yield significant user time savings in setting up the case.

initial field to dataout

@rloekvh @exapde
suggestion to print the initial field data.
The following commands start printing from t=0+dt onwards, not t=0.
<<
pde.dt = dt*ones(1,nt); % time step sizes
pde.soltime = 1:length(pde.dt);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.