Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
comm
test
Comm
subcommTestTeuchosComm.cpp
Go to the documentation of this file.
1
// Test to exercise fix to Teuchos::Comm's createSubcommunicator, which
2
// had leaked memory.
3
// The fix added MPI_Comm_free to the opaqueWrappers.
4
// 8/2018 This test hangs of platform waterman.
5
6
#include <stdio.h>
7
#include <mpi.h>
8
#include "
Teuchos_CommHelpers.hpp
"
9
#include "
Teuchos_DefaultComm.hpp
"
10
#include "
Teuchos_RCP.hpp
"
11
#include "
Teuchos_ArrayView.hpp
"
12
13
14
int
main
(
int
narg,
char
**arg)
15
{
16
Teuchos::GlobalMPISession
mpiSession(&narg,&arg);
17
18
Teuchos::RCP<const Teuchos::Comm<int>
>
19
comm =
Teuchos::DefaultComm<int>::getComm
();
20
int
me = comm->getRank();
21
int
np = comm->getSize();
22
23
int
niter = 4;
24
int
*ids =
new
int
[np/2+1];
25
for
(
int
i = 0; i < np/2+1; i++) ids[i] = i;
26
Teuchos::ArrayView<const int>
list(ids, np/2+1);
27
28
for
(
int
i = 0; i < niter; i++) {
29
Teuchos::RCP<const Teuchos::Comm<int>
> a
30
= comm->createSubcommunicator(list);
31
printf(
"iteration %d -- weak: %d strong: %d total: %d\n"
,
32
i, a.
weak_count
(), a.
strong_count
(), a.
total_count
());
33
}
34
delete
[] ids;
35
if
(me == 0)
36
printf(
"\nPASS\n"
);
37
38
return
0;
39
}
Teuchos_ArrayView.hpp
Teuchos::DefaultComm::getComm
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Definition:
Teuchos_DefaultComm.hpp:212
Teuchos::GlobalMPISession
Initialize, finalize, and query the global MPI session.
Definition:
Teuchos_GlobalMPISession.hpp:113
Teuchos_DefaultComm.hpp
main
int main(int argc, char *argv[])
Definition:
core/example/CommandLineProcessor/cxx_main.cpp:55
Teuchos::ArrayView
Nonowning array view.
Definition:
Teuchos_ArrayViewDecl.hpp:123
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition:
Teuchos_RCPDecl.hpp:429
Teuchos::RCP::strong_count
int strong_count() const
Return the number of active RCP<> objects that have a "strong" reference to the underlying reference-...
Definition:
Teuchos_RCP.hpp:462
Teuchos_RCP.hpp
Reference-counted pointer class and non-member templated function implementations.
Teuchos::RCP::weak_count
int weak_count() const
Return the number of active RCP<> objects that have a "weak" reference to the underlying reference-co...
Definition:
Teuchos_RCP.hpp:470
Teuchos_CommHelpers.hpp
Teuchos::RCP::total_count
int total_count() const
Total count (strong_count() + weak_count()).
Definition:
Teuchos_RCP.hpp:478
Generated by
1.8.5