1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 2000-2006
5 * Sparking support for GRAN, PAR and THREADED_RTS versions of the RTS.
7 * ---------------------------------------------------------------------------*/
13 StgInt newSpark (StgRegTable *reg, StgClosure *p);
16 #if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
17 StgClosure * findSpark (Capability *cap);
18 void initSparkPools (void);
19 void markSparkQueue (evac_fn evac);
20 void createSparkThread (Capability *cap, StgClosure *p);
22 INLINE_HEADER void discardSparks (StgSparkPool *pool);
23 INLINE_HEADER nat sparkPoolSize (StgSparkPool *pool);
24 INLINE_HEADER rtsBool emptySparkPool (StgSparkPool *pool);
26 INLINE_HEADER void discardSparksCap (Capability *cap);
27 INLINE_HEADER nat sparkPoolSizeCap (Capability *cap);
28 INLINE_HEADER rtsBool emptySparkPoolCap (Capability *cap);
31 #if defined(PARALLEL_HASKELL)
32 StgTSO *activateSpark (rtsSpark spark) ;
33 rtsBool add_to_spark_queue( StgClosure *closure, StgSparkPool *pool );
34 void markSparkQueue( void );
35 nat spark_queue_len( StgSparkPool *pool );
36 void disposeSpark( StgClosure *spark );
40 void findLocalSpark (rtsEvent *event, rtsBool *found_res, rtsSparkQ *spark_res);
41 rtsBool activateSpark (rtsEvent *event, rtsSparkQ spark);
42 rtsSpark *newSpark(StgClosure *node, nat name, nat gran_info,
43 nat size_info, nat par_info, nat local);
44 void add_to_spark_queue(rtsSpark *spark);
45 rtsSpark *delete_from_sparkq (rtsSpark *spark, PEs p, rtsBool dispose_too);
46 void disposeSpark(rtsSpark *spark);
47 void disposeSparkQ(rtsSparkQ spark);
48 void print_spark(rtsSpark *spark);
49 void print_sparkq(PEs proc);
50 void print_sparkq_stats(void);
51 nat spark_queue_len(PEs proc);
52 void markSparkQueue(void);
55 /* -----------------------------------------------------------------------------
57 * -------------------------------------------------------------------------- */
59 #if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
62 emptySparkPool (StgSparkPool *pool)
64 return (pool->hd == pool->tl);
68 emptySparkPoolCap (Capability *cap)
69 { return emptySparkPool(&cap->r.rSparks); }
72 sparkPoolSize (StgSparkPool *pool)
74 if (pool->hd <= pool->tl) {
75 return (pool->hd - pool->tl);
77 return (pool->lim - pool->hd + pool->tl - pool->base);
82 sparkPoolSizeCap (Capability *cap)
83 { return sparkPoolSize(&cap->r.rSparks); }
86 discardSparks (StgSparkPool *pool)
92 discardSparksCap (Capability *cap)
93 { return discardSparks(&cap->r.rSparks); }
96 #elif defined(THREADED_RTS)
99 emptySparkPoolCap (Capability *cap STG_UNUSED)
104 #endif /* SPARKS_H */