Re: [eigen] Help on solving a race condition |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Help on solving a race condition
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 8 Jun 2012 16:57:06 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=r5N/bmGXOlELUC+8x0ntz91ub+mIzR1yn2XS90C3hx4=; b=i7HVU9Nek38tWdw/BiptJOhDSdqaM3KBGUB2pYZzMMFnjJOMQwVQbKSrQTcES5KoE4 OFpMCO6ZQ9dO/UcZn2cIg2OaqDMIg63jMhryysVTARMFAdfcTlPXyxyy7hGjgeYuabdM sZ6aYenlmf9TRv6h5JhV4JXe3SHzGn/L2uPmKXTJ0XWQylBCU1b2itcCk37gxE2XQJNK bPSTPOQTwi18jy3Q/KS1CkIVq2mnkLF3dXQrJLl1zZ7gV6TiY2suTmw1PfEF1oC6jH1N ob3sNX5dq6KPXXLuL5JnGSQpx9td5pbZDrcYlnpl/gKuF6d7uRLTHCq1rWtI+KSCmqLK c7zg==
On Fri, Jun 8, 2012 at 4:35 PM, Hauke Heibel
<hauke.heibel@xxxxxxxxxxxxxx> wrote:
> #pragma omp critical
> {
> 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);
> }
yes that would work, but mutex introduces a too large overhead. This
function is called for every matrix product!
It seems OpenMP's support for atomics is not very good. I managed to
make helgrind happy with the following:
static tbb::atomic<std::ptrdiff_t> m_l1CacheSize;
static tbb::atomic<std::ptrdiff_t> m_l2CacheSize;
if(!m_l1CacheSize)
{
std::ptrdiff_t l1 =
manage_caching_sizes_helper(queryL1CacheSize(),8 * 1024);
m_l1CacheSize.fetch_and_store(l1);
}
if(!m_l2CacheSize)
{
std::ptrdiff_t l2 =
manage_caching_sizes_helper(queryTopLevelCacheSize(),1*1024 * 1024);
m_l2CacheSize.fetch_and_store(l2);
}
but 1) this requires Intel's TBB, 2) I still have to measure the
overhead of this solution.
best,
Gael.
gael.