9.2.4 Calling Simulation Tools

Since several types of software (and hardware) failures may occur when running simulation tools, especially in a networked environment, we extended the base language with a macro called with-retries. Its calling signature is (number-of-tries &body default-forms) &body body. with-retries executes its body until no error was raised, but at most number-of-tries times. Upon success the result values are those of the last form in body, otherwise the values returned by default-forms.

The first example tries to execute the body of the call three times and succeeds. The body in the second example is tried three times as well, but call to error defeats any success. The same happens in the third example; after three tries the default forms, here a call to p-norm, are executed and the resulting values are returned.

Example.

? (with-retries (3)
    (p-norm (vector 1 2 3)))
> 3.7416575
? (with-retries (3)
    (error "Foo!"))
> NIL
? (with-retries (3 (p-norm (vector 1 2 3)))
    (error "Foo!"))
> 3.7416575

Simulation tools are always passed one state as an argument when they are called. Calling simulation tools through the preferred interface entails the construction of an instance of class task, or a subclass thereof. Tasks contain all the information about calling a simulation tool and returning the required data. While subclasses and methods specialized to certain simulation tools are provided, the class hierarchy starting at task can also be specialized by the user, as well as the methods acting on tasks, e.g., the execute method.

The task manager schedules the execution of the tasks. In order to execute a task, it looks for reachable hosts (i.e., hosts whose load average can be retrieved) that are not disabled and that are not too busy. If such a host is available, the task is run on the host which currently provides the most computational resources. Otherwise, it waits until a host becomes available.

The following is an example of calling MINIMOS and extracting a certain vector from a result file. Here tm-exec constructs an instance of minimos-task and executes it using the task manager. MINIMOS is run at nice level 10 and it will consume at most 120 seconds of CPU time. The input state is constructed from the default values for a certain experiment (we assume this experiment has already been set up). Variables will be substituted in the given input deck (cf. Section 9.2.7) file. The input pif file [34] (containing the device structure) is given as well, and the last option means we request a curve file as result. After the task has finished, we parse the resulting curve file with parse-curve-file and return one of its column vectors. Other simulation tools are called similarly.

Example.

? (with-scratch-directory (dir)
    (find-column-vector-named
     (parse-curve-file
      (output-crv
       (tm-exec 'minimos-task
                :nice 10
                :max-cpu-time 120
                :input-state (make-state :e12)
                :input-deck #f"~/work/experiment-12/nmos.ipd"
                :input-pif #f"~/work/experiment-12/nmos.pif"
                :output-crv (make-unique-file "crv" :directory dir :pre "crv-"))))
     "Id"))
> #(-9.203809e-9)

Clemens Heitzinger 2003-05-08