Skip to content

Commit 76847c7

Browse files
committed
work to parallelize lazy ¨
1 parent 618522e commit 76847c7

File tree

3 files changed

+55
-23
lines changed

3 files changed

+55
-23
lines changed

libraries/dfns/array/array.apl

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ acc ← { ⊃⍺⍺{(⊂⍺ ⍺⍺⊃⍬⍴⍵),⍵}/1↓{⍵,⊂⍬⍴⍵}¯1
3636
disp { ⎕IO0 Boxed sketch of nested array.
3737
dec ctd2 1:decorated, 1:centred.
3838

39-
box{ ⎕IO0 Recursive boxing of nested array.
39+
box{ Recursive boxing of nested array.
4040
isor :⎕FMT ⎕or: '∇name'.
4141
1=,:dec open ⎕FMT dec open simple array: format.
4242
matmatr 1/dec open matrix of opened subarrays.
@@ -46,43 +46,43 @@ disp ← { ⎕IO←0 ⍝ Boxed sketch of nested ar
4646
()gaps plane subs collection into single plane.
4747
}
4848

49-
aligned{ ⎕IO0 Alignment and centring.
49+
aligned{ Alignment and centring.
5050
rows colssepr¨ subarray dimensions.
5151
sizes(/rows).,cols aligned subarray sizes.
5252
ctd=0:sizes¨ top-left alignment.
5353
v hsepr0.5×(¨)-sizes vertical and horizontal rotation.
5454
v¨h¨sizes¨ centred aligned subarrays.
5555
}
5656

57-
gaps{ ⎕IO0 Gap-separated sub-planes.
57+
gaps{ Gap-separated sub-planes.
5858
2: lowish rank: done.
5959
subs(-1)¨ sub-hyperplanes.
6060
widthsubs width of inter-plane gap.
6161
fill( width-3 0)' ' inter-plane gap.
6262
{fill}/1 open subs gap-separated planes.
6363
}
6464

65-
plane{ ⎕IO0 Boxed rank-2 plane.
65+
plane{ Boxed rank-2 plane.
6666
2<⍴⍴: join gap-separated sub-planes.
6767
odec(dec shape )outer outer type and shape decoration.
6868
idecinner inner type and shape decorations.
6969
(odec,idec)collect collected, formatted subarrays.
7070
}
7171

72-
join{ ⎕IO0 Join of gap-separated sub-planes.
72+
join{ Join of gap-separated sub-planes.
7373
sep()÷1 sub plane separation.
7474
split(0=sep|)[0] separation along first axis.
7575
(¯1)plane¨split sub-plane join.
7676
}
7777

78-
outer{ ⎕IO0 Outer decoration.
78+
outer{ Outer decoration.
7979
sizes1 0{()}¨sepr¨ row and col sizes of subarrays.
8080
sidessizes/¨¨'│─' vert and horiz cell sides.
8181
bordsdec¨'├┬'glue¨sides joined up outer borders.
8282
,¨/('' '') bords'└┐' vertical and horizontal borders.
8383
}
8484

85-
inner{ ⎕IO0 Inner subarray decorations.
85+
inner{ Inner subarray decorations.
8686
deco{(type ),1 shape } type and shape decorators.
8787
sepr deco¨matr dec open decorators: tt vv hh .
8888
}
@@ -94,20 +94,20 @@ disp ← { ⎕IO←0 ⍝ Boxed sketch of nested ar
9494
lft,top,/boxes completed collection.
9595
}
9696

97-
right{ ⎕IO0 Border right each subarray.
97+
right{ Border right each subarray.
9898
types2¨()=¯1+ right border lower corner types.
9999
chars'┼┤┴┘'[types] .. .. .. chars.
100100
rgt{,(-)()1 1/'',} form right border.
101101
((matr 1 open ),¨chars)rgt¨ cells bordered right.
102102
}
103103

104-
lower{ ⎕IO0 Border below each subarray.
104+
lower{ Border below each subarray.
105105
split{((¯2+1)/'')glue } decorators split with horiz line.
106106
bot{(-1) split } lower border.
107107
(matr,¨/)bot¨matr cells bordered below.
108108
}
109109

110-
type{ ⎕IO0 Type decoration char.
110+
type{ Type decoration char.
111111
dec<|:'' nested: '─'
112112
isor :'' ⎕or: '∇'
113113
sst{ simple scalar type.

utilities.lisp

+18-2
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,24 @@
111111
;; pass the environment variables if this is a user-defined function;
112112
;; remember not to add the nil argument if an internal
113113
;; variable state is being set
114+
;; ,(if (and (symbolp form)
115+
;; (string= "deco" (string form)))
116+
;; `(print (list :args ,args index-origin
117+
;; (when (not (getf ,this-meta :lexical-reference))
118+
;; (list (list :fn-params
119+
;; :index-origin index-origin))))))
114120
(apply ,form (append ,args (when (and (not (second ,args))
115-
(getf ,this-meta :lexical-reference))
121+
;; (getf ,this-meta :lexical-reference)
122+
)
116123
(list nil))
117124
(when (not (getf ,this-meta :lexical-reference))
118125
(list (list :fn-params
119-
:index-origin index-origin)))))))))))
126+
:index-origin index-origin
127+
;; ,@(if (and (symbolp form)
128+
;; (string= "deco" (string form)))
129+
;; `(:test-param 12)
130+
;; )
131+
)))))))))))
120132

121133
(let ((this-package (package-name *package*)))
122134
(defmacro in-april-workspace (name &body body)
@@ -245,6 +257,8 @@
245257
(declare (ignorable ,@(loop :for var :in params :when (not (eql '&optional var))
246258
:collect var)
247259
,env))
260+
;; (print (list :eee ,env ,@(loop :for var :in params :when (not (eql '&optional var))
261+
;; :collect var)))
248262
,@(loop :for var :in params :when (not (eql '&optional var))
249263
:collect `(setq ,var (render-varrays ,var)))
250264
;; (print (list :par ,@(remove '&optional (append params (list env 'abc)))))
@@ -257,6 +271,8 @@
257271
`(or (getf (rest ,env) ,(intern (string key) "KEYWORD"))
258272
,(find-symbol (string val) space)))))
259273
(declare (ignorable ,@vals-list))
274+
(if (getf (rest ,env) :test-param)
275+
(print (list :env ,env)))
260276
,@body))))
261277
#'∇self))))
262278

varray/varray.lisp

+27-11
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,34 @@
159159
(make-array (shape-of varray) :element-type (etype-of varray)))))
160160
output)
161161
(let ((output (make-array (shape-of varray) :element-type (etype-of varray))))
162-
(dotimes (i (array-total-size output))
162+
;; (dotimes (i (array-total-size output))
163163
;; (xdotimes output (i (array-total-size output))
164-
(let ((indexed (funcall indexer i)))
165-
;; (print (list :abc varray (shape-of varray) indexed prototype output))
166-
;; (print (list :in indexed))
167-
(if indexed (setf (row-major-aref output i)
168-
(funcall (if (and (not to-subrender)
169-
(not (subrendering-p indexed)))
170-
#'identity #'render)
171-
indexed))
172-
(setf (row-major-aref output i) prototype))))
173-
;; (print (list :out output))
164+
;; (let ((indexed (funcall indexer i)))
165+
;; ;; (print (list :abc varray (shape-of varray) indexed prototype output))
166+
;; ;; (print (list :in indexed))
167+
;; (if indexed (setf (row-major-aref output i)
168+
;; (funcall (if (and (not to-subrender)
169+
;; (not (subrendering-p indexed)))
170+
;; #'identity #'render)
171+
;; indexed))
172+
;; (setf (row-major-aref output i) prototype))))
173+
(flet ((render-index (i)
174+
(let ((indexed (funcall indexer i)))
175+
;; (print (list :abc varray (shape-of varray) indexed prototype output))
176+
;; (print (list :in indexed))
177+
(if indexed (setf (row-major-aref output i)
178+
(funcall (if (and (not to-subrender)
179+
(not (subrendering-p indexed)))
180+
#'identity #'render)
181+
indexed))
182+
(setf (row-major-aref output i) prototype)))))
183+
(render-index 0)
184+
(when (< 1 (array-total-size output))
185+
(dotimes (i (1- (array-total-size output)))
186+
;; (xdotimes output (i (1- (array-total-size output)))
187+
(render-index (1+ i)))
188+
;; (print (list :out output))
189+
output))
174190
output))
175191
(funcall (if (not (subrendering-p varray))
176192
#'render (lambda (item)

0 commit comments

Comments
 (0)