Click Here
home features news forums classifieds faqs links search
6077 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
Home
Features
News
Forums
Classifieds
Links
Downloads
Extras
OS4 Zone
IRC Network
AmigaWorld Radio
Newsfeed
Top Members
Amiga Dealers
Information
About Us
FAQs
Advertise
Polls
Terms of Service
Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
72 crawler(s) on-line.
 14 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!
 MEGA_RJ_MICAL:  7 mins ago
 Av8Retro:  1 hr 13 mins ago
 Trekiej:  2 hrs 14 mins ago
 ggw:  2 hrs 33 mins ago
 dalek:  2 hrs 56 mins ago
 PhantomInterrogative:  3 hrs 24 mins ago
 hardwaretech:  3 hrs 43 mins ago
 moddedamiga:  3 hrs 48 mins ago
 DiscreetFX:  3 hrs 57 mins ago
 eliyahu:  4 hrs 46 mins ago

/  Forum Index
   /  Amiga OS4.x \ Workbench 4.x
      /  Does AOS4 support ALTIVEC?
Register To Post

Goto page ( Previous Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 Next Page )
PosterThread
Karlos 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:07:11
#21 ]
Elite Member
Joined: 24-Aug-2003
Posts: 2020
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@EntilZha

Quote:

EntilZha wrote:
Another item on my Todo list: Thermal management. The PPC can watch the temperature, and if it's too high, it can generate an interrupt. The handler can then use the instruction fetch throttling to slow down (and cool) the CPU...


Is that just higher end PPCs or do the 603/604 have inbuilt temperature sensors?

_________________
IBrowse/AWeb user? amiga.org - classic browser edition

 Status: Offline
Profile     Report this post  
olegil 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:10:53
#22 ]
Elite Member
Joined: 22-Aug-2003
Posts: 5888
From: Work

@EntilZha

But if you only have one application that uses Altivec you'll still save/restore every time that task leaves/enters active state resp.

Or did I miss something?

The idea would be to only save if the another application WILL use it, and restore only if another application HAS used it. Or is that too tricky? (I know it is tricky, but is it TOO tricky? )

_________________
This weeks pet peeve:
Using "voltage" instead of "potential", which leads to inventing new words like "amperage" instead of "current" (I, measured in A) or possible "charge" (amperehours, Ah or Coulomb, C). Sometimes I don't even know what people mean.

 Status: Offline
Profile     Report this post  
EntilZha 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:18:45
#23 ]
OS4 Core Developer
Joined: 27-Aug-2003
Posts: 1679
From: The Jedi Academy, Yavin 4

@Atheist

Quote:
Could the Altivec keep computing, if the next "task" doesn't use it? Or something to that effect, anyway.


