Skip to content

Commit

Permalink
add --runsolver-wall-time-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurakgun committed Mar 29, 2024
1 parent 8ad1d61 commit 78f2b3f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/conjure-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--use-existing-models=FILE</td><td style='padding-left:2ex;'>File names of Essence' models generated beforehand.<br />If given, Conjure skips the modelling phase and uses the existing models for solving.<br />The models should be inside the output directory (See -o).</td></tr>
<tr><td colspan='3'>runsolver:</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--runsolver-cpu-time-limit=INT</td><td style='padding-left:2ex;'>Use runsolver to limit total CPU time (in seconds)</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--runsolver-wall-time-limit=INT</td><td style='padding-left:2ex;'>Use runsolver to limit total elapsed time (in seconds)</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--runsolver-memory-limit=INT</td><td style='padding-left:2ex;'>Use runsolver to limit total memory usage (Maximum RSS - in megabytes).</td></tr>
<tr><td colspan='3'>Options for other tools:</td></tr>
<tr><td style='padding-left:2ex;'>&nbsp;<td style='padding-left:1ex; white-space:nowrap;'>--savilerow-options=ITEM</td><td style='padding-left:2ex;'>Options passed to Savile Row.</td></tr>
Expand Down
1 change: 1 addition & 0 deletions docs/conjure-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
The models should be inside the output directory (See -o).
runsolver:
--runsolver-cpu-time-limit=INT Use runsolver to limit total CPU time (in seconds)
--runsolver-wall-time-limit=INT Use runsolver to limit total elapsed time (in seconds)
--runsolver-memory-limit=INT Use runsolver to limit total memory usage (Maximum RSS - in megabytes).
Options for other tools:
--savilerow-options=ITEM Options passed to Savile Row.
Expand Down
1 change: 1 addition & 0 deletions src/Conjure/Process/Enumerate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ enumerateDomain d = liftIO' $ withSystemTempDirectory ("conjure-enumerateDomain-
, copySolutions = False
, solutionsInOneFile = False
, runsolverCPUTimeLimit = Nothing
, runsolverWallTimeLimit = Nothing
, runsolverMemoryLimit = Nothing
, logLevel = LogNone
-- default values for the rest
Expand Down
7 changes: 7 additions & 0 deletions src/Conjure/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ data UI
, responsesRepresentation :: String
, solutionsInOneFile :: Bool
, runsolverCPUTimeLimit :: Maybe Int
, runsolverWallTimeLimit :: Maybe Int
, runsolverMemoryLimit :: Maybe Int
-- flags related to logging
, logLevel :: LogLevel
Expand Down Expand Up @@ -747,6 +748,12 @@ ui = modes
&= groupname "runsolver"
&= explicit
&= help "Use runsolver to limit total CPU time (in seconds)"
, runsolverWallTimeLimit
= def
&= name "runsolver-wall-time-limit"
&= groupname "runsolver"
&= explicit
&= help "Use runsolver to limit total elapsed time (in seconds)"
, runsolverMemoryLimit
= def
&= name "runsolver-memory-limit"
Expand Down
16 changes: 9 additions & 7 deletions src/Conjure/UI/MainHelper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,12 @@ savileRowNoParam ui@Solve{..} (modelPath, eprimeModel) = sh $ errExit False $ do
(outBase, modelPath, "<no param file>", ui)
tr (1::Int)
let runsolverArgs = maybe [] (\ limit -> ["-C", show limit]) runsolverCPUTimeLimit ++
maybe [] (\ limit -> ["-R", show limit]) runsolverMemoryLimit ++
maybe [] (\ limit -> ["-W", show limit]) runsolverWallTimeLimit ++
maybe [] (\ limit -> ["-R", show limit]) runsolverMemoryLimit ++
["--quiet", "-v", outputDirectory </> outBase ++ ".runsolver-info"]
(stdoutSR, solutions) <- partitionEithers <$>
case (runsolverCPUTimeLimit, runsolverMemoryLimit) of
(Nothing, Nothing) -> runHandle savilerowScriptName srArgs handler
case (runsolverCPUTimeLimit, runsolverWallTimeLimit, runsolverMemoryLimit) of
(Nothing, Nothing, Nothing) -> runHandle savilerowScriptName srArgs handler
_ ->
if os /= "linux"
then return [Left "runsolver is only supported on linux"]
Expand Down Expand Up @@ -854,11 +855,12 @@ savileRowWithParams ui@Solve{..} (modelPath, eprimeModel) (paramPath, essencePar
(outBase, modelPath, paramPath, ui)
tr (1::Int)
let runsolverArgs = maybe [] (\ limit -> ["-C", show limit]) runsolverCPUTimeLimit ++
maybe [] (\ limit -> ["-V", show limit]) runsolverMemoryLimit ++
["--quiet", "-v", outputDirectory </> outBase ++ ".runsolver-info"]
maybe [] (\ limit -> ["-W", show limit]) runsolverWallTimeLimit ++
maybe [] (\ limit -> ["-R", show limit]) runsolverMemoryLimit ++
["--quiet", "-v", outputDirectory </> outBase ++ ".runsolver-info"]
(stdoutSR, solutions) <- partitionEithers <$>
case (runsolverCPUTimeLimit, runsolverMemoryLimit) of
(Nothing, Nothing) -> runHandle savilerowScriptName srArgs handler
case (runsolverCPUTimeLimit, runsolverWallTimeLimit, runsolverMemoryLimit) of
(Nothing, Nothing, Nothing) -> runHandle savilerowScriptName srArgs handler
_ ->
if os /= "linux"
then return [Left "runsolver is only supported on linux"]
Expand Down

0 comments on commit 78f2b3f

Please sign in to comment.