Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
aacab1f2
Commit
aacab1f2
authored
Feb 19, 2021
by
COULAUD Olivier
Browse files
add comments and check if n_proc = 1
parent
99b1e6ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
experimental/include/scalfmm/tree/group_let.hpp
View file @
aacab1f2
...
...
@@ -106,7 +106,7 @@ namespace scalfmm::tree
#endif
}
return
std
::
make_tuple
(
buff_p
,
buff_n
);
}
}
// namespace distrib
///
/// \brief balanced_leaves
///
...
...
@@ -131,6 +131,13 @@ namespace scalfmm::tree
// we remove such case
auto
minIndex
{
mortonArray
[
0
]};
auto
maxIndex
{
mortonArray
[
mortonArray
.
size
()
-
1
]};
const
auto
nb_proc
=
manager
.
get_num_processes
();
std
::
vector
<
std
::
array
<
morton_type
,
2
>>
cell_distrib
(
nb_proc
,
{
0
,
0
});
if
(
nb_proc
==
1
)
{
cell_distrib
[
0
]
=
{
minIndex
,
maxIndex
};
}
#ifdef SCALFMM_USE_MPI
auto
minIndexNextProc
=
send_get_min_morton_idx
(
manager
,
minIndex
);
if
(
maxIndex
==
minIndexNextProc
)
...
...
@@ -141,7 +148,7 @@ namespace scalfmm::tree
//////////////////////////////////////////////////////////////////
/// Construct a uniform distribution of the morton index
///
#ifdef SCALFMM_USE_MPI
MortonArray_type
morton_distrib
;
try
{
...
...
@@ -163,15 +170,13 @@ namespace scalfmm::tree
// print("rank(" + std::to_string(rank) + ") Distrib cells Index: ", morton_distrib);
std
::
vector
<
std
::
array
<
morton_type
,
2
>>
cell_distrib
(
manager
.
get_num_processes
(),
{
0
,
0
});
cell_distrib
.
resize
(
manager
.
get_num_processes
(),
{
0
,
0
});
std
::
array
<
morton_type
,
2
>
local
{
morton_distrib
[
0
],
morton_distrib
[
morton_distrib
.
size
()
-
1
]};
// cell_distrib[0] = local;
/// share the distribution on all processors
manager
.
get_communicator
().
allgather
(
local
.
data
(),
sizeof
(
local
),
MPI_CHAR
,
cell_distrib
.
data
(),
sizeof
(
local
),
MPI_CHAR
/*, 0*/
);
// print("rank(" + std::to_string(rank) + ") cell_distrib: ", cell_distrib);
#else
std
::
vector
<
std
::
array
<
morton_type
,
2
>>
cell_distrib
(
1
,
{
minIndex
,
maxIndex
});
#endif
return
cell_distrib
;
...
...
@@ -201,7 +206,7 @@ namespace scalfmm::tree
auto
rank
=
manager
.
get_process_id
();
auto
nb_proc
=
manager
.
get_num_processes
();
std
::
vector
<
std
::
array
<
Morton_type
,
2
>>
morton_distrib
(
nb_proc
);
std
::
vector
<
std
::
array
<
Morton_type
,
2
>>
morton_distrib
(
nb_proc
,
{
0
,
0
}
);
auto
UmortonArray
(
morton_array
);
auto
last
=
std
::
unique
(
UmortonArray
.
begin
(),
UmortonArray
.
end
());
...
...
@@ -226,7 +231,7 @@ namespace scalfmm::tree
weight
[
pos
][
1
]
+=
1
;
weight
[
pos
][
0
]
=
UmortonArray
[
pos
];
}
out
::
print
(
"rank("
+
std
::
to_string
(
rank
)
+
") weight: "
,
weight
);
///
out::print("rank(" + std::to_string(rank) + ") weight: ", weight);
}
// // get max and min of the morton index owned by curent
...
...
@@ -236,6 +241,12 @@ namespace scalfmm::tree
// // we remove such case
auto
minIndex
{
weight
[
0
]};
auto
maxIndex
{
weight
[
weight
.
size
()
-
1
]};
if
(
nb_proc
==
1
)
{
morton_distrib
[
0
]
=
{
minIndex
[
0
],
maxIndex
[
0
]};
return
morton_distrib
;
}
#ifdef SCALFMM_USE_MPI
inria
::
mpi_config
conf
(
manager
.
get_communicator
());
...
...
@@ -371,7 +382,8 @@ namespace scalfmm::tree
{
leaf_idx
--
;
nb_part_to_right
+=
weight
[
leaf_idx
][
1
];
// std::cout << " - tosendR new pos " << leaf_idx << " " << nb_part_to_right << std::endl;
// std::cout << " - tosendR new pos " << leaf_idx << " " << nb_part_to_right <<
// std::endl;
}
nb_leaf_to_right
=
leaf_idx
+
1
;
morton_to_right
=
weight
[
leaf_idx
][
0
];
...
...
@@ -461,8 +473,7 @@ namespace scalfmm::tree
nb_elt
=
sizeof
(
local1
);
conf
.
comm
.
allgather
(
local1
.
data
(),
nb_elt
,
MPI_CHAR
,
morton_distrib
[
0
].
data
(),
nb_elt
,
MPI_CHAR
/*, 0*/
);
out
::
print
(
"rank("
+
std
::
to_string
(
rank
)
+
") morton distrib final: "
,
morton_distrib
);
#else
morton_distrib
=
{
minIndex
,
maxIndex
};
#endif
return
morton_distrib
;
}
...
...
@@ -609,7 +620,8 @@ namespace scalfmm::tree
std
::
tie
(
buffer_size_left
,
buffer_size_right
)
=
exchange_data_left_right
(
conf
,
nb_left
,
nb_right
);
// std::cout << "rank(" + std::to_string(my_rank) + ") nb_left: " << nb_left << std::endl;
// std::cout << "rank(" + std::to_string(my_rank) + ") nb_right: " << nb_right << std::endl;
// std::cout << "rank(" + std::to_string(my_rank) + ") buffer_size_left: " << buffer_size_left
// std::cout << "rank(" + std::to_string(my_rank) + ") buffer_size_left: " <<
// buffer_size_left
// << std::endl; std::cout << "rank(" + std::to_string(my_rank) + ") buffer_size_right: " <<
// buffer_size_right << std::endl;
///
...
...
@@ -625,8 +637,8 @@ namespace scalfmm::tree
if
(
nb_left
>
0
)
{
// std::cout << my_rank << " send first part to " << to_left << " nb val= " <<
nb_left <<
// " first p "
// std::cout << my_rank << " send first part to " << to_left << " nb val= " <<
//
nb_left <<
" first p "
// << particles[0] << std::endl;
conf
.
comm
.
isend
(
particles
.
data
(),
nb_left
*
sizeof
(
particle_type
),
MPI_CHAR
,
to_left
,
100
);
...
...
@@ -634,7 +646,8 @@ namespace scalfmm::tree
if
(
nb_right
>
0
)
{
int
start
=
particles
.
size
()
-
nb_right
;
// std::cout << my_rank << " send last part to " << to_right << " nb val= " << nb_right
// std::cout << my_rank << " send last part to " << to_right << " nb val= " <<
// nb_right
// << " first p "
// << particles[start] << std::endl;
conf
.
comm
.
isend
(
&
(
particles
[
start
]),
nb_right
*
sizeof
(
particle_type
),
MPI_CHAR
,
to_right
,
100
);
...
...
@@ -647,7 +660,8 @@ namespace scalfmm::tree
if
(
nb_commL
>
0
)
{
buffer_left
=
new
particle_type
[
buffer_size_left
];
// std::cout << my_rank << " post a receiv on left " << to_left << " b " << buffer_left
// std::cout << my_rank << " post a receiv on left " << to_left << " b " <<
// buffer_left
// << " size "
// << buffer_size_left << std::endl;
...
...
@@ -669,7 +683,8 @@ namespace scalfmm::tree
// Prepare the copy during the communications
//
int
new_part_size
=
particles
.
size
()
-
nb_left
-
nb_right
+
buffer_size_left
+
buffer_size_right
;
// std::cout << my_rank << " old size " << particles.size() << " new size " << new_part_size << std::endl;
// std::cout << my_rank << " old size " << particles.size() << " new size " << new_part_size <<
// std::endl;
ParticlesArray_type
newArray
(
new_part_size
);
/// Here we copy in the right place the particles that do not move
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment