Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pairs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
software
pairs
Commits
0c12c7b6
Commit
0c12c7b6
authored
2 years ago
by
Rafael Ravedutti
Browse files
Options
Downloads
Patches
Plain Diff
Add steps to remove particles after exchange
Signed-off-by:
Rafael Ravedutti
<
rafaelravedutti@gmail.com
>
parent
1c28ced7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pairs/sim/comm.py
+67
-3
67 additions, 3 deletions
src/pairs/sim/comm.py
src/pairs/sim/domain_partitioning.py
+12
-11
12 additions, 11 deletions
src/pairs/sim/domain_partitioning.py
with
79 additions
and
14 deletions
src/pairs/sim/comm.py
+
67
−
3
View file @
0c12c7b6
...
...
@@ -19,6 +19,8 @@ class Comm:
self
.
nsend
=
sim
.
add_array
(
'
nsend
'
,
[
max_neigh_ranks
],
Types
.
Int32
)
self
.
send_buffer
=
sim
.
add_array
(
'
send_buffer
'
,
[
self
.
send_capacity
,
max_buffer_elems
],
Types
.
Double
)
self
.
send_map
=
sim
.
add_array
(
'
send_map
'
,
[
self
.
send_capacity
],
Types
.
Int32
)
self
.
exchg_flag
=
sim
.
add_array
(
'
exchg_flag
'
,
[
sim
.
particle_capacity
],
Types
.
Int32
)
self
.
exchg_copy_to
=
sim
.
add_array
(
'
exchg_copy_to
'
,
[
self
.
send_capacity
],
Types
.
Int32
)
self
.
send_mult
=
sim
.
add_array
(
'
send_mult
'
,
[
self
.
send_capacity
,
sim
.
ndims
()],
Types
.
Int32
)
self
.
nrecv
=
sim
.
add_array
(
'
nrecv
'
,
[
max_neigh_ranks
],
Types
.
Int32
)
self
.
recv_buffer
=
sim
.
add_array
(
'
recv_buffer
'
,
[
self
.
recv_capacity
,
max_buffer_elems
],
Types
.
Double
)
...
...
@@ -27,10 +29,12 @@ class Comm:
class
DetermineGhostParticles
(
Lowerable
):
def
__init__
(
self
,
sim
,
comm
,
dom_part
):
def
__init__
(
self
,
sim
,
comm
,
dom_part
,
step
,
spacing
):
super
().
__init__
(
sim
)
self
.
comm
=
comm
self
.
dom_part
=
dom_part
self
.
step
=
step
self
.
spacing
=
spacing
@pairs_device_block
def
lower
(
self
):
...
...
@@ -42,7 +46,7 @@ class DetermineGhostParticles(Lowerable):
nb_rank_id
=
0
nsend_all
.
set
(
0
)
for
i
,
_
,
pbc
in
self
.
dom_part
.
ghost_particles
(
self
.
sim
.
position
(),
self
.
sim
.
cell_
spacing
()
):
for
i
,
_
,
pbc
in
self
.
dom_part
.
ghost_particles
(
step
,
self
.
sim
.
position
(),
self
.
spacing
):
n
=
AtomicAdd
(
self
.
sim
,
nsend_all
,
1
)
send_map
[
n
].
set
(
i
)
for
d
in
self
.
sim
.
ndims
():
...
...
@@ -118,7 +122,67 @@ class UnpackGhostParticles(Lowerable):
p_offset
+=
1
class
ExchangeParticles
(
Lowerable
):
class
RemoveExchangedParticles_part1
(
Lowerable
):
def
__init__
(
self
,
sim
,
comm
,
prop_list
):
super
().
__init__
(
sim
)
self
.
comm
=
comm
@pairs_host_block
def
lower
(
self
):
send_pos
=
sim
.
add_temp_var
(
grid
.
nparticles
)
sim
.
module_name
(
"
remove_exchanged_particles_pt1
"
)
for
i
in
For
(
self
.
sim
,
self
.
comm
.
nsend
):
for
is_local
in
Branch
(
self
.
sim
,
self
.
comm
.
send_map
[
i
]
<
self
.
sim
.
nlocal
-
self
.
comm
.
nsend
):
if
is_local
:
for
_
in
While
(
self
.
sim
,
BinOp
.
eq
(
self
.
comm
.
exchg_flags
[
send_pos
],
1
)):
send_pos
.
assign
(
send_pos
-
1
)
self
.
comm
.
exchg_copy_to
[
i
].
set
(
send_pos
)
send_pos
.
assign
(
send_pos
-
1
)
else
:
self
.
comm
.
exchg_copy_to
[
i
].
set
(
-
1
)
class
RemoveExchangedParticles_part2
(
Lowerable
):
def
__init__
(
self
,
sim
,
comm
,
prop_list
):
super
().
__init__
(
sim
)
self
.
comm
=
comm
self
.
prop_list
=
prop_list
@pairs_device_block
def
lower
(
self
):
sim
.
module_name
(
"
remove_exchanged_particles_pt2
"
)
for
i
in
ParticleFor
(
self
.
sim
):
src
=
self
.
comm
.
exchg_copy_to
[
i
]
for
_
in
Filter
(
self
.
sim
,
src
>
0
):
dst
=
self
.
comm
.
send_map
[
i
]
for
p
in
self
.
prop_list
:
if
p
.
type
()
==
Types
.
Vector
:
for
d
in
self
.
sim
.
ndims
():
p
[
dst
][
d
].
set
(
p
[
src
][
d
])
else
:
p
[
dst
].
set
(
p
[
src
])
self
.
sim
.
nlocal
.
set
(
self
.
sim
.
nlocal
-
self
.
comm
.
nsend
)
class
Synchronize
(
Lowerable
):
def
__init__
(
self
,
sim
,
comm
):
super
().
__init__
(
sim
)
self
.
comm
=
comm
class
Borders
(
Lowerable
):
def
__init__
(
self
,
sim
,
comm
):
super
().
__init__
(
sim
)
self
.
comm
=
comm
class
Exchange
(
Lowerable
):
def
__init__
(
self
,
sim
,
comm
):
super
().
__init__
(
sim
)
self
.
comm
=
comm
This diff is collapsed.
Click to expand it.
src/pairs/sim/domain_partitioning.py
+
12
−
11
View file @
0c12c7b6
...
...
@@ -14,15 +14,16 @@ class DimensionRanges:
self
.
pbc
=
sim
.
add_static_array
(
'
pbc
'
,
[
sim
.
ndims
()
*
2
],
Types
.
Int32
)
self
.
subdom
=
sim
.
add_static_array
(
'
subdom
'
,
[
sim
.
ndims
()
*
2
],
Types
.
Int32
)
def
ghost_particles
(
self
,
position
,
offset
=
0.0
):
for
dim
in
range
(
0
,
self
.
sim
.
ndims
()):
nall
=
self
.
sim
.
nlocal
+
self
.
sim
.
comm
.
nghost
for
i
in
For
(
sim
,
0
,
nall
):
j
=
dim
*
2
for
_
in
Filter
(
self
.
sim
,
position
<
self
.
subdom
[
j
]
+
offset
):
yield
i
,
self
.
neighbor_ranks
[
j
],
[
0
if
d
!=
dim
else
self
.
pbc
[
j
]
for
d
in
self
.
sim
.
ndims
()]
def
number_of_steps
(
self
):
return
self
.
sim
.
ndims
()
for
i
in
For
(
sim
,
0
,
nall
):
j
=
dim
*
2
+
1
for
_
in
Filter
(
self
.
sim
,
position
>
self
.
subdom
[
j
]
-
offset
):
yield
i
,
self
.
neighbor_ranks
[
j
],
[
0
if
d
!=
dim
else
self
.
pbc
[
j
]
for
d
in
self
.
sim
.
ndims
()]
def
ghost_particles
(
self
,
step
,
position
,
offset
=
0.0
):
for
i
in
For
(
sim
,
0
,
self
.
sim
.
nlocal
+
self
.
sim
.
comm
.
nghost
):
j
=
step
*
2
+
0
for
_
in
Filter
(
self
.
sim
,
position
<
self
.
subdom
[
j
]
+
offset
):
yield
i
,
self
.
neighbor_ranks
[
j
],
[
0
if
d
!=
step
else
self
.
pbc
[
j
]
for
d
in
self
.
sim
.
ndims
()]
for
i
in
For
(
sim
,
0
,
self
.
sim
.
nlocal
+
self
.
sim
.
comm
.
nghost
):
j
=
step
*
2
+
1
for
_
in
Filter
(
self
.
sim
,
position
>
self
.
subdom
[
j
]
-
offset
):
yield
i
,
self
.
neighbor_ranks
[
j
],
[
0
if
d
!=
step
else
self
.
pbc
[
j
]
for
d
in
self
.
sim
.
ndims
()]
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