Arcane  4.1.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestMainMpi.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include <gtest/gtest.h>
8
9#include "arccore/message_passing_mpi/MessagePassingMpiGlobal.h"
10
11#include <iostream>
12
13/*---------------------------------------------------------------------------*/
14/*---------------------------------------------------------------------------*/
15
16namespace AlinaTest
17{
18MPI_Comm global_mpi_comm_world = MPI_COMM_NULL;
19}
20
21using namespace AlinaTest;
22
23namespace
24{
25char** global_argv = nullptr;
26int global_argc = 0;
27
28class MPIEnvironment
29: public ::testing::Environment
30{
31 public:
32
33 void SetUp() override
34 {
35 int thread_required = MPI_THREAD_SERIALIZED;
36 int thread_provided = 0;
37 int mpi_error = ::MPI_Init_thread(&global_argc, &global_argv, thread_required, &thread_provided);
38 ASSERT_EQ(mpi_error, MPI_SUCCESS);
39
40 global_mpi_comm_world = MPI_COMM_WORLD;
41 int comm_rank = 0;
42 ::MPI_Comm_rank(global_mpi_comm_world, &comm_rank);
43 if (comm_rank == 0)
44 std::cout << "SETUP MPI result thread_required=" << thread_required << " provided=" << thread_provided << "\n";
45 }
46 void TearDown() override
47 {
48 int mpi_error = MPI_Finalize();
49 ASSERT_EQ(mpi_error,MPI_SUCCESS);
50 }
51};
52
53}
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58int main(int argc, char* argv[])
59{
60 global_argc = argc;
61 global_argv = argv;
62 ::testing::InitGoogleTest(&argc, argv);
63 ::testing::AddGlobalTestEnvironment(new MPIEnvironment());
64 return RUN_ALL_TESTS();
65}
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/