NEST main@caf0ae8
 
Loading...
Searching...
No Matches
mpi_manager_impl.h
Go to the documentation of this file.
1/*
2 * mpi_manager_impl.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef MPI_MANAGER_IMPL_H
24#define MPI_MANAGER_IMPL_H
25
26#include "config.h"
27
28#ifdef HAVE_MPI
29// C includes:
30#include <mpi.h>
31#endif /* #ifdef HAVE_MPI */
32
33#include "mpi_manager.h"
34
35// Includes from nestkernel:
36#include "kernel_manager.h"
37
38namespace nest
39{
40
41inline size_t
42MPIManager::get_process_id_of_vp( const size_t vp ) const
43{
44 return vp % num_processes_;
45}
46
47#ifdef HAVE_MPI
48
49// Variable to hold the MPI communicator to use.
50extern MPI_Comm comm;
51
52template < typename T >
53struct MPI_Type
54{
55 static MPI_Datatype type;
56};
57
58template < typename T >
59void
60MPIManager::communicate_Allgatherv( std::vector< T >& send_buffer,
61 std::vector< T >& recv_buffer,
62 std::vector< int >& displacements,
63 std::vector< int >& recv_counts )
64{
65 // attempt Allgather
66 MPI_Allgatherv( &( *send_buffer.begin() ),
67 send_buffer.size(),
68 MPI_Type< T >::type,
69 &recv_buffer[ 0 ],
70 &recv_counts[ 0 ],
71 &displacements[ 0 ],
72 MPI_Type< T >::type,
73 comm );
74}
75
76inline size_t
77MPIManager::get_process_id_of_node_id( const size_t node_id ) const
78{
80}
81
82#else // HAVE_MPI
83
84
85inline size_t
87{
88 return 0;
89}
90
91#endif /* HAVE_MPI */
92
93} // namespace nest
94
95#endif /* MPI_MANAGER_IMPL_H */
size_t get_process_id_of_node_id(const size_t node_id) const
Definition mpi_manager_impl.h:86
size_t get_process_id_of_vp(const size_t vp) const
Return the process id for a given virtual process.
Definition mpi_manager_impl.h:42
int num_processes_
number of MPI processes
Definition mpi_manager.h:307
size_t get_num_virtual_processes() const
Returns the number of virtual processes.
Definition vp_manager_impl.h:55
VPManager vp_manager
Definition kernel_manager.h:234
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311