• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] Altivec
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] Altivec


  • Subject: Re: [OT] Altivec
  • From: David Duncan <email@hidden>
  • Date: Fri, 4 Jul 2003 10:58:06 -0400

On Friday, July 4, 2003, at 06:43 AM, Mark's Studio wrote:

First is NSLog not supposed to print out vectors with the %vd format?

No idea. If it just calls into the BSD printf(), then I would think not (at least according to the man page) as it is not supported there.

Here is the problem

peakBuffer is a const void * [NSData mutableBytes]
vSInt8 lmin,lmax is from the vec_min(),vec_max()

*(vSInt8 *)peakBuffer = lmin; NSLog(@"%d",*(SInt8
*)peakBuffer); peakBuffer+= 1;
*(vSInt8 *)peakBuffer = rmin; NSLog(@"%d",*(SInt8
*)peakBuffer); peakBuffer+= 1;
*(vSInt8 *)peakBuffer = lmax; NSLog(@"%d",*(SInt8
*)peakBuffer); peakBuffer+= 1;
*(vSInt8 *)peakBuffer = rmax; NSLog(@"%d",*(SInt8
*)peakBuffer); peakBuffer+= 1;

Altivec loads & stores always happen on 16-byte boundries, so your efforts to store the vector into peakBuffer will always put them in an aligned location - which is probably not where you want it.

// this is just to check what was stored
peakBuffer-= 4;
SInt8 t1,t2,t3,t4;
t1 = *(SInt8 *)peakBuffer; peakBuffer+= 1;
t2 = *(SInt8 *)peakBuffer; peakBuffer+= 1;
t3 = *(SInt8 *)peakBuffer; peakBuffer+= 1;
t4 = *(SInt8 *)peakBuffer; peakBuffer+= 1;

NSLog(@"%d %d %d %d",t1,t2,t3,t4);

Here is a bit of the output, the original value is right, but why is
the check not the same ?

And if peakBuffer is not 16-byte aligned, then the check will print something completely different from the store above, as the scalar loads here can happen in places where you could have not stored anything in the prior section.

Is SInt8 and vSInt8 not the same size?

No they are not. SInt8 is 1 byte, while vSInt8 is 16 bytes (as are all vector types). Altivec also only loads on a 16-byte boundry - there is no way to load an entire vector off this alignment in a single instruction. So given what your seeing, I'd make sure that peakBuffer is 16-byte aligned.

--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.

David Duncan
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >[OT] Altivec (From: "Mark's Studio" <email@hidden>)

  • Prev by Date: Re: Fw: GetSharedLibrary
  • Next by Date: Re: Fw: GetSharedLibrary
  • Previous by thread: [OT] Altivec
  • Next by thread: Re: [OT] AltiVec
  • Index(es):
    • Date
    • Thread