Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pycomsdk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
com
pycomsdk
Commits
36839f25
Commit
36839f25
authored
5 years ago
by
Savva Golubitsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testparal.adot not works
parent
abf8c521
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
17 deletions
+30
-17
graph.cpython-37.pyc
comsdk/__pycache__/graph.cpython-37.pyc
+0
-0
graph.py
comsdk/graph.py
+22
-15
test_parser.py
test_parser.py
+1
-1
testparal.adot
tests/adot/testparal.adot
+7
-1
No files found.
comsdk/__pycache__/graph.cpython-37.pyc
View file @
36839f25
No preview for this file type
This diff is collapsed.
Click to expand it.
comsdk/graph.py
View file @
36839f25
...
...
@@ -34,13 +34,10 @@ class Func():
return
"{}.{}()"
.
format
(
self
.
module
,
self
.
name
)
class
Selector
(
Func
):
__slots__
=
(
'ntransf'
)
def
__init__
(
self
,
ntransf
,
module
=
""
,
name
=
""
,
dummy
=
False
):
if
module
==
""
and
name
==
""
:
dummy
=
True
self
.
ntransf
=
ntransf
self
.
dummy
=
dummy
super
()
.
__init__
(
module
,
name
,
func
=
(
lambda
x
:
[
True
for
i
in
range
(
ntransf
)])
if
dummy
else
None
)
...
...
@@ -51,9 +48,7 @@ class Transfer:
self
.
order
=
order
def
transfer
(
self
,
data
,
dynamic_keys_mapping
=
{}):
#print(dynamic_keys_mapping)
self
.
edge
.
morph
(
data
,
dynamic_keys_mapping
)
#return self.output_state, None
return
self
.
output_state
class
IdleRunType
(
Enum
):
...
...
@@ -120,6 +115,11 @@ class Graph:
if
not
'__WORKING_DIR__'
in
data
:
data
[
'__WORKING_DIR__'
]
=
data
[
'__CURRENT_WORKING_DIR__'
]
def
generate_cpp
(
self
):
pass
class
State
:
__slots__
=
[
'name'
,
...
...
@@ -133,6 +133,7 @@ class State:
'array_keys_mapping'
,
'_branching_states_history'
,
'_proxy_state'
,
'possible_branches'
]
def
__init__
(
self
,
name
,
parallelization_policy
=
None
,
...
...
@@ -147,6 +148,7 @@ class State:
self
.
looped_edges_number
=
0
self
.
activated_input_edges_number
=
0
self
.
transfers
=
[]
self
.
possible_branches
=
[]
self
.
is_term_state
=
False
self
.
_branching_states_history
=
None
self
.
_proxy_state
=
None
...
...
@@ -168,6 +170,8 @@ class State:
return
# no need to go further if we already were there
if
self
.
_branching_states_history
is
None
:
self
.
_branching_states_history
=
branching_states_history
print
(
self
.
name
,
":
\t
"
,
self
.
input_edges_number
,
len
(
self
.
transfers
))
print
(
self
.
_branching_states_history
)
elif
idle_run_type
==
IdleRunType
.
CLEANUP
:
self
.
activated_input_edges_number
=
0
# print('\tCLEANUP STATE {}, active: {}, branches_story: {}'.format(self.name, self.activated_input_edges_number, self._branching_states_history))
...
...
@@ -179,8 +183,8 @@ class State:
self
.
_branching_states_history
=
branching_states_history
else
:
self
.
activated_input_edges_number
+=
1
# BUG: here we need to choose somehow whether we proceed or not
# if len(self.output_edge
s) == 0:
#
print('Terminate state found')
# if len(self.transfer
s) == 0:
#
print('Terminate state found')
if
len
(
self
.
transfers
)
==
1
:
self
.
transfers
[
0
]
.
output_state
.
idle_run
(
idle_run_type
,
branching_states_history
)
else
:
...
...
@@ -202,7 +206,7 @@ class State:
def
run
(
self
,
data
,
implicit_parallelization_info
=
None
):
print
(
'STATE {}
\n\t
just entered, implicit_parallelization_info: {}'
.
format
(
self
.
name
,
implicit_parallelization_info
))
print
(
'
\t
{}'
.
format
(
data
))
#
print('\t{}'.format(data))
if
self
.
_proxy_state
is
not
None
:
return
self
.
_proxy_state
.
run
(
data
,
implicit_parallelization_info
)
self
.
_activate_input_edge
(
implicit_parallelization_info
)
...
...
@@ -227,7 +231,7 @@ class State:
raise
Exception
(
"
\t
ERROR: predicate {} returns {} running from STATE {}"
.
format
(
transf
.
edge
.
pred_name
,
transf
.
edge
.
predicate
(
data
,
dynamic_keys_mapping
),
self
.
name
))
return
self
.
parallelization_policy
.
make_transfer_func
(
selected_transfers
,
array_keys_mapping
=
self
.
array_keys_mapping
,
implicit_parallelization_info
=
implicit_parallelization_info
,),
\
implicit_parallelization_info
=
implicit_parallelization_info
,
state
=
self
),
\
implicit_parallelization_info
...
...
@@ -276,10 +280,12 @@ class State:
def
_has_loop
(
self
):
return
self
.
looped_edges_number
!=
0
def
cpp_print
(
self
,
parameter_list
):
def
generate_cpp
(
self
):
ststr
=
"{}:
\n\t
"
.
format
(
self
.
name
)
for
t
in
self
.
transfers
:
print
(
t
.
edge
)
if
len
(
self
.
transfers
)
==
1
:
print
(
"{}(data);
\n
{}(data);"
.
format
(
t
.
edge
.
pred_name
,
t
.
edge
.
morph
.
name
))
return
def
transfer_to_termination
(
data
):
return
None
...
...
@@ -290,8 +296,9 @@ class SerialParallelizationPolicy:
def
__init__
(
self
):
pass
def
make_transfer_func
(
self
,
morphisms
,
array_keys_mapping
=
None
,
implicit_parallelization_info
=
None
):
def
make_transfer_func
(
self
,
morphisms
,
array_keys_mapping
=
None
,
implicit_parallelization_info
=
None
,
state
=
None
):
def
_morph
(
data
):
# print("MORPHING FROM {}".format(state.name))
if
array_keys_mapping
is
None
:
dynamic_keys_mapping
=
build_dynamic_keys_mapping
(
implicit_parallelization_info
)
next_morphs
=
[
partial
(
morphism
.
transfer
,
dynamic_keys_mapping
=
dynamic_keys_mapping
)
for
morphism
in
morphisms
]
...
...
@@ -317,7 +324,7 @@ class SerialParallelizationPolicy:
#while len(next_morphs) != 1 or _is_implicitly_parallelized(next_impl_para_infos):
while
len
(
next_morphs
)
!=
1
or
_requires_joint_of_implicit_parallelization
(
array_keys_mapping
,
next_impl_para_infos
):
if
next_impl_para_infos
==
[]:
raise
Exception
(
"Morp
sh count on state is {}"
.
format
(
str
(
len
(
next_morphs
))))
raise
Exception
(
"Morp
hs count on state {} is {}"
.
format
(
state
.
name
,
str
(
len
(
next_morphs
))))
# print(array_keys_mapping, next_impl_para_infos)
cur_morphs
[:]
=
next_morphs
[:]
cur_impl_para_infos
[:]
=
next_impl_para_infos
[:]
...
...
This diff is collapsed.
Click to expand it.
test_parser.py
View file @
36839f25
...
...
@@ -23,7 +23,7 @@ graph = prsr.parse_file('./tests/adot/testparal.adot')
data
=
{
"a"
:
1
,
"b"
:
1
}
# graph.generate_cpp()
graph
.
run
(
data
)
print
(
data
)
...
...
This diff is collapsed.
Click to expand it.
tests/adot/testparal.adot
View file @
36839f25
...
...
@@ -5,7 +5,12 @@ digraph SIMPLEST {
INCR_A [predicate=PRED, function=FUNCA]
INCR_B [predicate=PRED, function=FUNCB]
__BEGIN__ -> ST2
ST2 -> ST3_1, ST3_2 [morphism=(INCR_A, INCR_B)]
ST3_1, ST3_2 -> __END__
ST3_1 -> ST3_1_1, ST3_1_2 [morphism=(INCR_A, INCR_B)]
ST3_2 -> ST3_2_1, ST3_2_2 [morphism=(INCR_A, INCR_B)]
//ST3_1_1 -> ST3_1_1_1, ST3_1_1_2
ST3_1_1, ST3_1_2, ST3_2_1, ST3_2_2 -> ST_TERM [morphism=(INCR_A, INCR_B, INCR_A, INCR_B)]
ST_TERM -> __END__
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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