Parallel solving in Z3

前端 未结 2 618
失恋的感觉
失恋的感觉 2021-01-13 14:55

One of the new features in Z3 4.8.1 is parallel solving:

A parallel mode is available for select theories, including QF_BV. By setting parallel.enab

2条回答
  •  太阳男子
    2021-01-13 15:01

    From the command line

    If you are using the z3 executable, then you simply pass the setting in the command line. That is, if your script is in file a.smt2, use:

     z3 parallel.enable=true a.smt2
    

    and z3 will use the parallel solver as it processes the benchmark. For instance:

    $ cat a.smt2
    (set-logic QF_AUFBV )
    (set-option :produce-models true)
    (declare-fun a () (_ BitVec 32))
    (declare-fun b () (_ BitVec 32))
    (assert (bvult a b))
    (check-sat)
    (get-model)
    

    Regular call:

    $ z3 a.smt2
    sat
    (model
      (define-fun a () (_ BitVec 32)
        #x00000000)
      (define-fun b () (_ BitVec 32)
        #x00000001)
    )
    

    Parallel mode:

    $ z3 parallel.enable=true a.smt2
    (tactic.parallel :progress 0% :closed 0 :open 1)
    (tactic.parallel :progress 100% :status sat :closed 0 :open 0)
    sat
    (model
      (define-fun a () (_ BitVec 32)
        #x00000000)
      (define-fun b () (_ BitVec 32)
        #x00000001)
    )
    

    Note the extra comments regarding the execution of the parallel mode in the second run.

    Programmatically

    If you're asking about how to use it from the programmatic API? For Python, it would look like:

    from z3 import *
    set_param('parallel.enable', True)
    

    I'm sure other API's have similar calls. (Caveat: I haven't actually used/tested this feature myself; and since it's rather new, it might be the case that not all programmatic APIs support it. Hopefully, you get a nice warning/error if that's the case!)

提交回复
热议问题