Re: [eigen] portable reallocation... |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] portable reallocation...
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Sun, 28 Feb 2010 11:51:26 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=y5+xumDjvHHRWi41EyI5HKC++roBjPpl+iDf46kfnYU=; b=hZeiuTN2dqeMLJ+exFrflmlWLe608v/a7JtYpnvAnRWbPbJU4wuypvw3jEpiOAQhPR 7MYbKl0Jh5fhzYUbezV925wAh1+KFktsDMV6l/+/+Ad01W9EVZtPmx3zQvX0vIdukmy3 TsMuMuUpPUK+uzovpK9jievQxljm2aSObZuUg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=m5rkQMGyWO9pwGTCe3pHq+K3Wi+2EHD97BMlocAYPUJC84M1wkIsL2wOcrWkDoBGWZ ucVzT0lOZ4//89q6nWTKFSfJTqhfDe5KnsR1E46Yk4Dat7KjylqTbzVsX3O2ZA/5CctT stHsnC5GBogpFdF9nMuCVh/T7c5Pme7WBkkrc=
On Sun, Feb 28, 2010 at 1:13 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> the posix_memalign case was unimplemented, I overlooked that when
> reviewing your patch. I did it, closely following your mm-realloc
> code, and I made a few changes in your code, and I have a few
> questions (...)
ups, thank you. ;)
> OK so here you were testing for (ptr!=0 && size==0) and I replaced
> that with just size==0.
>
> Why were you checking ptr!=0 here?
>
>
> {
> _mm_free(ptr);
> - return NULL;
> + return 0;
> }
Well, maybe that is not really required. Actually, I just did it
because all default implementations I tested do something like this
if (ptr==0) return malloc(size);
and interestingly this is not necessarily 0, when size==0. But maybe
it is a good idea to enforce that behaviour
> One more question:
>
> in the line
>
> #if defined(_MSC_VER) && defined(_mm_free)
>
> Why are you checking for _mm_free ? Is it even guaranteed to be a
> preprocessor symbol? Why don't you just check for EIGEN_HAS_MM_MALLOC?
>
> Last question: in this code:
>
> #if defined(_MSC_VER) && defined(_mm_free)
> result = _aligned_realloc(ptr,new_size,16);
> #else
> result = ei_mm_realloc(ptr,new_size,old_size);
> #endif
>
>
> You mean that MSVC's _aligned_ functions are cool because they have
> realloc, whereas the _mm functions don't. Then shouldn't we just move
> MSVC's functions up in the priority list of functions to use? Is there
> any disadvantage in using them instead of _mm functions, when they are
> available? This would allow to remove this #ifdef here.
Somehow these are related. In MSVC (at least the newer versions),
_mm_malloc and _mm_free are implemented in terms of
_aligned_malloc/free -- they are indeed typedefs. I am just double
checking that with "defined(_mm_free)" since it might be that some old
versions are implemented differently.
Thinking of it again, I think it should be possible to consolidate the
three hand-made implementations
(ei_handmake_aligned_realloc/ei_mm_realloc/ei_posix_memalign_realloc)
into a single function. I have to double check that.
- Hauke