1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 2000-2006
5 * Sparking support for GRAN, PAR and THREADED_RTS versions of the RTS.
7 * ---------------------------------------------------------------------------*/
12 #if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
13 StgClosure * findSpark (Capability *cap);
14 void initSparkPools (void);
15 void freeSparkPool (StgSparkPool *pool);
16 void createSparkThread (Capability *cap, StgClosure *p);
18 INLINE_HEADER void discardSparks (StgSparkPool *pool);
19 INLINE_HEADER nat sparkPoolSize (StgSparkPool *pool);
20 INLINE_HEADER rtsBool emptySparkPool (StgSparkPool *pool);
22 INLINE_HEADER void discardSparksCap (Capability *cap);
23 INLINE_HEADER nat sparkPoolSizeCap (Capability *cap);
24 INLINE_HEADER rtsBool emptySparkPoolCap (Capability *cap);
27 #if defined(PARALLEL_HASKELL)
28 StgTSO *activateSpark (rtsSpark spark) ;
29 rtsBool add_to_spark_queue( StgClosure *closure, StgSparkPool *pool );
30 void markSparkQueue( void );
31 nat spark_queue_len( StgSparkPool *pool );
32 void disposeSpark( StgClosure *spark );
36 void findLocalSpark (rtsEvent *event, rtsBool *found_res, rtsSparkQ *spark_res);
37 rtsBool activateSpark (rtsEvent *event, rtsSparkQ spark);
38 rtsSpark *newSpark(StgClosure *node, nat name, nat gran_info,
39 nat size_info, nat par_info, nat local);
40 void add_to_spark_queue(rtsSpark *spark);
41 rtsSpark *delete_from_sparkq (rtsSpark *spark, PEs p, rtsBool dispose_too);
42 void disposeSpark(rtsSpark *spark);
43 void disposeSparkQ(rtsSparkQ spark);
44 void print_spark(rtsSpark *spark);
45 void print_sparkq(PEs proc);
46 void print_sparkq_stats(void);
47 nat spark_queue_len(PEs proc);
48 void markSparkQueue(void);
51 /* -----------------------------------------------------------------------------
53 * -------------------------------------------------------------------------- */
55 #if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
58 emptySparkPool (StgSparkPool *pool)
60 return (pool->hd == pool->tl);
64 emptySparkPoolCap (Capability *cap)
65 { return emptySparkPool(&cap->r.rSparks); }
68 sparkPoolSize (StgSparkPool *pool)
70 if (pool->hd <= pool->tl) {
71 return (pool->hd - pool->tl);
73 return (pool->lim - pool->hd + pool->tl - pool->base);
78 sparkPoolSizeCap (Capability *cap)
79 { return sparkPoolSize(&cap->r.rSparks); }
82 discardSparks (StgSparkPool *pool)
88 discardSparksCap (Capability *cap)
89 { return discardSparks(&cap->r.rSparks); }
92 #elif defined(THREADED_RTS)
95 emptySparkPoolCap (Capability *cap STG_UNUSED)
100 #endif /* SPARKS_H */