Re: AltiVec on OSX in Cocoa
Re: AltiVec on OSX in Cocoa
- Subject: Re: AltiVec on OSX in Cocoa
- From: Charles Jolley <email@hidden>
- Date: Sun, 11 Nov 2001 07:47:41 -0600
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. ...
Cheers,
-Charles