summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2025-01-10 22:47:33 +0000
committerArun Isaac2025-01-20 01:47:23 +0000
commita0cd2b00e42c8d6c5d414d029c8a2924ab95e5b5 (patch)
tree5701a16fd254639ba8feba48cea1c77fbdb8beee
parenta65be6a6f445209a07ed72afb0abd7419fad20c3 (diff)
downloadravanan-a0cd2b00e42c8d6c5d414d029c8a2924ab95e5b5.tar.gz
ravanan-a0cd2b00e42c8d6c5d414d029c8a2924ab95e5b5.tar.lz
ravanan-a0cd2b00e42c8d6c5d414d029c8a2924ab95e5b5.zip
propnet: Schedule all propagators from inbox in a single step.
There is no value in making the loop recursion explicit. A single
append-map call is clearer.

* ravanan/propnet.scm (poll-propnet): Schedule all propagators from
inbox in a single step.
-rw-r--r--ravanan/propnet.scm50
1 files changed, 26 insertions, 24 deletions
diff --git a/ravanan/propnet.scm b/ravanan/propnet.scm
index e6155d8..dfe61ac 100644
--- a/ravanan/propnet.scm
+++ b/ravanan/propnet.scm
@@ -1,5 +1,5 @@
 ;;; ravanan --- High-reproducibility CWL runner powered by Guix
-;;; Copyright © 2024 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2024, 2025 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of ravanan.
 ;;;
@@ -204,28 +204,6 @@ add to the inbox."
       ;; cell-values-inbox are serviced.
       (()
        (match propagators-inbox
-         ;; Schedule one propagator in inbox.
-         ((propagator other-propagators ...)
-          (loop cells
-                cell-values-inbox
-                other-propagators
-                ;; We don't need to cancel or forget about previous runs of the
-                ;; same propagator because cells only *accumulate* information;
-                ;; they never remove it. Any previous runs of the same
-                ;; propagator will only *add to* the information in the output
-                ;; cells. Previous runs may be closer to completion and taking
-                ;; advantage of their output may allow later stages to start
-                ;; running sooner, thus improving throughput. In our CWL
-                ;; application of propnets, this will never result in the same
-                ;; step being recomputed; so this approach does not come at a
-                ;; higher computational cost.
-                (append (maybe-alist
-                         (cons (propagator-name propagator)
-                               (activate-propagator
-                                scheduler
-                                propagator
-                                (propagator-input-values cells propagator))))
-                        propagators-in-flight)))
          ;; Poll propagators in flight and update cell values if any of them are
          ;; done.
          (()
@@ -275,7 +253,31 @@ add to the inbox."
                                (append-map propagator-state->cell-values
                                            finished-propagators))
                         propagators-inbox
-                        propagators-still-in-flight))))))))))))
+                        propagators-still-in-flight)))))))
+         ;; Schedule propagators in inbox.
+         (_
+          (loop cells
+                cell-values-inbox
+                (list)
+                ;; We don't need to cancel or forget about previous runs of the
+                ;; same propagator because cells only *accumulate* information;
+                ;; they never remove it. Any previous runs of the same
+                ;; propagator will only *add to* the information in the output
+                ;; cells. Previous runs may be closer to completion and taking
+                ;; advantage of their output may allow later stages to start
+                ;; running sooner, thus improving throughput. In our CWL
+                ;; application of propnets, this will never result in the same
+                ;; step being recomputed; so this approach does not come at a
+                ;; higher computational cost.
+                (append (append-map (lambda (propagator)
+                                      (maybe-alist
+                                       (cons (propagator-name propagator)
+                                             (activate-propagator
+                                              scheduler
+                                              propagator
+                                              (propagator-input-values cells propagator)))))
+                                    propagators-inbox)
+                        propagators-in-flight))))))))
 
 (define (capture-propnet-output state)
   "Return output of propagator network @var{state}."