Re: [eigen] portable reallocation... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] portable reallocation...
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 26 Feb 2010 06:48:51 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=PKA8peLlAWoI7HRhCNqsWsq9tOd1TzdWqRlXnjvVBTA=; b=APEVYzPzAZHw7yUn+uRWgPEeWEK47L+rL+Tt18svOdzH8hw2b7sG3un013tcSDUQ2d cv4tZgA3S0U6EREN9pUrD/Rx1fjQyw4Hb7RizAzWHmySyo7APNGSEMKt2LR87dOH3Xmb QSE1Gq4Y7cKx+KTVFsfO+HZSlkWXAdzippNfk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=DEOURp7M0F4Sm+m0qt6Dmfc2PLa6TZTbqmTBgnJgCdp4PxXzKc2I7jlbvL2N4TAxA0 91vh4WrHZKUAn+8K8Svnl+ZhuFGFS2jYZ6+oKa7QAAc35oijvSDUsHkDqvvo59Zw6lJe LounPWvZXFq1iYe4ig02iabiKTGEdV4YodxxY=
2010/2/26 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Hi guys,
>
> Since somebody asked on the forum I looked into implementing
> .conservativeResize(...) based on realloc where that makes sense. Such
> an implementation might yield higher performance since in some cases
> the data does not need to be copied.
>
> The issue I am running into right now is that there is no portable
> version of _mm_realloc. On MSVC this is not really a problem since
> _mm_malloc = _aligned_alloc and thus I can fall back to
> _aligned_realloc. On other systems on the other hand side, I have no
> idea how _mm_malloc is implemented. An alternative would be to provide
> something as shown here
>
> http://stackoverflow.com/questions/1641067/i-figured-out-how-to-write-realloc-but-i-know-the-code-is-not-right
>
> Also not very nice and still no solution since the standard does not
> define a function mm_getsize. On MSVC it is called _msize and on other
> systems it has different names - when it exists at all.
>
> The gist is that without knowing the size of the memory buffer I am
> about to reallocate, there is no way in implementing a malloc/free
> based version of realloc.
>
> Any suggestions?
Since this will only be used by Eigen, specifically by
conservativeResize, your portable realloc wrapper doesn't have to have
the standard realloc API where only the new size is passed. You can
instead write your own realloc-like function that also takes the old
size as an argument.
This is just like our ei_aligned_delete: it takes the size as an
argument in order to implement the for loop calling destructors. This
is unlike the usual "delete[]" that determines the array size by
itself, but that doesn't matter, since in all contexts where we're
calling ei_aligned_delete, we do know the size.
Benoit
>
> - Hauke
>
>
>