Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F75554451
partitioner.hh
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
Fri, Aug 2, 22:37
Size
2 KB
Mime Type
text/x-c++
Expires
Sun, Aug 4, 22:37 (2 d)
Engine
blob
Format
Raw Data
Handle
19525035
Attached To
rTAMAAS tamaas
partitioner.hh
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/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef PARTITIONER_HH
#define PARTITIONER_HH
/* -------------------------------------------------------------------------- */
#include "fftw_interface.hh"
#include "mpi_interface.hh"
#include "tamaas.hh"
#include <algorithm>
#include <array>
#include <cstdlib>
/* -------------------------------------------------------------------------- */
namespace
tamaas
{
template
<
UInt
dim
>
struct
Partitioner
{
static
decltype
(
auto
)
global_size
(
std
::
array
<
UInt
,
dim
>
local
)
{
local
.
front
()
=
mpi
::
allreduce
<
operation
::
plus
>
(
local
.
front
());
return
local
;
}
static
decltype
(
auto
)
local_size
(
std
::
array
<
UInt
,
dim
>
global
)
{
auto
tup
=
fftw
::
mpi
::
local_size_many
(
dim
,
cast_size
(
global
).
data
(),
1
);
global
.
front
()
=
static_cast
<
UInt
>
(
std
::
get
<
1
>
(
tup
));
return
global
;
}
static
decltype
(
auto
)
local_offset
(
const
std
::
array
<
UInt
,
dim
>&
global
)
{
auto
tup
=
fftw
::
mpi
::
local_size_many
(
dim
,
cast_size
(
global
).
data
(),
1
);
return
static_cast
<
UInt
>
(
std
::
get
<
2
>
(
tup
));
}
static
decltype
(
auto
)
cast_size
(
const
std
::
array
<
UInt
,
dim
>&
s
)
{
std
::
array
<
std
::
ptrdiff_t
,
dim
>
n
;
std
::
copy
(
s
.
begin
(),
s
.
end
(),
n
.
begin
());
return
n
;
}
};
}
// namespace tamaas
#endif
Event Timeline
Log In to Comment