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
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
// Test to exercise fix to Teuchos::Comm's createSubcommunicator, which
11
// had leaked memory.
12
// The fix added MPI_Comm_free to the opaqueWrappers.
13
// 8/2018 This test hangs of platform waterman.
14
15
#include <stdio.h>
16
#include <mpi.h>
17
#include "
Teuchos_CommHelpers.hpp
"
18
#include "
Teuchos_DefaultComm.hpp
"
19
#include "
Teuchos_RCP.hpp
"
20
#include "
Teuchos_ArrayView.hpp
"
21
22
23
int
main
(
int
narg,
char
**arg)
24
{
25
Teuchos::GlobalMPISession
mpiSession(&narg,&arg);
26
27
Teuchos::RCP<const Teuchos::Comm<int>
>
28
comm =
Teuchos::DefaultComm<int>::getComm
();
29
int
me = comm->getRank();
30
int
np = comm->getSize();
31
32
int
niter = 4;
33
int
*ids =
new
int
[np/2+1];
34
for
(
int
i = 0; i < np/2+1; i++) ids[i] = i;
35
Teuchos::ArrayView<const int>
list(ids, np/2+1);
36
37
for
(
int
i = 0; i < niter; i++) {
38
Teuchos::RCP<const Teuchos::Comm<int>
> a
39
= comm->createSubcommunicator(list);
40
printf(
"iteration %d -- weak: %d strong: %d total: %d\n"
,
41
i, a.
weak_count
(), a.
strong_count
(), a.
total_count
());
42
}
43
delete
[] ids;
44
if
(me == 0)
45
printf(
"\nPASS\n"
);
46
47
return
0;
48
}
Teuchos_ArrayView.hpp
Teuchos::DefaultComm::getComm
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Definition:
Teuchos_DefaultComm.hpp:180
Teuchos::GlobalMPISession
Initialize, finalize, and query the global MPI session.
Definition:
Teuchos_GlobalMPISession.hpp:81
Teuchos_DefaultComm.hpp
main
int main(int argc, char *argv[])
Definition:
core/example/CommandLineProcessor/cxx_main.cpp:21
Teuchos::ArrayView
Nonowning array view.
Definition:
Teuchos_ArrayViewDecl.hpp:90
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition:
Teuchos_RCPDecl.hpp:397
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:439
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:447
Teuchos_CommHelpers.hpp
Teuchos::RCP::total_count
int total_count() const
Total count (strong_count() + weak_count()).
Definition:
Teuchos_RCP.hpp:455
Generated on Fri Dec 20 2024 09:21:21 for Teuchos Package Browser (Single Doxygen Collection) by
1.8.5