GCC Code Coverage Report


Directory: ./
File: Core/felisceTools.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 0 22 0.0%
Branches: 0 32 0.0%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: Sebastien Gilles
13 //
14
15 // System includes
16 #include <fstream>
17 #include <set>
18 #include <vector>
19
20 // External includes
21
22 // Project includes
23 #include "felisceTools.hpp"
24 #include "felisce_error.hpp"
25
26 namespace felisce::Tools
27 {
28 void allGatherSet( std::set<int> &locCont, std::set<int> &globCont )
29 {
30 int locContainerAsVec[locCont.size()];
31 int locCount(0), globCount(0);
32
33 for (auto it = locCont.begin(); it != locCont.end(); it++ ) {
34 locContainerAsVec[locCount] = *it;
35 locCount++;
36 }
37
38 MPI_Allreduce(&locCount, &globCount,1,MPI_INT,MPI_SUM,MpiInfo::petscComm());
39
40 int globContainerAsVec[globCount];
41
42 int displacements[MpiInfo::numProc()];
43 int localCountBroadcasted[MpiInfo::numProc()];
44 int ones[MpiInfo::numProc()];
45
46 for ( int proc(0); proc < MpiInfo::numProc(); proc++) {
47 localCountBroadcasted[proc]=0;
48 displacements[proc] = proc;
49 ones[proc] = 1;
50 }
51
52 MPI_Allgatherv(&locCount,1,MPI_INT,localCountBroadcasted,ones,displacements,MPI_INT,MpiInfo::petscComm());
53
54 displacements[0]=0;
55 for ( int proc(0); proc < MpiInfo::numProc()-1; proc++) {
56 displacements[proc+1] = displacements[proc] + localCountBroadcasted[proc];
57 }
58
59 MPI_Allgatherv(locContainerAsVec,locCount,MPI_INT,globContainerAsVec,localCountBroadcasted,displacements, MPI_INT,MpiInfo::petscComm());
60
61 for ( int i(0); i< globCount; i++ ) {
62 globCont.insert( globCont.end(), globContainerAsVec[i] );
63 }
64 }
65 } // namespace felisce
66
67
68