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: Sun, 28 Feb 2010 07:53:08 -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 :content-transfer-encoding; bh=14oQH0NGWjtxdNDtyBQFdeUO5PmVxl2o+2kXJBVu9bY=; b=H4Shnos4QcENtlRqkUU9OGWSp5hPGrUNGqGwqdKSeKo3Hw5EGT8pNrRKYyxNO/K6SQ LCkT1MFivgnm8mALuprnCjCmWQIML3LBzdnPb2aRQyyRDm7nqdnngIdliBtxnPAUuOwu 7nbTi6zwKc7vLDMSp1gl7YxfVMx0czZebrHP4=
- 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:content-transfer-encoding; b=uWiCOyuqZWWth5M14yNMBtgTw8jTjNpZl67n4YwhLE6tRk1hL2W5JDZoONMjia18Sa 5LChbkZqj54QIrzm6ngGsqLE7DlNYqNM8qR0H0FCOH0NMUiP9HbMh/7qZvM/BQfeQX5Z 7QsTMJciK16UpG4ECa2IDvscMpLp7SKrKpnkY=
Wait, one more comment.
The function name ei_handmade_aligned_realloc is unfortunate, since it
seems to suggests that it's the function for use with
ei_handmade_aligned_malloc.
So I would rather call it something like ei_generic_aligned_realloc.
Then, it would be interesting to actually code the
ei_handmade_aligned_realloc using std::realloc... indeed, in the
handmade case, that would give better realloc performance.
By the way, we also must call std::realloc and not realloc.
Benoit
2010/2/28 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> Great patch, just 1 comment:
>
> - /*errno = ENOMEM;*/ // according to the standard we should set
> errno = ENOMEM
> + errno = ENOMEM; // according to the standard
>
> Isn't it std::errno? Recently someone complained that the standard
> doesn't guarantee that the c++ headers will define these symbols in
> the global namespace, only in the std namespace. Putting std::
> everywhere was necessary to fix QNX/QCC compatibillity.
>
> OH WAIT!
>
> While we're at it, all the calls to free() must be replaced by std::free() !!
>
> Finally, let me re-ask (since either you didn't reply to that or I
> didn't understand the reply):
> - how about moving MSVC's functions _aligned_... up in the priority list?
>
> Benoit
>
> 2010/2/28 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
>> Here is a new patch. I found the navigation in Memory.h a little
>> complex so I tried to reorder the functions in order to achieve
>> better/cleaner grouping.
>>
>> - Hauke
>>
>> On Sun, Feb 28, 2010 at 11:55 AM, Hauke Heibel
>> <hauke.heibel@xxxxxxxxxxxxxx> wrote:
>>> So, how about this one (a single handmade version):
>>>
>>> inline void* ei_new_handmade_aligned_realloc(void* ptr, size_t size,
>>> size_t old_size)
>>> {
>>> if (ptr==0)
>>> return ei_aligned_malloc(size);
>>>
>>> if (size==0)
>>> {
>>> ei_aligned_free(ptr);
>>> return 0;
>>> }
>>>
>>> void* newptr = ei_aligned_malloc(size,16);
>>> if (newptr == 0)
>>> {
>>> /*errno = ENOMEM;*/ // according to the standard we should set
>>> errno = ENOMEM
>>> return 0;
>>> }
>>>
>>> if (ptr != 0)
>>> {
>>> std::memcpy(newptr, ptr, std::min(size,old_size));
>>> ei_aligned_free(ptr);
>>> }
>>>
>>> return newptr;
>>> }
>>>
>>> - Hauke
>>>
>>
>