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 markSparkQueue (evac_fn evac);
17 void createSparkThread (Capability *cap, StgClosure *p);
19 INLINE_HEADER void discardSparks (StgSparkPool *pool);
20 INLINE_HEADER nat sparkPoolSize (StgSparkPool *pool);
21 INLINE_HEADER rtsBool emptySparkPool (StgSparkPool *pool);
23 INLINE_HEADER void discardSparksCap (Capability *cap);
24 INLINE_HEADER nat sparkPoolSizeCap (Capability *cap);
25 INLINE_HEADER rtsBool emptySparkPoolCap (Capability *cap);
28 #if defined(PARALLEL_HASKELL)
29 StgTSO *activateSpark (rtsSpark spark) ;
30 rtsBool add_to_spark_queue( StgClosure *closure, StgSparkPool *pool );
31 void markSparkQueue( void );
32 nat spark_queue_len( StgSparkPool *pool );
33 void disposeSpark( StgClosure *spark );
37 void findLocalSpark (rtsEvent *event, rtsBool *found_res, rtsSparkQ *spark_res);
38 rtsBool activateSpark (rtsEvent *event, rtsSparkQ spark);
39 rtsSpark *newSpark(StgClosure *node, nat name, nat gran_info,
40 nat size_info, nat par_info, nat local);
41 void add_to_spark_queue(rtsSpark *spark);
42 rtsSpark *delete_from_sparkq (rtsSpark *spark, PEs p, rtsBool dispose_too);
43 void disposeSpark(rtsSpark *spark);
44 void disposeSparkQ(rtsSparkQ spark);
45 void print_spark(rtsSpark *spark);
46 void print_sparkq(PEs proc);
47 void print_sparkq_stats(void);
48 nat spark_queue_len(PEs proc);
49 void markSparkQueue(void);
52 /* -----------------------------------------------------------------------------
54 * -------------------------------------------------------------------------- */
56 #if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
59 emptySparkPool (StgSparkPool *pool)
61 return (pool->hd == pool->tl);
65 emptySparkPoolCap (Capability *cap)
66 { return emptySparkPool(&cap->r.rSparks); }
69 sparkPoolSize (StgSparkPool *pool)
71 if (pool->hd <= pool->tl) {
72 return (pool->hd - pool->tl);
74 return (pool->lim - pool->hd + pool->tl - pool->base);
79 sparkPoolSizeCap (Capability *cap)
80 { return sparkPoolSize(&cap->r.rSparks); }
83 discardSparks (StgSparkPool *pool)
89 discardSparksCap (Capability *cap)
90 { return discardSparks(&cap->r.rSparks); }
93 #elif defined(THREADED_RTS)
96 emptySparkPoolCap (Capability *cap STG_UNUSED)
101 #endif /* SPARKS_H */