Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sasa
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
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
verimag
synchrone
sasa
Commits
7212f2ea
Commit
7212f2ea
authored
5 years ago
by
erwan
Browse files
Options
Downloads
Patches
Plain Diff
Bug fix: handle array properly among processes (copying them when necessary)
parent
0802502f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/sasacore/env.ml
+15
-7
15 additions, 7 deletions
lib/sasacore/env.ml
lib/sasacore/env.mli
+6
-0
6 additions, 0 deletions
lib/sasacore/env.mli
lib/sasacore/sasa.ml
+17
-11
17 additions, 11 deletions
lib/sasacore/sasa.ml
test/dfs/p.ml
+1
-2
1 addition, 2 deletions
test/dfs/p.ml
with
39 additions
and
20 deletions
lib/sasacore/env.ml
+
15
−
7
View file @
7212f2ea
(* module Dico = Map.Make(struct type t = string * string let compare = compare end) *)
(* Time-stamp: <modified the 09/05/2019 (at 21:52) by Erwan Jahier> *)
module
Dico
=
Map
.
Make
(
String
)
open
Algo
(*
module Dico = Map.Make(String)
type t = value Dico.t Dico.t
*)
type
t
=
local_env
Dico
.
t
let
(
get
:
t
->
string
->
string
->
value
)
=
fun
e
pid
v
->
try
((
Dico
.
find
pid
e
)
v
)
with
_
->
failwith
(
Printf
.
sprintf
"Unknown value: %s.%s"
pid
v
)
let
rec
(
copy_value
:
value
->
value
)
=
fun
v
->
match
v
with
|
I
_
|
F
_
|
B
_
|
E
_
|
S
_
|
N
_
->
v
|
A
a
->
A
(
Array
.
copy
(
Array
.
map
copy_value
a
))
let
(
get_copy
:
t
->
string
->
string
->
value
)
=
fun
e
pid
v
->
copy_value
(
get
e
pid
v
)
let
(
set
:
t
->
string
->
string
->
value
->
t
)
=
fun
e
pid
v
value
->
Dico
.
add
pid
(
fun
x
->
if
x
=
v
then
value
else
Dico
.
find
pid
e
x
)
e
...
...
This diff is collapsed.
Click to expand it.
lib/sasacore/env.mli
+
6
−
0
View file @
7212f2ea
...
...
@@ -8,3 +8,9 @@ val set: t -> string -> string -> Algo.value -> t
(** [get env process_id var_name] *)
val
get
:
t
->
string
->
string
->
Algo
.
value
(** In order to make sure that arrays ref are not shared between processes,
this function performs an array copy of the value (if it is an array)
*)
val
get_copy
:
t
->
string
->
string
->
Algo
.
value
This diff is collapsed.
Click to expand it.
lib/sasacore/sasa.ml
+
17
−
11
View file @
7212f2ea
(* Time-stamp: <modified the
3
0/0
4
/2019 (at
16:02
) by Erwan Jahier> *)
(* Time-stamp: <modified the 0
9
/0
5
/2019 (at
21:58
) by Erwan Jahier> *)
open
Algo
open
Sasacore
let
(
update_env_with_init
:
Env
.
t
->
Process
.
t
list
->
Algo
.
neighbor
list
list
->
Env
.
t
)
=
let
(
update_env_with_init
:
Env
.
t
->
Process
.
t
list
->
Algo
.
neighbor
list
list
->
Env
.
t
)
=
fun
e
pl
neighbors
->
let
(
aux
:
Env
.
t
->
Process
.
t
->
Algo
.
neighbor
list
->
Env
.
t
)
=
fun
e
p
nl
->
...
...
@@ -32,7 +33,7 @@ let (get_neighors: Topology.t -> Env.t -> Process.t -> Algo.neighbor list) =
let
node
=
g
.
of_id
id
in
let
algo_id
=
Filename
.
chop_suffix
node
.
file
".cmxs"
in
{
lenv
=
Env
.
get
e
node
.
id
;
lenv
=
Env
.
get
_copy
e
node
.
id
;
n_vars
=
Algo
.
get_vars
algo_id
;
(* XXX For the 2 fields above, check the graph kind (anonymous,
identified, etc. *)
...
...
@@ -61,7 +62,7 @@ open SasArg
let
(
update_neighbor_env
:
Env
.
t
->
Algo
.
neighbor
->
Algo
.
neighbor
)
=
fun
e
n
->
{
n
with
lenv
=
Env
.
get
e
(
n
.
Algo
.
pid
()
)}
{
n
with
lenv
=
Env
.
get
_copy
e
(
n
.
Algo
.
pid
()
)}
type
layout
=
(
Process
.
t
*
Algo
.
neighbor
list
)
list
...
...
@@ -123,15 +124,16 @@ let (get_outputs_rif_decl: Process.t list -> (string * string) list) =
let
lll
=
List
.
map
(
fun
p
->
List
.
map
(
fun
(
n
,
vt
)
->
Algo
.
vart_to_rif_decl
vt
(
Printf
.
sprintf
"%s_%s"
p
.
pid
n
))
(
fun
(
n
,
vt
)
->
Algo
.
vart_to_rif_decl
vt
(
Printf
.
sprintf
"%s_%s"
p
.
pid
n
))
p
.
variables
)
pl
in
let
algo_vars
=
List
.
flatten
(
List
.
flatten
lll
)
in
let
action_vars
=
List
.
flatten
(
List
.
map
(
fun
p
->
List
.
map
(
fun
a
->
(
Printf
.
sprintf
"Enab_%s_%s"
p
.
pid
a
)
,
"bool"
)
p
.
actions
)
(
fun
p
->
List
.
map
(
fun
a
->
(
Printf
.
sprintf
"Enab_%s_%s"
p
.
pid
a
)
,
"bool"
)
p
.
actions
)
pl
)
in
algo_vars
@
action_vars
...
...
@@ -185,19 +187,22 @@ let (make : bool -> string array -> t) =
close_out
oc
;
exit
0
);
if
args
.
rif
then
(
Printf
.
printf
"%s"
(
Mypervasives
.
entete
"#"
SasaVersion
.
str
SasaVersion
.
sha
);
Printf
.
printf
"%s"
(
Mypervasives
.
entete
"#"
SasaVersion
.
str
SasaVersion
.
sha
);
if
args
.
demon
<>
Demon
.
Custom
then
Printf
.
printf
"#seed %i
\n
"
args
.
seed
;
let
inputs_decl
=
get_inputs_rif_decl
args
pl
in
Printf
.
printf
"#inputs %s
\n
"
(
String
.
concat
" "
(
List
.
map
(
fun
(
vn
,
vt
)
->
Printf
.
sprintf
"
\"
%s
\"
:%s"
vn
vt
)
inputs_decl
));
(
List
.
map
(
fun
(
vn
,
vt
)
->
Printf
.
sprintf
"
\"
%s
\"
:%s"
vn
vt
)
inputs_decl
));
Printf
.
printf
"#outputs %s
\n
"
(
env_rif_decl
pl
);
flush
stdout
)
else
(
if
args
.
demon
<>
Demon
.
Custom
then
(
Printf
.
printf
"The pseudo-random engine is used with seed %i
\n
"
args
.
seed
;
Printf
.
printf
"The pseudo-random engine is used with seed %i
\n
"
args
.
seed
;
flush
stdout
);
);
...
...
@@ -206,7 +211,8 @@ let (make : bool -> string array -> t) =
(
fun
p
->
List
.
iter
(
fun
a
->
ignore
(
RifRead
.
bool
(
args
.
verbose
>
1
)
p
a
))
p
.
actions
)
pl
;
Printf
.
eprintf
"Ignoring the first vectors of sasa inputs
\n
"
;
flush
stderr
;
Printf
.
eprintf
"Ignoring the first vectors of sasa inputs
\n
"
;
flush
stderr
;
);
args
,
pl_n
,
e
with
...
...
This diff is collapsed.
Click to expand it.
test/dfs/p.ml
+
1
−
2
View file @
7212f2ea
(* Time-stamp: <modified the 0
4
/0
4
/2019 (at 21:
07
) by Erwan Jahier> *)
(* Time-stamp: <modified the 0
9
/0
5
/2019 (at 21:
59
) by Erwan Jahier> *)
(* cf Collin-Dolex-94 *)
...
...
@@ -43,7 +43,6 @@ let rec end_of_a a i =
let
(
concat_path
:
value
array
->
int
->
value
array
)
=
fun
a
alpha
->
let
s
=
Array
.
length
a
in
let
a
=
Array
.
copy
a
in
(* ouch! *)
let
last
=
end_of_a
a
1
in
if
last
=
s
then
(
for
i
=
1
to
s
-
1
do
...
...
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