Skip to content

Commit 2ac6afb

Browse files
committed
remove live-in from stochastic & decomposer
1 parent 2369fd7 commit 2ac6afb

9 files changed

+50
-28
lines changed

GA/test-regression.rkt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
(test 'interp2 "@ @b b! - @b + -" 5
8888
'((data . 2)) #:sym #f #:prefix "2 b! dup !b a! @+") ;; @ - over + -
8989

90-
#|
9190
(test 1 "dup drop up a! @ !" 4 '((data . 1) memory) #:sym #t)
9291
;;(test 2 "dup drop up a! @+ !" 4 '((data . 1) memory) #:sym #t)
9392
(test 3 "dup drop up a! ! @" 4 '((data . 1) memory) #:sym #t)
@@ -103,7 +102,7 @@
103102
#:assume '((<= . 65535) (<= . 65535) (<= . 65535)) #:sym #f)
104103
(test 'shaf "0 a! !+ !+ push pop dup 1 b! @b and over - 0 b! @b and or push drop pop" 6
105104
'((data . 2) (return . 1)) #:sym #f)
106-
|#
105+
107106
#;(test 'complexB "drop 3 and + push drop pop dup 0 b! @b" 10
108107
'((data . 2)) #:sym #f) ;; very slow
109108
#;(test 'rrotate "2 b! !b push drop pop 2 b! @b 0 b! !b up b! @b 0 b! @b 2/ 2/ + 65535 and" 8

GA/test-search.rkt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
))
120120
#;(send stoch superoptimize encoded-code
121121
(send machine output-constraint '() 2 0) ;; constraint
122-
(send machine output-constraint '(a) 4 1) ;; live-in
123122
"./driver-0" 3600 #f)
124123

125124
;(require profile)

TODO

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
Performance
2-
* default mask-in with check (return early)
3-
- mask-in & mask-in again (ARM)
4-
- symbolic: provide input or not?
5-
61
TODO
7-
* run regression test
8-
* user don't have to provide live-in for stoch, use result from combine-live too
2+
* user don't have to provide live-in for stoch, use result from combine-live too [test stoch]
3+
- test regression
4+
- get rid of live-in parser
95

106
Correctness
117
- how to prevent users from making a mistake on machine description (ins & outs).
128
= e.g. putting arg 0 to be output of str# => backward can't find solution.
139
= SOLUTION: extract ins & outs from simulator!!!
1410

1511
1. Revisit
16-
- (reduce-precesion) in forwardbackward
17-
- change "public" to "protected"
18-
- remove (debug-inst) in forwardbackward
12+
- remove (debug-inst) in forwardbackward & live-in in stoch
1913
- template
2014

2115
2. May need to override these functions
@@ -26,9 +20,8 @@ Correctness
2620
= when using parallel driver, printer:compress-state-space
2721
= config can be use in program-structor, define-arg-type
2822
- efficient memory access. memory access operates in a granularity of # of bits defined
29-
- bit, const => reduce bitwidth
3023
- update-progstate-ins-load -store
31-
- want stact, contact me
24+
- want stack, contact me
3225
- say that (get) & (set) is used for update-live, update-live-backward, and inverse
3326
(get-arg-ranges) & (get-valid-opcode)
3427
- #:try-cmp? in enumerator, (try-cmp?) in forwardbackward

arm/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
for name in p10_nlz_eq_o0 p12_nlz_le_o0 p21_cycle_o0 p22_parity_o0 p23_count_o0 p19_exchange_o0 p11_nlz_lt_o0 p20_next_higher_o0 p24_roundpower_o0 p13_sign_o0 p14_floor_avg_o0 p15_ceil_avg_o0 p16_max_o0 p17_off_right_o0 p18_is_power_o0 p25_smmul_o0
22
do
33
echo $name
4-
racket optimize.rkt --enum -p -t 150 -c 4 -d $name programs/$name.s
4+
racket optimize.rkt --stoch -s -t 30 -c 1 -d $name programs/$name.s
55
done

arm/test-search.rkt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
;; p25 -O3
8181
;; z3: >5 min, java: 9 s
8282

83-
(define livein (send printer encode-live '(0 3)))
8483
(define constraint (send printer encode-live '(0)))
8584

8685
(define encoded-prefix (send printer encode prefix))
@@ -101,7 +100,6 @@
101100

102101
#;(send stoch superoptimize encoded-code
103102
constraint ;; constraint
104-
livein ;; live-in
105103
"./driver-0" 3600 #f)
106104

107105
(send backward synthesize-window

decomposer.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
;; The cooperative search tries L, 2L, 3L, 4L
2424
(define (window-size) (* 2 (len-limit)))
2525

26-
(define (superoptimize spec constraint live-in name time-limit size
26+
(define (superoptimize spec constraint name time-limit size
2727
#:prefix [prefix (vector)] #:postfix [postfix (vector)]
2828
#:assume [assumption (send machine no-assumption)]
2929
#:input-file [input-file #f]

llvm/test-search.rkt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ store i32 %1, i32* %2
118118
))
119119
#;(send stoch superoptimize encoded-code
120120
constraint ;; constraint
121-
(send printer encode-live (vector '(%2) #t)) ;; live-in
122121
"./driver-0" 3600)
123122

124123
;; Step 4: create enumerative search

parallel-driver.rkt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,8 @@
126126
(pretty-display (format "(define encoded-start-code (send printer encode start-code))"))
127127
)
128128
(pretty-display
129-
(format "(send search superoptimize encoded-code ~a ~a \"~a-~a\" ~a ~a #:assume ~a #:input-file ~a #:start-prog ~a #:prefix encoded-prefix #:postfix encoded-postfix)"
129+
(format "(send search superoptimize encoded-code ~a \"~a-~a\" ~a ~a #:assume ~a #:input-file ~a #:start-prog ~a #:prefix encoded-prefix #:postfix encoded-postfix)"
130130
(send printer output-constraint-string live-out)
131-
(send printer output-constraint-string live-in)
132131
path id time-limit prog-size
133132
(send printer output-assume-string assume)
134133
(if input-file (string-append "\"" input-file "\"") #f)
@@ -182,7 +181,7 @@
182181
(define cores-enum
183182
(cond
184183
[(equal? search-type `enum) cores]
185-
[(equal? search-type `hybrid) (floor (* (/ 2 6) cores))] ;;(floor (* (/ 3 6) cores))]
184+
[(equal? search-type `hybrid) (floor (* (/ 3 6) cores))] ;;(floor (* (/ 3 6) cores))]
186185
[else 0]
187186
))
188187
(define cores-solver

stochastic.rkt

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
(define (inst-copy-with-op x op) (struct-copy inst x [op op]))
4141
(define (inst-copy-with-args x args) (struct-copy inst x [args args]))
4242

43-
(define (superoptimize spec constraint this-live-in
43+
(define (superoptimize spec constraint
4444
name time-limit size
4545
#:prefix [prefix (vector)]
4646
#:postfix [postfix (vector)]
@@ -50,12 +50,47 @@
5050
(send machine reset-opcode-pool)
5151
(send machine reset-arg-ranges)
5252
(send validator adjust-memory-config spec)
53-
54-
(set! live-in (send machine progstate->vector this-live-in))
53+
54+
;; 1) User-provided live-in
55+
;; (define live-in-user (send machine progstate->vector this-live-in))
56+
;; (for ([x prefix])
57+
;; (set! live-in-user (send machine update-live live-in x)))
58+
59+
;; 2) Combined automatic live-in
60+
;; (define live1 (send validator get-live-in (vector-append spec postfix) constraint))
61+
;; (define live0 (send validator-abst get-live-in (vector-append prefix spec postfix) constraint))
62+
;; (define live0-list (send machine progstate->vector live0))
63+
64+
;; (define live1-list-alt live0-list)
65+
;; (for ([x prefix])
66+
;; (set! live1-list-alt (send machine update-live live1-list-alt x)))
67+
;; (define live1-list (send machine progstate->vector live1))
68+
;; (set! live-in (combine-live live1-list-alt live1-list))
69+
70+
;; 3) get-live-in then update-live
71+
(define live0 (send validator get-live-in (vector-append prefix spec postfix) constraint))
72+
(define live0-list (send machine progstate->vector live0))
73+
74+
(set! live-in live0-list)
5575
(for ([x prefix])
5676
(set! live-in (send machine update-live live-in x)))
57-
;; (unless live-in
58-
;; (raise "stochastic: live-in at spec cannot be #f"))
77+
78+
;; (unless (vector? live-in-user)
79+
;; (for ([l1 live-in]
80+
;; [l2 live-in-user])
81+
;; (cond
82+
;; [(boolean? l1)
83+
;; (when (and l2 (not l1))
84+
;; (pretty-display `(live-in ,live-in ,live-in-user))
85+
;; (raise "done"))]
86+
;; [else
87+
;; (for ([ll1 l1]
88+
;; [ll2 l2])
89+
;; (when (and ll2 (not ll1))
90+
;; (pretty-display `(live-in ,live-in ,live-in-user))
91+
;; (raise "done")))])))
92+
93+
5994

6095
(send machine analyze-args (vector) spec (vector) live-in constraint)
6196
(send machine analyze-opcode (vector) spec (vector))

0 commit comments

Comments
 (0)