image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old April 10th, 2001, 12:40 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,186
Thanks: 0
Thanked 0 Times in 0 Posts
rharder is on a distinguished road
Does anyone know how to get AltiVec instructions to compile in OS X?

I was going through <a href="http://developer.apple.com/hardware/ve/tutorial.html">Apple's tutorial</a>, and I couldn't get anything to compile with "cc" or "cpp."

Are there special header files? Special compiler?

-Rob
Reply With Quote
  #2  
Old April 11th, 2001, 08:54 AM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,186
Thanks: 0
Thanked 0 Times in 0 Posts
rharder is on a distinguished road
Ah. There's a -faltivec flag for the "cc" compiler, and that gets you a little further but not all the way.

-Rob
Reply With Quote
  #3  
Old April 13th, 2001, 12:27 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,186
Thanks: 0
Thanked 0 Times in 0 Posts
rharder is on a distinguished road
I still can't compile AltiVec code. The "vector" keyword seems to throw it for a loop when I compile with "cc -altivec".

Anyone successfully compiled AltiVec code on OS X?

-Rob
Reply With Quote
  #4  
Old April 13th, 2001, 01:00 PM
Registered User
 
Join Date: Mar 2001
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
JSR COUT is on a distinguished road
Have you tried searching the header files for the word 'vector'? Sounds like you may not be including a needed header file.
Reply With Quote
  #5  
Old April 13th, 2001, 01:24 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,186
Thanks: 0
Thanked 0 Times in 0 Posts
rharder is on a distinguished road
No luck with the header files, but I might have had a different error after all. Here's a simple file that takes two 4-float arrays and does a a[i]*x + b[i] calculation on them in one fell swoop. I present it as starter code for those who would like to start incorporating AltiVec instructions in their code (like me). With a little tweak you could as easily do a a[i]*x[i] + b[i] also:

Code:
main()
{
    float a[] = { 1, 2, 3, 4 };
    float b[] = { 5, 6, 7, 8 };
    float x = 3.14;
    int memOffset = 0;
    float result[4];
    vector float aV, bV, xV, resultV;

    // Convert scalar x to vector xV
    vector float dummy = (vector float)(0);
    *((float *)&dummy) = x;
    xV = vec_splat( dummy, 0 );

    // Create vector types from 4-float arrays
    aV = vec_ld( memOffset, &a[0] );
    bV = vec_ld( memOffset, &b[0] );

    // Perform the a[i]*x + b[i] calculation
    resultV = vec_madd( xV, aV, bV );

    // Save vector type in a 4-float array
    vec_st( resultV, memOffset, &result[0] );

    return 0;
}
I don't know how the dummy code works. I modeled it after some sample code I found from the VAST guys.

-Rob
Reply With Quote
  #6  
Old April 15th, 2001, 10:07 AM
Registered User
 
Join Date: Jan 2001
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
monty is on a distinguished road
Thank you rob! the -faltivec switch does the trick.

I think that the thing were doing differently is that you're not adding the vecLib Framework to your project. By the way add that -faltivec to the OTHER_CFLAGS in Expert build settings.

peter
Reply With Quote
  #7  
Old April 15th, 2001, 03:40 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,186
Thanks: 0
Thanked 0 Times in 0 Posts
rharder is on a distinguished road
Thanks, Peter. You're way ahead of me. I haven't even gotten to the ProjectBuilder stuff yet.

-Rob
Reply With Quote
  #8  
Old April 16th, 2001, 08:49 AM
Registered User
 
Join Date: Jan 2001
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
monty is on a distinguished road
rob,

Just an update, you don't need the vecLib framework after all. It adds convenience funtions and stuff like that. all you need is the switch. also I'm not ahead of you, I couldn't get anything to work until you told me about the -faltivec switch. And just like you I'm still copying and pasting routines without having a clue how to write my own. Know any good docs?

Funny i did the project builder stuff first. I think its easier that way, just set the switch and you're away.

Peter
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php won't compile on Panther Gnomo Mac OS X System & Mac Software 0 October 27th, 2003 11:12 AM
HELP: I have no idea how to compile! Berk Software Programming & Web Scripting 2 October 31st, 2002 12:55 PM
simple "hello world" code using c++ huck Unix & X11 3 October 1st, 2002 02:25 PM
How to compile stuff fintler Unix & X11 1 August 28th, 2002 08:57 AM
tk compile crash buc99 Software Programming & Web Scripting 0 June 6th, 2002 12:38 AM


All times are GMT -5. The time now is 01:56 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.