Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Temporary memcpy unaligned data - is it recommended?



On Nov 1, 2005, at 12:10 AM, Rustam Muginov wrote:

Hello all.
Then performing opportunistic optimization, its not always possible to rework data structures for proper alignment.
So most of the time I have to deal with unaligned data.
My question is - does anyone have the experience with the following technique:
Allocate memory block (or create in on stack if maximum data size is small enough and known at compile time). Make it 15 bytes larger then maximum data size.
Create an "aligned" pointer to the data (like adding 15 to the address and then clearing less significunt 4 bits).
Copy data into this aligned buffer.
Perform altivec operations.
Copy data back into the structure.

Use vec_perm instead; it is essentially executed for free. You should use the padded-alignment technique when allocating your data structure memory, but please note that malloc in Mac OS X always returns 16-byte aligned blocks. If you're accessing a struct and the alignment is unknown, you need lvsl/lvsr and perm, and you can always use lve/sve if necessary.
--
Shaun Wexler
MacFOH
http://www.macfoh.com



_______________________________________________ Do not post admin requests to the list. They will be ignored. PerfOptimization-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden
References: 
 >Temporary memcpy unaligned data - is it recommended? (From: Rustam Muginov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.