pipeline   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/contrib/stream.xtm

Implementation

(bind-func pipeline:[[void]*,[[void]*,!a]*,[[void]*,!a,!b]*,[[void]*,!b,!c]*,[[void]*,!c,!d]*,[[void]*,!d,!e]*,[[void]*,!e]*]*
  (lambda (a b c d e f)
    (let ((depth 6) (i 0) (cnt 0)
    (f1 (pipeline_stage a depth))
    (f2 (pipeline_stage b (* (a.push) (filter_rate f1)) depth (filter_output f1)))
    (f3 (pipeline_stage c (* (b.push) (filter_rate f2)) depth (filter_output f2)))
    (f4 (pipeline_stage d (* (c.push) (filter_rate f3)) depth (filter_output f3)))
    (f5 (pipeline_stage e (* (d.push) (filter_rate f4)) depth (filter_output f4)))
    (f6 (pipeline_stage f (* (e.push) (filter_rate f5)) (filter_output f5))))
      ;; do prework!
      ((filter_prework f1))
      ((filter_prework f2))
      ((filter_prework f3))
      ((filter_prework f4))
      ((filter_prework f5))
      ((filter_prework f6))
      ;; prime pipeline!
      (dotimes (i (- (* 6 (filter_rate f1)) 1)) ((filter_work f1)))
      (dotimes (i (- (* 5 (filter_rate f2)) 1)) ((filter_work f2)))
      (dotimes (i (- (* 4 (filter_rate f3)) 1)) ((filter_work f3)))
      (dotimes (i (- (* 3 (filter_rate f4)) 1)) ((filter_work f4)))
      (dotimes (i (- (* 2 (filter_rate f5)) 1)) ((filter_work f5)))
      (dotimes (i (- (* 1 (filter_rate f6)) 1)) ((filter_work f6)))
      ;; now ready for real work!
      (lambda ()
  (set! cnt (+ cnt 1))
        (sync
         (spawn (filter_lwork f1))
         (spawn (filter_lwork f2))
         (spawn (filter_lwork f3))
         (spawn (filter_lwork f4))
         (spawn (filter_lwork f5))
         (spawn (filter_lwork f6)))
        void))))


Back to Index

Similar Entries