ALL 0.9.3
A Loadbalacing Library
Loading...
Searching...
No Matches
border_shift_1d.cpp
Go to the documentation of this file.
1/*
2Copyright 2018-2020 Rene Halver, Forschungszentrum Juelich GmbH, Germany
3Copyright 2018-2020 Godehard Sutmann, Forschungszentrum Juelich GmbH, Germany
4
5Redistribution and use in source and binary forms, with or without modification,
6are permitted provided that the following conditions are met:
7
81. Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10
112. Redistributions in binary form must reproduce the above copyright notice,
12this list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
14
153. Neither the name of the copyright holder nor the names of its contributors
16may be used to endorse or promote products derived from this software without
17 specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*/
30
31#define BOOST_TEST_MAIN
32
33#define BOOST_TEST_MODULE borderShift1d
34#include "ALL_Functions.hpp"
35#include <boost/test/unit_test.hpp>
36#include <iostream>
37#include <list>
38#include <mpi.h>
39#include <vector>
40
41BOOST_AUTO_TEST_SUITE(borderShift1d)
42
44
45BOOST_AUTO_TEST_CASE(double_normal_case) {
46
47 int remote_rank = 384;
48 int local_coord = 3;
49 int global_dim = 8;
50 double local_work = 0.6;
51 double remote_work = 0.4;
52 double local_size = 1.0;
53 double remote_size = 1.0;
54 double gamma = 4.0;
55 double min_size = 0.2;
56
57 double shift =
58 borderShift1d(remote_rank, local_coord, global_dim, local_work,
59 remote_work, local_size, remote_size, gamma, min_size);
60
61 BOOST_CHECK_CLOSE(shift, -0.05, 1e-9);
62}
63
64BOOST_AUTO_TEST_CASE(double_neighbor_null) {
65
66 int remote_rank = MPI_PROC_NULL;
67 int local_coord = 3;
68 int global_dim = 8;
69 double local_work = 0.6;
70 double remote_work = 0.4;
71 double local_size = 1.0;
72 double remote_size = 1.0;
73 double gamma = 4.0;
74 double min_size = 0.2;
75
76 double shift =
77 borderShift1d(remote_rank, local_coord, global_dim, local_work,
78 remote_work, local_size, remote_size, gamma, min_size);
79
80 BOOST_CHECK_CLOSE(shift, 0.0, 1e-9);
81}
82
83BOOST_AUTO_TEST_CASE(double_neighbor_larger_than_min_size) {
84
85 int remote_rank = 384;
86 int local_coord = 3;
87 int global_dim = 8;
88 double local_work = 0.6;
89 double remote_work = 0.4;
90 double local_size = 1.0;
91 double remote_size = 1.0;
92 double gamma = 4.0;
93 double min_size = 0.98;
94
95 double shift =
96 borderShift1d(remote_rank, local_coord, global_dim, local_work,
97 remote_work, local_size, remote_size, gamma, min_size);
98
99 BOOST_CHECK_CLOSE(shift, -0.02 * 0.49, 1e-9);
100}
101
102BOOST_AUTO_TEST_CASE(double_local_process_on_edge) {
103
104 int remote_rank = 384;
105 int local_coord = 3;
106 int global_dim = 4;
107 double local_work = 0.6;
108 double remote_work = 0.4;
109 double local_size = 1.0;
110 double remote_size = 1.0;
111 double gamma = 4.0;
112 double min_size = 0.98;
113
114 double shift =
115 borderShift1d(remote_rank, local_coord, global_dim, local_work,
116 remote_work, local_size, remote_size, gamma, min_size);
117
118 BOOST_CHECK_CLOSE(shift, 0, 1e-9);
119}
120
121BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(double_normal_case)
T borderShift1d(const int remote_rank, const int local_coord, const int global_dim, const W local_work, const W remote_work, const T local_size, const T remote_size, const T gamma, const T minSize)
T borderShift1d(const int remote_rank, const int local_coord, const int global_dim, const W local_work, const W remote_work, const T local_size, const T remote_size, const T gamma, const T minSize)