\* Generic routines for event counting. You set the event-src, and then call "counts>buf" with arguments indicating the size of the subsector that you wish to scan. This subsector has to fit within a sector. The results go into a buffer called "resultbuf" that is resized to ge exactly the rigth length. Results are copied into this buffer at exactly the positions they would occupy if the entire space were being updated by one module. Note: For the moment, these routines assume y-strip-topology. *\ 25 create-buffer countbuf0 25 create-buffer countbuf1 25 create-buffer countbuf2 25 create-buffer countbuf3 25 create-buffer countbuf4 25 create-buffer countbuf5 25 create-buffer countbuf6 25 create-buffer countbuf7 : countbuf (s n -- ) {{ countbuf0 countbuf1 countbuf2 countbuf3 countbuf4 countbuf5 countbuf6 countbuf7 }} ; : n-count (s n -- n.count ) 0 #modules 0 do over i countbuf 25 0 buffer bf@ + loop nip ; : nm-count (s layer module# -- n.count ) countbuf 25 0 buffer bf@ ; 0 create-buffer resultbuf \ Limitations: assumes y-strip-topology, and uses kernel memory for \ result buffer, when it could use regular memory allocation instead. \ For the moment, the count-volume must all lie within a single subsector. \ Note: we don't set event source here; that is the responsibility \ of the user!! \ Note: we start data with module 1 for compatibility with y-strip-topology. 0 value event-addr-delta 0 value subsectors/face 0 value face-addr-delta 64 constant event-entry-len ( bytes ) : counts>buf (s x1 x2 .. xd -- ) #dim @ reverse #dim @ 1 ?do by loop subsector subsectors/sector #modules * event-entry-len /w / * ['] resultbuf change-reglen 1 0 lp/sector 2@ drop << 1 0 lp 2@ drop << / ( #subsectors.across ) 1 1 lp/sector 2@ drop << 1 1 lp 2@ drop << / ( #subsectors.down ) * dup is subsectors/face event-entry-len * dup is event-addr-delta #modules * is face-addr-delta scan-format 25 ecl! site-src site kick subsectors/sector subsectors/face / 0 ?do subsectors/face 0 ?do run free new-count run no-scan new-count select read *select-buf #modules 0 do select i module' event read i countbuf loop select *select-buf *step* #modules 0 do k 16 0 do i j nm-count ( face event.count ) over face-addr-delta * ( face event.count face.delta ) resultbuf buffer + ( face event.count base.addr ) k event-entry-len * + ( face event.count base+entry# ) j event-addr-delta * + ( face event.count base+entry+module) i /l* + ! loop drop loop loop loop full-space step ; : count-layer (s n -- count ) save-select/sector/src full-space scan-format 25 ecl! site-src site event-src site kick run new-count run no-scan new-count #modules 0 ?do select i module event read i countbuf loop restore-select/sector/src *step* 0 #modules 0 ?do over 25 i countbuf buffer slice@ + loop nip ;