GithubHelp home page GithubHelp logo

raptor-library / raptor Goto Github PK

View Code? Open in Web Editor NEW
57.0 13.0 11.0 23.26 MB

General, high performance algebraic multigrid solver

License: BSD 2-Clause "Simplified" License

C++ 88.97% CMake 6.92% Python 1.97% Jupyter Notebook 2.14%
mpi parallel sparse cpp multigrid krylov

raptor's Introduction

ci Codecov

raptor

RAPtor is a general, high performance algebraic multigrid solver.

Requirements

  • MPI
  • cmake

Build Instructions

  1. Configure the build
cmake -Bbuild [OPTIONS]
  1. Build the RAPtor library
cmake --build build --parallel
  1. Test RAPtor
ctest --test-dir build -V

Note: to test with a hostfile, hostfile.txt, use

cmake -Bbuild -DWITH_HOSTFILE=ON -DHOSTFILE=<full path to>/hostfile.txt
cmake --build build --parallel
ctest --test-dir build -V

Options

  • WITH_HYPRE: Includes hypre_wrapper in the build. Hypre must be installed before building with this option. If not installed to /usr/local, set the HYPRE_DIR option.

  • WITH_MFEM: Includes mfem_wrapper, mfem files, and hypre_wrapper in the build. Mfem, Metis, and Hypre must be installed before building with this option. For any packages not installed to /usr/local, set the directory option (<package>_DIR).

  • HYPRE_DIR: Sets the directory of hypre containing the include and lib folders

  • METIS_DIR: Sets the directory of metis containing the include and libmetis folders

  • MFEM_DIR: Sets the directory of mfem containing mfem.h and libmfem

Unit Testing

The build system uses GoogleTest. The build searches the source tree and adds any test directory to ctest. For a simple example, see raptor/core/tests/ParVector.cpp.

Citing

