compiler.cfg.dependence/scheduling.tests: new tests, some that doesnt work yet

db4
Björn Lindqvist 2014-11-11 04:44:48 +01:00 committed by Doug Coleman
parent 8347f43f84
commit 0feece123c
2 changed files with 180 additions and 12 deletions

View File

@ -1,7 +1,8 @@
USING: accessors arrays combinators.short-circuit compiler.cfg.dependence
compiler.cfg.instructions fry kernel namespaces sequences tools.test ;
USING: accessors arrays assocs combinators.short-circuit
compiler.cfg.dependence compiler.cfg.instructions compiler.cfg.registers fry
grouping kernel math namespaces random sequences tools.test vectors ;
IN: compiler.cfg.dependence.tests
FROM: sets => set= ;
FROM: sets => members set= ;
{
V{
@ -9,13 +10,11 @@ FROM: sets => set= ;
{ number 1 }
{ insn T{ ##inc-r } }
{ precedes H{ } }
{ follows V{ } }
}
T{ node
{ number 2 }
{ insn T{ ##inc-d } }
{ precedes H{ } }
{ follows V{ } }
}
}
} [
@ -36,7 +35,6 @@ FROM: sets => set= ;
3 iota [ node new swap >>number ] map first3
over attach-parent over attach-parent ;
! Verification tests
ERROR: node-missing-parent trees nodes ;
ERROR: node-missing-children trees nodes ;
@ -73,3 +71,112 @@ ERROR: node-missing-children trees nodes ;
[
{ } 3node-tree 1array verify-trees
] [ node-missing-children? ] must-fail-with
! select-parent tests
{ f } [
{ } select-parent
] unit-test
: dummy-node ( number -- node )
node new over >>number ##allot new rot >>insn# >>insn ;
! No parent because it has +control+
{ f } [
10 20 [ dummy-node ] bi@ 2array { +data+ +control+ } zip select-parent
] unit-test
! Yes parent
{ 10 } [
10 dummy-node +data+ 2array 1array select-parent insn>> insn#>>
] unit-test
{ 0 } [
20 iota [ dummy-node +data+ 2array ] map randomize
select-parent insn>> insn#>>
] unit-test
! Shared with compiler.cfg.scheduling
: test-not-in-order ( -- nodes )
V{
##load-tagged
##allot
##set-slot-imm
##load-reference
##allot
##set-slot-imm
##set-slot-imm
##set-slot-imm
##replace
} [ [ new ] [ 2 * ] bi* >>insn# ] map-index ;
{ 7 } [
test-not-in-order [ <node> ] map dup
build-dependence-graph
make-trees length
] unit-test
! Another
{ t } [
100 [
test-not-in-order [ <node> ] map [ build-dependence-graph ] keep
[ precedes>> select-parent ] map [ dup [ insn>> ] when ] map
] replicate all-equal?
] unit-test
{ t } [
100 [
test-not-in-order [ <node> ] map dup dup
build-dependence-graph [ maybe-set-parent ] each
[ children>> length ] map
] replicate all-equal?
] unit-test
: test-some-kind-of-dep ( -- insns )
V{
T{ ##peek { dst 275 } { loc D 2 } }
T{ ##load-tagged { dst 277 } { val 0 } }
T{ ##allot
{ dst 280 }
{ size 16 }
{ class-of array }
{ temp 6 }
}
T{ ##set-slot-imm
{ src 277 }
{ obj 280 }
{ slot 1 }
{ tag 2 }
}
T{ ##load-reference
{ dst 283 }
{ obj
{
vector
2
1
tuple
258304024774
vector
8390923745423
}
}
}
T{ ##allot
{ dst 285 }
{ size 32 }
{ class-of tuple }
{ temp 12 }
}
T{ ##set-slot-imm
{ src 283 }
{ obj 285 }
{ slot 1 }
{ tag 7 }
}
T{ ##set-slot-imm
{ src 280 }
{ obj 285 }
{ slot 2 }
{ tag 7 }
}
} [ 2 * >>insn# ] map-index ;

View File

@ -1,6 +1,7 @@
USING: accessors compiler.cfg compiler.cfg.instructions
USING: accessors arrays assocs compiler.cfg compiler.cfg.dependence
compiler.cfg.dependence.tests compiler.cfg.instructions
compiler.cfg.linearization compiler.cfg.scheduling compiler.cfg.utilities
vocabs.loader namespaces tools.test arrays kernel random sequences sets words ;
grouping kernel math namespaces tools.test random sequences sets words ;
IN: compiler.cfg.scheduling.tests
! Test split-insns
@ -79,7 +80,7 @@ IN: compiler.cfg.scheduling.tests
##replace-imm
##replace
##branch
} [ new ] map ;
} [ [ new ] [ 2 * ] bi* >>insn# ] map-index ;
{
{
@ -105,9 +106,69 @@ IN: compiler.cfg.scheduling.tests
}
V{ T{ ##branch } }
}
} [ test-1187 split-insns ] unit-test
} [ test-1187 [ f >>insn# ] map split-insns ] unit-test
{
V{
T{ ##load-tagged { insn# 0 } }
T{ ##load-reference { insn# 6 } }
T{ ##set-slot-imm { insn# 14 } }
T{ ##replace { insn# 16 } }
}
} [
test-not-in-order setup-nodes [ ready? ] filter [ insn>> ] map
] unit-test
{
V{
T{ ##allot { insn# 2 } }
T{ ##set-slot-imm { insn# 4 } }
T{ ##allot { insn# 8 } }
T{ ##set-slot-imm { insn# 10 } }
T{ ##load-tagged { insn# 0 } }
T{ ##load-reference { insn# 6 } }
T{ ##set-slot-imm { insn# 12 } }
T{ ##set-slot-imm { insn# 14 } }
T{ ##replace { insn# 16 } }
}
} [ test-not-in-order reorder-body ] unit-test
{ t f } [
node new ready?
node new { { 1 2 } } >>precedes ready?
] unit-test
{ t } [
100 [
test-not-in-order setup-nodes [ insn>> ] map
] replicate all-equal?
] unit-test
{ t } [
100 [
test-not-in-order setup-nodes [ score ] map
] replicate all-equal?
] unit-test
! You should get the exact same instruction order each time.
{ 1 } [
10 [ test-1187 split-insns 1 swap nth ] replicate members length
{ t } [
100 [ test-not-in-order reorder-body ] replicate all-equal?
] unit-test
{ t } [
100 [ test-1187 split-insns 1 swap nth reorder ] replicate all-equal?
] unit-test
{ t f } [
0 node-number set-global test-some-kind-of-dep [ <node> ] map
dup build-dependence-graph
! Anyone preceding node number 8?
[
[ precedes>> keys [ number>> ] map 8 swap member? ] any?
]
[
unclip-last over swap remove-node
[ precedes>> keys [ number>> ] map 8 swap member? ] any?
] bi
] unit-test