From bac6c575e7c03a1946ea46379a5bc98f009408fd Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 17 Nov 2023 14:19:59 +0000 Subject: 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. --- ccwl/ccwl.scm | 28 ++++++++++++++++++++++++---- 1 file 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 objects, and steps are represented by 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 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)))) -- cgit v1.2.3