@MISC{BiOl2017,
      author = {Bienz, Amanda and Olson, Luke N.},
      title = {{RAPtor}: parallel algebraic multigrid v0.1},
      year = {2017},
      url = {https://github.com/lukeolson/raptor},
      note = {Release 0.1}
      }

Full Example

From the examples directory:

mpirun -n 4 ./example

This example is maintained in raptor/examples/example.cpp

// Copyright (c) 2015-2017, Raptor Developer Team
// License: Simplified BSD, http://opensource.org/licenses/BSD-2-Clause
#include <mpi.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream>

// Include raptor
#include "raptor/raptor.hpp"

// This is a basic use case.
int main(int argc, char *argv[])
{
    // set rank and number of processors
    int rank, num_procs;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &num_procs);

    // Create parallel matrix and vectors
    ParCSRMatrix* A;
    ParVector x;
    ParVector b;

    // Timers
    double time_setup, time_solve, time_base;

    // Problems size and type
    int dim = 2;
    int n = 100;

    aligned_vector<int> grid;
    grid.resize(dim, n);

    // Anisotropic diffusion
    coarsen_t coarsen_type = CLJP;
    interp_t interp_type = ModClassical;
    relax_t relax_type = SOR;
    double eps = 0.001;
    double theta = M_PI/8.0;
    double* stencil = NULL;
    stencil = diffusion_stencil_2d(eps, theta);
    A = par_stencil_grid(stencil, grid.data(), dim);
    delete[] stencil;

    x = ParVector(A->global_num_cols, A->on_proc_num_cols);
    b = ParVector(A->global_num_rows, A->local_num_rows);

    x.set_const_value(1.0);
    A->mult(x, b);
    x.set_const_value(0.0);

    // AMG parameters
    double strong_threshold = 0.25;

    // Create a multilevel object
    ParMultilevel* ml;

    // Setup Raptor Hierarchy
    MPI_Barrier(MPI_COMM_WORLD);
    time_base = MPI_Wtime();
    ml = new ParRugeStubenSolver(strong_threshold, coarsen_type, interp_type, Classical, relax_type);
    ml->setup(A);
    time_setup = MPI_Wtime() - time_base;

    // Print out information on the AMG hierarchy
    int64_t lcl_nnz;
    int64_t nnz;

    if (rank == 0) std::cout << "Level\tNumRows\tNNZ" << std::endl;
    if (rank == 0) std::cout << "-----\t-------\t---" << std::endl;
    for (int64_t i = 0; i < ml->num_levels; i++)
    {
        ParCSRMatrix* Al = ml->levels[i]->A;
        lcl_nnz = Al->local_nnz;
        MPI_Reduce(&lcl_nnz, &nnz, 1, MPI_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
        if (rank == 0) std::cout << i << "\t" << Al->global_num_rows << "\t" << nnz << std::endl;
    }

    // Solve Raptor Hierarchy
    MPI_Barrier(MPI_COMM_WORLD);
    time_base = MPI_Wtime();
    ml->solve(x, b);
    time_solve = MPI_Wtime() - time_base;

    MPI_Reduce(&time_setup, &time_base, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
    if (rank == 0) printf("Raptor AMG Setup Time: %e\n", time_base);
    MPI_Reduce(&time_solve, &time_base, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
    if (rank == 0) printf("Raptor AMG Solve Time: %e\n", time_base);

    // Delete AMG hierarchy
    delete ml;
    delete A;
    MPI_Finalize();

    return 0;
}

License

This code is distributed under BSD: http://opensource.org/licenses/BSD-2-Clause

Please see LICENSE.txt and COPYRIGHT.txt for more information.

raptor's People

Contributors

alexey-voronin avatar andrewreisner avatar bienz2 avatar bowmanat avatar joncalhoun40 avatar lukeolson avatar mwang81 avatar sll2 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

Watchers

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

raptor's Issues

when i compile raptor, error occurs

hi ,
I'm having some difficulties, when I type cmake .. under build and type make, I meet the following error:

[ 50%] Linking CXX executable test_par_scale_aniso
/usr/local/lib/liblapack.a(xerbla.o): In function `xerbla_':
xerbla.f:(.text+0x53): undefined reference to `_gfortran_st_write'
xerbla.f:(.text+0x5e): undefined reference to `_gfortran_string_len_trim'
xerbla.f:(.text+0x73): undefined reference to `_gfortran_transfer_character_write'
xerbla.f:(.text+0x83): undefined reference to `_gfortran_transfer_integer_write'
xerbla.f:(.text+0x8b): undefined reference to `_gfortran_st_write_done'
xerbla.f:(.text+0x94): undefined reference to `_gfortran_stop_string'
collect2: error: ld returned 1 exit status
raptor/util/tests/CMakeFiles/test_par_scale_aniso.dir/build.make:99: recipe for target 'raptor/util/tests/test_par_scale_aniso' failed
make[2]: *** [raptor/util/tests/test_par_scale_aniso] Error 1
CMakeFiles/Makefile2:1466: recipe for target 'raptor/util/tests/CMakeFiles/test_par_scale_aniso.dir/all' failed
make[1]: *** [raptor/util/tests/CMakeFiles/test_par_scale_aniso.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

I added the -lgfortran option when compiling LAPACK, but the problem is still not solved. Is this a LAPACK problem or should I add any compilation options in RAPtor?

Looking forward to your reply!

best wishes!

segfault on test 5 or 6

there's a segfault on test 5 or 6 when i run

mpirun -n 2 ./benchmark.out

specifically i get an area saying

Test 4 - b0[0] = 0.000
Test 4 - b0[1] = 0.000

Test 4 - b0[2] = 0.000
Test 4 - b0[3] = 0.000

Test 5 - b0[0] = 0.000


===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   PID 6790 RUNNING AT Appa
=   EXIT CODE: 11
=   CLEANING UP REMAINING PROCESSES
=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions

Question with aggregation using METIS

Hi, thanks for your previous reply to the compilation question.

I have another question to discuss with you about aggregating using Metis.

Due to Metis limitation on the number of segmented subgraphs, when the fine-grid layer matrix is large enough, Metis cannot aggregate enough coarse nodes (for example, the fine-grid layer has a million nodes, each two of which aggregates into points on the next layer of the grid, which will result in about 500,000 aggregates, and Metis cannot split a graph of this size). Do you have any good suggestions for this situation?

I look forward to receiving your reply, and I will benefit from any help you give me.

Best wishes

add parameters to a json file

Parameters such as smoother, sweeps, iterations, etc should be expressed in some sort of config structure and set in a json file.

make in build isn't working

after i run
mkdir build cmake .. build
right when it's almost finished it gives me this error:
/usr/bin/ld: cannot find -lraptor collect2: error: ld returned 1 exit status make[2]: *** [examples/vecnorm] Error 1 make[1]: *** [examples/CMakeFiles/vecnorm.dir/all] Error 2 make: *** [all] Error 2

can't test until i fix this.i think it might have to do with how i have mpicxx instead of mpiCC. the result of this is when i try to run make for benchmark.cpp, is a compile error saying:
mpicxx -O2 -std=c++11 -I//home/mwang81/Desktop/olson/raptor/external/ -I//home/mwang81/Desktop/olson/raptor/raptor/ benchmark.cpp -L//home/mwang81/Desktop/olson/raptor/build/raptor -lraptor -o benchmark.out benchmark.cpp:13:35: fatal error: util/linalg/matmult.hpp: No such file or directory #include "util/linalg/matmult.hpp"

Python bindings?

As far as I know, raptor is a completely different implementation than PyAMG. Given that PyAMG still lacks parallelism support, are there any plans to have python bindings for raptor (along the lines of petsc4py and slepc4py)?

Complex Doubles and Long Integers

Change variables in raptor to RAPTOR_DOUBLE, RAPTOR_INT, RAPTOR_I, RAPTOR_F (or something similar) where RAPTOR_I can be int or long, and RAPTOR_F can be double or complex

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.