Re: AltiVec on OSX in Cocoa
Re: AltiVec on OSX in Cocoa
- Subject: Re: AltiVec on OSX in Cocoa
- From: Brendan Younger <email@hidden>
- Date: Sun, 11 Nov 2001 14:06:14 -0500
On Sunday, November 11, 2001, at 08:47 AM, Charles Jolley wrote:
MrC has really complete support for altivec, unfortunately, gcc is not
quite as tailored to it.
The C extensions and the "vector" keyword are both fully supported,
but the memory allocation is a little sketchy.
Stack-based vectors will be automatically aligned correctly, but
AFAIK, there is no vec_malloc() which will guarantee 16-bit aligned
memory blocks. So, you are stuck either rolling your own, or using
NewPtr() (from Carbon). However, I have had some difficulties with
NewPtr() (more specifically, DisposePtr()). Hence, I suggest using a
custom struct which will hold both a pointer to the actual memory
allocated and a pointer to the next 16-bit aligned memory address.
You know, the Performance documentation I was reading the other day
states that the standard malloc always allocates memory on the heap
aligned to 16-byte boundaries. It might be worth just trying with
standard malloc first.
See /Developer/Documentation/Essentials/Performance/Performace.pdf, p22
(Understanding Malloc):
... The granularity of the blocks malloc returns is 16 bytes. So if you
ask for 4 bytes, malloc consumes 16 bytes, and if you ask for 24 bytes,
malloc will consume 32 bytes. ...
Yeah, sorry about that, silly me for reading the man pages . . .
"Malloc and free provide a general-purpose memory alloca-
tion package. Malloc returns a pointer to a block of at
least size bytes beginning on a long boundary."
But hey, if it works, so much the better.
Brendan Younger