Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
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
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
particle_methods
hysop
Commits
e66e6289
Commit
e66e6289
authored
11 years ago
by
Jean-Matthieu Etancelin
Browse files
Options
Downloads
Patches
Plain Diff
Add missing file
parent
7216c074
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
HySoP/hysop/constants.py
+3
-3
3 additions, 3 deletions
HySoP/hysop/constants.py
HySoP/hysop/tools/problem2dot.py
+163
-0
163 additions, 0 deletions
HySoP/hysop/tools/problem2dot.py
with
166 additions
and
3 deletions
HySoP/hysop/constants.py
+
3
−
3
View file @
e66e6289
...
@@ -18,13 +18,13 @@ else:
...
@@ -18,13 +18,13 @@ else:
PI
=
math
.
pi
PI
=
math
.
pi
# Set default type for real and integer numbers
# Set default type for real and integer numbers
PARMES_REAL
=
np
.
float
64
PARMES_REAL
=
np
.
float
32
# type for array indices
# type for array indices
PARMES_INDEX
=
np
.
uint32
PARMES_INDEX
=
np
.
uint32
# type for integers
# type for integers
PARMES_INTEGER
=
np
.
int
64
PARMES_INTEGER
=
np
.
int
32
# float type for MPI messages
# float type for MPI messages
PARMES_MPI_REAL
=
MPI
.
DOUBLE
PARMES_MPI_REAL
=
MPI
.
FLOAT
## default array layout (fortran or C convention)
## default array layout (fortran or C convention)
ORDER
=
'
F
'
ORDER
=
'
F
'
## Default array layout for MPI
## Default array layout for MPI
...
...
This diff is collapsed.
Click to expand it.
HySoP/hysop/tools/problem2dot.py
0 → 100644
+
163
−
0
View file @
e66e6289
"""
@file problem2dot.py
Converts a problem instance to a graph throw dot syntax.
"""
from
parmepy.operator.monitors.monitoring
import
Monitoring
from
parmepy.operator.redistribute
import
Redistribute
from
parmepy.methods_keys
import
Support
from
parmepy.constants
import
S_DIR
import
pydot
colors
=
[
"
#dc322f
"
,
"
#859900
"
,
"
#268bd2
"
,
"
#b58900
"
,
"
#d33682
"
,
"
#2aa198
"
,
"
#cb4b16
"
,
"
#6c71c4
"
,
"
#ffffff
"
]
def
_operators2node
(
op_list
,
ltopos
):
"""
Create nodes from operators list
"""
nodes
=
{}
for
op_id
,
op
in
enumerate
(
op_list
):
label
=
"
op
"
+
str
(
op_id
)
if
not
isinstance
(
op
,
Redistribute
):
label
+=
"
_
"
+
op
.
__class__
.
__name__
else
:
if
op
.
component
is
None
:
for
v
in
op
.
variables
:
label
+=
"
_R_
"
+
v
.
name
else
:
for
v
in
op
.
variables
:
label
+=
"
_R_
"
+
v
.
name
+
S_DIR
[
op
.
component
]
if
isinstance
(
op
,
Redistribute
):
shape
=
'
octagon
'
elif
isinstance
(
op
,
Monitoring
):
shape
=
'
ellipse
'
else
:
shape
=
'
box
'
if
not
isinstance
(
op
,
Redistribute
):
c_id
=
ltopos
.
index
(
op
.
discreteFields
[
op
.
variables
[
0
]].
topology
)
try
:
if
op
.
method
[
Support
].
find
(
'
gpu
'
)
>=
0
:
c_id
=
len
(
ltopos
)
c_id
+=
ltopos
.
index
(
op
.
discreteFields
[
op
.
variables
[
0
]].
topology
)
except
:
pass
else
:
c_id
=
-
1
nodes
[
op
]
=
pydot
.
Node
(
op_id
,
label
=
label
,
fillcolor
=
colors
[
c_id
],
shape
=
shape
,
fontname
=
'
times-bold
'
,
style
=
'
filled
'
)
return
nodes
def
defaultEdges
(
op
,
op_id
,
op_list
,
op_nodes
,
black_list
=
[]):
"""
Create edges to given operator from the operator list
"""
edges
=
[]
for
v
in
op
.
input
:
if
not
v
in
black_list
:
v_from
=
None
i_from
=
op_id
-
1
while
(
v_from
is
None
):
if
not
isinstance
(
op_list
[
i_from
],
Redistribute
):
if
v
in
op_list
[
i_from
].
output
:
v_from
=
op_list
[
i_from
]
i_from
-=
1
color
=
'
black
'
if
i_from
<
0
:
color
=
colors
[
0
]
if
not
isinstance
(
op
,
Redistribute
):
edges
.
append
(
pydot
.
Edge
(
op_nodes
[
v_from
],
op_nodes
[
op
],
label
=
v
.
name
,
color
=
color
))
else
:
edges
.
append
(
pydot
.
Edge
(
op_nodes
[
v_from
],
op_nodes
[
op
],
color
=
color
))
return
edges
def
toDot
(
pb
,
filename
=
'
graph.pdf
'
):
"""
Create a dot grapg from problem operator list
"""
graph
=
pydot
.
Dot
(
pb
.
__class__
.
__name__
,
graph_type
=
'
digraph
'
)
# Build a topology set (for colors)
topos
=
[]
topos_gpu
=
[]
#nt = 0
for
op
in
pb
.
operators
:
if
not
isinstance
(
op
,
Redistribute
):
for
v
in
op
.
variables
:
t
=
op
.
discreteFields
[
v
].
topology
try
:
if
op
.
method
[
Support
].
find
(
'
gpu
'
)
>=
0
:
if
not
t
in
topos_gpu
:
topos_gpu
.
append
(
op
.
discreteFields
[
v
].
topology
)
else
:
if
not
t
in
topos
:
topos
.
append
(
op
.
discreteFields
[
v
].
topology
)
except
:
if
not
t
in
topos
:
topos
.
append
(
op
.
discreteFields
[
v
].
topology
)
# Build nodes from operators
op_nodes
=
_operators2node
(
pb
.
operators
,
topos
)
for
n
in
op_nodes
.
values
():
graph
.
add_node
(
n
)
# Build edges
edges
=
[]
for
i
in
xrange
(
len
(
pb
.
operators
)
-
1
,
-
1
,
-
1
):
op
=
pb
.
operators
[
i
]
if
not
isinstance
(
op
,
Monitoring
):
req_vars
=
[]
# Create edges for redistribute requirements
for
req
in
op
.
getRedistributeRequirement
():
for
v
in
req
.
output
:
color
=
'
black
'
if
pb
.
operators
.
index
(
req
)
>
pb
.
operators
.
index
(
op
):
color
=
'
red
'
edges
.
append
(
pydot
.
Edge
(
op_nodes
[
req
],
op_nodes
[
op
],
color
=
color
))
req_vars
.
append
(
v
)
# Create edges for other variables
ed
=
defaultEdges
(
op
,
i
,
pb
.
operators
,
op_nodes
,
black_list
=
req_vars
)
edges
+=
ed
for
i
in
xrange
(
len
(
pb
.
operators
)
-
1
,
-
1
,
-
1
):
op
=
pb
.
operators
[
i
]
if
isinstance
(
op
,
Monitoring
):
ed
=
defaultEdges
(
op
,
i
,
pb
.
operators
,
op_nodes
,
black_list
=
req_vars
)
edges
+=
ed
for
e
in
edges
:
graph
.
add_edge
(
e
)
# Add key
subg
=
pydot
.
Subgraph
(
'
Key
'
,
rank
=
'
same
'
)
subg
.
add_node
(
pydot
.
Node
(
'
Computational
'
,
shape
=
'
box
'
))
subg
.
add_node
(
pydot
.
Node
(
'
Monitoring
'
,
shape
=
'
ellipse
'
))
subg
.
add_node
(
pydot
.
Node
(
'
Redistribute
'
,
shape
=
'
octagon
'
))
a
=
pydot
.
Node
(
'
a
'
,
shape
=
'
point
'
)
b
=
pydot
.
Node
(
'
b
'
,
shape
=
'
point
'
)
e
=
pydot
.
Edge
(
a
,
b
,
color
=
colors
[
0
],
label
=
'
New iteration
'
)
subg
.
add_node
(
a
)
subg
.
add_node
(
b
)
subg
.
add_edge
(
e
)
for
t_id
,
t
in
enumerate
(
topos
):
subg
.
add_node
(
pydot
.
Node
(
'
Topo
'
+
str
(
t_id
),
shape
=
'
plaintext
'
,
fontcolor
=
colors
[
t_id
]))
for
t_id
,
t
in
enumerate
(
topos_gpu
):
subg
.
add_node
(
pydot
.
Node
(
'
Topo
'
+
str
(
topos
.
index
(
t
))
+
'
_GPU
'
,
shape
=
'
plaintext
'
,
fontcolor
=
colors
[
len
(
topos
)
+
topos
.
index
(
t
)]))
graph
.
add_subgraph
(
subg
)
# Write graph in the format specified by filename extension
graph
.
write
(
filename
,
format
=
filename
.
split
(
'
.
'
)[
-
1
])
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