2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * *
* * T h e Y a p T a b / Y a p O r / O P T Y a p s y s t e m s * *
* * * *
* * Y a p T a b e x t e n d s t h e Y a p P r o l o g e n g i n e to s u p p o r t s e q u e n t i a l t a b l i n g * *
* * Y a p O r e x t e n d s t h e Y a p P r o l o g e n g i n e to s u p p o r t o r - p a r a l l e l i s m * *
* * O P T Y a p e x t e n d s t h e Y a p P r o l o g e n g i n e to s u p p o r t o r - p a r a l l e l t a b l i n g * *
* * * *
* * * *
* * Y a p P r o l o g w a s d e v e l o p e d at U n i v e r s i t y of P o r t o , P o r t u g a l * *
* * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * T a b l i n g i n s t r u c t i o n s : a u x i l i a r y m a c r o s * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2001-04-09 20:54:03 +01:00
2005-07-06 20:34:12 +01:00
# i f def L O W _ L E V E L _ T R A C E R
2010-04-18 04:59:11 +01:00
# define s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( C P , T A B _ E N T ) \
C P - > c p _ p r e d _ e n t r y = T a b E n t _ p e ( T A B _ E N T )
2005-07-06 20:34:12 +01:00
# else
# define s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( C P , T A B _ E N T )
# e n d i f /* L O W _ L E V E L _ T R A C E R */
2011-12-22 16:50:20 +00:00
# define T A B L I N G _ E R R O R _ C H E C K I N G _ S T A C K \
T A B L I N G _ E R R O R _ C H E C K I N G ( s t o r e _ n o d e , U n s i g n e d ( H ) + 1024 > U n s i g n e d ( B ) ) ; \
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( s t o r e _ n o d e , U n s i g n e d ( H _ F Z ) + 1024 > U n s i g n e d ( B ) )
2005-07-06 20:34:12 +01:00
2011-12-22 16:50:20 +00:00
# define s t o r e _ g e n e r a t o r _ n o d e ( T A B _ E N T , S G _ F R , A R I T Y , A P ) \
{ r e g i s t e r C E L L * p t _ a r g s ; \
r e g i s t e r c h o i c e p t r g c p ; \
/* s t o r e a r g s */ \
p t _ a r g s = X R E G S + ( A R I T Y ) ; \
while ( p t _ a r g s > X R E G S ) { \
r e g i s t e r C E L L a u x _ a r g = p t _ a r g s [ 0 ] ; \
- - Y E N V ; \
- - p t _ a r g s ; \
* Y E N V = a u x _ a r g ; \
} \
/* i n i t i a l i z e g c p a n d a d j u s t s u b g o a l f r a m e f i e l d */ \
Y E N V = ( C E L L * ) ( G E N _ C P ( Y E N V ) - 1 ) ; \
g c p = N O R M _ C P ( Y E N V ) ; \
S g F r _ g e n _ c p ( S G _ F R ) = g c p ; \
/* s t o r e g e n e r a t o r c h o i c e p o i n t */ \
H B R E G = H ; \
s t o r e _ y a a m _ r e g _ c p d e p t h ( g c p ) ; \
g c p - > c p _ t r = T R ; \
g c p - > c p _ a p = ( y a m o p * ) ( A P ) ; \
g c p - > c p _ h = H ; \
g c p - > c p _ b = B ; \
g c p - > c p _ e n v = E N V ; \
g c p - > c p _ c p = C P R E G ; \
if ( I s M o d e _ L o c a l ( T a b E n t _ m o d e ( T A B _ E N T ) ) ) { \
/* g o l o c a l */ \
r e g i s t e r d e p _ f r _ p t r n e w _ d e p _ f r ; \
/* a d j u s t f r e e z e r e g i s t e r s */ \
H _ F Z = H ; \
B _ F Z = g c p ; \
T R _ F Z = T R ; \
/* s t o r e d e p e n d e n c y f r a m e */ \
n e w _ d e p e n d e n c y _ f r a m e ( n e w _ d e p _ f r , TRUE , L O C A L _ t o p _ o r _ f r , g c p , \
g c p , S G _ F R , FALSE , L O C A L _ t o p _ d e p _ f r ) ; \
L O C A L _ t o p _ d e p _ f r = n e w _ d e p _ f r ; \
G E N _ C P ( g c p ) - > c p _ d e p _ f r = L O C A L _ t o p _ d e p _ f r ; \
} else { \
/* g o b a t c h e d */ \
G E N _ C P ( g c p ) - > c p _ d e p _ f r = NULL ; \
} \
G E N _ C P ( g c p ) - > c p _ s g _ f r = S G _ F R ; \
s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( G E N _ C P ( g c p ) , T A B _ E N T ) ; \
s e t _ c u t ( ( C E L L * ) g c p , B ) ; \
B = g c p ; \
Y A P O R _ S E T _ L O A D ( B ) ; \
S E T _ B B ( B ) ; \
T A B L I N G _ E R R O R _ C H E C K I N G _ S T A C K ; \
2001-04-09 20:54:03 +01:00
}
2009-07-03 00:54:39 +01:00
# i f def D E T E R M I N I S T I C _ T A B L I N G
# define s t o r e _ d e t e r m i n i s t i c _ g e n e r a t o r _ n o d e ( T A B _ E N T , S G _ F R ) \
{ r e g i s t e r c h o i c e p t r g c p ; \
/* i n i t i a l i z e g c p a n d a d j u s t s u b g o a l f r a m e f i e l d */ \
Y E N V = ( C E L L * ) ( D E T _ G E N _ C P ( Y E N V ) - 1 ) ; \
g c p = N O R M _ C P ( Y E N V ) ; \
S g F r _ g e n _ c p ( S G _ F R ) = g c p ; \
/* s t o r e d e t e r m i n i s t i c g e n e r a t o r c h o i c e p o i n t */ \
H B R E G = H ; \
s t o r e _ y a a m _ r e g _ c p d e p t h ( g c p ) ; \
g c p - > c p _ a p = C O M P L E T I O N ; \
g c p - > c p _ b = B ; \
2009-08-09 03:38:07 +01:00
g c p - > c p _ t r = T R ; \
g c p - > c p _ h = H ; \
2009-07-03 00:54:39 +01:00
D E T _ G E N _ C P ( g c p ) - > c p _ s g _ f r = S G _ F R ; \
s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( D E T _ G E N _ C P ( g c p ) , T A B _ E N T ) ; \
s e t _ c u t ( ( C E L L * ) g c p , B ) ; \
B = g c p ; \
Y A P O R _ S E T _ L O A D ( B ) ; \
S E T _ B B ( B ) ; \
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G _ S T A C K ; \
2009-07-03 00:54:39 +01:00
}
# e n d i f /* D E T E R M I N I S T I C _ T A B L I N G */
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
# define s t o r e _ g e n e r a t o r _ c o n s u m e r _ n o d e ( T A B _ E N T , S G _ F R , D E P _ O N _ S T A C K , A R I T Y ) \
{ r e g i s t e r C E L L * p t _ a r g s ; \
r e g i s t e r c h o i c e p t r g c c p ; \
r e g i s t e r d e p _ f r _ p t r n e w _ d e p _ f r ; \
/* s t o r e a r g s */ \
p t _ a r g s = X R E G S + ( A R I T Y ) ; \
while ( p t _ a r g s > X R E G S ) { \
r e g i s t e r C E L L a u x _ a r g = p t _ a r g s [ 0 ] ; \
- - Y E N V ; \
- - p t _ a r g s ; \
* Y E N V = a u x _ a r g ; \
} \
/* i n i t i a l i z e g c p a n d a d j u s t s u b g o a l f r a m e f i e l d */ \
Y E N V = ( C E L L * ) ( G E N _ C P ( Y E N V ) - 1 ) ; \
g c c p = N O R M _ C P ( Y E N V ) ; \
S g F r _ g e n _ c p ( S G _ F R ) = g c c p ; \
/* s t o r e g e n e r a t o r c h o i c e p o i n t */ \
H B R E G = H ; \
s t o r e _ y a a m _ r e g _ c p d e p t h ( g c c p ) ; \
g c c p - > c p _ t r = T R ; \
g c c p - > c p _ a p = A N S W E R _ R E S O L U T I O N _ C O M P L E T I O N ; \
g c c p - > c p _ h = H ; \
g c c p - > c p _ b = B ; \
g c c p - > c p _ e n v = E N V ; \
g c c p - > c p _ c p = C P R E G ; \
/* s t o r e d e p e n d e n c y f r a m e */ \
n e w _ d e p e n d e n c y _ f r a m e ( n e w _ d e p _ f r , D E P _ O N _ S T A C K , L O C A L _ t o p _ o r _ f r , \
g c c p , g c c p , S G _ F R , TRUE , L O C A L _ t o p _ d e p _ f r ) ; \
L O C A L _ t o p _ d e p _ f r = n e w _ d e p _ f r ; \
G E N _ C P ( g c c p ) - > c p _ d e p _ f r = L O C A L _ t o p _ d e p _ f r ; \
G E N _ C P ( g c c p ) - > c p _ s g _ f r = S G _ F R ; \
/* a d j u s t f r e e z e r e g i s t e r s */ \
H _ F Z = H ; \
B _ F Z = g c c p ; \
T R _ F Z = T R ; \
s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( G E N _ C P ( g c c p ) , T A B _ E N T ) ; \
s e t _ c u t ( ( C E L L * ) g c c p , B ) ; \
B = g c c p ; \
Y A P O R _ S E T _ L O A D ( B ) ; \
S E T _ B B ( B ) ; \
T A B L I N G _ E R R O R _ C H E C K I N G _ S T A C K ; \
}
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-03-04 20:30:14 +00:00
# define r e s t o r e _ g e n e r a t o r _ n o d e ( A R I T Y , A P ) \
2001-04-09 20:54:03 +01:00
{ r e g i s t e r C E L L * p t _ a r g s , * x _ a r g s ; \
2005-04-07 18:56:58 +01:00
r e g i s t e r c h o i c e p t r g c p = B ; \
2001-04-09 20:54:03 +01:00
/* r e s t o r e g e n e r a t o r c h o i c e p o i n t */ \
2005-04-07 18:56:58 +01:00
H = H B R E G = P R O T E C T _ F R O Z E N _ H ( g c p ) ; \
r e s t o r e _ y a a m _ r e g _ c p d e p t h ( g c p ) ; \
C P R E G = g c p - > c p _ c p ; \
E N V = g c p - > c p _ e n v ; \
2001-04-09 20:54:03 +01:00
Y A P O R _ u p d a t e _ a l t e r n a t i v e ( P R E G , ( y a m o p * ) A P ) \
2005-04-07 18:56:58 +01:00
g c p - > c p _ a p = ( y a m o p * ) A P ; \
2001-04-09 20:54:03 +01:00
/* r e s t o r e a r g s */ \
2005-04-07 18:56:58 +01:00
p t _ a r g s = ( C E L L * ) ( G E N _ C P ( g c p ) + 1 ) + A R I T Y ; \
2001-04-09 20:54:03 +01:00
x _ a r g s = X R E G S + 1 + A R I T Y ; \
while ( x _ a r g s > X R E G S + 1 ) { \
r e g i s t e r C E L L x = p t _ a r g s [ - 1 ] ; \
- - x _ a r g s ; \
- - p t _ a r g s ; \
* x _ a r g s = x ; \
} \
}
2005-03-04 20:30:14 +00:00
# define p o p _ g e n e r a t o r _ n o d e ( A R I T Y ) \
{ r e g i s t e r C E L L * p t _ a r g s , * x _ a r g s ; \
2005-04-07 18:56:58 +01:00
r e g i s t e r c h o i c e p t r g c p = B ; \
2005-03-04 20:30:14 +00:00
/* p o p g e n e r a t o r c h o i c e p o i n t */ \
2005-04-07 18:56:58 +01:00
H = P R O T E C T _ F R O Z E N _ H ( g c p ) ; \
p o p _ y a a m _ r e g _ c p d e p t h ( g c p ) ; \
C P R E G = g c p - > c p _ c p ; \
E N V = g c p - > c p _ e n v ; \
T R = g c p - > c p _ t r ; \
B = g c p - > c p _ b ; \
2005-03-04 20:30:14 +00:00
H B R E G = P R O T E C T _ F R O Z E N _ H ( B ) ; \
/* p o p a r g s */ \
x _ a r g s = X R E G S + 1 ; \
2005-04-07 18:56:58 +01:00
p t _ a r g s = ( C E L L * ) ( G E N _ C P ( g c p ) + 1 ) ; \
2005-03-04 20:30:14 +00:00
while ( x _ a r g s < X R E G S + 1 + A R I T Y ) { \
r e g i s t e r C E L L x = p t _ a r g s [ 0 ] ; \
p t _ a r g s + + ; \
x _ a r g s + + ; \
x _ a r g s [ - 1 ] = x ; \
} \
Y E N V = p t _ a r g s ; \
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) ) ; \
2001-04-09 20:54:03 +01:00
}
2011-12-22 16:50:20 +00:00
# define s t o r e _ c o n s u m e r _ n o d e ( T A B _ E N T , S G _ F R , L E A D E R _ C P , D E P _ O N _ S T A C K ) \
{ r e g i s t e r c h o i c e p t r c c p ; \
r e g i s t e r d e p _ f r _ p t r n e w _ d e p _ f r ; \
/* i n i t i a l i z e c c p */ \
Y E N V = ( C E L L * ) ( C O N S _ C P ( Y E N V ) - 1 ) ; \
c c p = N O R M _ C P ( Y E N V ) ; \
/* a d j u s t f r e e z e r e g i s t e r s */ \
H _ F Z = H ; \
B _ F Z = c c p ; \
T R _ F Z = T R ; \
/* s t o r e d e p e n d e n c y f r a m e */ \
n e w _ d e p e n d e n c y _ f r a m e ( n e w _ d e p _ f r , D E P _ O N _ S T A C K , L O C A L _ t o p _ o r _ f r , \
L E A D E R _ C P , c c p , S G _ F R , FALSE , L O C A L _ t o p _ d e p _ f r ) ; \
L O C A L _ t o p _ d e p _ f r = n e w _ d e p _ f r ; \
/* s t o r e c o n s u m e r c h o i c e p o i n t */ \
H B R E G = H ; \
s t o r e _ y a a m _ r e g _ c p d e p t h ( c c p ) ; \
c c p - > c p _ t r = T R ; \
c c p - > c p _ a p = A N S W E R _ R E S O L U T I O N ; \
c c p - > c p _ h = H ; \
c c p - > c p _ b = B ; \
c c p - > c p _ e n v = E N V ; \
c c p - > c p _ c p = C P R E G ; \
C O N S _ C P ( c c p ) - > c p _ d e p _ f r = L O C A L _ t o p _ d e p _ f r ; \
s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( C O N S _ C P ( c c p ) , T A B _ E N T ) ; \
/* s e t _ c u t ( ( C E L L * ) c c p , B ) ; - - > n o e f f e c t */ \
B = c c p ; \
Y A P O R _ S E T _ L O A D ( B ) ; \
S E T _ B B ( B ) ; \
T A B L I N G _ E R R O R _ C H E C K I N G _ S T A C K ; \
2001-04-09 20:54:03 +01:00
}
2005-07-06 20:34:12 +01:00
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
# define c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( D E P _ F R , A N S W E R ) \
{ C E L L * s u b s _ p t r ; \
/* r e s t o r e c o n s u m e r c h o i c e p o i n t */ \
H = H B R E G = P R O T E C T _ F R O Z E N _ H ( B ) ; \
r e s t o r e _ y a a m _ r e g _ c p d e p t h ( B ) ; \
C P R E G = B - > c p _ c p ; \
E N V = B - > c p _ e n v ; \
/* s e t _ c u t ( Y E N V , B - > c p _ b ) ; - - > n o e f f e c t */ \
P R E G = ( y a m o p * ) C P R E G ; \
P R E F E T C H _ O P ( P R E G ) ; \
/* l o a d a n s w e r f r o m t a b l e t o g l o b a l s t a c k */ \
if ( B = = D e p F r _ l e a d e r _ c p ( D E P _ F R ) | | D e p F r _ e x t e r n a l ( D E P _ F R ) ) { \
/* B i s a g e n e r a t o r - c o n s u m e r n o d e */ \
T A B L I N G _ E R R O R _ C H E C K I N G ( g e n e r a t o r _ c o n s u m e r , I S _ B A T C H E D _ G E N _ C P ( B ) ) ; \
s u b s _ p t r = ( C E L L * ) ( G E N _ C P ( B ) + 1 ) ; \
s u b s _ p t r + = S g F r _ a r i t y ( G E N _ C P ( B ) - > c p _ s g _ f r ) ; \
} else { \
s u b s _ p t r = ( C E L L * ) ( C O N S _ C P ( B ) + 1 ) ; \
} \
l o a d _ a n s w e r ( A N S W E R , s u b s _ p t r ) ; \
/* p r o c c e e d */ \
Y E N V = E N V ; \
G O N e x t ( ) ; \
}
# else
2010-04-18 04:59:11 +01:00
# define c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( D E P _ F R , A N S W E R ) \
{ C E L L * s u b s _ p t r ; \
/* r e s t o r e c o n s u m e r c h o i c e p o i n t */ \
H = H B R E G = P R O T E C T _ F R O Z E N _ H ( B ) ; \
r e s t o r e _ y a a m _ r e g _ c p d e p t h ( B ) ; \
C P R E G = B - > c p _ c p ; \
E N V = B - > c p _ e n v ; \
/* s e t _ c u t ( Y E N V , B - > c p _ b ) ; - - > n o e f f e c t */ \
P R E G = ( y a m o p * ) C P R E G ; \
P R E F E T C H _ O P ( P R E G ) ; \
/* l o a d a n s w e r f r o m t a b l e t o g l o b a l s t a c k */ \
if ( B = = D e p F r _ l e a d e r _ c p ( D E P _ F R ) ) { \
/* B i s a g e n e r a t o r - c o n s u m e r n o d e */ \
/* n e v e r h e r e i f b a t c h e d s c h e d u l i n g */ \
T A B L I N G _ E R R O R _ C H E C K I N G ( g e n e r a t o r _ c o n s u m e r , I S _ B A T C H E D _ G E N _ C P ( B ) ) ; \
s u b s _ p t r = ( C E L L * ) ( G E N _ C P ( B ) + 1 ) ; \
s u b s _ p t r + = S g F r _ a r i t y ( G E N _ C P ( B ) - > c p _ s g _ f r ) ; \
} else { \
s u b s _ p t r = ( C E L L * ) ( C O N S _ C P ( B ) + 1 ) ; \
} \
l o a d _ a n s w e r ( A N S W E R , s u b s _ p t r ) ; \
/* p r o c c e e d */ \
Y E N V = E N V ; \
G O N e x t ( ) ; \
2001-04-09 20:54:03 +01:00
}
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2001-04-09 20:54:03 +01:00
2005-07-06 20:34:12 +01:00
# define s t o r e _ l o a d e r _ n o d e ( T A B _ E N T , A N S W E R ) \
{ r e g i s t e r c h o i c e p t r l c p ; \
/* i n i t i a l i z e l c p */ \
l c p = N O R M _ C P ( L O A D _ C P ( Y E N V ) - 1 ) ; \
/* s t o r e l o a d e r c h o i c e p o i n t */ \
H B R E G = H ; \
s t o r e _ y a a m _ r e g _ c p d e p t h ( l c p ) ; \
l c p - > c p _ t r = T R ; \
l c p - > c p _ a p = L O A D _ A N S W E R ; \
l c p - > c p _ h = H ; \
l c p - > c p _ b = B ; \
l c p - > c p _ e n v = E N V ; \
l c p - > c p _ c p = C P R E G ; \
L O A D _ C P ( l c p ) - > c p _ l a s t _ a n s w e r = A N S W E R ; \
s t o r e _ l o w _ l e v e l _ t r a c e _ i n f o ( L O A D _ C P ( l c p ) , T A B _ E N T ) ; \
/* s e t _ c u t ( ( C E L L * ) l c p , B ) ; - - > n o e f f e c t */ \
B = l c p ; \
Y A P O R _ S E T _ L O A D ( B ) ; \
S E T _ B B ( B ) ; \
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G _ S T A C K ; \
2005-07-06 20:34:12 +01:00
}
# define r e s t o r e _ l o a d e r _ n o d e ( A N S W E R ) \
H = H B R E G = P R O T E C T _ F R O Z E N _ H ( B ) ; \
r e s t o r e _ y a a m _ r e g _ c p d e p t h ( B ) ; \
C P R E G = B - > c p _ c p ; \
E N V = B - > c p _ e n v ; \
L O A D _ C P ( B ) - > c p _ l a s t _ a n s w e r = A N S W E R ; \
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) )
# define p o p _ l o a d e r _ n o d e ( ) \
H = P R O T E C T _ F R O Z E N _ H ( B ) ; \
p o p _ y a a m _ r e g _ c p d e p t h ( B ) ; \
C P R E G = B - > c p _ c p ; \
T A B L I N G _ c l o s e _ a l t ( B ) ; \
E N V = B - > c p _ e n v ; \
B = B - > c p _ b ; \
H B R E G = P R O T E C T _ F R O Z E N _ H ( B ) ; \
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) )
2001-11-16 20:27:06 +00:00
# i f def D E P T H _ L I M I T
2005-05-31 01:49:49 +01:00
# define a l l o c a t e _ e n v i r o n m e n t ( ) \
Y E N V [ E _ C P ] = ( C E L L ) C P R E G ; \
Y E N V [ E _ E ] = ( C E L L ) E N V ; \
Y E N V [ E _ B ] = ( C E L L ) B ; \
Y E N V [ E _ D E P T H ] = ( C E L L ) D E P T H ; \
E N V = Y E N V
2001-11-16 20:27:06 +00:00
# else
2005-05-31 01:49:49 +01:00
# define a l l o c a t e _ e n v i r o n m e n t ( ) \
Y E N V [ E _ C P ] = ( C E L L ) C P R E G ; \
Y E N V [ E _ E ] = ( C E L L ) E N V ; \
Y E N V [ E _ B ] = ( C E L L ) B ; \
E N V = Y E N V
# e n d i f /* D E P T H _ L I M I T */
2001-04-09 20:54:03 +01:00
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * c l a u s e _ w i t h _ c u t * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2001-04-09 20:54:03 +01:00
# i f def T A B L I N G _ I N N E R _ C U T S
O p ( c l a u s e _ w i t h _ c u t , e )
if ( L O C A L _ p r u n i n g _ s c o p e ) {
if ( Y O U N G E R _ C P ( L O C A L _ p r u n i n g _ s c o p e , B ) )
L O C A L _ p r u n i n g _ s c o p e = B ;
} else {
L O C A L _ p r u n i n g _ s c o p e = B ;
P U T _ I N _ P R U N I N G ( w o r k e r _ i d ) ;
}
P R E G = N E X T O P ( P R E G , e ) ;
G O N e x t ( ) ;
E N D O p ( ) ;
# e n d i f /* T A B L I N G _ I N N E R _ C U T S */
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ l o a d _ a n s w e r * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
P B O p ( t a b l e _ l o a d _ a n s w e r , O t a p l )
2005-08-01 16:40:39 +01:00
C E L L * s u b s _ p t r ;
a n s _ n o d e _ p t r a n s _ n o d e ;
# i f def Y A P O R
if ( S C H _ t o p _ s h a r e d _ c p ( B ) ) {
2010-01-14 17:38:39 +00:00
# if 0
2005-08-01 16:40:39 +01:00
P R O B L E M : c p _ l a s t _ a n s w e r field is l o c a l to t h e c p !
- > w e n e e d a shared d a t a s t r u c t u r e to a v o i d r e d u n d a n t c o m p u t a t i o n s !
U N L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
2010-01-14 17:38:39 +00:00
# else
2011-05-25 18:38:46 +01:00
S f p r i n t f ( S e r r o r , "PROBLEM: cp_last_answer field is local to the cp!\n" ) ;
2010-01-14 17:38:39 +00:00
e x i t ( 1 ) ;
# e n d i f
2005-08-01 16:40:39 +01:00
}
# e n d i f /* Y A P O R */
s u b s _ p t r = ( C E L L * ) ( L O A D _ C P ( B ) + 1 ) ;
a n s _ n o d e = T r N o d e _ c h i l d ( L O A D _ C P ( B ) - > c p _ l a s t _ a n s w e r ) ;
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ! = NULL ) {
r e s t o r e _ l o a d e r _ n o d e ( a n s _ n o d e ) ;
} else {
p o p _ l o a d e r _ n o d e ( ) ;
}
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , s u b s _ p t r ) ;
2005-08-01 16:40:39 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
E N D P B O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ t r y _ a n s w e r * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
P B O p ( t a b l e _ t r y _ a n s w e r , O t a p l )
2005-08-01 16:40:39 +01:00
# i f def I N C O M P L E T E _ T A B L I N G
s g _ f r _ p t r s g _ f r ;
a n s _ n o d e _ p t r a n s _ n o d e ;
s g _ f r = G E N _ C P ( B ) - > c p _ s g _ f r ;
a n s _ n o d e = T r N o d e _ c h i l d ( S g F r _ t r y _ a n s w e r ( s g _ f r ) ) ;
if ( a n s _ n o d e ) {
C E L L * s u b s _ p t r = ( C E L L * ) ( G E N _ C P ( B ) + 1 ) + S g F r _ a r i t y ( s g _ f r ) ;
H = H B R E G = P R O T E C T _ F R O Z E N _ H ( B ) ;
r e s t o r e _ y a a m _ r e g _ c p d e p t h ( B ) ;
C P R E G = B - > c p _ c p ;
E N V = B - > c p _ e n v ;
S g F r _ t r y _ a n s w e r ( s g _ f r ) = a n s _ n o d e ;
# i f def Y A P O R
if ( S C H _ t o p _ s h a r e d _ c p ( B ) )
U N L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
# e n d i f /* Y A P O R */
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) ) ;
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , s u b s _ p t r ) ;
2005-08-01 16:40:39 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
y a m o p * c o d e _ a p ;
P R E G = S g F r _ c o d e ( s g _ f r ) ;
2005-08-01 19:26:28 +01:00
if ( P R E G - > o p c = = Y a p _ o p c o d e ( _ t a b l e _ t r y ) ) {
2005-08-01 16:40:39 +01:00
/* t a b l e _ t r y */
2008-09-05 05:22:19 +01:00
c o d e _ a p = N E X T O P ( P R E G , O t a p l ) ;
P R E G = P R E G - > u . O t a p l . d ;
2005-08-01 19:26:28 +01:00
} else if ( P R E G - > o p c = = Y a p _ o p c o d e ( _ t a b l e _ t r y _ s i n g l e ) ) {
2005-08-01 16:40:39 +01:00
/* t a b l e _ t r y _ s i n g l e */
c o d e _ a p = C O M P L E T I O N ;
2008-09-05 05:22:19 +01:00
P R E G = P R E G - > u . O t a p l . d ;
2005-08-01 19:26:28 +01:00
} else {
/* t a b l e _ t r y _ m e */
2008-09-05 05:22:19 +01:00
c o d e _ a p = P R E G - > u . O t a p l . d ;
P R E G = N E X T O P ( P R E G , O t a p l ) ;
2005-08-01 16:40:39 +01:00
}
2006-01-17 14:10:42 +00:00
P R E F E T C H _ O P ( P R E G ) ;
2005-08-01 16:40:39 +01:00
r e s t o r e _ g e n e r a t o r _ n o d e ( S g F r _ a r i t y ( s g _ f r ) , c o d e _ a p ) ;
Y E N V = ( C E L L * ) P R O T E C T _ F R O Z E N _ B ( B ) ;
s e t _ c u t ( Y E N V , B - > c p _ b ) ;
S E T _ B B ( N O R M _ C P ( Y E N V ) ) ;
a l l o c a t e _ e n v i r o n m e n t ( ) ;
G O N e x t ( ) ;
}
2006-01-17 14:10:42 +00:00
# else
2008-09-05 05:22:19 +01:00
P R E G = P R E G - > u . O t a p l . d ;
2007-04-26 15:13:21 +01:00
P R E F E T C H _ O P ( P R E G ) ;
G O N e x t ( ) ;
2005-08-01 16:40:39 +01:00
# e n d i f /* I N C O M P L E T E _ T A B L I N G */
E N D P B O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ t r y _ s i n g l e * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
P B O p ( t a b l e _ t r y _ s i n g l e , O t a p l )
2001-04-09 20:54:03 +01:00
t a b _ e n t _ p t r t a b _ e n t ;
s g _ f r _ p t r s g _ f r ;
2005-08-05 15:55:03 +01:00
c h e c k _ t r a i l ( T R ) ;
2008-09-05 05:22:19 +01:00
t a b _ e n t = P R E G - > u . O t a p l . t e ;
2006-01-17 14:10:42 +00:00
Y E N V 2 M E M ;
s g _ f r = s u b g o a l _ s e a r c h ( P R E G , Y E N V _ A D D R E S S ) ;
M E M 2 Y E N V ;
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s t a t e ( s g _ f r ) < = r e a d y ) {
L O C K _ S G _ F R ( s g _ f r ) ;
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) > = complete )
S g F r _ s t a t e ( s g _ f r ) = S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) ;
else
S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) + + ;
U N L O C K _ S G _ F R ( s g _ f r ) ;
}
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2011-12-05 16:54:22 +00:00
L O C K _ S G _ F R ( s g _ f r ) ;
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
if ( S g F r _ s t a t e ( s g _ f r ) = = r e a d y _ e x t e r n a l ) {
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
s t o r e _ g e n e r a t o r _ c o n s u m e r _ n o d e ( t a b _ e n t , s g _ f r , TRUE , P R E G - > u . O t a p l . s ) ;
P R E F E T C H _ O P ( P R E G ) ;
a l l o c a t e _ e n v i r o n m e n t ( ) ;
c h e c k _ f o r _ d e a d l o c k ( s g _ f r ) ;
g o t o a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n ;
} else
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) = = r e a d y ) {
2005-08-01 16:40:39 +01:00
/* s u b g o a l n e w */
2005-04-07 18:56:58 +01:00
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2009-07-03 00:54:39 +01:00
# i f def D E T E R M I N I S T I C _ T A B L I N G
if ( I s M o d e _ B a t c h e d ( T a b E n t _ m o d e ( t a b _ e n t ) ) ) {
s t o r e _ d e t e r m i n i s t i c _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r ) ;
} else
# e n d i f /* D E T E R M I N I S T I C _ T A B L I N G */
{
s t o r e _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r , P R E G - > u . O t a p l . s , C O M P L E T I O N ) ;
}
2008-09-05 05:22:19 +01:00
P R E G = P R E G - > u . O t a p l . d ; /* s h o u l d w o r k a l s o w i t h P R E G = N E X T O P ( P R E G , O t a p l ) ; */
2001-04-09 20:54:03 +01:00
P R E F E T C H _ O P ( P R E G ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2001-04-09 20:54:03 +01:00
G O N e x t ( ) ;
2005-08-04 16:45:56 +01:00
# i f def I N C O M P L E T E _ T A B L I N G
} else if ( S g F r _ s t a t e ( s g _ f r ) = = i n c o m p l e t e ) {
/* s u b g o a l i n c o m p l e t e - - > s t a r t b y l o a d i n g t h e a n s w e r s a l r e a d y f o u n d */
a n s _ n o d e _ p t r a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
C E L L * s u b s _ p t r = Y E N V ;
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-08-04 16:45:56 +01:00
S g F r _ t r y _ a n s w e r ( s g _ f r ) = a n s _ n o d e ;
2008-09-05 05:22:19 +01:00
s t o r e _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r , P R E G - > u . O t a p l . s , T R Y _ A N S W E R ) ;
2005-08-04 16:45:56 +01:00
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , s u b s _ p t r ) ;
2005-08-04 16:45:56 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
# e n d i f /* I N C O M P L E T E _ T A B L I N G */
2005-04-07 18:56:58 +01:00
} else if ( S g F r _ s t a t e ( s g _ f r ) = = e v a l u a t i n g ) {
/* s u b g o a l i n e v a l u a t i o n */
c h o i c e p t r l e a d e r _ c p ;
int l e a d e r _ d e p _ o n _ s t a c k ;
f i n d _ d e p e n d e n c y _ n o d e ( s g _ f r , l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
f i n d _ l e a d e r _ n o d e ( l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2005-07-06 20:34:12 +01:00
s t o r e _ c o n s u m e r _ n o d e ( t a b _ e n t , s g _ f r , l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2005-04-07 18:56:58 +01:00
c h o i c e p t r a u x _ c p ;
a u x _ c p = B ;
2010-01-14 15:58:19 +00:00
while ( Y O U N G E R _ C P ( a u x _ c p , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) )
2005-04-07 18:56:58 +01:00
a u x _ c p = a u x _ c p - > c p _ b ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( t a b l e _ t r y _ s i n g l e , a u x _ c p - > c p _ o r _ f r ! = D e p F r _ t o p _ o r _ f r ( L O C A L _ t o p _ d e p _ f r ) ) ;
2005-04-07 18:56:58 +01:00
a u x _ c p = B ;
while ( Y O U N G E R _ C P ( a u x _ c p , D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) )
a u x _ c p = a u x _ c p - > c p _ b ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( t a b l e _ t r y _ s i n g l e , a u x _ c p ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) ;
2005-04-07 18:56:58 +01:00
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2005-04-07 18:56:58 +01:00
g o t o a n s w e r _ r e s o l u t i o n ;
} else {
/* s u b g o a l c o m p l e t e d */
2005-07-06 20:34:12 +01:00
a n s _ n o d e _ p t r a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
if ( a n s _ n o d e = = NULL ) {
2005-04-07 18:56:58 +01:00
/* n o a n s w e r s - - > f a i l */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
g o t o f a i l ;
2005-07-06 20:34:12 +01:00
} else if ( a n s _ n o d e = = S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) {
2005-04-07 18:56:58 +01:00
/* y e s a n s w e r - - > p r o c c e e d */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
2005-07-06 20:34:12 +01:00
/* a n s w e r s - > g e t f i r s t a n s w e r */
2005-08-04 16:45:56 +01:00
# i f def L I M I T _ T A B L I N G
if ( S g F r _ s t a t e ( s g _ f r ) = = complete | | S g F r _ s t a t e ( s g _ f r ) = = c o m p i l e d ) {
S g F r _ s t a t e ( s g _ f r ) + + ; /* c o m p l e t e - - > c o m p l e t e _ i n _ u s e : c o m p i l e d - - > c o m p i l e d _ i n _ u s e */
r e m o v e _ f r o m _ g l o b a l _ s g _ f r _ l i s t ( s g _ f r ) ;
T R A I L _ F R A M E ( s g _ f r ) ;
}
# e n d i f /* L I M I T _ T A B L I N G */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) | | S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) > 0 ) {
# else
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) ) {
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
/* l o a d a n s w e r s f r o m t h e t r i e */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ! = NULL ) {
s t o r e _ l o a d e r _ n o d e ( t a b _ e n t , a n s _ n o d e ) ;
}
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , Y E N V ) ;
2005-07-06 20:34:12 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
/* e x e c u t e c o m p i l e d c o d e f r o m t h e t r i e */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) < c o m p i l e d )
# else
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) < c o m p i l e d )
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
u p d a t e _ a n s w e r _ t r i e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
P R E G = ( y a m o p * ) T r N o d e _ c h i l d ( S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) ;
P R E F E T C H _ O P ( P R E G ) ;
* - - Y E N V = 0 ; /* v a r s _ a r i t y */
* - - Y E N V = 0 ; /* h e a p _ a r i t y */
G O N e x t ( ) ;
}
2001-04-09 20:54:03 +01:00
}
}
E N D P B O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ t r y _ m e * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
P B O p ( t a b l e _ t r y _ m e , O t a p l )
2001-04-09 20:54:03 +01:00
t a b _ e n t _ p t r t a b _ e n t ;
s g _ f r _ p t r s g _ f r ;
2005-08-05 15:55:03 +01:00
c h e c k _ t r a i l ( T R ) ;
2008-09-05 05:22:19 +01:00
t a b _ e n t = P R E G - > u . O t a p l . t e ;
2006-01-17 14:10:42 +00:00
Y E N V 2 M E M ;
s g _ f r = s u b g o a l _ s e a r c h ( P R E G , Y E N V _ A D D R E S S ) ;
M E M 2 Y E N V ;
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s t a t e ( s g _ f r ) < = r e a d y ) {
L O C K _ S G _ F R ( s g _ f r ) ;
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) > = complete )
S g F r _ s t a t e ( s g _ f r ) = S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) ;
else
S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) + + ;
U N L O C K _ S G _ F R ( s g _ f r ) ;
}
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2011-12-05 16:54:22 +00:00
L O C K _ S G _ F R ( s g _ f r ) ;
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
if ( S g F r _ s t a t e ( s g _ f r ) = = r e a d y _ e x t e r n a l ) {
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
U N L O C K _ S G _ F R ( s g _ f r ) ;
s t o r e _ g e n e r a t o r _ c o n s u m e r _ n o d e ( t a b _ e n t , s g _ f r , TRUE , P R E G - > u . O t a p l . s ) ;
P R E F E T C H _ O P ( P R E G ) ;
a l l o c a t e _ e n v i r o n m e n t ( ) ;
c h e c k _ f o r _ d e a d l o c k ( s g _ f r ) ;
g o t o a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n ;
} else
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) = = r e a d y ) {
2005-08-01 16:40:39 +01:00
/* s u b g o a l n e w */
2005-04-07 18:56:58 +01:00
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2008-09-05 05:22:19 +01:00
s t o r e _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r , P R E G - > u . O t a p l . s , P R E G - > u . O t a p l . d ) ;
P R E G = N E X T O P ( P R E G , O t a p l ) ;
2001-04-09 20:54:03 +01:00
P R E F E T C H _ O P ( P R E G ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2001-04-09 20:54:03 +01:00
G O N e x t ( ) ;
2005-08-04 16:45:56 +01:00
# i f def I N C O M P L E T E _ T A B L I N G
} else if ( S g F r _ s t a t e ( s g _ f r ) = = i n c o m p l e t e ) {
/* s u b g o a l i n c o m p l e t e - - > s t a r t b y l o a d i n g t h e a n s w e r s a l r e a d y f o u n d */
a n s _ n o d e _ p t r a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
C E L L * s u b s _ p t r = Y E N V ;
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-08-04 16:45:56 +01:00
S g F r _ t r y _ a n s w e r ( s g _ f r ) = a n s _ n o d e ;
2008-09-05 05:22:19 +01:00
s t o r e _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r , P R E G - > u . O t a p l . s , T R Y _ A N S W E R ) ;
2005-08-04 16:45:56 +01:00
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , s u b s _ p t r ) ;
2005-08-04 16:45:56 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
# e n d i f /* I N C O M P L E T E _ T A B L I N G */
2005-04-07 18:56:58 +01:00
} else if ( S g F r _ s t a t e ( s g _ f r ) = = e v a l u a t i n g ) {
/* s u b g o a l i n e v a l u a t i o n */
c h o i c e p t r l e a d e r _ c p ;
int l e a d e r _ d e p _ o n _ s t a c k ;
f i n d _ d e p e n d e n c y _ n o d e ( s g _ f r , l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
f i n d _ l e a d e r _ n o d e ( l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2005-07-06 20:34:12 +01:00
s t o r e _ c o n s u m e r _ n o d e ( t a b _ e n t , s g _ f r , l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2005-04-07 18:56:58 +01:00
c h o i c e p t r a u x _ c p ;
a u x _ c p = B ;
2010-01-14 15:58:19 +00:00
while ( Y O U N G E R _ C P ( a u x _ c p , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) )
2005-04-07 18:56:58 +01:00
a u x _ c p = a u x _ c p - > c p _ b ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( t a b l e _ t r y _ m e , a u x _ c p - > c p _ o r _ f r ! = D e p F r _ t o p _ o r _ f r ( L O C A L _ t o p _ d e p _ f r ) ) ;
2005-04-07 18:56:58 +01:00
a u x _ c p = B ;
while ( Y O U N G E R _ C P ( a u x _ c p , D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) )
a u x _ c p = a u x _ c p - > c p _ b ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( t a b l e _ t r y _ m e , a u x _ c p ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) ;
2005-04-07 18:56:58 +01:00
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2005-04-07 18:56:58 +01:00
g o t o a n s w e r _ r e s o l u t i o n ;
} else {
/* s u b g o a l c o m p l e t e d */
2005-07-06 20:34:12 +01:00
a n s _ n o d e _ p t r a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
if ( a n s _ n o d e = = NULL ) {
2005-04-07 18:56:58 +01:00
/* n o a n s w e r s - - > f a i l */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
g o t o f a i l ;
2006-05-02 09:01:27 +01:00
} else if ( a n s _ n o d e = = S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) {
2005-04-07 18:56:58 +01:00
/* y e s a n s w e r - - > p r o c c e e d */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
2005-07-06 20:34:12 +01:00
/* a n s w e r s - > g e t f i r s t a n s w e r */
2005-08-04 16:45:56 +01:00
# i f def L I M I T _ T A B L I N G
if ( S g F r _ s t a t e ( s g _ f r ) = = complete | | S g F r _ s t a t e ( s g _ f r ) = = c o m p i l e d ) {
S g F r _ s t a t e ( s g _ f r ) + + ; /* c o m p l e t e - - > c o m p l e t e _ i n _ u s e : c o m p i l e d - - > c o m p i l e d _ i n _ u s e */
r e m o v e _ f r o m _ g l o b a l _ s g _ f r _ l i s t ( s g _ f r ) ;
T R A I L _ F R A M E ( s g _ f r ) ;
}
# e n d i f /* L I M I T _ T A B L I N G */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) | | S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) > 0 ) {
# else
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) ) {
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
/* l o a d a n s w e r s f r o m t h e t r i e */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ! = NULL ) {
s t o r e _ l o a d e r _ n o d e ( t a b _ e n t , a n s _ n o d e ) ;
}
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , Y E N V ) ;
2005-07-06 20:34:12 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
/* e x e c u t e c o m p i l e d c o d e f r o m t h e t r i e */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) < c o m p i l e d )
# else
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) < c o m p i l e d )
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
u p d a t e _ a n s w e r _ t r i e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
P R E G = ( y a m o p * ) T r N o d e _ c h i l d ( S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) ;
P R E F E T C H _ O P ( P R E G ) ;
* - - Y E N V = 0 ; /* v a r s _ a r i t y */
* - - Y E N V = 0 ; /* h e a p _ a r i t y */
G O N e x t ( ) ;
}
2001-04-09 20:54:03 +01:00
}
}
E N D P B O p ( ) ;
2005-06-03 09:19:18 +01:00
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ t r y * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
P B O p ( t a b l e _ t r y , O t a p l )
2003-12-18 16:38:40 +00:00
t a b _ e n t _ p t r t a b _ e n t ;
s g _ f r _ p t r s g _ f r ;
2005-08-05 15:55:03 +01:00
c h e c k _ t r a i l ( T R ) ;
2008-09-05 05:22:19 +01:00
t a b _ e n t = P R E G - > u . O t a p l . t e ;
2006-01-17 14:10:42 +00:00
Y E N V 2 M E M ;
s g _ f r = s u b g o a l _ s e a r c h ( P R E G , Y E N V _ A D D R E S S ) ;
M E M 2 Y E N V ;
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s t a t e ( s g _ f r ) < = r e a d y ) {
L O C K _ S G _ F R ( s g _ f r ) ;
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) > = complete )
S g F r _ s t a t e ( s g _ f r ) = S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) ;
else
S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) + + ;
U N L O C K _ S G _ F R ( s g _ f r ) ;
}
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2011-12-05 16:54:22 +00:00
L O C K _ S G _ F R ( s g _ f r ) ;
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
if ( S g F r _ s t a t e ( s g _ f r ) = = r e a d y _ e x t e r n a l ) {
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
U N L O C K _ S G _ F R ( s g _ f r ) ;
s t o r e _ g e n e r a t o r _ c o n s u m e r _ n o d e ( t a b _ e n t , s g _ f r , TRUE , P R E G - > u . O t a p l . s ) ;
P R E F E T C H _ O P ( P R E G ) ;
a l l o c a t e _ e n v i r o n m e n t ( ) ;
c h e c k _ f o r _ d e a d l o c k ( s g _ f r ) ;
g o t o a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n ;
} else
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) = = r e a d y ) {
2005-08-01 16:40:39 +01:00
/* s u b g o a l n e w */
2005-04-07 18:56:58 +01:00
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2008-09-05 05:22:19 +01:00
s t o r e _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r , P R E G - > u . O t a p l . s , N E X T O P ( P R E G , O t a p l ) ) ;
P R E G = P R E G - > u . O t a p l . d ;
2003-12-18 16:38:40 +00:00
P R E F E T C H _ O P ( P R E G ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2003-12-18 16:38:40 +00:00
G O N e x t ( ) ;
2005-08-04 16:45:56 +01:00
# i f def I N C O M P L E T E _ T A B L I N G
} else if ( S g F r _ s t a t e ( s g _ f r ) = = i n c o m p l e t e ) {
/* s u b g o a l i n c o m p l e t e - - > s t a r t b y l o a d i n g t h e a n s w e r s a l r e a d y f o u n d */
a n s _ n o d e _ p t r a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
C E L L * s u b s _ p t r = Y E N V ;
i n i t _ s u b g o a l _ f r a m e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-08-04 16:45:56 +01:00
S g F r _ t r y _ a n s w e r ( s g _ f r ) = a n s _ n o d e ;
2008-09-05 05:22:19 +01:00
s t o r e _ g e n e r a t o r _ n o d e ( t a b _ e n t , s g _ f r , P R E G - > u . O t a p l . s , T R Y _ A N S W E R ) ;
2005-08-04 16:45:56 +01:00
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , s u b s _ p t r ) ;
2005-08-04 16:45:56 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
# e n d i f /* I N C O M P L E T E _ T A B L I N G */
2005-04-07 18:56:58 +01:00
} else if ( S g F r _ s t a t e ( s g _ f r ) = = e v a l u a t i n g ) {
/* s u b g o a l i n e v a l u a t i o n */
c h o i c e p t r l e a d e r _ c p ;
int l e a d e r _ d e p _ o n _ s t a c k ;
f i n d _ d e p e n d e n c y _ n o d e ( s g _ f r , l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
f i n d _ l e a d e r _ n o d e ( l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2005-07-06 20:34:12 +01:00
s t o r e _ c o n s u m e r _ n o d e ( t a b _ e n t , s g _ f r , l e a d e r _ c p , l e a d e r _ d e p _ o n _ s t a c k ) ;
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2005-04-07 18:56:58 +01:00
c h o i c e p t r a u x _ c p ;
a u x _ c p = B ;
2010-01-14 15:58:19 +00:00
while ( Y O U N G E R _ C P ( a u x _ c p , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) )
2005-04-07 18:56:58 +01:00
a u x _ c p = a u x _ c p - > c p _ b ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( t a b l e _ t r y , a u x _ c p - > c p _ o r _ f r ! = D e p F r _ t o p _ o r _ f r ( L O C A L _ t o p _ d e p _ f r ) ) ;
2005-04-07 18:56:58 +01:00
a u x _ c p = B ;
while ( Y O U N G E R _ C P ( a u x _ c p , D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) )
a u x _ c p = a u x _ c p - > c p _ b ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( t a b l e _ t r y , a u x _ c p ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) ;
2005-04-07 18:56:58 +01:00
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2005-04-07 18:56:58 +01:00
g o t o a n s w e r _ r e s o l u t i o n ;
} else {
/* s u b g o a l c o m p l e t e d */
2005-07-06 20:34:12 +01:00
a n s _ n o d e _ p t r a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
if ( a n s _ n o d e = = NULL ) {
2005-04-07 18:56:58 +01:00
/* n o a n s w e r s - - > f a i l */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
g o t o f a i l ;
2006-05-02 09:01:27 +01:00
} else if ( a n s _ n o d e = = S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) {
2005-04-07 18:56:58 +01:00
/* y e s a n s w e r - - > p r o c c e e d */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
2005-07-06 20:34:12 +01:00
/* a n s w e r s - > g e t f i r s t a n s w e r */
2005-08-04 16:45:56 +01:00
# i f def L I M I T _ T A B L I N G
if ( S g F r _ s t a t e ( s g _ f r ) = = complete | | S g F r _ s t a t e ( s g _ f r ) = = c o m p i l e d ) {
S g F r _ s t a t e ( s g _ f r ) + + ; /* c o m p l e t e - - > c o m p l e t e _ i n _ u s e : c o m p i l e d - - > c o m p i l e d _ i n _ u s e */
r e m o v e _ f r o m _ g l o b a l _ s g _ f r _ l i s t ( s g _ f r ) ;
T R A I L _ F R A M E ( s g _ f r ) ;
}
# e n d i f /* L I M I T _ T A B L I N G */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) | | S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) > 0 ) {
# else
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) ) {
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
/* l o a d a n s w e r s f r o m t h e t r i e */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ! = NULL ) {
s t o r e _ l o a d e r _ n o d e ( t a b _ e n t , a n s _ n o d e ) ;
}
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , Y E N V ) ;
2005-07-06 20:34:12 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
/* e x e c u t e c o m p i l e d c o d e f r o m t h e t r i e */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) < c o m p i l e d )
# else
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) < c o m p i l e d )
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
u p d a t e _ a n s w e r _ t r i e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
P R E G = ( y a m o p * ) T r N o d e _ c h i l d ( S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) ;
P R E F E T C H _ O P ( P R E G ) ;
* - - Y E N V = 0 ; /* v a r s _ a r i t y */
* - - Y E N V = 0 ; /* h e a p _ a r i t y */
G O N e x t ( ) ;
}
2003-12-18 16:38:40 +00:00
}
}
E N D P B O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ r e t r y _ m e * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
O p ( t a b l e _ r e t r y _ m e , O t a p l )
r e s t o r e _ g e n e r a t o r _ n o d e ( P R E G - > u . O t a p l . s , P R E G - > u . O t a p l . d ) ;
2003-12-18 16:38:40 +00:00
Y E N V = ( C E L L * ) P R O T E C T _ F R O Z E N _ B ( B ) ;
s e t _ c u t ( Y E N V , B - > c p _ b ) ;
S E T _ B B ( N O R M _ C P ( Y E N V ) ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2008-09-05 05:22:19 +01:00
P R E G = N E X T O P ( P R E G , O t a p l ) ;
2003-12-18 16:38:40 +00:00
G O N e x t ( ) ;
E N D O p ( ) ;
2001-04-09 20:54:03 +01:00
2005-06-03 09:19:18 +01:00
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ r e t r y * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
O p ( t a b l e _ r e t r y , O t a p l )
r e s t o r e _ g e n e r a t o r _ n o d e ( P R E G - > u . O t a p l . s , N E X T O P ( P R E G , O t a p l ) ) ;
2002-11-26 22:19:48 +00:00
Y E N V = ( C E L L * ) P R O T E C T _ F R O Z E N _ B ( B ) ;
s e t _ c u t ( Y E N V , B - > c p _ b ) ;
S E T _ B B ( N O R M _ C P ( Y E N V ) ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2008-09-05 05:22:19 +01:00
P R E G = P R E G - > u . O t a p l . d ;
2001-04-09 20:54:03 +01:00
G O N e x t ( ) ;
E N D O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ t r u s t _ m e * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
O p ( t a b l e _ t r u s t _ m e , O t a p l )
r e s t o r e _ g e n e r a t o r _ n o d e ( P R E G - > u . O t a p l . s , C O M P L E T I O N ) ;
2009-07-03 00:54:39 +01:00
# i f def D E T E R M I N I S T I C _ T A B L I N G
if ( B _ F Z > B && IS_BATCHED_NORM_GEN_CP(B)) {
C E L L * s u b s _ p t r = ( C E L L * ) ( G E N _ C P ( B ) + 1 ) + P R E G - > u . O t a p l . s ;
c h o i c e p t r g c p = N O R M _ C P ( D E T _ G E N _ C P ( s u b s _ p t r ) - 1 ) ;
s g _ f r _ p t r s g _ f r = G E N _ C P ( B ) - > c p _ s g _ f r ;
D E T _ G E N _ C P ( g c p ) - > c p _ s g _ f r = s g _ f r ;
2009-08-09 03:38:07 +01:00
g c p - > c p _ h = B - > c p _ h ;
2009-07-03 00:54:39 +01:00
# i f def D E P T H _ L I M I T
g c p - > c p _ d e p t h = B - > c p _ d e p t h ;
# e n d i f /* D E P T H _ L I M I T */
g c p - > c p _ t r = B - > c p _ t r ;
g c p - > c p _ b = B - > c p _ b ;
g c p - > c p _ a p = B - > c p _ a p ;
S g F r _ g e n _ c p ( s g _ f r ) = B = g c p ;
}
# e n d i f /* D E T E R M I N I S T I C _ T A B L I N G */
2002-11-26 22:19:48 +00:00
Y E N V = ( C E L L * ) P R O T E C T _ F R O Z E N _ B ( B ) ;
s e t _ c u t ( Y E N V , B - > c p _ b ) ;
S E T _ B B ( N O R M _ C P ( Y E N V ) ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2008-09-05 05:22:19 +01:00
P R E G = N E X T O P ( P R E G , O t a p l ) ;
2001-04-09 20:54:03 +01:00
G O N e x t ( ) ;
E N D O p ( ) ;
2005-06-03 09:19:18 +01:00
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ t r u s t * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
O p ( t a b l e _ t r u s t , O t a p l )
r e s t o r e _ g e n e r a t o r _ n o d e ( P R E G - > u . O t a p l . s , C O M P L E T I O N ) ;
2009-07-03 00:54:39 +01:00
# i f def D E T E R M I N I S T I C _ T A B L I N G
if ( B _ F Z > B && IS_BATCHED_NORM_GEN_CP(B)) {
C E L L * s u b s _ p t r = ( C E L L * ) ( G E N _ C P ( B ) + 1 ) + P R E G - > u . O t a p l . s ;
c h o i c e p t r g c p = N O R M _ C P ( D E T _ G E N _ C P ( s u b s _ p t r ) - 1 ) ;
s g _ f r _ p t r s g _ f r = G E N _ C P ( B ) - > c p _ s g _ f r ;
D E T _ G E N _ C P ( g c p ) - > c p _ s g _ f r = s g _ f r ;
2009-08-09 03:38:07 +01:00
g c p - > c p _ h = B - > c p _ h ;
2009-07-03 00:54:39 +01:00
# i f def D E P T H _ L I M I T
g c p - > c p _ d e p t h = B - > c p _ d e p t h ;
# e n d i f /* D E P T H _ L I M I T */
g c p - > c p _ t r = B - > c p _ t r ;
g c p - > c p _ b = B - > c p _ b ;
g c p - > c p _ a p = B - > c p _ a p ;
S g F r _ g e n _ c p ( s g _ f r ) = B = g c p ;
}
# e n d i f /* D E T E R M I N I S T I C _ T A B L I N G */
2003-12-18 16:38:40 +00:00
Y E N V = ( C E L L * ) P R O T E C T _ F R O Z E N _ B ( B ) ;
s e t _ c u t ( Y E N V , B - > c p _ b ) ;
S E T _ B B ( N O R M _ C P ( Y E N V ) ) ;
2005-05-31 01:49:49 +01:00
a l l o c a t e _ e n v i r o n m e n t ( ) ;
2008-09-05 05:22:19 +01:00
P R E G = P R E G - > u . O t a p l . d ;
2003-12-18 16:38:40 +00:00
G O N e x t ( ) ;
E N D O p ( ) ;
2001-04-09 20:54:03 +01:00
2005-06-03 09:19:18 +01:00
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ n e w _ a n s w e r * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2001-04-09 20:54:03 +01:00
P B O p ( t a b l e _ n e w _ a n s w e r , s )
C E L L * s u b s _ p t r ;
2005-04-07 18:56:58 +01:00
c h o i c e p t r g c p ;
2001-04-09 20:54:03 +01:00
s g _ f r _ p t r s g _ f r ;
a n s _ n o d e _ p t r a n s _ n o d e ;
2005-04-07 18:56:58 +01:00
g c p = N O R M _ C P ( Y E N V [ E _ B ] ) ;
2009-07-03 00:54:39 +01:00
# i f def D E T E R M I N I S T I C _ T A B L I N G
if ( I S _ D E T _ G E N _ C P ( g c p ) ) {
s g _ f r = D E T _ G E N _ C P ( g c p ) - > c p _ s g _ f r ;
s u b s _ p t r = ( C E L L * ) ( D E T _ G E N _ C P ( g c p ) + 1 ) ;
} else
# e n d i f /* D E T E R M I N I S T I C _ T A B L I N G */
{
s g _ f r = G E N _ C P ( g c p ) - > c p _ s g _ f r ;
s u b s _ p t r = ( C E L L * ) ( G E N _ C P ( g c p ) + 1 ) + P R E G - > u . s . s ;
}
2010-04-18 04:59:11 +01:00
# if defined ( D E B U G _ T A B L I N G ) && !defined(DETERMINISTIC_TABLING)
2001-04-09 20:54:03 +01:00
{
int i , j , a r i t y _ a r g s , a r i t y _ s u b s ;
C E L L * a u x _ a r g s ;
C E L L * a u x _ s u b s ;
a r i t y _ a r g s = P R E G - > u . s . s ;
a r i t y _ s u b s = * s u b s _ p t r ;
2005-04-07 18:56:58 +01:00
a u x _ a r g s = ( C E L L * ) ( G E N _ C P ( g c p ) + 1 ) ;
2001-04-09 20:54:03 +01:00
a u x _ s u b s = s u b s _ p t r ;
for ( i = 1 ; i < = a r i t y _ s u b s ; i + + ) {
Term t e r m _ s u b s = D e r e f ( * ( a u x _ s u b s + i ) ) ;
for ( j = 0 ; j < a r i t y _ a r g s ; j + + ) {
Term t e r m _ a r g = D e r e f ( * ( a u x _ a r g s + j ) ) ;
if ( t e r m _ s u b s = = t e r m _ a r g ) break ;
}
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( t a b l e _ n e w _ a n s w e r , j = = a r i t y _ a r g s ) ;
2001-04-09 20:54:03 +01:00
}
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ T A B L I N G & & ! D E T E R M I N I S T I C _ T A B L I N G */
2011-11-15 16:57:51 +00:00
L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
2011-10-22 16:49:13 +01:00
# i f def M O D E _ D I R E C T E D _ T A B L I N G
2011-11-15 16:57:51 +00:00
if ( S g F r _ m o d e _ d i r e c t e d ( s g _ f r ) ) {
a n s _ n o d e = m o d e _ d i r e c t e d _ a n s w e r _ s e a r c h ( s g _ f r , s u b s _ p t r ) ;
if ( a n s _ n o d e = = NULL ) {
/* n o a n s w e r i n s e r t e d */
U N L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
g o t o f a i l ;
}
} else
2011-11-09 11:00:31 +00:00
# e n d i f /* M O D E _ D I R E C T E D _ T A B L I N G */
2011-11-15 16:57:51 +00:00
a n s _ n o d e = a n s w e r _ s e a r c h ( s g _ f r , s u b s _ p t r ) ;
L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
2001-04-09 20:54:03 +01:00
if ( ! I S _ A N S W E R _ L E A F _ N O D E ( a n s _ n o d e ) ) {
/* n e w a n s w e r */
# i f def T A B L I N G _ I N N E R _ C U T S
/* c h e c k f o r p o t e n c i a l p r u n i n g s */
2011-05-10 11:47:18 +01:00
if ( ! B I T M A P _ e m p t y ( G L O B A L _ b m _ p r u n i n g _ w o r k e r s ) ) {
2001-04-09 20:54:03 +01:00
int u n t i l _ d e p t h , d e p t h ;
u n t i l _ d e p t h = O r F r _ d e p t h ( S g F r _ g e n _ t o p _ o r _ f r ( s g _ f r ) ) ;
d e p t h = O r F r _ d e p t h ( L O C A L _ t o p _ o r _ f r ) ;
if ( d e p t h > u n t i l _ d e p t h ) {
int i , l t t ;
b i t m a p p r u n e _ m e m b e r s , m e m b e r s ;
o r _ f r _ p t r l e f t m o s t _ o r _ f r , o r _ f r , n e a r e s t _ o r _ f r ;
2011-05-10 11:47:18 +01:00
B I T M A P _ c o p y ( p r u n e _ m e m b e r s , G L O B A L _ b m _ p r u n i n g _ w o r k e r s ) ;
2001-04-09 20:54:03 +01:00
B I T M A P _ d e l e t e ( p r u n e _ m e m b e r s , w o r k e r _ i d ) ;
l t t = B R A N C H _ L T T ( w o r k e r _ i d , d e p t h ) ;
B I T M A P _ i n t e r s e c t i o n ( m e m b e r s , p r u n e _ m e m b e r s , O r F r _ m e m b e r s ( L O C A L _ t o p _ o r _ f r ) ) ;
if ( m e m b e r s ) {
2011-05-10 11:47:18 +01:00
for ( i = 0 ; i < G L O B A L _ n u m b e r _ w o r k e r s ; i + + ) {
2001-04-09 20:54:03 +01:00
if ( B I T M A P _ m e m b e r ( m e m b e r s , i ) &&
B R A N C H _ L T T ( i , d e p t h ) > l t t &&
2010-01-14 15:58:19 +00:00
E Q U A L _ O R _ Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , R E M O T E _ p r u n i n g _ s c o p e ( i ) ) ) {
2001-04-09 20:54:03 +01:00
l e f t m o s t _ o r _ f r = L O C A L _ t o p _ o r _ f r ;
p e n d i n g _ t a b l e _ n e w _ a n s w e r :
2011-11-15 16:57:51 +00:00
U N L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
U N L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
2001-04-09 20:54:03 +01:00
L O C K _ O R _ F R A M E ( l e f t m o s t _ o r _ f r ) ;
2010-01-27 11:01:28 +00:00
if ( G e t _ L O C A L _ p r u n e _ r e q u e s t ( ) ) {
2001-04-09 20:54:03 +01:00
U N L O C K _ O R _ F R A M E ( l e f t m o s t _ o r _ f r ) ;
S C H E D U L E R _ G E T _ W O R K ( ) ;
} else {
2005-04-07 18:56:58 +01:00
C U T _ s t o r e _ t g _ a n s w e r ( l e f t m o s t _ o r _ f r , a n s _ n o d e , g c p , l t t ) ;
2001-04-09 20:54:03 +01:00
U N L O C K _ O R _ F R A M E ( l e f t m o s t _ o r _ f r ) ;
}
2005-04-07 18:56:58 +01:00
if ( I S _ B A T C H E D _ G E N _ C P ( g c p ) ) {
/* d e a l l o c a t e a n d p r o c c e e d */
P R E G = ( y a m o p * ) Y E N V [ E _ C P ] ;
P R E F E T C H _ O P ( P R E G ) ;
C P R E G = P R E G ;
S R E G = Y E N V ;
E N V = Y E N V = ( C E L L * ) Y E N V [ E _ E ] ;
2005-05-31 01:49:49 +01:00
# i f def D E P T H _ L I M I T
D E P T H = Y E N V [ E _ D E P T H ] ;
# e n d i f /* D E P T H _ L I M I T */
2005-04-07 18:56:58 +01:00
G O N e x t ( ) ;
} else {
/* f a i l */
g o t o f a i l ;
}
2001-04-09 20:54:03 +01:00
}
}
B I T M A P _ m i n u s ( p r u n e _ m e m b e r s , m e m b e r s ) ;
}
l e f t m o s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( L O C A L _ t o p _ o r _ f r ) ;
d e p t h = O r F r _ d e p t h ( l e f t m o s t _ o r _ f r ) ;
if ( d e p t h > u n t i l _ d e p t h ) {
l t t = B R A N C H _ L T T ( w o r k e r _ i d , d e p t h ) ;
B I T M A P _ i n t e r s e c t i o n ( m e m b e r s , p r u n e _ m e m b e r s , O r F r _ m e m b e r s ( l e f t m o s t _ o r _ f r ) ) ;
if ( m e m b e r s ) {
2011-05-10 11:47:18 +01:00
for ( i = 0 ; i < G L O B A L _ n u m b e r _ w o r k e r s ; i + + ) {
2001-04-09 20:54:03 +01:00
if ( B I T M A P _ m e m b e r ( m e m b e r s , i ) &&
B R A N C H _ L T T ( i , d e p t h ) > l t t &&
2010-01-14 17:38:39 +00:00
E Q U A L _ O R _ Y O U N G E R _ C P ( G e t O r F r _ n o d e ( l e f t m o s t _ o r _ f r ) , R E M O T E _ p r u n i n g _ s c o p e ( i ) ) )
2001-04-09 20:54:03 +01:00
g o t o p e n d i n g _ t a b l e _ n e w _ a n s w e r ;
}
B I T M A P _ m i n u s ( p r u n e _ m e m b e r s , m e m b e r s ) ;
}
/* r e a c h i n g t h a t p o i n t w e s h o u l d u p d a t e t h e n e a r e s t l e f t n o d e d a t a */
l e f t m o s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( l e f t m o s t _ o r _ f r ) ;
d e p t h = O r F r _ d e p t h ( l e f t m o s t _ o r _ f r ) ;
while ( d e p t h > u n t i l _ d e p t h ) {
l t t = B R A N C H _ L T T ( w o r k e r _ i d , d e p t h ) ;
B I T M A P _ i n t e r s e c t i o n ( m e m b e r s , p r u n e _ m e m b e r s , O r F r _ m e m b e r s ( l e f t m o s t _ o r _ f r ) ) ;
if ( m e m b e r s ) {
2011-05-10 11:47:18 +01:00
for ( i = 0 ; i < G L O B A L _ n u m b e r _ w o r k e r s ; i + + ) {
2001-04-09 20:54:03 +01:00
if ( B I T M A P _ m e m b e r ( m e m b e r s , i ) &&
B R A N C H _ L T T ( i , d e p t h ) > l t t &&
2010-01-14 17:38:39 +00:00
E Q U A L _ O R _ Y O U N G E R _ C P ( G e t O r F r _ n o d e ( l e f t m o s t _ o r _ f r ) , R E M O T E _ p r u n i n g _ s c o p e ( i ) ) ) {
2001-04-09 20:54:03 +01:00
/* u p d a t e n e a r e s t l e f t n o d e d a t a */
o r _ f r = L O C A L _ t o p _ o r _ f r ;
n e a r e s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( o r _ f r ) ;
while ( O r F r _ d e p t h ( n e a r e s t _ o r _ f r ) > d e p t h ) {
L O C K _ O R _ F R A M E ( o r _ f r ) ;
O r F r _ n e a r e s t _ l e f t n o d e ( o r _ f r ) = l e f t m o s t _ o r _ f r ;
U N L O C K _ O R _ F R A M E ( o r _ f r ) ;
o r _ f r = n e a r e s t _ o r _ f r ;
n e a r e s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( o r _ f r ) ;
}
g o t o p e n d i n g _ t a b l e _ n e w _ a n s w e r ;
}
}
B I T M A P _ m i n u s ( p r u n e _ m e m b e r s , m e m b e r s ) ;
}
l e f t m o s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( l e f t m o s t _ o r _ f r ) ;
d e p t h = O r F r _ d e p t h ( l e f t m o s t _ o r _ f r ) ;
}
/* u p d a t e n e a r e s t l e f t n o d e d a t a */
o r _ f r = L O C A L _ t o p _ o r _ f r ;
n e a r e s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( o r _ f r ) ;
while ( O r F r _ d e p t h ( n e a r e s t _ o r _ f r ) > d e p t h ) {
L O C K _ O R _ F R A M E ( o r _ f r ) ;
O r F r _ n e a r e s t _ l e f t n o d e ( o r _ f r ) = l e f t m o s t _ o r _ f r ;
U N L O C K _ O R _ F R A M E ( o r _ f r ) ;
o r _ f r = n e a r e s t _ o r _ f r ;
n e a r e s t _ o r _ f r = O r F r _ n e a r e s t _ l e f t n o d e ( o r _ f r ) ;
}
}
}
}
/* c h e c k f o r p r u n e r e q u e s t s */
2010-01-27 11:01:28 +00:00
if ( G e t _ L O C A L _ p r u n e _ r e q u e s t ( ) ) {
2011-11-15 16:57:51 +00:00
U N L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
U N L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
2001-04-09 20:54:03 +01:00
S C H E D U L E R _ G E T _ W O R K ( ) ;
}
# e n d i f /* T A B L I N G _ I N N E R _ C U T S */
T A G _ A S _ A N S W E R _ L E A F _ N O D E ( a n s _ n o d e ) ;
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ F U L L _ S H A R I N G
I N F O _ T H R E A D S ( "new answer (1) sgfr=%p ans_node=%p" , S g F r _ s g _ e n t ( s g _ f r ) , a n s _ n o d e ) ;
if ( I s M o d e _ B a t c h e d ( T a b E n t _ m o d e ( S g F r _ t a b _ e n t ( s g _ f r ) ) ) ) {
A N S W E R _ L E A F _ N O D E _ I N S T R _ R E L A T I V E ( a n s _ n o d e ) ;
if ( w o r k e r _ i d < A N S W E R _ L E A F _ N O D E _ M A X _ T H R E A D S )
A N S W E R _ L E A F _ N O D E _ S E T _ W I D ( a n s _ n o d e , w o r k e r _ i d ) ;
}
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G */
2011-11-15 16:57:51 +00:00
U N L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
# i f n def A N S W E R _ T R I E _ L O C K _ A T _ E N T R Y _ L E V E L
2011-12-05 16:54:22 +00:00
L O C K _ S G _ F R ( s g _ f r ) ;
2011-11-15 16:57:51 +00:00
# e n d i f /* ! A N S W E R _ T R I E _ L O C K _ A T _ E N T R Y _ L E V E L */
2005-05-31 01:49:49 +01:00
if ( S g F r _ f i r s t _ a n s w e r ( s g _ f r ) = = NULL )
S g F r _ f i r s t _ a n s w e r ( s g _ f r ) = a n s _ n o d e ;
else
2001-04-09 20:54:03 +01:00
T r N o d e _ c h i l d ( S g F r _ l a s t _ a n s w e r ( s g _ f r ) ) = a n s _ n o d e ;
S g F r _ l a s t _ a n s w e r ( s g _ f r ) = a n s _ n o d e ;
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ T A B L I N G
2001-04-09 20:54:03 +01:00
{
a n s _ n o d e _ p t r a u x _ a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
while ( a u x _ a n s _ n o d e ! = S g F r _ l a s t _ a n s w e r ( s g _ f r ) ) {
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( t a b l e _ n e w _ a n s w e r , ! I S _ A N S W E R _ L E A F _ N O D E ( a u x _ a n s _ n o d e ) ) ;
2001-04-09 20:54:03 +01:00
a u x _ a n s _ n o d e = T r N o d e _ c h i l d ( a u x _ a n s _ n o d e ) ;
}
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ T A B L I N G */
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-04-07 18:56:58 +01:00
if ( I S _ B A T C H E D _ G E N _ C P ( g c p ) ) {
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ F U L L _ S H A R I N G
if ( w o r k e r _ i d > = A N S W E R _ L E A F _ N O D E _ M A X _ T H R E A D S )
S g F r _ b a t c h e d _ c a c h e d _ a n s w e r s _ c h e c k _ i n s e r t ( s g _ f r , a n s _ n o d e ) ; //add to buffer all answers except the ans_node
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G */
2009-08-06 02:27:59 +01:00
# i f def T A B L I N G _ E A R L Y _ C O M P L E T I O N
2009-08-08 03:53:51 +01:00
if ( g c p = = P R O T E C T _ F R O Z E N _ B ( B ) && (*subs_ptr == 0 || gcp->cp_ap == COMPLETION)) {
/* i f t h e c u r r e n t g e n e r a t o r c h o i c e p o i n t i s t h e t o p m o s t c h o i c e p o i n t a n d t h e c u r r e n t */
/* c a l l i s d e t e r m i n i s t i c ( i . e . , t h e n u m b e r o f s u b s t i t u t i o n v a r i a b l e s i s z e r o o r */
/* t h e r e a r e n o m o r e a l t e r n a t i v e s ) t h e n t h e c u r r e n t a n s w e r i s d e t e r m i n i s t i c a n d w e */
/* c a n p e r f o r m a n e a r l y c o m p l e t i o n a n d r e m o v e t h e c u r r e n t g e n e r a t o r c h o i c e p o i n t */
2009-07-03 00:54:39 +01:00
p r i v a t e _ c o m p l e t i o n ( s g _ f r ) ;
B = B - > c p _ b ;
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) ) ;
2009-08-08 03:53:51 +01:00
} else if ( * s u b s _ p t r = = 0 ) {
/* i f t h e n u m b e r o f s u b s t i t u t i o n v a r i a b l e s i s z e r o , a n a n s w e r i s s u f f i c i e n t t o p e r f o r m */
/* a n e a r l y c o m p l e t i o n , b u t t h e c u r r e n t g e n e r a t o r c h o i c e p o i n t c a n n o t b e r e m o v e d */
m a r k _ a s _ c o m p l e t e d ( s g _ f r ) ;
2009-08-06 02:27:59 +01:00
if ( g c p - > c p _ a p ! = NULL )
g c p - > c p _ a p = C O M P L E T I O N ;
2008-05-20 19:25:37 +01:00
}
2009-08-06 02:27:59 +01:00
# e n d i f /* T A B L I N G _ E A R L Y _ C O M P L E T I O N */
2005-04-07 18:56:58 +01:00
/* d e a l l o c a t e a n d p r o c c e e d */
P R E G = ( y a m o p * ) Y E N V [ E _ C P ] ;
P R E F E T C H _ O P ( P R E G ) ;
C P R E G = P R E G ;
S R E G = Y E N V ;
E N V = Y E N V = ( C E L L * ) Y E N V [ E _ E ] ;
2005-05-31 01:49:49 +01:00
# i f def D E P T H _ L I M I T
D E P T H = Y E N V [ E _ D E P T H ] ;
# e n d i f /* D E P T H _ L I M I T */
2005-04-07 18:56:58 +01:00
G O N e x t ( ) ;
} else {
2009-08-06 02:27:59 +01:00
# i f def T A B L I N G _ E A R L Y _ C O M P L E T I O N
if ( * s u b s _ p t r = = 0 ) {
2009-08-08 03:53:51 +01:00
/* i f t h e n u m b e r o f s u b s t i t u t i o n v a r i a b l e s i s z e r o , a n a n s w e r i s s u f f i c i e n t t o p e r f o r m */
/* a n e a r l y c o m p l e t i o n , b u t t h e c u r r e n t g e n e r a t o r c h o i c e p o i n t c a n n o t b e r e m o v e d */
m a r k _ a s _ c o m p l e t e d ( s g _ f r ) ;
2009-08-06 02:27:59 +01:00
if ( g c p - > c p _ a p ! = A N S W E R _ R E S O L U T I O N )
g c p - > c p _ a p = C O M P L E T I O N ;
2008-05-20 19:25:37 +01:00
}
2009-08-06 02:27:59 +01:00
# e n d i f /* T A B L I N G _ E A R L Y _ C O M P L E T I O N */
2005-04-07 18:56:58 +01:00
/* f a i l */
g o t o f a i l ;
}
2001-04-09 20:54:03 +01:00
} else {
/* r e p e a t e d a n s w e r */
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ F U L L _ S H A R I N G
if ( I s M o d e _ B a t c h e d ( T a b E n t _ m o d e ( S g F r _ t a b _ e n t ( s g _ f r ) ) ) ) {
if ( w o r k e r _ i d > = A N S W E R _ L E A F _ N O D E _ M A X _ T H R E A D S ) {
U N L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
U N L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
S g F r _ b a t c h e d _ c a c h e d _ a n s w e r s _ c h e c k _ i n s e r t ( s g _ f r , NULL ) ;
I N F O _ T H R E A D S ( "new answer (2) sgfr=%p ans_node=%p" , S g F r _ s g _ e n t ( s g _ f r ) , a n s _ n o d e ) ;
if ( S g F r _ b a t c h e d _ c a c h e d _ a n s w e r s _ c h e c k _ r e m o v e ( s g _ f r , a n s _ n o d e ) = = 1 ) {
I N F O _ T H R E A D S ( "ans_node=%p not found" , a n s _ n o d e ) ;
g o t o f a i l ;
}
/* d e a l l o c a t e a n d p r o c c e e d */
P R E G = ( y a m o p * ) Y E N V [ E _ C P ] ;
P R E F E T C H _ O P ( P R E G ) ;
C P R E G = P R E G ;
S R E G = Y E N V ;
E N V = Y E N V = ( C E L L * ) Y E N V [ E _ E ] ;
# i f def D E P T H _ L I M I T
D E P T H = Y E N V [ E _ D E P T H ] ;
# e n d i f /* D E P T H _ L I M I T */
G O N e x t ( ) ;
} else {
if ( ! A N S W E R _ L E A F _ N O D E _ C H E C K _ W I D ( a n s _ n o d e , w o r k e r _ i d ) ) {
A N S W E R _ L E A F _ N O D E _ S E T _ W I D ( a n s _ n o d e , w o r k e r _ i d ) ;
U N L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
U N L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
/* d e a l l o c a t e a n d p r o c c e e d */
I N F O _ T H R E A D S ( "new answer (2) sgfr=%p ans_node=%p" , S g F r _ s g _ e n t ( s g _ f r ) , a n s _ n o d e ) ;
P R E G = ( y a m o p * ) Y E N V [ E _ C P ] ;
P R E F E T C H _ O P ( P R E G ) ;
C P R E G = P R E G ;
S R E G = Y E N V ;
E N V = Y E N V = ( C E L L * ) Y E N V [ E _ E ] ;
# i f def D E P T H _ L I M I T
D E P T H = Y E N V [ E _ D E P T H ] ;
# e n d i f /* D E P T H _ L I M I T */
G O N e x t ( ) ;
}
}
}
# else
2011-11-15 16:57:51 +00:00
U N L O C K _ A N S W E R _ N O D E ( a n s _ n o d e ) ;
U N L O C K _ A N S W E R _ T R I E ( s g _ f r ) ;
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G */
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
I N F O _ T H R E A D S ( "new answer(rep) sgfr=%p ans_node=%p" , S g F r _ s g _ e n t ( s g _ f r ) , a n s _ n o d e ) ;
# else
I N F O _ T H R E A D S ( "new answer(rep) sgfr=%p ans_node=%p" , s g _ f r , a n s _ n o d e ) ;
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2001-04-09 20:54:03 +01:00
g o t o f a i l ;
}
E N D P B O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ a n s w e r _ r e s o l u t i o n * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
B O p ( t a b l e _ a n s w e r _ r e s o l u t i o n , O t a p l )
2001-04-09 20:54:03 +01:00
# i f def Y A P O R
if ( S C H _ t o p _ s h a r e d _ c p ( B ) ) {
U N L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
}
# e n d i f /* Y A P O R */
2006-05-02 09:01:27 +01:00
2001-04-09 20:54:03 +01:00
a n s w e r _ r e s o l u t i o n :
I N I T _ P R E F E T C H ( )
d e p _ f r _ p t r d e p _ f r ;
a n s _ n o d e _ p t r a n s _ n o d e ;
2010-04-18 04:59:11 +01:00
O P T Y A P _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , S C H _ t o p _ s h a r e d _ c p ( B ) && B->cp_or_fr->alternative != ANSWER_RESOLUTION);
O P T Y A P _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , ! S C H _ t o p _ s h a r e d _ c p ( B ) && B->cp_ap != ANSWER_RESOLUTION);
2005-04-07 18:56:58 +01:00
d e p _ f r = C O N S _ C P ( B ) - > c p _ d e p _ f r ;
2011-12-05 16:54:22 +00:00
L O C K _ D E P _ F R ( d e p _ f r ) ;
2005-04-07 18:56:58 +01:00
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) ;
2011-11-09 11:00:31 +00:00
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) {
/* u n c o n s u m e d a n s w e r s */
2011-10-22 16:49:13 +01:00
# i f def M O D E _ D I R E C T E D _ T A B L I N G
2011-12-22 16:50:20 +00:00
if ( I S _ A N S W E R _ I N V A L I D _ N O D E ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) ) {
2011-11-16 12:47:43 +00:00
a n s _ n o d e _ p t r o l d _ a n s _ n o d e ;
o l d _ a n s _ n o d e = a n s _ n o d e ;
2011-11-09 11:00:31 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-11 19:17:55 +00:00
do {
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-12-22 16:50:20 +00:00
} while ( I S _ A N S W E R _ I N V A L I D _ N O D E ( a n s _ n o d e ) ) ;
2011-11-16 12:47:43 +00:00
T r N o d e _ c h i l d ( o l d _ a n s _ n o d e ) = a n s _ n o d e ;
2011-11-11 19:17:55 +00:00
} else
2011-11-09 11:00:31 +00:00
# e n d i f /* M O D E _ D I R E C T E D _ T A B L I N G */
2011-11-11 19:17:55 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-10-22 16:49:13 +01:00
D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) = a n s _ n o d e ;
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( d e p _ f r , a n s _ n o d e ) ;
}
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
2005-04-07 18:56:58 +01:00
# i f def Y A P O R
if ( B = = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) {
/* B i s a g e n e r a t o r - c o n s u m e r n o d e * *
* * n e v e r h e r e if b a t c h e d s c h e d u l i n g * /
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , I S _ B A T C H E D _ G E N _ C P ( B ) ) ;
2001-04-09 20:54:03 +01:00
g o t o c o m p l e t i o n ;
}
2005-04-07 18:56:58 +01:00
# e n d i f /* Y A P O R */
2001-04-09 20:54:03 +01:00
/* n o u n c o n s u m e d a n s w e r s */
if ( D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) = = NULL ) {
/* n o r m a l b a c k t r a c k */
# i f def Y A P O R
if ( S C H _ t o p _ s h a r e d _ c p ( B ) ) {
S C H E D U L E R _ G E T _ W O R K ( ) ;
}
# e n d i f /* Y A P O R */
B = B - > c p _ b ;
g o t o f a i l ;
} else {
/* c h a i n b a c k t r a c k */
c h o i c e p t r t o p _ c h a i n _ c p , c h a i n _ c p ;
# i f def Y A P O R
o r _ f r _ p t r s t a r t _ o r _ f r , e n d _ o r _ f r ;
# e n d i f /* Y A P O R */
/* f i n d c h a i n c h o i c e p o i n t t o b a c k t r a c k */
t o p _ c h a i n _ c p = D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) ;
c h a i n _ c p = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ;
if ( Y O U N G E R _ C P ( t o p _ c h a i n _ c p , c h a i n _ c p ) )
c h a i n _ c p = t o p _ c h a i n _ c p ;
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( t o p _ c h a i n _ c p , B ) ) ;
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( c h a i n _ c p , B ) ) ;
2001-04-09 20:54:03 +01:00
/* c h e c k f o r d e p e n d e n c y f r a m e s w i t h u n c o n s u m e d a n s w e r s */
d e p _ f r = D e p F r _ n e x t ( d e p _ f r ) ;
while ( Y O U N G E R _ C P ( D e p F r _ c o n s _ c p ( d e p _ f r ) , c h a i n _ c p ) ) {
2011-12-05 16:54:22 +00:00
L O C K _ D E P _ F R ( d e p _ f r ) ;
2005-04-07 18:56:58 +01:00
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) ;
2011-11-09 11:00:31 +00:00
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) {
/* d e p e n d e n c y f r a m e w i t h u n c o n s u m e d a n s w e r s */
2011-10-22 16:49:13 +01:00
# i f def M O D E _ D I R E C T E D _ T A B L I N G
2011-12-22 16:50:20 +00:00
if ( I S _ A N S W E R _ I N V A L I D _ N O D E ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) ) {
2011-11-16 12:47:43 +00:00
a n s _ n o d e _ p t r o l d _ a n s _ n o d e ;
o l d _ a n s _ n o d e = a n s _ n o d e ;
2011-11-09 11:00:31 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-11 19:17:55 +00:00
do {
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-12-22 16:50:20 +00:00
} while ( I S _ A N S W E R _ I N V A L I D _ N O D E ( a n s _ n o d e ) ) ;
2011-11-16 12:47:43 +00:00
T r N o d e _ c h i l d ( o l d _ a n s _ n o d e ) = a n s _ n o d e ;
2011-11-11 19:17:55 +00:00
} else
2011-11-09 11:00:31 +00:00
# e n d i f /* M O D E _ D I R E C T E D _ T A B L I N G */
2011-11-11 19:17:55 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-09 11:00:31 +00:00
D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) = a n s _ n o d e ;
2001-04-09 20:54:03 +01:00
# i f def Y A P O R
if ( Y O U N G E R _ C P ( D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) , t o p _ c h a i n _ c p ) )
# e n d i f /* Y A P O R */
D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) = t o p _ c h a i n _ c p ;
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
c h a i n _ c p = D e p F r _ c o n s _ c p ( d e p _ f r ) ;
# i f def Y A P O R
/* u p d a t e s h a r e d n o d e s */
s t a r t _ o r _ f r = L O C A L _ t o p _ o r _ f r ;
e n d _ o r _ f r = D e p F r _ t o p _ o r _ f r ( d e p _ f r ) ;
if ( s t a r t _ o r _ f r ! = e n d _ o r _ f r ) {
L O C A L _ t o p _ o r _ f r = e n d _ o r _ f r ;
2010-01-14 17:38:39 +00:00
S e t _ L O C A L _ t o p _ c p ( G e t O r F r _ n o d e ( e n d _ o r _ f r ) ) ;
2001-04-09 20:54:03 +01:00
do {
2010-01-14 17:38:39 +00:00
while ( Y O U N G E R _ C P ( G e t O r F r _ n o d e ( s t a r t _ o r _ f r ) , G e t O r F r _ n o d e ( e n d _ o r _ f r ) ) ) {
2001-04-09 20:54:03 +01:00
L O C K _ O R _ F R A M E ( s t a r t _ o r _ f r ) ;
B I T M A P _ d e l e t e ( O r F r _ m e m b e r s ( s t a r t _ o r _ f r ) , w o r k e r _ i d ) ;
if ( B I T M A P _ e m p t y ( O r F r _ m e m b e r s ( s t a r t _ o r _ f r ) ) ) {
if ( f r a m e _ w i t h _ s u s p e n s i o n s _ n o t _ c o l l e c t e d ( s t a r t _ o r _ f r ) ) {
c o l l e c t _ s u s p e n s i o n _ f r a m e s ( s t a r t _ o r _ f r ) ;
}
# i f def T A B L I N G _ I N N E R _ C U T S
if ( O r F r _ t g _ s o l u t i o n s ( s t a r t _ o r _ f r ) ) {
t g _ s o l _ f r _ p t r t g _ s o l u t i o n s ;
o r _ f r _ p t r l e f t m o s t _ u n t i l ;
t g _ s o l u t i o n s = O r F r _ t g _ s o l u t i o n s ( s t a r t _ o r _ f r ) ;
l e f t m o s t _ u n t i l = C U T _ l e f t m o s t _ u n t i l ( s t a r t _ o r _ f r , O r F r _ d e p t h ( T g S o l F r _ g e n _ c p ( t g _ s o l u t i o n s ) - > c p _ o r _ f r ) ) ;
O r F r _ t g _ s o l u t i o n s ( s t a r t _ o r _ f r ) = NULL ;
U N L O C K _ O R _ F R A M E ( s t a r t _ o r _ f r ) ;
if ( l e f t m o s t _ u n t i l ) {
L O C K _ O R _ F R A M E ( l e f t m o s t _ u n t i l ) ;
t g _ s o l u t i o n s = C U T _ s t o r e _ t g _ a n s w e r s ( l e f t m o s t _ u n t i l , t g _ s o l u t i o n s ,
B R A N C H _ L T T ( w o r k e r _ i d , O r F r _ d e p t h ( l e f t m o s t _ u n t i l ) ) ) ;
U N L O C K _ O R _ F R A M E ( l e f t m o s t _ u n t i l ) ;
}
C U T _ v a l i d a t e _ t g _ a n s w e r s ( t g _ s o l u t i o n s ) ;
g o t o c o n t i n u e _ u p d a t e _ l o o p 1 ;
}
# e n d i f /* T A B L I N G _ I N N E R _ C U T S */
}
U N L O C K _ O R _ F R A M E ( s t a r t _ o r _ f r ) ;
# i f def T A B L I N G _ I N N E R _ C U T S
c o n t i n u e _ u p d a t e _ l o o p 1 :
# e n d i f /* T A B L I N G _ I N N E R _ C U T S */
s t a r t _ o r _ f r = O r F r _ n e x t ( s t a r t _ o r _ f r ) ;
}
2010-01-14 17:38:39 +00:00
while ( Y O U N G E R _ C P ( G e t O r F r _ n o d e ( e n d _ o r _ f r ) , G e t O r F r _ n o d e ( s t a r t _ o r _ f r ) ) ) {
2001-04-09 20:54:03 +01:00
L O C K _ O R _ F R A M E ( e n d _ o r _ f r ) ;
B I T M A P _ i n s e r t ( O r F r _ m e m b e r s ( e n d _ o r _ f r ) , w o r k e r _ i d ) ;
B R A N C H ( w o r k e r _ i d , O r F r _ d e p t h ( e n d _ o r _ f r ) ) = 1 ;
U N L O C K _ O R _ F R A M E ( e n d _ o r _ f r ) ;
e n d _ o r _ f r = O r F r _ n e x t ( e n d _ o r _ f r ) ;
}
} while ( s t a r t _ o r _ f r ! = e n d _ o r _ f r ) ;
2010-01-27 11:01:28 +00:00
if ( G e t _ L O C A L _ p r u n e _ r e q u e s t ( ) )
2001-04-09 20:54:03 +01:00
p r u n i n g _ o v e r _ t a b l i n g _ d a t a _ s t r u c t u r e s ( ) ;
}
# e n d i f /* Y A P O R */
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2010-04-18 04:59:11 +01:00
c h o i c e p t r a u x _ c p ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) ) ;
a u x _ c p = c h a i n _ c p ;
while ( a u x _ c p ! = G e t _ L O C A L _ t o p _ c p ( ) ) {
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , a u x _ c p ) ) ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) , a u x _ c p ) ) ;
a u x _ c p = a u x _ c p - > c p _ b ;
}
2001-04-09 20:54:03 +01:00
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2001-04-09 20:54:03 +01:00
/* r e s t o r e b i n d i n g s , u p d a t e r e g i s t e r s , c o n s u m e a n s w e r a n d p r o c c e e d */
r e s t o r e _ b i n d i n g s ( B - > c p _ t r , c h a i n _ c p - > c p _ t r ) ;
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , T R ! = B - > c p _ t r && !IsPairTerm((CELL)TrailTerm(TR - 1)));
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , T R ! = B - > c p _ t r && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
2001-04-09 20:54:03 +01:00
B = c h a i n _ c p ;
T R = T R _ F Z ;
2001-06-08 21:21:59 +01:00
T R A I L _ L I N K ( B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( d e p _ f r , a n s _ n o d e ) ;
}
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
d e p _ f r = D e p F r _ n e x t ( d e p _ f r ) ;
}
/* n o d e p e n d e n c y f r a m e s w i t h u n c o n s u m e d a n s w e r s f o u n d */
# i f def Y A P O R
/* u p d a t e s h a r e d n o d e s */
2010-01-14 15:58:19 +00:00
if ( E Q U A L _ O R _ Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) , c h a i n _ c p ) ) {
2001-04-09 20:54:03 +01:00
e n d _ o r _ f r = c h a i n _ c p - > c p _ o r _ f r ;
s t a r t _ o r _ f r = L O C A L _ t o p _ o r _ f r ;
if ( s t a r t _ o r _ f r ! = e n d _ o r _ f r ) {
L O C A L _ t o p _ o r _ f r = e n d _ o r _ f r ;
2010-01-14 17:38:39 +00:00
S e t _ L O C A L _ t o p _ c p ( G e t O r F r _ n o d e ( e n d _ o r _ f r ) ) ;
2001-04-09 20:54:03 +01:00
while ( s t a r t _ o r _ f r ! = e n d _ o r _ f r ) {
L O C K _ O R _ F R A M E ( s t a r t _ o r _ f r ) ;
B I T M A P _ d e l e t e ( O r F r _ m e m b e r s ( s t a r t _ o r _ f r ) , w o r k e r _ i d ) ;
if ( B I T M A P _ e m p t y ( O r F r _ m e m b e r s ( s t a r t _ o r _ f r ) ) ) {
if ( f r a m e _ w i t h _ s u s p e n s i o n s _ n o t _ c o l l e c t e d ( s t a r t _ o r _ f r ) ) {
c o l l e c t _ s u s p e n s i o n _ f r a m e s ( s t a r t _ o r _ f r ) ;
}
# i f def T A B L I N G _ I N N E R _ C U T S
if ( O r F r _ t g _ s o l u t i o n s ( s t a r t _ o r _ f r ) ) {
t g _ s o l _ f r _ p t r t g _ s o l u t i o n s ;
o r _ f r _ p t r l e f t m o s t _ u n t i l ;
t g _ s o l u t i o n s = O r F r _ t g _ s o l u t i o n s ( s t a r t _ o r _ f r ) ;
l e f t m o s t _ u n t i l = C U T _ l e f t m o s t _ u n t i l ( s t a r t _ o r _ f r , O r F r _ d e p t h ( T g S o l F r _ g e n _ c p ( t g _ s o l u t i o n s ) - > c p _ o r _ f r ) ) ;
O r F r _ t g _ s o l u t i o n s ( s t a r t _ o r _ f r ) = NULL ;
U N L O C K _ O R _ F R A M E ( s t a r t _ o r _ f r ) ;
if ( l e f t m o s t _ u n t i l ) {
L O C K _ O R _ F R A M E ( l e f t m o s t _ u n t i l ) ;
t g _ s o l u t i o n s = C U T _ s t o r e _ t g _ a n s w e r s ( l e f t m o s t _ u n t i l , t g _ s o l u t i o n s ,
B R A N C H _ L T T ( w o r k e r _ i d , O r F r _ d e p t h ( l e f t m o s t _ u n t i l ) ) ) ;
U N L O C K _ O R _ F R A M E ( l e f t m o s t _ u n t i l ) ;
}
C U T _ v a l i d a t e _ t g _ a n s w e r s ( t g _ s o l u t i o n s ) ;
g o t o c o n t i n u e _ u p d a t e _ l o o p 2 ;
}
# e n d i f /* T A B L I N G _ I N N E R _ C U T S */
}
U N L O C K _ O R _ F R A M E ( s t a r t _ o r _ f r ) ;
# i f def T A B L I N G _ I N N E R _ C U T S
c o n t i n u e _ u p d a t e _ l o o p 2 :
# e n d i f /* T A B L I N G _ I N N E R _ C U T S */
s t a r t _ o r _ f r = O r F r _ n e x t ( s t a r t _ o r _ f r ) ;
}
2010-01-27 11:01:28 +00:00
if ( G e t _ L O C A L _ p r u n e _ r e q u e s t ( ) )
2001-04-09 20:54:03 +01:00
p r u n i n g _ o v e r _ t a b l i n g _ d a t a _ s t r u c t u r e s ( ) ;
}
}
# e n d i f /* Y A P O R */
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2010-04-18 04:59:11 +01:00
c h o i c e p t r a u x _ c p ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) ) ;
a u x _ c p = c h a i n _ c p ;
while ( a u x _ c p ! = G e t _ L O C A L _ t o p _ c p ( ) ) {
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , a u x _ c p ) ) ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) , a u x _ c p ) ) ;
a u x _ c p = a u x _ c p - > c p _ b ;
2001-04-09 20:54:03 +01:00
}
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2001-04-09 20:54:03 +01:00
/* u n b i n d v a r i a b l e s */
u n b i n d _ v a r i a b l e s ( B - > c p _ t r , c h a i n _ c p - > c p _ t r ) ;
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , T R ! = B - > c p _ t r && !IsPairTerm((CELL)TrailTerm(TR - 1)));
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n , T R ! = B - > c p _ t r && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
2005-04-07 18:56:58 +01:00
if ( D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) = = c h a i n _ c p && (
/* c h a i n _ c p i s a l e a d e r n o d e A N D . . . */
2001-04-09 20:54:03 +01:00
# i f def Y A P O R
2005-04-07 18:56:58 +01:00
/* t h e l e a d e r d e p e n d e n c y i s n o t o n s t a c k O R . . . */
D e p F r _ l e a d e r _ d e p _ i s _ o n _ s t a c k ( L O C A L _ t o p _ d e p _ f r ) = = FALSE | |
/* t h e l e a d e r d e p e n d e n c y i s o n s t a c k ( t h i s m e a n s t h a t c h a i n _ c p i s a g e n e r a t o r n o d e ) a n d */
2001-04-09 20:54:03 +01:00
# e n d i f /* Y A P O R */
2005-04-07 18:56:58 +01:00
/* t h e r e a r e n o u n e x p l o i t e d a l t e r n a t i v e s * *
* * ( NULL if b a t c h e d s c h e d u l i n g OR A N S W E R _ R E S O L U T I O N if l o c a l s c h e d u l i n g ) * /
c h a i n _ c p - > c p _ a p = = NULL | | c h a i n _ c p - > c p _ a p = = A N S W E R _ R E S O L U T I O N ) ) {
B = c h a i n _ c p ;
T R = T R _ F Z ;
T R A I L _ L I N K ( B - > c p _ t r ) ;
g o t o c o m p l e t i o n ;
2001-04-09 20:54:03 +01:00
}
/* b a c k t r a c k t o c h a i n c h o i c e p o i n t */
P R E G = c h a i n _ c p - > c p _ a p ;
P R E F E T C H _ O P ( P R E G ) ;
B = c h a i n _ c p ;
T R = T R _ F Z ;
2001-06-08 21:21:59 +01:00
T R A I L _ L I N K ( B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
G O N e x t ( ) ;
}
E N D _ P R E F E T C H ( )
E N D B O p ( ) ;
2010-04-03 05:58:14 +01:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ c o m p l e t i o n * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2008-09-05 05:22:19 +01:00
B O p ( t a b l e _ c o m p l e t i o n , O t a p l )
2001-04-09 20:54:03 +01:00
# i f def Y A P O R
if ( S C H _ t o p _ s h a r e d _ c p ( B ) ) {
2005-04-07 18:56:58 +01:00
if ( I S _ B A T C H E D _ G E N _ C P ( B ) ) {
S C H _ n e w _ a l t e r n a t i v e ( P R E G , NULL ) ;
if ( B ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) && EQUAL_OR_YOUNGER_CP(B_FZ, B)) {
/* n o t l e a d e r o n t h a t n o d e */
S C H E D U L E R _ G E T _ W O R K ( ) ;
}
} else {
S C H _ n e w _ a l t e r n a t i v e ( P R E G , A N S W E R _ R E S O L U T I O N ) ;
if ( B ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) {
/* n o t l e a d e r o n t h a t n o d e */
S C H E D U L E R _ G E T _ W O R K ( ) ;
}
}
2001-04-09 20:54:03 +01:00
} else
# e n d i f /* Y A P O R */
2005-04-07 18:56:58 +01:00
{
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
g o t o a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n ;
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-04-07 18:56:58 +01:00
if ( I S _ B A T C H E D _ G E N _ C P ( B ) ) {
B - > c p _ a p = NULL ;
if ( E Q U A L _ O R _ Y O U N G E R _ C P ( B _ F Z , B ) && B != DepFr_leader_cp(LOCAL_top_dep_fr)) {
/* n o t l e a d e r o n t h a t n o d e */
B = B - > c p _ b ;
g o t o f a i l ;
}
} else {
B - > c p _ a p = A N S W E R _ R E S O L U T I O N ;
if ( B ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) {
/* n o t l e a d e r o n t h a t n o d e */
B = B - > c p _ b ;
g o t o f a i l ;
}
2001-04-09 20:54:03 +01:00
}
}
/* l e a d e r o n t h a t n o d e */
c o m p l e t i o n :
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
g o t o a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n ;
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2001-04-09 20:54:03 +01:00
I N I T _ P R E F E T C H ( )
d e p _ f r _ p t r d e p _ f r ;
a n s _ n o d e _ p t r a n s _ n o d e ;
# i f def Y A P O R
# i f def T I M E S T A M P _ C H E C K
l o n g t i m e s t a m p = 0 ;
# e n d i f /* T I M E S T A M P _ C H E C K */
int e n t r y _ o w n e r s = 0 ;
if ( S C H _ t o p _ s h a r e d _ c p ( B ) ) {
# i f def T I M E S T A M P _ C H E C K
2011-05-10 11:47:18 +01:00
t i m e s t a m p = + + G L O B A L _ t i m e s t a m p ;
2001-04-09 20:54:03 +01:00
# e n d i f /* T I M E S T A M P _ C H E C K */
e n t r y _ o w n e r s = O r F r _ o w n e r s ( L O C A L _ t o p _ o r _ f r ) ;
}
# e n d i f /* Y A P O R */
/* c h e c k f o r d e p e n d e n c y f r a m e s w i t h u n c o n s u m e d a n s w e r s */
d e p _ f r = L O C A L _ t o p _ d e p _ f r ;
while ( Y O U N G E R _ C P ( D e p F r _ c o n s _ c p ( d e p _ f r ) , B ) ) {
2011-12-05 16:54:22 +00:00
L O C K _ D E P _ F R ( d e p _ f r ) ;
2005-04-07 18:56:58 +01:00
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) ;
2011-11-09 11:00:31 +00:00
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) {
/* d e p e n d e n c y f r a m e w i t h u n c o n s u m e d a n s w e r s */
2011-10-22 16:49:13 +01:00
# i f def M O D E _ D I R E C T E D _ T A B L I N G
2011-12-22 16:50:20 +00:00
if ( I S _ A N S W E R _ I N V A L I D _ N O D E ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) ) {
2011-11-16 12:47:43 +00:00
a n s _ n o d e _ p t r o l d _ a n s _ n o d e ;
o l d _ a n s _ n o d e = a n s _ n o d e ;
2011-11-09 11:00:31 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-11 19:17:55 +00:00
do {
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-12-22 16:50:20 +00:00
} while ( I S _ A N S W E R _ I N V A L I D _ N O D E ( a n s _ n o d e ) ) ;
2011-11-16 12:47:43 +00:00
T r N o d e _ c h i l d ( o l d _ a n s _ n o d e ) = a n s _ n o d e ;
2011-11-11 19:17:55 +00:00
} else
2011-11-09 11:00:31 +00:00
# e n d i f /* M O D E _ D I R E C T E D _ T A B L I N G */
2011-11-11 19:17:55 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-09 11:00:31 +00:00
D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) = a n s _ n o d e ;
2001-04-09 20:54:03 +01:00
if ( B - > c p _ a p ) {
# i f def Y A P O R
if ( Y O U N G E R _ C P ( D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) , B ) )
# e n d i f /* Y A P O R */
D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) = B ;
} else {
# i f def Y A P O R
if ( Y O U N G E R _ C P ( D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) , B - > c p _ b ) )
# e n d i f /* Y A P O R */
D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) = B - > c p _ b ;
}
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2010-04-18 04:59:11 +01:00
c h o i c e p t r a u x _ c p ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , G e t _ L O C A L _ t o p _ c p ( ) , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) ;
a u x _ c p = D e p F r _ c o n s _ c p ( d e p _ f r ) ;
while ( Y O U N G E R _ C P ( a u x _ c p , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) )
a u x _ c p = a u x _ c p - > c p _ b ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , a u x _ c p - > c p _ o r _ f r ! = D e p F r _ t o p _ o r _ f r ( d e p _ f r ) ) ;
2001-04-09 20:54:03 +01:00
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2001-04-09 20:54:03 +01:00
# i f def Y A P O R
/* u p d a t e s h a r e d n o d e s */
2010-01-14 15:58:19 +00:00
if ( Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) , G e t _ L O C A L _ t o p _ c p ( ) ) ) {
2001-04-09 20:54:03 +01:00
o r _ f r _ p t r o r _ f r a m e = D e p F r _ t o p _ o r _ f r ( d e p _ f r ) ;
while ( o r _ f r a m e ! = L O C A L _ t o p _ o r _ f r ) {
L O C K _ O R _ F R A M E ( o r _ f r a m e ) ;
B I T M A P _ i n s e r t ( O r F r _ m e m b e r s ( o r _ f r a m e ) , w o r k e r _ i d ) ;
B R A N C H ( w o r k e r _ i d , O r F r _ d e p t h ( o r _ f r a m e ) ) = 1 ;
U N L O C K _ O R _ F R A M E ( o r _ f r a m e ) ;
o r _ f r a m e = O r F r _ n e x t ( o r _ f r a m e ) ;
}
L O C A L _ t o p _ o r _ f r = D e p F r _ t o p _ o r _ f r ( d e p _ f r ) ;
2010-01-14 17:38:39 +00:00
S e t _ L O C A L _ t o p _ c p ( G e t O r F r _ n o d e ( L O C A L _ t o p _ o r _ f r ) ) ;
2001-04-09 20:54:03 +01:00
}
# e n d i f /* Y A P O R */
2010-04-18 04:59:11 +01:00
# i f def D E B U G _ O P T Y A P
2011-06-21 15:19:07 +01:00
if ( G L O B A L _ p a r a l l e l _ m o d e = = P A R A L L E L _ M O D E _ R U N N I N G ) {
2010-04-18 04:59:11 +01:00
c h o i c e p t r a u x _ c p ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) ) ) ;
a u x _ c p = D e p F r _ c o n s _ c p ( d e p _ f r ) ;
while ( a u x _ c p ! = G e t _ L O C A L _ t o p _ c p ( ) ) {
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p ( ) , a u x _ c p ) ) ;
O P T Y A P _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( G e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( ) , a u x _ c p ) ) ;
a u x _ c p = a u x _ c p - > c p _ b ;
}
2001-04-09 20:54:03 +01:00
}
2010-04-18 04:59:11 +01:00
# e n d i f /* D E B U G _ O P T Y A P */
2001-04-09 20:54:03 +01:00
/* r e b i n d v a r i a b l e s , u p d a t e r e g i s t e r s , c o n s u m e a n s w e r a n d p r o c c e e d */
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( B , D e p F r _ c o n s _ c p ( d e p _ f r ) ) ) ;
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , B - > c p _ t r > D e p F r _ c o n s _ c p ( d e p _ f r ) - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
r e b i n d _ v a r i a b l e s ( D e p F r _ c o n s _ c p ( d e p _ f r ) - > c p _ t r , B - > c p _ t r ) ;
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , T R ! = B - > c p _ t r && !IsPairTerm((CELL)TrailTerm(TR - 1)));
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , T R ! = B - > c p _ t r && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
2001-04-09 20:54:03 +01:00
B = D e p F r _ c o n s _ c p ( d e p _ f r ) ;
T R = T R _ F Z ;
if ( T R ! = B - > c p _ t r )
2001-06-08 21:21:59 +01:00
T R A I L _ L I N K ( B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( d e p _ f r , a n s _ n o d e ) ;
}
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
# i f def T I M E S T A M P _ C H E C K
D e p F r _ t i m e s t a m p ( d e p _ f r ) = t i m e s t a m p ;
# e n d i f /* T I M E S T A M P _ C H E C K */
d e p _ f r = D e p F r _ n e x t ( d e p _ f r ) ;
}
/* n o d e p e n d e n c y f r a m e s w i t h u n c o n s u m e d a n s w e r s f o u n d */
# i f def Y A P O R
if ( S C H _ t o p _ s h a r e d _ c p ( B ) ) {
if ( e n t r y _ o w n e r s > 1 ) {
/* m o r e o w n e r s w h e n w e s t a r t l o o k i n g f o r d e p e n d e n c y f r a m e s w i t h u n c o n s u m e d a n s w e r s */
if ( Y O U N G E R _ C P ( B _ F Z , B ) ) {
s u s p e n d _ b r a n c h ( ) ;
/* c h e c k f o r s u s p e n s i o n f r a m e s t o b e r e s u m e d */
2010-01-14 17:38:39 +00:00
while ( Y O U N G E R _ C P ( G e t O r F r _ n o d e ( L O C A L _ t o p _ s u s p _ o r _ f r ) , G e t _ L O C A L _ t o p _ c p ( ) ) ) {
2001-04-09 20:54:03 +01:00
o r _ f r _ p t r s u s p _ o r _ f r ;
s u s p _ f r _ p t r r e s u m e _ f r ;
s u s p _ o r _ f r = L O C A L _ t o p _ s u s p _ o r _ f r ;
L O C K _ O R _ F R A M E ( s u s p _ o r _ f r ) ;
# i f def T I M E S T A M P _ C H E C K
r e s u m e _ f r = s u s p e n s i o n _ f r a m e _ t o _ r e s u m e ( s u s p _ o r _ f r , t i m e s t a m p ) ;
# else
r e s u m e _ f r = s u s p e n s i o n _ f r a m e _ t o _ r e s u m e ( s u s p _ o r _ f r ) ;
# e n d i f /* T I M E S T A M P _ C H E C K */
if ( r e s u m e _ f r ) {
if ( O r F r _ s u s p e n s i o n s ( s u s p _ o r _ f r ) = = NULL ) {
L O C A L _ t o p _ s u s p _ o r _ f r = O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) ;
O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) = s u s p _ o r _ f r ;
}
U N L O C K _ O R _ F R A M E ( s u s p _ o r _ f r ) ;
2010-01-14 17:38:39 +00:00
r e b i n d _ v a r i a b l e s ( G e t O r F r _ n o d e ( s u s p _ o r _ f r ) - > c p _ t r , B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
r e s u m e _ s u s p e n s i o n _ f r a m e ( r e s u m e _ f r , s u s p _ o r _ f r ) ;
2010-01-14 15:58:19 +00:00
B = G e t _ L O C A L _ t o p _ c p ( ) ;
2001-04-09 20:54:03 +01:00
S E T _ B B ( B _ F Z ) ;
T R = T R _ F Z ;
2001-06-08 21:21:59 +01:00
T R A I L _ L I N K ( B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
g o t o c o m p l e t i o n ;
}
L O C A L _ t o p _ s u s p _ o r _ f r = O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) ;
O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) = NULL ;
U N L O C K _ O R _ F R A M E ( s u s p _ o r _ f r ) ;
}
}
} else {
/* u n i q u e o w n e r */
if ( f r a m e _ w i t h _ s u s p e n s i o n s _ n o t _ c o l l e c t e d ( L O C A L _ t o p _ o r _ f r ) )
c o l l e c t _ s u s p e n s i o n _ f r a m e s ( L O C A L _ t o p _ o r _ f r ) ;
/* c h e c k f o r s u s p e n s i o n f r a m e s t o b e r e s u m e d */
2010-01-14 17:38:39 +00:00
while ( E Q U A L _ O R _ Y O U N G E R _ C P ( G e t O r F r _ n o d e ( L O C A L _ t o p _ s u s p _ o r _ f r ) , G e t _ L O C A L _ t o p _ c p ( ) ) ) {
2001-04-09 20:54:03 +01:00
o r _ f r _ p t r s u s p _ o r _ f r ;
s u s p _ f r _ p t r r e s u m e _ f r ;
s u s p _ o r _ f r = L O C A L _ t o p _ s u s p _ o r _ f r ;
# i f def T I M E S T A M P _ C H E C K
r e s u m e _ f r = s u s p e n s i o n _ f r a m e _ t o _ r e s u m e ( s u s p _ o r _ f r , t i m e s t a m p ) ;
# else
r e s u m e _ f r = s u s p e n s i o n _ f r a m e _ t o _ r e s u m e ( s u s p _ o r _ f r ) ;
# e n d i f /* T I M E S T A M P _ C H E C K */
if ( r e s u m e _ f r ) {
if ( O r F r _ s u s p e n s i o n s ( s u s p _ o r _ f r ) = = NULL ) {
L O C A L _ t o p _ s u s p _ o r _ f r = O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) ;
O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) = s u s p _ o r _ f r ;
}
if ( Y O U N G E R _ C P ( B _ F Z , B ) ) {
s u s p e n d _ b r a n c h ( ) ;
}
2010-01-14 17:38:39 +00:00
r e b i n d _ v a r i a b l e s ( G e t O r F r _ n o d e ( s u s p _ o r _ f r ) - > c p _ t r , B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
r e s u m e _ s u s p e n s i o n _ f r a m e ( r e s u m e _ f r , s u s p _ o r _ f r ) ;
2010-01-14 15:58:19 +00:00
B = G e t _ L O C A L _ t o p _ c p ( ) ;
2001-04-09 20:54:03 +01:00
S E T _ B B ( B _ F Z ) ;
T R = T R _ F Z ;
2001-06-08 21:21:59 +01:00
T R A I L _ L I N K ( B - > c p _ t r ) ;
2001-04-09 20:54:03 +01:00
g o t o c o m p l e t i o n ;
}
L O C A L _ t o p _ s u s p _ o r _ f r = O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) ;
O r F r _ n e a r e s t _ s u s p n o d e ( s u s p _ o r _ f r ) = NULL ;
}
/* c o m p l e t e a l l */
p u b l i c _ c o m p l e t i o n ( ) ;
}
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , T R ! = B - > c p _ t r && !IsPairTerm((CELL)TrailTerm(TR - 1)));
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , T R ! = B - > c p _ t r && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
2005-04-07 18:56:58 +01:00
if ( B = = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) {
/* B i s a g e n e r a t o r - c o n s u m e r n o d e */
/* n e v e r h e r e i f b a t c h e d s c h e d u l i n g */
2001-04-09 20:54:03 +01:00
a n s _ n o d e _ p t r a n s _ n o d e ;
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , I S _ B A T C H E D _ G E N _ C P ( B ) ) ;
2001-04-09 20:54:03 +01:00
T R = B - > c p _ t r ;
S E T _ B B ( B ) ;
L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
2011-12-05 16:54:22 +00:00
L O C K _ D E P _ F R ( L O C A L _ t o p _ d e p _ f r ) ;
2005-04-07 18:56:58 +01:00
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( L O C A L _ t o p _ d e p _ f r ) ;
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) {
2011-11-09 11:00:31 +00:00
/* u n c o n s u m e d a n s w e r s */
2005-04-07 18:56:58 +01:00
U N L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
2011-11-09 11:00:31 +00:00
# i f def M O D E _ D I R E C T E D _ T A B L I N G
2011-12-22 16:50:20 +00:00
if ( I S _ A N S W E R _ I N V A L I D _ N O D E ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) ) {
2011-11-16 12:47:43 +00:00
a n s _ n o d e _ p t r o l d _ a n s _ n o d e ;
o l d _ a n s _ n o d e = a n s _ n o d e ;
2011-11-09 11:00:31 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-11 19:17:55 +00:00
do {
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-12-22 16:50:20 +00:00
} while ( I S _ A N S W E R _ I N V A L I D _ N O D E ( a n s _ n o d e ) ) ;
2011-11-16 12:47:43 +00:00
T r N o d e _ c h i l d ( o l d _ a n s _ n o d e ) = a n s _ n o d e ;
2011-11-11 19:17:55 +00:00
} else
2011-11-09 11:00:31 +00:00
# e n d i f /* M O D E _ D I R E C T E D _ T A B L I N G */
2011-11-11 19:17:55 +00:00
a n s _ n o d e = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
2011-11-09 11:00:31 +00:00
D e p F r _ l a s t _ a n s w e r ( L O C A L _ t o p _ d e p _ f r ) = a n s _ n o d e ;
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( L O C A L _ t o p _ d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( L O C A L _ t o p _ d e p _ f r , a n s _ n o d e ) ;
}
/* n o u n c o n s u m e d a n s w e r s */
2011-12-05 16:54:22 +00:00
U N L O C K _ D E P _ F R ( L O C A L _ t o p _ d e p _ f r ) ;
2001-04-09 20:54:03 +01:00
if ( O r F r _ o w n e r s ( L O C A L _ t o p _ o r _ f r ) > 1 ) {
/* m o r e o w n e r s - > m o v e u p o n e n o d e */
2011-12-22 16:50:20 +00:00
S e t _ L O C A L _ t o p _ c p _ o n _ s t a c k ( G e t O r F r _ n o d e ( O r F r _ n e x t _ o n _ s t a c k ( L O C A L _ t o p _ o r _ f r ) ) ) ;
2001-04-09 20:54:03 +01:00
B I T M A P _ d e l e t e ( O r F r _ m e m b e r s ( L O C A L _ t o p _ o r _ f r ) , w o r k e r _ i d ) ;
O r F r _ o w n e r s ( L O C A L _ t o p _ o r _ f r ) - - ;
L O C A L _ t o p _ d e p _ f r = D e p F r _ n e x t ( L O C A L _ t o p _ d e p _ f r ) ;
U N L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
2010-01-14 15:58:19 +00:00
if ( L O C A L _ t o p _ s g _ f r && Get_LOCAL_top_cp() == SgFr_gen_cp(LOCAL_top_sg_fr)) {
2001-04-09 20:54:03 +01:00
L O C A L _ t o p _ s g _ f r = S g F r _ n e x t ( L O C A L _ t o p _ s g _ f r ) ;
}
S C H _ u p d a t e _ l o c a l _ o r _ t o p s ( ) ;
C U T _ r e s e t _ p r u n e _ r e q u e s t ( ) ;
a d j u s t _ f r e e z e _ r e g i s t e r s ( ) ;
g o t o s h a r e d _ f a i l ;
} else {
/* f r e e t o p d e p e n d e n c y f r a m e - - > g e t w o r k */
O r F r _ a l t e r n a t i v e ( L O C A L _ t o p _ o r _ f r ) = NULL ;
U N L O C K _ O R _ F R A M E ( L O C A L _ t o p _ o r _ f r ) ;
d e p _ f r = D e p F r _ n e x t ( L O C A L _ t o p _ d e p _ f r ) ;
F R E E _ D E P E N D E N C Y _ F R A M E ( L O C A L _ t o p _ d e p _ f r ) ;
L O C A L _ t o p _ d e p _ f r = d e p _ f r ;
a d j u s t _ f r e e z e _ r e g i s t e r s ( ) ;
S C H E D U L E R _ G E T _ W O R K ( ) ;
}
}
/* g o t o g e t w o r k */
P R E G = B - > c p _ a p ;
P R E F E T C H _ O P ( P R E G ) ;
T R = B - > c p _ t r ;
S E T _ B B ( B ) ;
G O N e x t ( ) ;
} else
# e n d i f /* Y A P O R */
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
c o m p l e t e _ a l l :
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2001-04-09 20:54:03 +01:00
{
/* c o m p l e t e a l l */
s g _ f r _ p t r s g _ f r ;
2009-07-03 00:54:39 +01:00
# i f def D E T E R M I N I S T I C _ T A B L I N G
if ( I S _ D E T _ G E N _ C P ( B ) )
s g _ f r = D E T _ G E N _ C P ( B ) - > c p _ s g _ f r ;
else
# e n d i f /* D E T E R M I N I S T I C _ T A B L I N G */
s g _ f r = G E N _ C P ( B ) - > c p _ s g _ f r ;
2001-04-09 20:54:03 +01:00
p r i v a t e _ c o m p l e t i o n ( s g _ f r ) ;
2011-12-22 16:50:20 +00:00
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
if ( I S _ B A T C H E D _ G E N _ C P ( B ) | | S g F r _ g e n _ w o r k e r ( s g _ f r ) ! = w o r k e r _ i d ) { / * i f i t i s a n g e n _ c o n s n o d e t h e n a l l t h e a n s w e r s w e r e a l r e a d y c o n s u m e d * /
# else
2005-04-07 18:56:58 +01:00
if ( I S _ B A T C H E D _ G E N _ C P ( B ) ) {
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-04-07 18:56:58 +01:00
/* b a c k t r a c k */
2001-04-09 20:54:03 +01:00
B = B - > c p _ b ;
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) ) ;
g o t o f a i l ;
2005-04-07 18:56:58 +01:00
} else {
/* s u b g o a l c o m p l e t e d */
2005-07-06 20:34:12 +01:00
a n s _ n o d e = S g F r _ f i r s t _ a n s w e r ( s g _ f r ) ;
if ( a n s _ n o d e = = NULL ) {
2005-04-07 18:56:58 +01:00
/* n o a n s w e r s - - > f a i l */
B = B - > c p _ b ;
S E T _ B B ( P R O T E C T _ F R O Z E N _ B ( B ) ) ;
g o t o f a i l ;
}
2010-04-18 04:59:11 +01:00
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , T R ! = B - > c p _ t r && !IsPairTerm((CELL)TrailTerm(TR - 1)));
T A B L I N G _ E R R O R _ C H E C K I N G ( c o m p l e t i o n , T R ! = B - > c p _ t r && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
2005-04-07 18:56:58 +01:00
p o p _ g e n e r a t o r _ n o d e ( S g F r _ a r i t y ( s g _ f r ) ) ;
2005-07-06 20:34:12 +01:00
if ( a n s _ n o d e = = S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) {
2005-04-07 18:56:58 +01:00
/* y e s a n s w e r - - > p r o c c e e d */
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
2005-07-06 20:34:12 +01:00
/* a n s w e r s - > g e t f i r s t a n s w e r */
t a b _ e n t _ p t r t a b _ e n t = S g F r _ t a b _ e n t ( s g _ f r ) ;
2005-08-04 16:45:56 +01:00
# i f def L I M I T _ T A B L I N G
S g F r _ s t a t e ( s g _ f r ) + + ; /* c o m p l e t e - - > c o m p l e t e _ i n _ u s e */
r e m o v e _ f r o m _ g l o b a l _ s g _ f r _ l i s t ( s g _ f r ) ;
T R A I L _ F R A M E ( s g _ f r ) ;
# e n d i f /* L I M I T _ T A B L I N G */
2005-07-06 20:34:12 +01:00
if ( I s M o d e _ L o a d A n s w e r s ( T a b E n t _ m o d e ( t a b _ e n t ) ) ) {
/* l o a d a n s w e r s f r o m t h e t r i e */
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ! = NULL ) {
s t o r e _ l o a d e r _ n o d e ( t a b _ e n t , a n s _ n o d e ) ;
}
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
2009-09-27 02:31:31 +01:00
l o a d _ a n s w e r ( a n s _ n o d e , Y E N V ) ;
2005-07-06 20:34:12 +01:00
Y E N V = E N V ;
G O N e x t ( ) ;
} else {
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
L O C K _ S G _ F R ( s g _ f r ) ;
if ( S g F r _ a c t i v e _ w o r k e r s ( s g _ f r ) > 0 ) {
/* l o a d a n s w e r s f r o m t h e t r i e */
U N L O C K _ S G _ F R ( s g _ f r ) ;
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ! = NULL ) {
s t o r e _ l o a d e r _ n o d e ( t a b _ e n t , a n s _ n o d e ) ;
}
P R E G = ( y a m o p * ) C P R E G ;
P R E F E T C H _ O P ( P R E G ) ;
l o a d _ a n s w e r ( a n s _ n o d e , Y E N V ) ;
Y E N V = E N V ;
G O N e x t ( ) ;
}
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
/* e x e c u t e c o m p i l e d c o d e f r o m t h e t r i e */
2011-12-22 16:50:20 +00:00
# if defined ( T H R E A D S _ F U L L _ S H A R I N G ) | | defined ( T H R E A D S _ C O N S U M E R _ S H A R I N G )
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) < c o m p i l e d )
# else
2011-12-05 16:54:22 +00:00
L O C K _ S G _ F R ( s g _ f r ) ;
2005-08-04 16:45:56 +01:00
if ( S g F r _ s t a t e ( s g _ f r ) < c o m p i l e d )
2011-12-22 16:50:20 +00:00
# e n d i f /* T H R E A D S _ F U L L _ S H A R I N G | | T H R E A D S _ C O N S U M E R _ S H A R I N G */
2005-07-06 20:34:12 +01:00
u p d a t e _ a n s w e r _ t r i e ( s g _ f r ) ;
2011-12-05 16:54:22 +00:00
U N L O C K _ S G _ F R ( s g _ f r ) ;
2005-07-06 20:34:12 +01:00
P R E G = ( y a m o p * ) T r N o d e _ c h i l d ( S g F r _ a n s w e r _ t r i e ( s g _ f r ) ) ;
P R E F E T C H _ O P ( P R E G ) ;
* - - Y E N V = 0 ; /* v a r s _ a r i t y */
2010-04-15 01:09:59 +01:00
* - - Y E N V = 0 ; /* h e a p _ a r i t y */
2005-07-06 20:34:12 +01:00
G O N e x t ( ) ;
}
}
2001-04-09 20:54:03 +01:00
}
}
E N D _ P R E F E T C H ( )
E N D B O p ( ) ;
2011-12-22 16:50:20 +00:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * t a b l e _ a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
# i f def T H R E A D S _ C O N S U M E R _ S H A R I N G
B O p ( t a b l e _ a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n , O t a p l )
a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n :
{
I N I T _ P R E F E T C H ( )
int d o _ n o t _ c o m p l e t e _ t a b l e s ;
int w i d = w o r k e r _ i d ;
do {
d e p _ f r _ p t r d e p _ f r ;
a n s _ n o d e _ p t r a n s _ n o d e ;
d o _ n o t _ c o m p l e t e _ t a b l e s = 0 ; /* 0 - c o m p l e t e a l l t h e t a b l e s 1 - d o n o t c o m p l e t e a l l t h e t a b l e s */
if ( B - > c p _ a p = = A N S W E R _ R E S O L U T I O N _ C O M P L E T I O N ) {
/* g e n e r a t o r c o n s u m e r n o d e ( e x t e r n a l n o d e ) */
if ( ( I S _ B A T C H E D _ G E N _ C P ( B ) && (EQUAL_OR_YOUNGER_CP(B_FZ, B) && B != DepFr_leader_cp(LOCAL_top_dep_fr))) ||
( B ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) ) {
/* n o t l e a d e r o n t h a t n o d e */
I N F O _ T H R E A D S ( "ans_reso_com (1) : not leader on that node dep_fr = %p leader_node =%p" , L O C A L _ t o p _ d e p _ f r , G E N _ C P ( D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) - > c p _ d e p _ f r ) ;
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = w o r k i n g ;
B - > c p _ a p = A N S W E R _ R E S O L U T I O N ;
g o t o a n s w e r _ r e s o l u t i o n ;
}
/* l e a d e r o n t h a t n o d e */
d e p _ f r = G E N _ C P ( B ) - > c p _ d e p _ f r ;
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) ;
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) {
/* u n c o n s u m e d a n s w e r */
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = w o r k i n g ;
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
I N F O _ T H R E A D S ( "ans_reso_com (2) : consume_answer =%p dep_fr = %p leader_node =%p" , a n s _ n o d e , d e p _ f r , G E N _ C P ( D e p F r _ l e a d e r _ c p ( d e p _ f r ) ) - > c p _ d e p _ f r ) ;
c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( d e p _ f r , a n s _ n o d e ) ;
}
s g _ f r _ p t r s g _ f r = G E N _ C P ( B ) - > c p _ s g _ f r ;
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) < complete | | ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) > = complete && TrNode_child(ans_node)!= NULL))
d o _ n o t _ c o m p l e t e _ t a b l e s = 1 ;
} else { / * u s i n g t h e B - > c p _ a p = = A N S W E R _ R E S O L U T I O N _ C O M P L E T I O N t o d i s t i n g u i s h g e n _ c o n s n o d e s f r o m g e n * /
/* g e n e r a t o r n o d e */
if ( I S _ B A T C H E D _ G E N _ C P ( B ) ) {
if ( E Q U A L _ O R _ Y O U N G E R _ C P ( B _ F Z , B ) && B != DepFr_leader_cp(LOCAL_top_dep_fr)) {
/* n o t l e a d e r o n t h a t n o d e */
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = w o r k i n g ;
B - > c p _ a p = NULL ;
B = B - > c p _ b ;
g o t o f a i l ;
}
} else {
if ( B ! = D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) {
/* n o t l e a d e r o n t h a t n o d e */
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = w o r k i n g ;
B - > c p _ a p = A N S W E R _ R E S O L U T I O N ;
B = B - > c p _ b ;
I N F O _ T H R E A D S ( "ans_reso_com (3) : not leader on that node dep_fr = %p leader_node =%p" , L O C A L _ t o p _ d e p _ f r , G E N _ C P ( D e p F r _ l e a d e r _ c p ( L O C A L _ t o p _ d e p _ f r ) ) - > c p _ d e p _ f r ) ;
g o t o f a i l ;
}
}
}
/* l e a d e r o n t h a t n o d e */
/* n o u n c o n s u m e d a n s w e r s */
d e p _ f r = L O C A L _ t o p _ d e p _ f r ;
/* c h e c k f o r d e p e n d e n c y f r a m e s w i t h u n c o n s u m e d a n s w e r s */
while ( Y O U N G E R _ C P ( D e p F r _ c o n s _ c p ( d e p _ f r ) , B ) ) {
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) ;
if ( T r N o d e _ c h i l d ( a n s _ n o d e ) ) {
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = w o r k i n g ;
/* d e p e n d e n c y f r a m e w i t h u n c o n s u m e d a n s w e r s */
a n s _ n o d e = D e p F r _ l a s t _ a n s w e r ( d e p _ f r ) = T r N o d e _ c h i l d ( a n s _ n o d e ) ;
if ( I S _ B A T C H E D _ G E N _ C P ( B ) )
D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) = B - > c p _ b ;
else
D e p F r _ b a c k c h a i n _ c p ( d e p _ f r ) = B ;
/* r e b i n d v a r i a b l e s , u p d a t e r e g i s t e r s , c o n s u m e a n s w e r a n d p r o c c e e d */
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n , E Q U A L _ O R _ Y O U N G E R _ C P ( B , D e p F r _ c o n s _ c p ( d e p _ f r ) ) ) ;
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n , B - > c p _ t r > D e p F r _ c o n s _ c p ( d e p _ f r ) - > c p _ t r ) ;
r e b i n d _ v a r i a b l e s ( D e p F r _ c o n s _ c p ( d e p _ f r ) - > c p _ t r , B - > c p _ t r ) ; //don't know if it is the same unbind_variables(DepFr_cons_cp(dep_fr)->cp_tr, B->cp_tr);
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n , T R ! = B - > c p _ t r && !IsPairTerm((CELL)TrailTerm(TR - 1)));
T A B L I N G _ E R R O R _ C H E C K I N G ( a n s w e r _ r e s o l u t i o n _ c o m p l e t i o n , T R ! = B - > c p _ t r && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
B = D e p F r _ c o n s _ c p ( d e p _ f r ) ;
T R = T R _ F Z ;
if ( T R ! = B - > c p _ t r )
T R A I L _ L I N K ( B - > c p _ t r ) ;
I N F O _ T H R E A D S ( "ans_reso_com (4) : consume_answer =%p dep_fr = %p leader_node =%p" , a n s _ n o d e , d e p _ f r , G E N _ C P ( D e p F r _ l e a d e r _ c p ( d e p _ f r ) ) - > c p _ d e p _ f r ) ;
c o n s u m e _ a n s w e r _ a n d _ p r o c c e e d ( d e p _ f r , a n s _ n o d e ) ;
}
if ( D e p F r _ e x t e r n a l ( d e p _ f r ) = = TRUE ) {
s g _ f r _ p t r s g _ f r = G E N _ C P ( D e p F r _ c o n s _ c p ( d e p _ f r ) ) - > c p _ s g _ f r ;
if ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) < complete | | ( S g F r _ s g _ e n t _ s t a t e ( s g _ f r ) > = complete && TrNode_child(ans_node)!= NULL))
d o _ n o t _ c o m p l e t e _ t a b l e s = 1 ;
}
d e p _ f r = D e p F r _ n e x t ( d e p _ f r ) ;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * a t e r m i n a ç a o d a s t h r e a d s * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
if ( d o _ n o t _ c o m p l e t e _ t a b l e s = = 1 ) {
/* a l l t h e d e p e n d e n c y f r a m e s h a v e c o n s u m e d a l l a n s w e r s a n d w e h a v e e x t e r n a l t a b l e s */
if ( T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = = w i d )
/* w o r k e r _ i d i s n o t i n s i d e a n S C C */
c o n t i n u e ;
if ( T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = = w o r k i n g ) {
int c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) ;
do {
T h D e p F r _ t e r m i n a t o r ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) = 1 ;
c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) ;
} while ( c _ w i d ! = w i d ) ;
T h D e p F r _ t e r m i n a t o r ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = 1 ;
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = i d l e ;
} else if ( T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = = i d l e ) {
int l _ w i d = w i d ; /* l e a d e r w i d */
int c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) ;
int j u m p _ s t a t e = TRUE ;
do {
if ( T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) ! = i d l e ) {
j u m p _ s t a t e = FALSE ;
break ;
} else
if ( l _ w i d > c _ w i d )
l _ w i d = c _ w i d ;
c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) ;
} while ( c _ w i d ! = w i d ) ;
if ( j u m p _ s t a t e && l_wid == wid){
/* w i d i s t h e c u r r e n t l e a d e r t h r e a d */
T h D e p F r _ t e r m i n a t o r ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = 0 ;
c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) ;
do {
d e p _ f r _ p t r r e m o t e _ d e p _ f r = R E M O T E _ t o p _ d e p _ f r ( c _ w i d ) ;
while ( Y O U N G E R _ C P ( D e p F r _ c o n s _ c p ( r e m o t e _ d e p _ f r ) , D e p F r _ l e a d e r _ c p ( R E M O T E _ t o p _ d e p _ f r ( c _ w i d ) ) ) ) {
if ( T r N o d e _ c h i l d ( D e p F r _ l a s t _ a n s w e r ( r e m o t e _ d e p _ f r ) ) ) {
/* d e p e n d e n c y f r a m e w i t h u n c o n s u m e d a n s w e r s */
j u m p _ s t a t e = FALSE ;
break ;
}
r e m o t e _ d e p _ f r = D e p F r _ n e x t ( r e m o t e _ d e p _ f r ) ;
}
if ( T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) ! = i d l e ) {
j u m p _ s t a t e = FALSE ;
break ;
}
c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) ;
} while ( c _ w i d ! = w i d ) ;
}
if ( j u m p _ s t a t e && ThDepFr_terminator(GLOBAL_th_dep_fr(wid)) == 0){
c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) ;
do {
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) = c o m p l e t i n g ;
c _ w i d = T h D e p F r _ n e x t ( G L O B A L _ t h _ d e p _ f r ( c _ w i d ) ) ;
} while ( c _ w i d ! = w i d ) ;
T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = c o m p l e t i n g ;
}
} else if ( T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) = = c o m p l e t i n g ) {
I N F O _ T H R E A D S ( "ans_reso_com (5) : completing thread_state =%d" , T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w i d ) ) ) ;
break ; /* d o _ n o t _ c o m p l e t e _ t a b l e s = 0 ; - - s a m e a s " b r e a k ; " */
}
}
} while ( d o _ n o t _ c o m p l e t e _ t a b l e s ) ;
E N D _ P R E F E T C H ( )
I N F O _ T H R E A D S ( "ans_reso_com (6) : completing thread_state =%d" , T h D e p F r _ s t a t e ( G L O B A L _ t h _ d e p _ f r ( w o r k e r _ i d ) ) ) ;
g o t o c o m p l e t e _ a l l ;
}
E N D B O p ( ) ;
# e n d i f /* T H R E A D S _ C O N S U M E R _ S H A R I N G */