Altivec is "just" like an FPU: It's executing instructions from the "normal" isntruction stream. It doesn't work by itself, and it doesn't work in it's own "thread" (i.e. it does not use it's own instruction stream).

The 745x's used in the A1's are all next-gen Altivec implementations, with 4 execution units forming the Altivec unit (two vector integer units, one vector floating point unit, and one permute unit). These work in parallel, so when an Altivec instruction is being process, other instrucitons can be handled in other parts of the CPU.

So theoretically, long-running instructions could even be executing while the next task is already on the job. However, this doesn't work. The task switch is an exception, and exceptions are syncronizing, meaning they are taken in program order. The result is that the exception isn't taken until all previous instructions finished.

But even then, most Altivec instructions have very low latency. Most of the instructions use 1 4 cycles.

_________________
Thomas, the kernel guy

"I don't have a frigging clue. I'm norwegian" -- Ole-Egil

All opinions expressed are my own and do not necessarily represent those of Hyperion Entertainment

 Status: Offline
Profile     Report this post  
Karlos 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:19:35
#24 ]
Elite Member
Joined: 24-Aug-2003
Posts: 2020
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@olegil

OK, how about the following embelishment to EntilZha's scheme?

You keep a pointer to the last task that was known to save/modify the altivec registers. When the task switch occurs, if the task being switched to is the same as the task that last used the altivec registers, you supress the (redundant) reload. Saving as you switch out of the task would still be needed since you dont know if a fututre usurping task will use it.

But, you can even get around this.

If the "last altivec user" task pointer is kept somewhere completely accessible to exec at all times (without scouring through the task list etc), you can examine the task you are about to switch to.

If that task doesnt use altivec, you dont save your (possibly changed) registers back to the "last altivec user" task's context data.

If/when you do switch to a task that will use altivec (according to the machine state), that isnt the same task as the "last altivec user", you then save the registers back to the "last altivec user" first, before updating that pointer to point to the new task.

This way, altivec registers are only ever saved/restored during task switches between different tasks using altivec.

You could even do the same for the FPU

_________________
IBrowse/AWeb user? amiga.org - classic browser edition

 Status: Offline
Profile     Report this post  
Geomol 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:39:51
#25 ]
Regular Member
Joined: 19-May-2003
Posts: 214
From: Denmark

K.I.S.S.!!! or Keep It Simple, Stupid!

If you go with what CodeSmith suggested, the system will be faster, if you often have tasks, that use the Altivec very little. The downside is, that if you have tasks, that use the Altivec alot, the system will be slower.

Karlos idea is another possibility, but what is the overhead of checking pointers, compared to just copying the registers? With Karlos idea, the system will maybe be faster, if you have very few tasks, that use the Altivec, but it will be slower, if you have alot of tasks, that use the Altivec.

I'm for the most simple way of doing it. That may be just copying the registers, if the task is set to use the Altivec.

/John.

 Status: Offline
Profile     Report this post  
Geomol 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:48:12
#26 ]
Regular Member
Joined: 19-May-2003
Posts: 214
From: Denmark

Btw. wasn't it supposed to be possible to change the scheduler in OS4+? The OS could then default do it in a very simple way, and if you have a special case, where another way of managing registers in the Altivec would give a benefit, the scheduler could then just be changed.

/John.

 Status: Offline
Profile     Report this post  
Karlos 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:49:32
#27 ]
Elite Member
Joined: 24-Aug-2003
Posts: 2020
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@Geomol

If you have a lot of tasks using altivec, the overhead of a single pointer comparison (you are only looking for equality, after all) has got to be vastly less than the overhead in actually moving 1024 bytes worth of data (512 to save the last user and 512 to load the next) where the registers need to be swapped.

Basically my idea implies a pointer check for each task switch that uses altivec, but not for those that don't. I dont see the impact of that being detectable, let alone measurable.

_________________
IBrowse/AWeb user? amiga.org - classic browser edition

 Status: Offline
Profile     Report this post  
EntilZha 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:55:12
#28 ]
OS4 Core Developer
Joined: 27-Aug-2003
Posts: 1679
From: The Jedi Academy, Yavin 4

@olegil

Quote:
Or did I miss something?


No, that's correct. Remember, though, that you'll only store/restore the register that you actually use...

Quote:
The idea would be to only save if the another application WILL use it, and restore only if another application HAS used it. Or is that too tricky? (I know it is tricky, but is it TOO tricky? )


The question is is it worth the hassle ? Right now, a context switch takes about 2 microseconds on an 800 MHz machine, which is quite low. The overhead of storing/restoring a few vector register now and then probably don't matter that much, then...

It's probably a matter of testing how much overhead is really involved, and then deciding if it's worth the hassle...

_________________
Thomas, the kernel guy

"I don't have a frigging clue. I'm norwegian" -- Ole-Egil

All opinions expressed are my own and do not necessarily represent those of Hyperion Entertainment

 Status: Offline
Profile     Report this post  
Geomol 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 13:56:35
#29 ]
Regular Member
Joined: 19-May-2003
Posts: 214
From: Denmark

@Karlos

You've got a point! (I didn't realize, it was 1024 bytes of data.)

Maybe real tests are needed to make a decision, that gives the fastest system. And it should be possible to do such tests with AmigaOS.

/John.

 Status: Offline
Profile     Report this post  
Karlos 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 14:05:59
#30 ]
Elite Member
Joined: 24-Aug-2003
Posts: 2020
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@Geomol

I was thnking something like this:

if (nextTask->usesAltivec && nextTask != lastAltivecUser)
{
    saveAltivecRegs(lastAltivecUser);
    loadAltivecRegs(nextTask);
    lastAltivecUser = nextTask;
}



_________________
IBrowse/AWeb user? amiga.org - classic browser edition

 Status: Offline
Profile     Report this post  
Treke 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 15:44:27
#31 ]
Regular Member
Joined: 17-Mar-2003
Posts: 137
From: EU

@Karlos

Hi
Not efficient, not flexible

The ' low coupling' solution is:

Each task should have associated a pointer to IContextSwitcher interface
which should have 2 implementations:
1. NormalSwitcher - preforms normal context switch
2. AltivecSwitcher - preforms normal context switch + copies altivec vector registers

will look like this:

class IContextSwitcher
{
Public:
void ContextSwitch( , , , )=0; // A 'contract' for performing the context switch
};


