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
efa97a25
Commit
efa97a25
authored
2 years ago
by
Rafael Ravedutti
Browse files
Options
Downloads
Patches
Plain Diff
Small fixes into exchange
Signed-off-by:
Rafael Ravedutti
<
rafaelravedutti@gmail.com
>
parent
b460fe6b
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
+27
-7
27 additions, 7 deletions
src/pairs/sim/comm.py
src/pairs/sim/simulation.py
+1
-1
1 addition, 1 deletion
src/pairs/sim/simulation.py
with
28 additions
and
8 deletions
src/pairs/sim/comm.py
+
27
−
7
View file @
efa97a25
...
@@ -16,8 +16,8 @@ class Comm:
...
@@ -16,8 +16,8 @@ class Comm:
self
.
sim
=
sim
self
.
sim
=
sim
self
.
dom_part
=
dom_part
self
.
dom_part
=
dom_part
self
.
nsend_all
=
sim
.
add_var
(
'
nsend_all
'
,
Types
.
Int32
)
self
.
nsend_all
=
sim
.
add_var
(
'
nsend_all
'
,
Types
.
Int32
)
self
.
send_capacity
=
sim
.
add_var
(
'
send_capacity
'
,
Types
.
Int32
,
10000
)
self
.
send_capacity
=
sim
.
add_var
(
'
send_capacity
'
,
Types
.
Int32
,
10000
0
)
self
.
recv_capacity
=
sim
.
add_var
(
'
recv_capacity
'
,
Types
.
Int32
,
10000
)
self
.
recv_capacity
=
sim
.
add_var
(
'
recv_capacity
'
,
Types
.
Int32
,
10000
0
)
self
.
elem_capacity
=
sim
.
add_var
(
'
elem_capacity
'
,
Types
.
Int32
,
10
)
self
.
elem_capacity
=
sim
.
add_var
(
'
elem_capacity
'
,
Types
.
Int32
,
10
)
self
.
neigh_capacity
=
sim
.
add_var
(
'
neigh_capacity
'
,
Types
.
Int32
,
6
)
self
.
neigh_capacity
=
sim
.
add_var
(
'
neigh_capacity
'
,
Types
.
Int32
,
6
)
self
.
nsend
=
sim
.
add_array
(
'
nsend
'
,
[
self
.
neigh_capacity
],
Types
.
Int32
)
self
.
nsend
=
sim
.
add_array
(
'
nsend
'
,
[
self
.
neigh_capacity
],
Types
.
Int32
)
...
@@ -60,14 +60,23 @@ class Comm:
...
@@ -60,14 +60,23 @@ class Comm:
prop_list
=
[
self
.
sim
.
property
(
p
)
for
p
in
[
'
mass
'
,
'
position
'
,
'
velocity
'
]]
prop_list
=
[
self
.
sim
.
property
(
p
)
for
p
in
[
'
mass
'
,
'
position
'
,
'
velocity
'
]]
for
step
in
range
(
self
.
dom_part
.
number_of_steps
()):
for
step
in
range
(
self
.
dom_part
.
number_of_steps
()):
self
.
nsend_all
.
set
(
0
)
self
.
nsend_all
.
set
(
0
)
self
.
sim
.
nghost
.
set
(
0
)
for
s
in
range
(
step
):
for
j
in
self
.
dom_part
.
step_indexes
(
s
):
self
.
nsend
[
j
].
set
(
0
)
self
.
nrecv
[
j
].
set
(
0
)
self
.
send_offsets
[
j
].
set
(
0
)
self
.
recv_offsets
[
j
].
set
(
0
)
DetermineGhostParticles
(
self
,
step
,
0.0
)
DetermineGhostParticles
(
self
,
step
,
0.0
)
CommunicateSizes
(
self
,
step
)
SetCommunicationOffsets
(
self
,
step
)
PackGhostParticles
(
self
,
step
,
prop_list
)
PackGhostParticles
(
self
,
step
,
prop_list
)
RemoveExchangedParticles_part1
(
self
)
RemoveExchangedParticles_part1
(
self
)
RemoveExchangedParticles_part2
(
self
,
prop_list
)
RemoveExchangedParticles_part2
(
self
,
prop_list
)
CommunicateSizes
(
self
,
step
)
CommunicateData
(
self
,
step
,
prop_list
)
CommunicateData
(
self
,
step
,
prop_list
)
ChangeSizeAfterExchange
(
self
,
step
)
UnpackGhostParticles
(
self
,
step
,
prop_list
)
UnpackGhostParticles
(
self
,
step
,
prop_list
)
ChangeSizeAfterExchange
(
self
,
step
)
class
CommunicateSizes
(
Lowerable
):
class
CommunicateSizes
(
Lowerable
):
...
@@ -113,7 +122,9 @@ class DetermineGhostParticles(Lowerable):
...
@@ -113,7 +122,9 @@ class DetermineGhostParticles(Lowerable):
nrecv
=
self
.
comm
.
nrecv
nrecv
=
self
.
comm
.
nrecv
send_map
=
self
.
comm
.
send_map
send_map
=
self
.
comm
.
send_map
send_mult
=
self
.
comm
.
send_mult
send_mult
=
self
.
comm
.
send_mult
ghost_or_exchg
=
"
exchange
"
if
self
.
spacing
==
0.0
else
"
ghost
"
# TODO: module_params(self.spacing)
exchg_flag
=
self
.
comm
.
exchg_flag
is_exchange
=
(
self
.
spacing
==
0.0
)
# TODO: module_params(self.spacing)
ghost_or_exchg
=
"
exchange
"
if
is_exchange
else
"
ghost
"
self
.
sim
.
module_name
(
f
"
determine_
{
ghost_or_exchg
}
_particles
{
self
.
step
}
"
)
self
.
sim
.
module_name
(
f
"
determine_
{
ghost_or_exchg
}
_particles
{
self
.
step
}
"
)
self
.
sim
.
check_resize
(
self
.
comm
.
send_capacity
,
nsend
)
self
.
sim
.
check_resize
(
self
.
comm
.
send_capacity
,
nsend
)
...
@@ -121,9 +132,17 @@ class DetermineGhostParticles(Lowerable):
...
@@ -121,9 +132,17 @@ class DetermineGhostParticles(Lowerable):
nsend
[
j
].
set
(
0
)
nsend
[
j
].
set
(
0
)
nrecv
[
j
].
set
(
0
)
nrecv
[
j
].
set
(
0
)
if
is_exchange
:
for
i
in
ParticleFor
(
self
.
sim
):
exchg_flag
[
i
].
set
(
0
)
for
i
,
j
,
_
,
pbc
in
self
.
comm
.
dom_part
.
ghost_particles
(
self
.
step
,
self
.
sim
.
position
(),
self
.
spacing
):
for
i
,
j
,
_
,
pbc
in
self
.
comm
.
dom_part
.
ghost_particles
(
self
.
step
,
self
.
sim
.
position
(),
self
.
spacing
):
next_idx
=
AtomicAdd
(
self
.
sim
,
nsend_all
,
1
)
next_idx
=
AtomicAdd
(
self
.
sim
,
nsend_all
,
1
)
send_map
[
next_idx
].
set
(
i
)
send_map
[
next_idx
].
set
(
i
)
if
is_exchange
:
exchg_flag
[
i
].
set
(
1
)
for
d
in
range
(
self
.
sim
.
ndims
()):
for
d
in
range
(
self
.
sim
.
ndims
()):
send_mult
[
next_idx
][
d
].
set
(
pbc
[
d
])
send_mult
[
next_idx
][
d
].
set
(
pbc
[
d
])
...
@@ -244,9 +263,10 @@ class RemoveExchangedParticles_part1(Lowerable):
...
@@ -244,9 +263,10 @@ class RemoveExchangedParticles_part1(Lowerable):
@pairs_host_block
@pairs_host_block
def
lower
(
self
):
def
lower
(
self
):
self
.
sim
.
module_name
(
"
remove_exchanged_particles_pt1
"
)
self
.
sim
.
module_name
(
"
remove_exchanged_particles_pt1
"
)
send_pos
=
self
.
sim
.
add_temp_var
(
self
.
sim
.
n
particles
)
send_pos
=
self
.
sim
.
add_temp_var
(
self
.
sim
.
n
local
)
for
i
in
For
(
self
.
sim
,
0
,
self
.
comm
.
nsend_all
):
for
i
in
For
(
self
.
sim
,
0
,
self
.
comm
.
nsend_all
):
for
need_copy
in
Branch
(
self
.
sim
,
self
.
comm
.
send_map
[
i
]
<
self
.
sim
.
nlocal
-
self
.
comm
.
nsend_all
):
particle_id
=
self
.
comm
.
send_map
[
i
]
for
need_copy
in
Branch
(
self
.
sim
,
particle_id
<
self
.
sim
.
nlocal
-
self
.
comm
.
nsend_all
):
if
need_copy
:
if
need_copy
:
for
_
in
While
(
self
.
sim
,
BinOp
.
cmp
(
self
.
comm
.
exchg_flag
[
send_pos
],
1
)):
for
_
in
While
(
self
.
sim
,
BinOp
.
cmp
(
self
.
comm
.
exchg_flag
[
send_pos
],
1
)):
send_pos
.
set
(
send_pos
-
1
)
send_pos
.
set
(
send_pos
-
1
)
...
...
This diff is collapsed.
Click to expand it.
src/pairs/sim/simulation.py
+
1
−
1
View file @
efa97a25
...
@@ -28,7 +28,7 @@ from pairs.transformations import Transformations
...
@@ -28,7 +28,7 @@ from pairs.transformations import Transformations
class
Simulation
:
class
Simulation
:
def
__init__
(
self
,
code_gen
,
dims
=
3
,
timesteps
=
100
,
particle_capacity
=
10000
):
def
__init__
(
self
,
code_gen
,
dims
=
3
,
timesteps
=
100
,
particle_capacity
=
10000
00
):
self
.
code_gen
=
code_gen
self
.
code_gen
=
code_gen
self
.
code_gen
.
assign_simulation
(
self
)
self
.
code_gen
.
assign_simulation
(
self
)
self
.
position_prop
=
None
self
.
position_prop
=
None
...
...
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