qthread_fork_{*} and nested thread safety

11 views
Skip to first unread message

John Leidel

unread,
Jan 12, 2012, 4:59:17 PM1/12/12
to qthr...@googlegroups.com
All, quick question about the safety of nested parallel regions in qthreads.  Is it safe/permissible to nest calls to one or more of the qthread_fork_{*}() routines?  [I'm not familiar with qthreads' rules of scoping] 

EG: 


#-- BAR
aligned_t bar( void )
{
    //-- do stuff
}

#-- FOO
aligned_t foo( void )
{

   qthread_fork( bar(), .., .. );

}

#-- MAIN 
int main( )
{
qthread_initialize();

qthread_fork( foo(), .. , .. )

....

}

--
John D. Leidel
Software Architect
Convey Computer
jle...@conveycomputer.com
(g) 972.836.7901
(m) 214.578.8510

Stark, Dylan

unread,
Jan 12, 2012, 6:11:50 PM1/12/12
to <qthreads@googlegroups.com>, John Leidel
John,

On Jan 12, 2012, at 2:59 PM, John Leidel wrote:

All, quick question about the safety of nested parallel regions in qthreads.  Is it safe/permissible to nest calls to one or more of the qthread_fork_{*}() routines?  [I'm not familiar with qthreads' rules of scoping] 


Your example pseudocode is certainly safe/permissible with respect to nesting. Each call to qthread_for_{*}() simply creates a new asynchronous task that is added to a work queue and scheduled to execute by the runtime. Your primary concern would be making sure that you set up your synchronization such that all spawned tasks finish before qthread_finalize() is called or main() exits. Aside from that, there are no explicit dependencies between tasks that are managed by Qthreads.

You might check out `<qthreads>/test/benchmarks/generic/time_fib.c` for a simple example of nested spawns.

EG: 


#-- BAR
aligned_t bar( void )
{
    //-- do stuff
}

#-- FOO
aligned_t foo( void )
{

   qthread_fork( bar(), .., .. );

}

#-- MAIN 
int main( )
{
qthread_initialize();

qthread_fork( foo(), .. , .. )

....

}

--
John D. Leidel
Software Architect
Convey Computer
jle...@conveycomputer.com
(g) 972.836.7901
(m) 214.578.8510

Dylan Stark
Scalable Computer Architectures Dept
Sandia National Laboratories

Reply all
Reply to author
Forward
0 new messages