class OS4Task
{

IContextSwitcher* switcher;
};

Initially the task information structure ( or class ) should have set this pointer to NormalSwitcher. When 'that' exception triggers (task is using altivec) Exec should change the pointer to AltivecSwitcher

It means it will be sufficient to call

task -> switcher -> ContextSwitch(...,processor,bla, bla) // Just example

Note:
1. This example is written without insight
2. Emphasises _only_ the change of rather complex condition evaluation to one polymorphic call.
3. Saves proc time, increases reusability (Ying and Yan -TM- Craig Larman - )
4. To couple SO directly the switcher with task is very discutable
5. I'm sure it is not so easy as I tell it here

re

Treke


 Status: Offline
Profile     Report this post  
Karlos 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 16:25:13
#32 ]
Elite Member
Joined: 24-Aug-2003
Posts: 2020
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@Treke

Well, first off I was only using the code to demonstrate the idea in "easy to follow" fashion.

-edit-

Also, you need to consider that you don't know in advance if your task is going to be an altivec using one or not. You only discover it is after it firsts uses the atlivec unit, causing a change in the CPU state registers you can spot later.

That seriously complicates your approach. Once you detect the altivec unit was used, you'd need to change your virtual function pointer, effectively changing the class of your Task.

You can't avoid a degree of coupling when working at such a low level.

-/edit-

Implementation could be vastly different, eg., using a virtual function as you imply. As a C++ programmer, I agree that does indeed give a lot of additional flexibility.

Note the kernel is not written in C++, but an Interface has the virtual call mechanisn your approach would require. The virtual function call mechanism used for OS4 interfaces is a good deal more efficient (in terms of overhead) than C++ virtual calls (if ever so slightly less flexible).

As to the efficiency, you'd need to test the condition versus the virtual call.

_________________
IBrowse/AWeb user? amiga.org - classic browser edition

 Status: Offline
Profile     Report this post  
EntilZha 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 16:40:00
#33 ]
OS4 Core Developer
Joined: 27-Aug-2003
Posts: 1679
From: The Jedi Academy, Yavin 4

@Karlos

Quote:
Implementation could be vastly different, eg., using a virtual function as you imply. As a C++ programmer, I agree that does indeed give a lot of additional flexibility.


Note, though, that at this point (i.e. inside the scheduler) you will have to watch carefully what you're doing. This part has to be written in assembly, especially if you're juggling around registers.

What I intent do do (you know, the ever growing todo list ) is to make the scheduler adaptive, probably through an exec interface with some functions that have a special calling mechanism (i.e. not using normal registers for parameter passing, etc). That way, it can be exchanged, even on the fly...

_________________
Thomas, the kernel guy

"I don't have a frigging clue. I'm norwegian" -- Ole-Egil

All opinions expressed are my own and do not necessarily represent those of Hyperion Entertainment

 Status: Offline
Profile     Report this post  
Karlos 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 16:42:47
#34 ]
Elite Member
Joined: 24-Aug-2003
Posts: 2020
From: As-sassin-aaate! As-sassin-aaate! Ooh! We forgot the ammunition!

@EntilZha

Cool. I'll have some of that

_________________
IBrowse/AWeb user? amiga.org - classic browser edition

 Status: Offline
Profile     Report this post  
ssolie 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 16:47:38
#35 ]
Elite Member
Joined: 10-Mar-2003
Posts: 2755
From: Alberta, Canada

@EntilZha
Quote:
It's probably a matter of testing how much overhead is really involved, and then deciding if it's worth the hassle...


Personally, I like XP's advice in this kind of situation. The AltiVec feature is important but the effort to tune it now may not be worth it as it affects a very small set of programs at the moment (1 by my count). Besides, you can always improve it in a later iteration (e.g. BoingBag, 4.1) if need be.

Besides, there are much more important features to worry about *cough* SNAP *cough* in my opinion.

_________________
ExecSG Team Lead

 Status: Offline
Profile     Report this post  
Treke 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 19:16:58
#36 ]
Regular Member
Joined: 17-Mar-2003
Posts: 137
From: EU

@Karlos

Quote:
Also, you need to consider that you don't know in advance if your task is going to be an altivec using one or not. You only discover it is after it firsts uses the atlivec unit, causing a change in the CPU state registers you can spot later.


AFAIK from this thread, that triggers and exception and then you change the pointer to polymorphic class using Altivec Switching.
Until then, no altivec registers are copied.

I don't know, maybe I'm too far from reality, but in theory I don't see the problem
In practice -> juggling with registers .... hmmm

