Sparks.h 2.93 KB
Newer Older
1
2
3
4
/* -----------------------------------------------------------------------------
 *
 * (c) The GHC Team, 2000
 *
5
6
 * Sparking support for GRAN, PAR and SMP versions of the RTS.
 * 
7
8
 * ---------------------------------------------------------------------------*/

9
10
11
#ifndef SPARKS_H
#define SPARKS_H

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#if defined(PARALLEL_HASKELL) || defined(SMP)
StgClosure * findSpark         (Capability *cap);
void         initSparkPools    (void);
void         markSparkQueue    (evac_fn evac);
void         createSparkThread (Capability *cap, StgClosure *p);
StgInt       newSpark          (StgRegTable *reg, StgClosure *p);

INLINE_HEADER void     discardSparks  (StgSparkPool *pool);
INLINE_HEADER nat      sparkPoolSize  (StgSparkPool *pool);
INLINE_HEADER rtsBool  emptySparkPool (StgSparkPool *pool);

INLINE_HEADER void     discardSparksCap  (Capability *cap);
INLINE_HEADER nat      sparkPoolSizeCap  (Capability *cap);
INLINE_HEADER rtsBool  emptySparkPoolCap (Capability *cap);
#endif

#if defined(PARALLEL_HASKELL)
StgTSO      *activateSpark (rtsSpark spark) ;
rtsBool      add_to_spark_queue( StgClosure *closure, StgSparkPool *pool );
void         markSparkQueue( void );
nat          spark_queue_len( StgSparkPool *pool );
void         disposeSpark( StgClosure *spark );
#endif
35

36
#if defined(GRAN)
37
38
39
40
41
42
43
44
45
46
47
48
49
void      findLocalSpark (rtsEvent *event, rtsBool *found_res, rtsSparkQ *spark_res);
rtsBool   activateSpark (rtsEvent *event, rtsSparkQ spark);
rtsSpark *newSpark(StgClosure *node, nat name, nat gran_info, 
		   nat size_info, nat par_info, nat local);
void      add_to_spark_queue(rtsSpark *spark);
rtsSpark *delete_from_sparkq (rtsSpark *spark, PEs p, rtsBool dispose_too);
void 	  disposeSpark(rtsSpark *spark);
void 	  disposeSparkQ(rtsSparkQ spark);
void 	  print_spark(rtsSpark *spark);
void      print_sparkq(PEs proc);
void 	  print_sparkq_stats(void);
nat  	  spark_queue_len(PEs proc);
void      markSparkQueue(void);
50
51
52
53
54
#endif

/* -----------------------------------------------------------------------------
 * PRIVATE below here
 * -------------------------------------------------------------------------- */
55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#if defined(PARALLEL_HASKELL) || defined(SMP)

INLINE_HEADER rtsBool
emptySparkPool (StgSparkPool *pool)
{
    return (pool->hd == pool->tl);
}

INLINE_HEADER rtsBool
emptySparkPoolCap (Capability *cap) 
{ return emptySparkPool(&cap->r.rSparks); }

INLINE_HEADER nat
sparkPoolSize (StgSparkPool *pool) 
{
    if (pool->hd <= pool->tl) {
	return (pool->hd - pool->tl);
    } else {
	return (pool->lim - pool->hd + pool->tl - pool->base);
    }
}

INLINE_HEADER nat
sparkPoolSizeCap (Capability *cap) 
{ return sparkPoolSize(&cap->r.rSparks); }

INLINE_HEADER void
discardSparks (StgSparkPool *pool)
{
    pool->hd = pool->tl;
}

INLINE_HEADER void
discardSparksCap (Capability *cap) 
{ return discardSparks(&cap->r.rSparks); }
91
92


93
94
95
96
97
98
#elif defined(THREADED_RTS) 

INLINE_HEADER rtsBool
emptySparkPoolCap (Capability *cap STG_UNUSED)
{ return rtsTrue; }

99
#endif
100
101

#endif /* SPARKS_H */