Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
caisar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
pub
caisar
Commits
cc4e446a
Commit
cc4e446a
authored
2 years ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
[cmdline] Move time and memory limit conversion functions into main module.
parent
5c4205fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.ml
+58
-6
58 additions, 6 deletions
src/main.ml
src/verification.ml
+2
-57
2 additions, 57 deletions
src/verification.ml
src/verification.mli
+2
-2
2 additions, 2 deletions
src/verification.mli
with
62 additions
and
65 deletions
src/main.ml
+
58
−
6
View file @
cc4e446a
...
...
@@ -87,11 +87,62 @@ let config detect () =
Whyconf
.
print_prover
Pp
.
nothing
)
provers
))
(* conversion string -> int for memlimit and timeout *)
(* auxiliary functions, TODO move to a better place *)
(* first, find the first non-numerical character, and return a couple of
substrings *)
let
rec
find_first_non_num
(
s
:
string
)
(
i
:
int
)
(
m
:
int
)
=
(* MUST be called with m = String.length s*)
if
i
>=
m
then
i
else
match
s
.
[
i
]
with
|
'
0
'
|
'
1
'
|
'
2
'
|
'
3
'
|
'
4
'
|
'
5
'
|
'
6
'
|
'
7
'
|
'
8
'
|
'
9
'
->
find_first_non_num
s
(
i
+
1
)
m
|
_
->
i
let
split_non_num
(
s
:
string
)
=
let
m
=
String
.
length
s
in
let
x
=
find_first_non_num
s
0
m
in
if
x
=
m
then
(
s
,
""
)
else
(
String
.
sub
s
~
pos
:
0
~
len
:
x
,
String
.
sub
s
~
pos
:
x
~
len
:
(
m
-
x
))
let
find_mult_memlimit
=
function
|
""
->
1
|
"M"
|
"MB"
|
"mega"
|
"megabytes"
->
1
|
"G"
|
"GB"
|
"giga"
|
"gigabytes"
->
1000
|
"T"
|
"TB"
|
"tera"
|
"terabytes"
->
1000000
|
_
->
failwith
"Unknown unit for memory limit"
let
find_mult_timeout
=
function
|
""
->
1
|
"s"
|
"seconds"
->
1
|
"min"
|
"minutes"
->
60
|
"h"
|
"hours"
->
3600
|
_
->
failwith
"Unknown unit for timeout"
let
convert_memlimit
(
s
:
string
option
)
:
int
option
=
match
s
with
|
None
->
None
|
Some
s
->
let
mem1
,
mem2
=
split_non_num
(
String
.
strip
s
)
in
Some
(
Int
.
of_string
mem1
*
find_mult_memlimit
mem2
)
let
convert_timelimit
s
=
match
s
with
|
None
->
None
|
Some
s
->
let
time1
,
time2
=
split_non_num
(
String
.
strip
s
)
in
Some
(
Int
.
of_string
time1
*
find_mult_timeout
time2
)
let
verify
format
loadpath
memlimit
timeout
prover
dataset_csv
files
=
let
debug
=
log_level_is_debug
()
in
let
memlimit
=
convert_memlimit
memlimit
in
let
timelimit
=
convert_timelimit
timeout
in
List
.
iter
~
f
:
(
Verification
.
verify
~
debug
format
loadpath
?
memlimit
?
time
ou
t
prover
(
Verification
.
verify
~
debug
format
loadpath
?
memlimit
?
time
limi
t
prover
?
dataset_csv
)
files
...
...
@@ -164,7 +215,7 @@ let verify_cmd =
&
opt
(
some
string
)
None
&
info
[
"m"
;
"memlimit"
]
~
doc
~
docv
:
"MEM"
)
in
let
time
ou
t
=
let
time
limi
t
=
let
doc
=
"Time limit. $(docv) is intended in seconds (s) by default, but \
minutes (m) and hours (h) may also be specified instead."
...
...
@@ -196,12 +247,13 @@ let verify_cmd =
Term
.(
ret
(
const
(
fun
format
loadpath
memlimit
time
ou
t
prover
dataset_csv
files
_
->
(
fun
format
loadpath
memlimit
time
limi
t
prover
dataset_csv
files
_
->
`Ok
(
exec_cmd
cmdname
(
fun
()
->
verify
format
loadpath
memlimit
timeout
prover
dataset_csv
files
)))
$
format
$
loadpath
$
memlimit
$
timeout
$
prover
$
dataset_csv
$
files
$
setup_logs
))
verify
format
loadpath
memlimit
timelimit
prover
dataset_csv
files
)))
$
format
$
loadpath
$
memlimit
$
timelimit
$
prover
$
dataset_csv
$
files
$
setup_logs
))
in
Cmd
.
v
info
term
...
...
This diff is collapsed.
Click to expand it.
src/verification.ml
+
2
−
57
View file @
cc4e446a
...
...
@@ -136,69 +136,14 @@ let call_prover ~limit config env prover config_prover driver dataset_csv task =
Fmt
.(
option
~
none
:
nop
(
any
" "
++
string
))
additional_info
)
(* conversion string -> int for memlimit and timeout *)
(* auxiliary functions, TODO move to a better place *)
(* first, find the first non-numerical character, and return a couple of substrings *)
let
rec
find_first_non_num
(
s
:
string
)
(
i
:
int
)
(
m
:
int
)
=
(* MUST be called with m = String.length s*)
if
i
>=
m
then
i
else
begin
match
s
.
[
i
]
with
|
'
0
'
|
'
1
'
|
'
2
'
|
'
3
'
|
'
4
'
|
'
5
'
|
'
6
'
|
'
7
'
|
'
8
'
|
'
9
'
->
find_first_non_num
s
(
i
+
1
)
m
|
_
->
i
end
let
split_non_num
(
s
:
string
)
=
let
m
=
String
.
length
s
in
let
x
=
find_first_non_num
s
0
m
in
if
x
=
m
then
(
s
,
""
)
else
(
String
.
sub
s
~
pos
:
0
~
len
:
x
,
String
.
sub
s
~
pos
:
x
~
len
:
(
m
-
x
))
let
find_mult_memlimit
=
function
""
->
1
|
"M"
|
"MB"
|
"mega"
|
"megabytes"
->
1
|
"G"
|
"GB"
|
"giga"
|
"gigabytes"
->
1000
|
"T"
|
"TB"
|
"tera"
|
"terabytes"
->
1000000
|
_
->
failwith
"Unkown unit for memory limit"
let
find_mult_timeout
=
function
""
->
1
|
"s"
|
"seconds"
->
1
|
"min"
|
"minutes"
->
60
|
"h"
|
"hours"
->
3600
|
_
->
failwith
"Unkown unit for timeout"
let
convert_memlimit
(
s
:
string
option
)
:
int
option
=
match
s
with
None
->
None
|
Some
s
->
let
(
mem1
,
mem2
)
=
split_non_num
s
in
(*(String.trim s) in*)
Some
((
Int
.
of_string
mem1
)
*
(
find_mult_memlimit
mem2
))
let
convert_timeout
(
s
:
string
option
)
:
int
option
=
match
s
with
None
->
None
|
Some
s
->
let
(
time1
,
time2
)
=
split_non_num
s
in
Some
((
Int
.
of_string
time1
)
*
(
find_mult_timeout
time2
))
let
verify
?
(
debug
=
false
)
format
loadpath
?
memlimit
?
timeout
prover
let
verify
?
(
debug
=
false
)
format
loadpath
?
memlimit
?
timelimit
prover
?
dataset_csv
file
=
if
debug
then
Debug
.
set_flag
(
Debug
.
lookup_flag
"call_prover"
);
let
memlimit
=
convert_memlimit
memlimit
in
let
timeout
=
convert_timeout
timeout
in
let
env
,
config
=
create_env
~
debug
loadpath
in
let
limit
=
let
main
=
Whyconf
.
get_main
config
in
let
memlimit
=
Option
.
value
memlimit
~
default
:
(
Whyconf
.
memlimit
main
)
in
let
timelimit
=
Option
.
value
time
ou
t
~
default
:
(
Whyconf
.
timelimit
main
)
in
let
timelimit
=
Option
.
value
time
limi
t
~
default
:
(
Whyconf
.
timelimit
main
)
in
let
def
=
Call_provers
.
empty_limit
in
{
Call_provers
.
limit_time
=
timelimit
;
...
...
This diff is collapsed.
Click to expand it.
src/verification.mli
+
2
−
2
View file @
cc4e446a
...
...
@@ -31,8 +31,8 @@ val verify :
?
debug
:
bool
->
string
option
->
string
list
->
?
memlimit
:
str
in
g
->
?
time
out
:
str
in
g
->
?
memlimit
:
in
t
->
?
time
limit
:
in
t
->
Prover
.
t
->
?
dataset_csv
:
string
->
File
.
t
->
...
...
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