Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65165069
test_mpi.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 1, 09:52
Size
3 KB
Mime Type
text/x-c++
Expires
Mon, Jun 3, 09:52 (2 d)
Engine
blob
Format
Raw Data
Handle
18016480
Attached To
rTAMAAS tamaas
test_mpi.cpp
View Options
/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-2020 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fftw_mpi_engine.hh"
#include "grid.hh"
#include "grid_hermitian.hh"
#include "grid_view.hh"
#include "partitioner.hh"
#include "test.hh"
#include <fftw3-mpi.h>
using namespace tamaas;
using fft = fftw::helper<Real>;
/* -------------------------------------------------------------------------- */
template <typename T>
struct span {
T* ptr;
std::size_t size;
~span() { fftw::free(ptr); }
const T* begin() const { return ptr; }
const T* end() const { return ptr + size; }
T* begin() { return ptr; }
T* end() { return ptr + size; }
operator T*() { return ptr; }
};
/* -------------------------------------------------------------------------- */
TEST(TestFFTWInterface, MPISizes) {
const std::ptrdiff_t N0 = 100, N1 = 100;
std::ptrdiff_t local_n0, local_n0_start;
auto alloc_local = fftw_mpi_local_size_2d(N0, N1 / 2 + 1, MPI_COMM_WORLD,
&local_n0, &local_n0_start);
const std::ptrdiff_t N[] = {N0, N1 / 2 + 1};
auto sizes = fftw::mpi::local_size_many(2, N, 1);
ASSERT_EQ(std::get<0>(sizes), alloc_local);
ASSERT_EQ(std::get<1>(sizes), local_n0);
ASSERT_EQ(std::get<2>(sizes), local_n0_start);
}
/* -------------------------------------------------------------------------- */
TEST(TestPartitioner, LocalSizes) {
const std::ptrdiff_t N0 = 100, N1 = 100;
std::ptrdiff_t local_n0, local_n0_start;
fftw_mpi_local_size_2d(N0, N1 / 2 + 1, MPI_COMM_WORLD, &local_n0,
&local_n0_start);
auto local_size = Partitioner<2>::local_size({N0, N1 / 2 + 1});
ASSERT_EQ(local_size[0], local_n0);
ASSERT_EQ(local_size[1], N1 / 2 + 1);
ASSERT_EQ(Partitioner<2>::local_offset({N0, N1 / 2 + 1}), local_n0_start);
}
/* -------------------------------------------------------------------------- */
TEST(TestPartitioner, LocalOffsetInGrid) {
std::array<UInt, 2> N = {10, 10};
std::array<UInt, 2> Nglobal = {mpi::allreduce(N.front()), N.back()};
Grid<UInt, 2> local(N, 1), global(Nglobal, 1);
auto offset = Partitioner<2>::local_offset(local);
auto local_n0_start = Partitioner<2>::local_offset(Nglobal);
ASSERT_EQ(offset, &global(local_n0_start, 0) - &global(0, 0));
}
Event Timeline
Log In to Comment