Quote:
As to the efficiency, you'd need to test the condition versus the virtual call.

Agree.
A base of a condition is a CMP-like instruction, for virtual call is an indirectional JMP i.e. a JMP-like instruction
If a condition is simple , than you compare one CMP to one JMP, but if not, you compare more CMP to one JMP. I guess one JMP is faster. Just guess...

Off course pasting one if to code is much faster than doing 3 classes

re

Treke

 Status: Offline
Profile     Report this post  
CodeSmith 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 21:19:32
#37 ]
Elite Member
Joined: 8-Mar-2003
Posts: 3045
From: USA

@Treke

That's the main difference between the algorithm that I suggested and the one the Friedens are considering using. The way I understand their algorithm, all tasks are assumed to not be using Altivec when they are first created - so there's no need to save and restore Altivec state for them. The first time a task uses Altivec, it triggers a trap that marks that task as one that uses Altivec. This in turn causes saving and restoring of Altivec state for that task from then on.

My algorithm is different - it is adaptive. Instead of looking at "uses altivec" for the lifetime of the task (this is "no" until the first time Altivec is used, and then it is "yes" from them on), I look at this for the lifetime of the current 20ms scheduler timeslice (20ms or however long that is in OS4). In other words, instead of "has this task used altivec at all", my algorthm asks "is this task using altivec during these 20ms". The answer to this question will change many times for a single task as it runs. Even tasks that use Altivec don't use it 100% of the time - typically there will be bursts where altivec is used, and then it isn't used for a long time (eg a movie player that uses altivec to decode the video stream - sure it uses altivec a lot, but it also spends time painting stuff on the window, handling events, etc). Since my algorithm only cares about altivec use 20ms at a time, altivec state only gets moved around when absolutely necessary. Worst case scenario is that Altivec is used 100% of the time, and then performance will be the same as if it got saved and restored all the time anyway.

 Status: Offline
Profile     Report this post  
Jose 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 21:35:22
#38 ]
Cult Member
Joined: 10-Mar-2003
Posts: 955
From: Unknown

@EntilZha

"..It's probably a matter of testing how much overhead is really involved, and then deciding if it's worth the hassle..."

The scheduler's efficiency is our pride and joy.
You should do it
Just make it a lower priority if there's not such a big difference.
[EDIT] Yeah, 604's don't have ALTIVEC...

_________________

JosÚ

 Status: Offline
Profile     Report this post  
Chris_Y 
Re: Does AOS4 support ALTIVEC?
Posted on 13-May-2004 21:47:46
#39 ]
Elite Member
Joined: 21-Jun-2003
Posts: 3166
From: Beds, UK

@CodeSmith

Don't the Altivec registers need to be preserved for the lifetime of any task that is using Altivec? If a task puts a value in an Altivec register, surely this value should still be available when the task next looks at it (which might be within 20ms, but then it might be after the user answers some question)? If the task finds an unexpected value in a register then strange things will happen, so if it is using Altivec registers then they should be saved and restored no matter when they were last used.

Is there really any performance difference between:
1. Saving and restoring all registers (inc. Altivec)
2. Checking the task list to see if the task used Altivec, and not saving/restoring Altivec registers if it didn't

If anything I would argue that (2) would be slower.

Chris

_________________
"Miracles we do at once, the impossible takes a little longer" - AJS on Hyperion
Avatar is Tabitha by Eric W Schwartz

 Status: Offline
Profile     Report this post  
CodeSmith 
Re: Does AOS4 support ALTIVEC?
Posted on 14-May-2004 7:05:53
#40 ]
Elite Member
Joined: 8-Mar-2003
Posts: 3045
From: USA

@Chris_Y

The altivec registers need to be current only when the task needs them to be, ie between the first time they are used and the last time. This means it's perfectly allright for the altivec registers to be carrying data that "belongs" to another task, as long as the current task does not try to do anything with that data. If it does, then we've already set things up so that an interrupt gets triggered, the handler for which makes sure that the altivec registers have the proper values for this task. There's no need to hunt around task lists, because there is a pointer that keeps track of the task whose state needs to be saved, and the task whose state needs to be restored is the current task. It's all quite simple, really

BTW, 2 would not be slower because that 1 because 2 happens on an interrupt (that gets triggered when the task uses altivec, ie when you need it). It's like the difference between polling the keyboard every so often to see if anyone's pressed a key yet, and having and interrupt that gets triggered when someone does.

 Status: Offline
Profile     Report this post  
Goto page ( Previous Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 Next Page )

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle