using altivec under amigaos4.1fe

8 posts / 0 new
Last post
flash
flash's picture
Offline
Last seen: 6 months 1 day ago
Joined: 2018-02-24 17:25
using altivec under amigaos4.1fe

Hi everybody,
it's first time I write in this forum, after many years of other interests I'm coming back to coding under amigaos :-)

I'm just developing further an old amigaos program targeting it for OS4.1
I want use altivec extensions because I'd like to speedup thinghs and use program also for bench purposes..

Sadly I got a lot of problems compiling it with altivec extensions, so tryng to understand how stuff works I came back to a much simpler program like this:

/*
* FILE: vec_add.c
*/
#include <stdio.h>
#include <altivec.h>

/*
* declares input/output scalar varialbes
*/
int a[4] __attribute__((aligned(16))) = { 1, 3, 5, 7 };
int b[4] __attribute__((aligned(16))) = { 2, 4, 6, 8 };
int c[4] __attribute__((aligned(16)));

int main(int argc, char **argv)
{
/*
* declares vector variables which points to scalar arrays
*/
__vector signed int *va = (__vector signed int *) a;
__vector signed int *vb = (__vector signed int *) b;
__vector signed int *vc = (__vector signed int *) c;

/*
* adds four signed intergers at once
*/
*vc = vec_add(*va, *vb); // 1 + 2, 3 + 4, 5 + 6, 7 + 8

/*
* output results
*/
printf("c[0]=%d, c[1]=%d, c[2]=%d, c[3]=%d\n", c[0], c[1], c[2], c[3]);

return 0;
}

and tryed to compile with following line:

gcc -maltivec -mabi=altivec -o vec_add vec_add.c

..the epilog of the story is a grimreaper, why?

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
Re: using altivec under amigaos4.1fe

AFAIK to do the above your should code like this rather:

  1. __vector int va, vb, vc;
  2.  
  3. va = vec_ld(0, a);
  4. vb = vec_ld(0, b);
  5.  
  6. vc = vec_add(va, vb);
  7.  
  8. vec_st(vc, 0, c);
flash
flash's picture
Offline
Last seen: 6 months 1 day ago
Joined: 2018-02-24 17:25
Re: using altivec under amigaos4.1fe

The example posted it's not my code but was taken over internet ad compiled fine under linux ppc.

So I have written another example as simple as possible:

#include <stdio.h>
#include <altivec.h>

int main ()
{
vector signed int v1 = {1,1,1,1};
vector signed int v2 = {1,1,1,1};
vector signed int v3;

v3 = vec_add (v1,v2);

printf ("Numbers v1: %9.8vld\n", v1);
printf ("Numbers v2: %9.8vld\n", v2);
printf ("Sum v1+v2: %9.8vld\n", v3);

return 0;
}

compiled with following command line:

gcc -maltivec -mabi=altivec -o vecadd vecadd.c

result: still crashes!

for debug purpose Grim reaper evidence the following line:
08b1acd8: 81630000 lwz r11,0(r3)

I got no warnings and no errors at compiling time.

What's wrong? Something in the source file or a gcc command line switch or.. what else?

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
Re: using altivec under amigaos4.1fe

Your second example won't compile for with ppc-amigaos-gcc 6.1.0. It gives the error "unknown conversion type character ā€˜vā€™ in format".

Your first example compiles fine but I can't say how well it runs because I don't have an altivec equipped CPU in any of my AmigaOS systems.

The code I posted above is basically the method I use in srec (zmbv encoder), and it is working correctly there according to the people who have tested it.

flash
flash's picture
Offline
Last seen: 6 months 1 day ago
Joined: 2018-02-24 17:25
Re: using altivec under amigaos4.1fe

I'm very very sorry, I just realized I lack some useful infos..

I used Gcc 4.2.4 (present in the latest amigaos4 sdk) and OS4.1 under winuae platform.
So.. no real amiga! :-(

Do you think could this be the problem? Does QEMU support Altivec ISA?

..Meanwhile I have updated to adtools archive present to osdepot, but it's still a v5, instead you have a gcc v6.
Can I update to v6 too? Is there a precompiled archive somewhere on the web?

Thank you very much for your support!

flash
flash's picture
Offline
Last seen: 6 months 1 day ago
Joined: 2018-02-24 17:25
Re: using altivec under amigaos4.1fe

I did some researches over the web but informations about qemu and altivec were a bit cloudy.
So I decided to exdpand my project quering tags inside cpuinfo exec function and surprise... I discovered Winuae doesn't support altivec vector unit under ppc emulation.

I realized also there's a lack of this simple command in amigados so maybe I'll make a simple command version to upload on aminet/os4depot. :-)

Happy coding @all!

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
Re: using altivec under amigaos4.1fe

I discovered Winuae doesn't support altivec vector unit under ppc emulation.

WinUAE emulates CyberstormPPC/BlizzardPPC expansions, neither of which used CPUs with altivec unit.

I wrote a simple commandline program havealtivec for use in mpg123.library Install script to detect which version of the library should be installed. It could also be used in an AmigaDOS script to detect if an altivec unit is available.

  1. havealtivec
  2.  
  3. if warn
  4. echo "No altivec unit detected."
  5. else
  6. echo "Altivec unit detected."
  7. endif
flash
flash's picture
Offline
Last seen: 6 months 1 day ago
Joined: 2018-02-24 17:25
Re: using altivec under amigaos4.1fe

Just uploaded on Aminet and Os4depot sites: PPCCpuInfo (source code included).
In quiet mode it acts just like your app, with an ok or a warning return code (vector unit present or not).
Very useful to be executed in scripts :-)

Tnx @all!

Log in or register to post comments