Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
MachineInfo.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
8#include <mpi.h>
9
10#include <alien/utils/Precomp.h>
11
12#ifdef ALIEN_USE_CUDA
13#include <cuda_runtime.h>
14#endif
15#ifdef ALIEN_USE_HIP
16#include <hip_runtime.h>
17#endif
18
19#include <arccore/message_passing/IMessagePassingMng.h>
20#include <alien/utils/system/MachineInfo.h>
21
22namespace Alien {
23
24MachineInfo::MachineInfo(Arccore::MessagePassing::IMessagePassingMng* parellel_mng)
25: m_parallel_mng(parellel_mng)
26{
27 m_my_rank = 0 ;
28 m_nb_procs = 1 ;
29 if(m_parallel_mng)
30 {
31 m_my_rank = m_parallel_mng->commRank() ;
32 m_nb_procs = m_parallel_mng->commSize() ;
33 }
34 // Assigner un GPU par processus MPI
35#ifdef ALIEN_USE_CUDA
36 cudaGetDeviceCount(&m_nb_accelerators_per_node);
37#endif
38#ifdef ALIEN_USE_HIP
39 hipGetDeviceCount(&m_nb_accelerators_per_node);
40#endif
41
42 if(m_nb_accelerators_per_node>0)
43 {
44 m_device_id = m_my_rank % m_nb_accelerators_per_node;
45 }
46 std::cout<<" MACHINE INFO : "<<std::endl ;
47 std::cout<<" Rank : "<<m_my_rank<<std::endl;
48 std::cout<<" Device Id : "<<m_device_id<<std::endl;
49 std::cout<<" Nb Devices per Node : "<<m_nb_accelerators_per_node<<std::endl ;
50 //cudaSetDevice(device);
51}
52
53}
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17