[eigen] Help on solving a race condition |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] Help on solving a race condition
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 8 Jun 2012 15:12:44 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=aGHWZn2JK7KsU+WSoIjvl+OV9kHpXRt6KE+t0GPFUOQ=; b=naD5TYCEU14ZFKX42BYPemdJb8pau3VEBBSyLjaWCjxHLYWAdxhrvqL2iVgAN+nmAR wAFGJSvJ4dTgVEE+D3KHWZ84U4MPL2d64p3mz3GWHUq4a6cyaEvOmLzhDhuZ8BvVdeEj MzayIj1WjGfrBZyZZX3oCQ5BDlEHX3hDqTNHsC1Lw5YjmeH05AQSMsXfTMRAkcRvMiqG upjrFBmT9Vel+NwFFkFx5A1+GK1Egkp3y8Ntxh2BI73uTxqLoo96sZlqINai1nK4ziUt SoniOS0IkYMdIXaG10D8KYxuyxe4NMVRJVYVkWc20eBstYUiE6jd9uFQUyeiXPjub/Pb ebkw==
Hi,
I'm looking for some help on understanding how the following piece of
code in Eigen can lead to a race condition when the function
manage_caching_sizes is called from different threads:
inline std::ptrdiff_t manage_caching_sizes_helper(std::ptrdiff_t a,
std::ptrdiff_t b)
{
return a<=0 ? b : a;
}
inline void manage_caching_sizes(Action action, std::ptrdiff_t* l1=0,
std::ptrdiff_t* l2=0)
{
static std::ptrdiff_t m_l1CacheSize =
manage_caching_sizes_helper(queryL1CacheSize(),8 * 1024);
static std::ptrdiff_t m_l2CacheSize =
manage_caching_sizes_helper(queryTopLevelCacheSize(),1*1024*1024);
...
}
During it's first call, this function computes and store the cache sizes.
I would like to find a solution that avoids making the static variable
"thread private" as suggested there:
http://stackoverflow.com/questions/8828466/using-openmp-and-eigen-causes-infinite-loop-deadlock/10540025
The problem with this approach, is that the cache-sizes are recomputed
for every thread.
thanks,
Gaël