Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Amin Bandali
alloy-catalyst
Commits
7ed802a9
Verified
Commit
7ed802a9
authored
May 30, 2019
by
Amin Bandali
Browse files
Add --parallel option for making parallel streams optional
parent
12512076
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
org.aminb.alloy.catalyst/src/main/java/org/aminb/alloy/catalyst/MainCLI.java
...alyst/src/main/java/org/aminb/alloy/catalyst/MainCLI.java
+21
-17
org.aminb.alloy.catalyst/src/main/java/org/aminb/alloy/catalyst/Options.java
...alyst/src/main/java/org/aminb/alloy/catalyst/Options.java
+3
-0
No files found.
org.aminb.alloy.catalyst/src/main/java/org/aminb/alloy/catalyst/MainCLI.java
View file @
7ed802a9
...
...
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.Stream
;
import
edu.mit.csail.sdg.alloy4.A4Reporter
;
import
edu.mit.csail.sdg.alloy4.ConstList
;
...
...
@@ -117,9 +118,10 @@ public final class MainCLI {
.
collect
(
Collectors
.
toList
());
cr
.
file_count
=
files
.
size
();
mainPr
.
ln
(
"number of "
+
corpus
+
" models: "
+
cr
.
file_count
);
r
.
total_file_count
+=
cr
.
file_count
;
AtomicInteger
i
=
new
AtomicInteger
(
1
);
files
.
parallelStream
()
.
filter
(
p
->
p
.
getFileName
().
toString
().
endsWith
(
".als"
))
Stream
<
Path
>
fs
=
o
.
parallel
?
files
.
parallelStream
()
:
files
.
stream
();
fs
.
filter
(
p
->
p
.
getFileName
().
toString
().
endsWith
(
".als"
))
.
filter
(
p
->
!
Arrays
.
asList
(
o
.
ignoredFiles
).
contains
(
p
.
getFileName
().
toString
()))
.
forEach
(
p
->
cr
.
file_results
.
add
(
analyzeFile
(
mainPr
,
p
,
corpus
,
i
.
getAndIncrement
(),
cr
.
file_count
)));
}
catch
(
Exception
e
)
{
...
...
@@ -310,21 +312,23 @@ public final class MainCLI {
ConstList
<
Sig
>
allReachableSigs
=
module
.
getAllReachableSigs
();
A4Options
options
=
new
A4Options
();
options
.
solver
=
solver
.
solver
;
module
.
getAllCommands
()
.
parallelStream
()
.
forEach
(
c
->
{
RunReporter
rep
=
new
RunReporter
();
Run
run
=
new
Run
();
run
.
solver_id
=
solver
.
solver
.
id
();
run
.
solver_name
=
solver
.
solver
.
toString
();
run
.
command
=
c
.
toString
();
run
.
takes
=
Collections
.
synchronizedList
(
new
ArrayList
<
RunResult
>());
rep
.
run
=
run
;
IntStream
.
range
(
0
,
3
).
parallel
().
forEach
(
i
->
{
TranslateAlloyToKodkod
.
execute_command
(
rep
,
allReachableSigs
,
c
,
options
);
});
mr
.
runs
.
add
(
run
);
});
Stream
<
edu
.
mit
.
csail
.
sdg
.
ast
.
Command
>
cs
=
o
.
parallel
?
module
.
getAllCommands
().
parallelStream
()
:
module
.
getAllCommands
().
stream
();
cs
.
forEach
(
c
->
{
RunReporter
rep
=
new
RunReporter
();
Run
run
=
new
Run
();
run
.
solver_id
=
solver
.
solver
.
id
();
run
.
solver_name
=
solver
.
solver
.
toString
();
run
.
command
=
c
.
toString
();
run
.
takes
=
Collections
.
synchronizedList
(
new
ArrayList
<
RunResult
>());
rep
.
run
=
run
;
IntStream
is
=
o
.
parallel
?
IntStream
.
range
(
0
,
3
).
parallel
()
:
IntStream
.
range
(
0
,
3
);
is
.
forEach
(
i
->
{
TranslateAlloyToKodkod
.
execute_command
(
rep
,
allReachableSigs
,
c
,
options
);
});
mr
.
runs
.
add
(
run
);
});
Instant
stop
=
Instant
.
now
();
...
...
org.aminb.alloy.catalyst/src/main/java/org/aminb/alloy/catalyst/Options.java
View file @
7ed802a9
...
...
@@ -69,6 +69,9 @@ public class Options implements Runnable {
@Option
(
names
=
"--ssr"
,
description
=
"Structure Signature Removal (SSR) mode"
)
protected
boolean
ssr
;
@Option
(
names
=
"--parallel"
,
description
=
"Parallel mode (use parallel streams)"
)
protected
boolean
parallel
;
public
Options
(
MainCLI
cli
)
{
app
=
cli
;
...
...
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