diff options
author | Arun Isaac | 2023-11-17 14:19:59 +0000 |
---|---|---|
committer | Arun Isaac | 2023-11-17 16:22:37 +0000 |
commit | bac6c575e7c03a1946ea46379a5bc98f009408fd (patch) | |
tree | cca58d75f049b022bf1a3b04fa8023bff60cd6d5 | |
parent | adb7d89709fabe14791fe9b570d9db3e993d43f6 (diff) | |
download | ccwl-bac6c575e7c03a1946ea46379a5bc98f009408fd.tar.gz ccwl-bac6c575e7c03a1946ea46379a5bc98f009408fd.tar.lz ccwl-bac6c575e7c03a1946ea46379a5bc98f009408fd.zip |
ccwl: Implement cross product scattering operations.
* ccwl/ccwl.scm (collect-steps): Implement scatter-cross and
scatter-nested-cross.
(key->output): Nest output array types for nested cross product
scatters.
-rw-r--r-- | ccwl/ccwl.scm | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 0127b3c..11d6d05 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -578,7 +578,7 @@ supplied input keys." output keys and a list of steps. INPUT-KEYS is a list of supplied input keys. Keys are represented by <key> objects, and steps are represented by <step> objects." - (syntax-case x (pipe tee rename scatter) + (syntax-case x (pipe tee rename scatter scatter-cross scatter-nested-cross) ;; pipe ((pipe expressions ...) (foldn (lambda (expression input-keys steps) @@ -605,6 +605,10 @@ represented by <step> objects." ;; TODO: Support cross product scatter methods. ((scatter _ ...) (collect-scatter-step x input-keys 'dotproduct)) + ((scatter-cross _ ...) + (collect-scatter-step x input-keys 'flat_crossproduct)) + ((scatter-nested-cross _ ...) + (collect-scatter-step x input-keys 'nested_crossproduct)) ((function (step-id) args ...) ;; Run a whole bunch of tests so that we can produce useful error ;; messages. @@ -749,9 +753,25 @@ commands." ;; Convert stdout type outputs to File type outputs. (let ((type (stdout->file-type (output-type output-for-key)))) ;; If step scatters, convert to an array type. - (if (null? (step-scattered-inputs step-with-output)) - type - (make-array-type type)))))) + (cond + ((null? (step-scattered-inputs step-with-output)) + type) + (step-scatter-method step-with-output) + ;; For dot products and flat cross products, create a + ;; singly nested array type. + ((memq (step-scatter-method step-with-output) + '(dotproduct flat_crossproduct)) + (make-array-type type)) + ;; For nested cross products, create a sufficiently + ;; nested array type. + ((eq? (step-scatter-method step-with-output) + 'nested_crossproduct) + (fold (lambda (_ result) + (make-array-type result)) + type + (step-scattered-inputs step-with-output))) + (else + (error "This should not be possible!"))))))) ;; Construct syntax to recreate output object. #`(make-output #,(with-syntax ((id (datum->syntax #f (output-id output)))) |