schwz  Generated automatically from develop
utils.hpp (1cd0e3b)
1 
2 /*******************************<SCHWARZ LIB LICENSE>***********************
3 Copyright (c) 2019, the SCHWARZ LIB authors
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ******************************<SCHWARZ LIB LICENSE>*************************/
33 
34 
35 #ifndef utils_hpp
36 #define utils_hpp
37 
38 
39 #include <fstream>
40 #include <iostream>
41 #include <memory>
42 #include <string>
43 
44 
45 #include <mpi.h>
46 #include <ginkgo/ginkgo.hpp>
47 
48 
49 #include <settings.hpp>
50 
51 
52 namespace schwz {
53 
54 
64 template <typename ValueType = gko::default_precision,
65  typename IndexType = gko::int32>
66 struct Utils {
67  Utils() = default;
68 
69  static int get_local_rank(MPI_Comm mpi_communicator);
70 
71  static int get_local_num_procs(MPI_Comm mpi_communicator);
72 
73  static bool check_subd_locality(MPI_Comm mpi_communicator,
74  int neighbor_rank, int my_rank);
75 
76  static void print_matrix(
77  const gko::matrix::Csr<ValueType, IndexType> *matrix, int rank,
78  std::string name);
79 
80  static void print_vector(const gko::matrix::Dense<ValueType> *vector,
81  int rank, std::string name);
82 
83  static int find_duplicates(IndexType val, std::size_t index,
84  const IndexType *data, std::size_t length);
85 
86  static bool assert_correct_permutation(
87  const gko::matrix::Permutation<IndexType> *input_perm);
88 
89  static bool assert_correct_cuda_devices(int num_devices, int my_rank);
90 };
91 
92 
93 } // namespace schwz
94 
95 
96 #endif // utils.hpp
The utilities class which provides some checks and basic utilities.
Definition: utils.hpp:66
The Schwarz wrappers namespace.
Definition: comm_helpers.hpp:49