Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
dcd61482
Commit
dcd61482
authored
7 years ago
by
Berenger Bramas
Browse files
Options
Downloads
Patches
Plain Diff
Debug from updated tests (not included yet)
parent
70f6d0a3
No related branches found
No related tags found
1 merge request
!23
WIP: Feature/use cmake
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bfps/cpp/particles/p2p_distr_mpi.hpp
+59
-48
59 additions, 48 deletions
bfps/cpp/particles/p2p_distr_mpi.hpp
with
59 additions
and
48 deletions
bfps/cpp/particles/p2p_distr_mpi.hpp
+
59
−
48
View file @
dcd61482
...
...
@@ -73,6 +73,7 @@ protected:
std
::
array
<
real_number
,
3
>
spatial_box_offset
;
const
real_number
cutoff_radius_compute
;
const
int
nb_cells_factor
;
const
real_number
cutoff_radius
;
std
::
array
<
long
int
,
3
>
nb_cell_levels
;
...
...
@@ -104,12 +105,12 @@ protected:
}
}
static
real_number
getGridCutoff
(
const
real_number
in_cutoff_radius
,
const
std
::
array
<
real_number
,
3
>&
in_spatial_box_width
){
static
int
foundGridFactor
(
const
real_number
in_cutoff_radius
,
const
std
::
array
<
real_number
,
3
>&
in_spatial_box_width
){
int
idx_factor
=
1
;
while
(
in_cutoff_radius
<=
in_spatial_box_width
[
IDX_Z
]
/
real_number
(
idx_factor
+
1
)){
idx_factor
+=
1
;
}
return
in_spatial_box_width
[
IDX_Z
]
/
real_number
(
idx_factor
)
;
return
idx_factor
;
}
public
:
...
...
@@ -128,7 +129,8 @@ public:
field_grid_dim
(
in_field_grid_dim
),
spatial_box_width
(
in_spatial_box_width
),
spatial_box_offset
(
in_spatial_box_offset
),
cutoff_radius_compute
(
in_cutoff_radius
),
cutoff_radius
(
getGridCutoff
(
in_cutoff_radius
,
in_spatial_box_width
)){
nb_cells_factor
(
foundGridFactor
(
in_cutoff_radius
,
in_spatial_box_width
)),
cutoff_radius
(
in_spatial_box_width
[
IDX_Z
]
/
real_number
(
nb_cells_factor
)){
AssertMpi
(
MPI_Comm_rank
(
current_com
,
&
my_rank
));
AssertMpi
(
MPI_Comm_size
(
current_com
,
&
nb_processes
));
...
...
@@ -158,21 +160,29 @@ public:
assert
(
int
(
field_grid_dim
[
IDX_Z
])
==
partition_interval_offset_per_proc
[
nb_processes_involved
]);
nb_cell_levels
[
IDX_X
]
=
spatial_box_width
[
IDX_X
]
/
cutoff_radius
;
nb_cell_levels
[
IDX_Y
]
=
spatial_box_width
[
IDX_Y
]
/
cutoff_radius
;
nb_cell_levels
[
IDX_Z
]
=
spatial_box_width
[
IDX_Z
]
/
cutoff_radius
;
nb_cell_levels
[
IDX_X
]
=
nb_cells_factor
;
nb_cell_levels
[
IDX_Y
]
=
nb_cells_factor
;
nb_cell_levels
[
IDX_Z
]
=
nb_cells_factor
;
}
virtual
~
p2p_distr_mpi
(){}
////////////////////////////////////////////////////////////////////////////
int
getGridFactor
()
const
{
return
nb_cells_factor
;
}
real_number
getGridCutoff
()
const
{
return
cutoff_radius
;
}
long
int
get_cell_coord_x_from_index
(
const
long
int
index
)
const
{
return
index
%
nb_cell_levels
[
IDX_X
];
}
long
int
get_cell_coord_y_from_index
(
const
long
int
index
)
const
{
return
(
index
-
get_cell_coord_z_from_index
(
index
)
*
(
nb_cell_levels
[
IDX_X
]
*
nb_cell_levels
[
IDX_Y
]))
return
(
index
%
(
nb_cell_levels
[
IDX_X
]
*
nb_cell_levels
[
IDX_Y
]))
/
nb_cell_levels
[
IDX_X
];
}
...
...
@@ -259,17 +269,18 @@ public:
particles_positions
[(
idxPart
)
*
size_particle_positions
+
IDX_Y
],
particles_positions
[(
idxPart
)
*
size_particle_positions
+
IDX_Z
]);
assert
(
my_down_z_cell_level
<=
get_cell_coord_z_from_index
(
particles_coord
[
idxPart
]));
if
(
!
(
get_cell_coord_z_from_index
(
particles_coord
[
idxPart
])
<=
my_top_z_cell_level
)){
// TODO
printf
(
"Coord index %ld - %ld (tree index %ld)
\n
"
,
idxPart
,
inout_index_particles
[
idxPart
],
particles_coord
[
idxPart
]);
printf
(
">> Box index %ld - %ld - %ld
\n
"
,
get_cell_coord_x_from_index
(
particles_coord
[
idxPart
]),
get_cell_coord_y_from_index
(
particles_coord
[
idxPart
]),
get_cell_coord_z_from_index
(
particles_coord
[
idxPart
]));
printf
(
">> idxPartition %d
\n
"
,
idxPartition
);
printf
(
">> my_top_z_cell_level %ld
\n
"
,
my_top_z_cell_level
);
printf
(
">> position %e %e %e
\n
"
,
particles_positions
[(
idxPart
)
*
size_particle_positions
+
IDX_X
],
particles_positions
[(
idxPart
)
*
size_particle_positions
+
IDX_Y
],
particles_positions
[(
idxPart
)
*
size_particle_positions
+
IDX_Z
]);
}
assert
(
get_cell_coord_z_from_index
(
particles_coord
[
idxPart
])
<=
my_top_z_cell_level
);
// if(inout_index_particles[idxPart] == 547){// TODO
// printf("Coord index %ld - %ld (tree index %ld)\n", idxPart, inout_index_particles[idxPart],particles_coord[idxPart]);
// printf(">> Box index %ld - %ld - %ld\n", get_cell_coord_x_from_index(particles_coord[idxPart]),
// get_cell_coord_y_from_index(particles_coord[idxPart]),
// get_cell_coord_z_from_index(particles_coord[idxPart]));
// printf(">> idxPartition %d\n", idxPartition);
// printf(">> position %e %e %e\n", particles_positions[(idxPart)*size_particle_positions + IDX_X],
// particles_positions[(idxPart)*size_particle_positions + IDX_Y],
// particles_positions[(idxPart)*size_particle_positions + IDX_Z]);
// }
}
}
...
...
@@ -396,9 +407,9 @@ public:
// Find process with at least one neighbor
{
//
std::cout << my_rank << ">> my_top_z_cell_level " << my_top_z_cell_level << std::endl;
//
std::cout << my_rank << ">> my_down_z_cell_level " << my_down_z_cell_level << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
">> my_top_z_cell_level "
<<
my_top_z_cell_level
<<
std
::
endl
;
std
::
cout
<<
my_rank
<<
">> my_down_z_cell_level "
<<
my_down_z_cell_level
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
int
dest_proc
=
(
my_rank
+
1
)
%
nb_processes_involved
;
while
(
dest_proc
!=
my_rank
...
...
@@ -411,10 +422,10 @@ public:
nb_levels_to_send
+=
1
;
}
//
std::cout << my_rank << " dest_proc " << dest_proc << std::endl;
//
std::cout << my_rank << ">> first_cell_level_proc(dest_proc) " << first_cell_level_proc(dest_proc) << std::endl;
//
std::cout << my_rank << ">> last_cell_level_proc(dest_proc) " << last_cell_level_proc(dest_proc) << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
" dest_proc "
<<
dest_proc
<<
std
::
endl
;
std
::
cout
<<
my_rank
<<
">> first_cell_level_proc(dest_proc) "
<<
first_cell_level_proc
(
dest_proc
)
<<
std
::
endl
;
std
::
cout
<<
my_rank
<<
">> last_cell_level_proc(dest_proc) "
<<
last_cell_level_proc
(
dest_proc
)
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
NeighborDescriptor
descriptor
;
descriptor
.
destProc
=
dest_proc
;
...
...
@@ -422,21 +433,21 @@ public:
descriptor
.
nbParticlesToExchange
=
particles_offset_layers
[
my_nb_cell_levels
]
-
particles_offset_layers
[
my_nb_cell_levels
-
nb_levels_to_send
];
descriptor
.
isRecv
=
false
;
//
std::cout << my_rank << " SEND" << std::endl;
//
std::cout << ">> descriptor.destProc " << descriptor.destProc << std::endl;
//
std::cout << ">> descriptor.nbLevelsToExchange " << descriptor.nbLevelsToExchange << std::endl;
//
std::cout << ">> descriptor.nbParticlesToExchange " << descriptor.nbParticlesToExchange << std::endl;
//
std::cout << ">> descriptor.isRecv " << descriptor.isRecv << std::endl;
//
std::cout << ">> neigDescriptors.size() " << neigDescriptors.size() << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
" SEND"
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.destProc "
<<
descriptor
.
destProc
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.nbLevelsToExchange "
<<
descriptor
.
nbLevelsToExchange
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.nbParticlesToExchange "
<<
descriptor
.
nbParticlesToExchange
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.isRecv "
<<
descriptor
.
isRecv
<<
std
::
endl
;
std
::
cout
<<
">> neigDescriptors.size() "
<<
neigDescriptors
.
size
()
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
neigDescriptors
.
emplace_back
(
std
::
move
(
descriptor
));
dest_proc
=
(
dest_proc
+
1
)
%
nb_processes_involved
;
}
//
std::cout << my_rank << " NO dest_proc " << dest_proc << std::endl;
//
std::cout << my_rank << " NO first_cell_level_proc(dest_proc) " << first_cell_level_proc(dest_proc) << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
" NO dest_proc "
<<
dest_proc
<<
std
::
endl
;
std
::
cout
<<
my_rank
<<
" NO first_cell_level_proc(dest_proc) "
<<
first_cell_level_proc
(
dest_proc
)
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
int
src_proc
=
(
my_rank
-
1
+
nb_processes_involved
)
%
nb_processes_involved
;
while
(
src_proc
!=
my_rank
...
...
@@ -449,9 +460,9 @@ public:
nb_levels_to_recv
+=
1
;
}
//
std::cout << my_rank << " src_proc " << src_proc << std::endl;
//
std::cout << my_rank << " first_cell_level_proc(src_proc) " << first_cell_level_proc(src_proc) << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
" src_proc "
<<
src_proc
<<
std
::
endl
;
std
::
cout
<<
my_rank
<<
" first_cell_level_proc(src_proc) "
<<
first_cell_level_proc
(
src_proc
)
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
NeighborDescriptor
descriptor
;
descriptor
.
destProc
=
src_proc
;
...
...
@@ -461,20 +472,20 @@ public:
neigDescriptors
.
emplace_back
(
std
::
move
(
descriptor
));
//
std::cout << my_rank << "] RECV" << std::endl;
//
std::cout << ">> descriptor.destProc " << descriptor.destProc << std::endl;
//
std::cout << ">> descriptor.nbLevelsToExchange " << descriptor.nbLevelsToExchange << std::endl;
//
std::cout << ">> descriptor.nbParticlesToExchange " << descriptor.nbParticlesToExchange << std::endl;
//
std::cout << ">> descriptor.nbParticlesToExchange " << descriptor.nbParticlesToExchange << std::endl;
//
std::cout << ">> descriptor.isRecv " << descriptor.isRecv << std::endl;
//
std::cout << ">> neigDescriptors.size() " << neigDescriptors.size() << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
"] RECV"
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.destProc "
<<
descriptor
.
destProc
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.nbLevelsToExchange "
<<
descriptor
.
nbLevelsToExchange
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.nbParticlesToExchange "
<<
descriptor
.
nbParticlesToExchange
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.nbParticlesToExchange "
<<
descriptor
.
nbParticlesToExchange
<<
std
::
endl
;
std
::
cout
<<
">> descriptor.isRecv "
<<
descriptor
.
isRecv
<<
std
::
endl
;
std
::
cout
<<
">> neigDescriptors.size() "
<<
neigDescriptors
.
size
()
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
src_proc
=
(
src_proc
-
1
+
nb_processes_involved
)
%
nb_processes_involved
;
}
//
std::cout << my_rank << " NO src_proc " << src_proc << std::endl;
//
std::cout << my_rank << " NO first_cell_level_proc(src_proc) " << first_cell_level_proc(src_proc) << std::endl;
//
std::cout.flush();// TODO
std
::
cout
<<
my_rank
<<
" NO src_proc "
<<
src_proc
<<
std
::
endl
;
std
::
cout
<<
my_rank
<<
" NO first_cell_level_proc(src_proc) "
<<
first_cell_level_proc
(
src_proc
)
<<
std
::
endl
;
std
::
cout
.
flush
();
// TODO
}
//////////////////////////////////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment