home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Equalizer BBS
/
equalizer-bbs-collection_2004.zip
/
equalizer-bbs-collection
/
DEMOSCENE-STUFF
/
NL-DEM83.ZIP
/
DN_2OF3.082
< prev
next >
Wrap
Text File
|
1995-02-05
|
45KB
|
859 lines
DemoNews.082.continued.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.part.2.of.3
SECTIONS ARTICLES
---------------- -----------------------------------
Music Interview with Maelcum/KFMF
Code Optimizing Vector Transforms. on P5
Denthor's High The Perfect Body
School Essays
Back Issues How to Get 'em, Descriptions
Advertisements Mind Side Out
Help Me!
Closing Comments DemoNews Top 10 LIst
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
<<Music>>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
_____Interview with Maelcum
_ _ _
/ \ / \ ___ _____ | | ____ __ _ _
/ \/ \/ _ \/ ___ \| |/ __// / __/ \_/ \ Interview with Maelcum
---/ /\__/\ \/ \ \ \_/ /| | / \ \ \ \/\_/\ \------------------------
\ \ / /\_/ \ /_| |\ \___\ \__/ /\ / / of the Kosmic
\__\ /__/\___/\_\_____\| \____\\____/\_\ /_/ Free Music Foundation
GD = GraveDigger of uuDW/CoRE ............. digger@freeside.scsd.k12.ny.us
MA = Maelcum of Kosmic .................... dan@bowker.com
--------------------------------------------------------------------------
Maelcum is the head man of the Kosmic Free Music Foundation, a group of
18 composers, 2 artists (who are also musicians), 2 coders (one is also
a musician), and 2 PR members, totaling 24 people. Maelcum himself has
written somewhere in the range of 1500-2000 tracks in his lifetime, and he
currently prefers Renaissance's MultiTracker for composing.
With such a large number of tunes under his belt, Maelcum probably boasts the
largest personal PC music library. "This will sound like I'm an ego-maniac,"
he told me, "but I haven't talked to anyone else who's written more than half
the amount of stuff I've written that I can remember. The only person I can
remember being anywhere close is Sidewinder. I think he's been tracking a lot
longer than me though :)"
In 1994, Maelcum released 52 tracks under Kosmic (an average of one a week).
This makes up a little more than 1/3 of Kosmic's 125 total releases in 1994.
When I first approached Maelcum about being interviewed for DemoNews, I
asked if he wanted to set up a time to meet on IRC to conduct the interview.
He then suggested that I mail him a list of questions instead. This sounded
like the better option, due to the fact that I was unlikely to find time to
do this anyways, with my finals approaching. I mailed him three sets of
questions, and in each case, got the responses less than a day later.
Due to the fact that it was already Saturday by the time I got the first
completed list of questions, and DemoNews comes out on Sundays... plus, the
interview had not yet been completely formatted and Maelcum doesn't like to
use capital letters, this interview is actually a week late. I tried to get
it done in time, but despite Snowman's plea to have it done to avoid another
small issue of DemoNews, well... here it is, however late it may be.
--------------------------------------------------------------------------
GD: How old are you, where do you go to school, and what is your major?
MA: I'm 20 years old. I dropped out of Union County College (cheapo state
school) in 1993. I was studying Communications.
GD: Where are you living? Are you currently employed?
MA: I live with my mother in a small house. I do freelance music and graphics
work for different companies. Mostly music for video games and graphics
for different corporate computer companies. I also do consulting, mostly
to at-home PC users in my area.
GD: Give us a run-down of a typical "Day in the life of Maelcum.."
MA: Wake up anywhere from 6am-6pm (depending on when I last fell asleep),
watch some tv or go onto the net, eat food, listen to news radio or
those lame top 40 stations, read email, write some music (never when
i've just woken up though). Not necessarily in that order! I go through
phases...
GD: What's been keeping you busy recently?
MA: Right now I'm just sitting around a lot trying to get different things
organized and keep up with different things that interest me, like the
Russians slaughtering the Chechen people and the various things going on
in Congress. if I had some iniative perhaps I might have gone into
politics.
GD: Tell us about your songwriting... Do you follow a specific pattern when
composing?
MA: Not really. I mean, subconsciously I'm sure I do, but I don't
intentionally try to follow any 'rules'. That's one of the things that
I hate about a lot of music - the really stupid rules. My only rule is
it has to sound good, or at least interesting. Actually a lot of the
"melodies", "riffs" or whatever they're all called, I just make up
randomly. Like I'll just hit some keys on the keyboard to randomly enter
notes, then go back and mess around with them till I get something
interesting.
GD: Approximately when did you start composing?
MA: From what I can tell, sometime in late 1991. I think the oldest song
that I have here (excluding the 1000+ on QIC-80s, some of those might be
older) is from October 4th, 1991. I couldn't have been composing for more
than a few weeks at that time.
GD: What made you decide to begin tracking?
MA: I really can't answer that, because I'm not sure. I basically just
started fooling around with Modedit when v1.0 came out. I'd been doing
stuff with waveform editors, multitracks and other stuff for about two
years before that, but i didn't really own any equipment so i couldn't
do much.
GD: What's the best part about composing?
MA: I dunno, maybe the money and the girls.
GD: How do you know when you've written a good tune?
MA: When i like what i've written. :)
GD: Do you have any background in music theory?
MA: I really don't know much real music stuff, even though my mom was a music
teacher. I probably know a lot of stuff that I just don't know what terms
to use for it - that's the downside to not having any clue about the
theory, I probably am re-inventing the wheel half the time. But I guess
that's some of the fun.
GD: What kind of sound equipment do you own?
MA: I use a Gravis UltraSound with 16-bit daughtercard and 1mb of ram
currently. It's hooked up to a Sony 70 watt/channel ProLogic (surround
sound) receiver which drives two 10 inch speakers left and right, a 6
inch center channel speaker, and two 7 inch rear channel speakers. All
my speakers are really old ones, I think the newest ones are probably
almost as old as I am. I have a few really cheap microphones, a bottom-of
the line Japanese DJ mixer, and a few really lousy MIDI modules from the
early to mid 80s. Probably my most expensive single piece of equipment is
the receiver, which cost $250 :)
GD: Of the 1500-2000 tracks you have composed, do you still have all of them?
MA: I *think* I have most of them. I say think because many of them
(primarily 4 channel and FastTracker 1 .MODs) are on QIC-80 tapes which
I have not been able to access for over a year since my tape backup drive
died. It would be really cool if someone would donate one, and it would
let me release a lot of material that's never been heard before :)
GD: What software do you use for sampling/tracking, and why? Are there any
programs that you hate?
MA: Usually I use Goldwave 2.10 (Windows program) to sample stuff in 16-bit,
edit everything in 16-bit and then resample it down to 8-bit samples and
load into MMEDIT v1.01b. I just use what works for me. A lot of people
say MMEDIT sucks compared to Screamtracker but I just can't stand the
interface of ScreamTracker. I couldn't exactly explain why but it really
slows me down. I've been thinking about starting to use Fasttracker 2
though, since I was using Fasttracker 1 before I used mmedit.
GD: From what source do you get the majority of your samples? How many of
the samples that you use are originals?
MA: I sample 90% or so of my stuff from different CDs. I have the x-static
goldmine sampling cds, but so many people use those same sounds that I
don't like to use them a lot unless I totally change them, like
re-sequence the drum loops, add reverb and flanging, that kind of thing.
A lot of people think they're great because you don't have to spend hours
trying to come up with the perfect sound, but I think that a good tracker
musician has to be able to make their own sounds.
GD: So, you frown on ripping samples?
MA: Ripping samples is fine, I do it quite a bit myself, but if everyone just
rips, the music will get really dull. Come to think of it, maybe that's
why so much of it sucks right now.
GD: What's the strangest thing you ever did to create a sound which you
sampled and used in a song?
MA: I don't know, I try to do a lot of things randomly. I guess maybe the
samples I made for "Bang A Can" where I smacked the microphone against a
PC tower case and then edited them to bits in goldwave was pretty
strange.
GD: There's something I'd never do! Of course, I'd probably end up wrecking
something in the process.
What is your favorite tracked music?
MA: I don't really listen to a lot of tracked music that I don't write. I
think a lot of people listen to too much of it - that's the only reason
I can possibly see for why amiga-style demo muzak which was popular six
years ago is still the most written kind of music by pc composers! It's
really sad I think, a real de-evolution. There are some good composers
out there though.
GD: Who, then, do you think of as a good composer?
MA: Everyone says Necros to these kinds of questions, and it's certainly
true. Nec is a great musician. December.s3m was one of the best tracked
songs i've ever heard. Krystall is also really good, he does just great
trance songs, those are always really good. There's a lot of people out
there who do a few great songs, but tons of crap. I'd like to see people
try to be more consistent in their creativity. Floss is a really creative
musician - here is a perfect example. The guy is really doing what needs
to be done - taking some inspiration perhaps from the tired old demo
muzak and really inventing something that no one else has thought about.
His stuff is always great.
GD: What's your opinion on the rest of the KFMF composers?
MA: The whole Kosmic group is full of really great musicians - yes, maybe
I'm biased, but I haven't seen another group which has so many diverse
and stylish musicians. I think it really is like a "Dream Team" of
tracker music.
GD: Yes, you are really lucky to have such a wide range of styles.
What kinds of professionally-recorded music do you prefer?
MA: As far as real music goes, it would take far too long to list it all. I'm
into lots of techno, ambient, trance, world music - I love lots of middle
eastern music, it's just so much more interesting than most western music.
Some groups, I guess would be like Orbital, Front 242, Depeche Mode,
Erasure, Brian Eno, Aphex Twin, Stone Temple Pilots, De La Soul, A Tribe
Called Quest, Tim Simenon (Bomb The Bass), The Orb, Bill Nelson, Public
Image Limited, Negativland, Enya, Moby, Bjork, Renegade Soundwave,
Primus, Ravi Shankar, Material... I just listen to lots of different
music. As much as there is crap music out there, there's some great
stuff too - you just gotta look for it.
A lot of people might find this funny, but the groups that I grew up on
were stuff like The Police, Men At Work, Dire Straits, the Pretenders..
Johnny Cash and U2 are huge influences.
GD: What are some favorite songs of your own?
MA: Well, right now I like a song I wrote called "Calling Heaven" quite a
lot. It's going to be on the Intelligent Dance Music list's compilation
CD "Threads". It's really simple, but the simplicity works. Of my past
KLF releases, some favorites are "That Noise," my remix of Material's
"Mantra,".. there's just too many. I used to hate everything I had
written more than 2 weeks ago, but looking back on it all i'm really
happy with most of it.
GD: Over the years you have been composing, your music has undergone changes
in style. Can you explain what causes that?
MA: I'm not really sure! I guess the easy answer is that it is because my
tastes have changed. Like in 1993 - I was totally into rave and
traditional techno. The prodigy, stuff like that. then I got into a lot
of IDM type stuff - orbital, black dog productions.. later in 1994 I
really started to get heavily into ambient music like Irresistable Force
and other weird stuff. Now i'm kind of coming out of that phase - a lot
of the stuff on the second FTZ album which i'm writing with IQ of Kosmic
is back to the hard techno stage. My latest thing though is not really
any kind of classified music that I know of. It might be 'trip hop' but
I really haven't heard anything that I knew IS trip-hop, so i'm not sure
what that is. A lot of slower, heavy groove things with different styles
of percussion use. It's music to bob your head to. So far 'loend' is
probably the only thing i've released that demonstrates this new
direction.
GD: Do you have any goals, such as tracking for a full-blown demo?
MA: I'm working on something like that right now - but that's not really a
major goal for me. I mean, this sounds cocky or something, but i've
already worked with people who are like the Steven Spielbergs of the
video game world on things that put my music in front of an audience of
40,000 people or more, so I really can't see demos as such a big thing.
It's the same thing as with music. Perfect test is to put the end result
on tape. Would you watch most PC demos on videotape? I wouldn't! MTV's
crap is more interesting! I guess changing the face of PC demos is one
goal i'd like to pursue. I'm much more interested as a long term goal in
things like doing music for a motion picture, and getting a lyrics-free
video on U.S. MTV.
GD: I have to agree, I wouldn't bother watching a PC demo on TV. It would
just take all the magic out of it. MTV, though, is a different kind of
media, and like you say, relies heavily on lyrics.
How and when did KLF come to be?
MA: I started it in either late 1991 or the very beginning of 1992 I think,
although I might be wrong by a year.. 1992 was basically the year it
began though. It started as a VGA and Ansi group, but we sucked pretty
hard at Ansi, so when I got into tracking it gradually became more and
more of a music group. by 1993 it was nearly all music. the group died
in spring 1993 but we resurrected it as a music-only group in September
of 1993. Now it's on it's way back away from music-only :)
GD: About a month ago, a decision was made to change the group's name from
Kosmic Loader Foundation [KLF] to Kosmic Free Music Foundation [KFMF].
Is this something you had been thinking about for a while? What made you
decide to change the name?
MA: Yeah, we had been considering a name change for at least half a year. We
needed to get away from being confused with both The KLF and Keen Like
Frogs, and we had started to use "Free Music Foundation" some, so it was
a pretty logical decision. This lets us put our names on CDs with a lot
less problem too :)
GD: So you're thinking in terms of an identity crisis and commercially...
which makes sense... why let others get any credit for your work? :)
On December 23, "Santro" was released with a track composed by you for
accompaniment. How much time went into "Santro?"
MA: I don't know exactly how much time went into Santro, because my only
involvement was writing the music. I wrote the music in two or three
hours I guess, all in one sitting. I think the whole coding was only
about the same, and Sophisto's cheezy santa anim can't have taken too
long :) It was put together really quickly.
GD: You usually write MTM's. Why was the DSM music format used for "Santro"?
MA: Ask GooRoo why DSM was used - I gave him an MTM in the first place :)
It's probably because we used DSIK for sound.
GD: What do you see in the future of Kosmic?
MA: Hopefully a lot more exposure. We'd like to get the word out to more
non-hacker people. That's probably going to mean doing less "free"
music, but we'll always be doing some. I'm really interested in working
out a kind of 'shareware' music - giving people a way to support
musicians directly if they like what they're doing. I think most of my
songs are worth at least $0.25 :)
GD: A quarter? Hmm. You might have some trouble with your shareware music,
then. :) How do you expect people to react to this "shareware music"
concept?
MA: While people might say "Oh no! That would suck!" They need to look at
the other side of it - if we could support ourselves doing this, or at
least help to support ourselves, we could do a lot more music, and a lot
better music. Most of us don't even have MIDI gear, and we're already
making music on a par with most commercial music.
GD: You've been working on a CD project... Any news on that?
MA: The sister of Kosmic, Area 51 Records, will be releasing my first CD
hopefully right around NAID. My partner Riku Nuottajarvi and I are
working really hard to get the company off the ground and well
established, and I think you'll be seeing some crossover between Area 51
and Kosmic.
GD: In early January 1995, Kosmic's "Egg2: Trancescrambled" MusicDisk was
released. What are your future musicdisk plans, if any?
MA: There will be another musicdisk or two in 1995, but right now other
things are the priority.
GD: What experience do you have in writing music for games?
MA: Well, i've written music for several already, and hopefully I'll be
getting more work in this field this year. I'd like to warn other
musicians out there that it's not necessarily as great as it sounds. The
first few were fun but I've had some projects that were really not much
fun. It's not a good thing to do just for money, as I've learned the hard
way. I am going to be more selective about what jobs I take in the
future, to only be involved with things that I can be happy with.
GD: Are you planning to attend and compete in NAID? If so, will you be taking
the "Kosmic Train" to get there?
MA: I'm hopefully going to attend NAID, although I don't know yet if I will
compete. I'm not too sure about how i'm going to get there though.
GD: What kind of advice could you give to other musicians out there, who are
just starting out?
MA: Don't listen to people who dis you and push you down - just keep working
at it. The best way to improve is to just keep writing lots of music. The
more you write, the better you'll get. And don't be discouraged if it
seems to take you a long time - some people just get it faster than
others. It took me three years to get to where I really feel "good".
Above all, try hard to be your own person. Individuality and creativity
is what separates great music from good music. Technical prowess may be
wonderful, but you're nothing more than a performer if you don't have
your own style.
GD: We better throw in a Kosmic plug... Where can others find your songs, as
well as other KFMF releases via FTP, and is there any WWW sites for the
KFMF?
MA: We have two FTP sites, one in the U.S. and one in Europe. Both of them
are really big sites but have occasional hardware problems, so if one is
down, try the other:
US: ftp.wit.com in /klf/songs/ subdirectories
Europe: ftp.luth.se in /pub/misc2/kosmic/songs/ subdirectories
We also have WWW sites on both of these machines, in various states of
disrepair:
US: http://www.wit.com/~klf/
Europe: http://ftp.luth.se/pub/misc2/kosmic/www/
GD: Thanks for doing this interview! Hope to hear more from you and the rest
of the Kosmic guys in the future. Anything you'd like to add before we
close?
MA: Yes. A huge thank you to all the people out there who listen and who have
really let me know they appreciate the music. You are the reason behind
the KFMF!
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
<<Code>>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
_____Optimizing Vector Transformations on a Pentium by Tom Verbeure
About 7 years ago, I sold my Commodore 128 after 2 years programming and
playing games (in C=64 mode) and bought my first 'big' computer: a 8088
clone, running at 8 Mhz with a hard disk of 32 MB.
A few months later, I was programming in assembler and trying to get the
maximum possible out of the processor. It was fun trying to make clever
combinations of exotic instructions instead of the normal ones, just to win
a few cycles. Back then, optimizing was a real art and the rules were not
clear.
Things have changed. Optimizing code on a 486 can be described by a
few simple rules:
1. try to avoid anything but MOV, ADD and a bunch of other
core-instructions.
2. Don't use the result of an instruction as in the next one.
Demo coders might add:
3. Avoid floating point, use fixed point math. It's almost always faster.
One of the only challenges left, is trying to find the best mapping of
registers to avoid memory variables in a main loop.
Since I bought a Pentium-90 about two months ago (yep, it has the famous
FDIV bug), things have changed again and optimizing is fun again too: not
only is the order in which instructions are executed extremely important,
there's also a major shift in the way calculations are done: under optimal
conditions, floating point adds are as fast as integer ones (1 cycle) and,
much more important, floating point multiplications can be more than 5
times as fast as their integer brothers!
During the rest of the article, I will show you how I optimized a standard
vector transformation in floating point. Starting with the compiler
generated code, ending with a routine that is about 40% faster.
Testing Environment:
* Pentium 90MHz with 8 mb ram
* C Compiler: Watcom 10.0a C/C++. 32-bits protected mode.
* Assembler: Tasm 3.0
* Dos extender: PMODE/W, public domain dos extender of Tran.
* Timer: ZenTimer of Michael Abrash, converted to 32-bits, with a
precision of 1 microsecond.
ZenTimer and PMODE/W are available at Hornet.
Timings were done as follows:
Diskcache disabled, to prevent disk operations during timings. First a dummy
loop was executed to time all overhead. The dummy loop had exactly the same
instructions, only the call to XformVect was replaced by XformVectDummy, an
empty routine in another c-file. (Don't place the dummy routine in the
C-file with the timing code. Watcom is clever enough to eliminate the dummy
code completely!) After the dummy loop, the main loop was executed, with
XformVect. By subtracting the dummy time from the real time, one gets the
time spend in XformVect.
Results:
I will upload the results and source code to Hornet as soon as possible. I
hope to have FTP-access on Friday, but no promises...
XFORMVECT:
The caller of XformVect has to give three parameters: a source and
destination vector and one 3x4 matrix to transform between them. As the
bottom row of a transformation matrix is mostly [0.0 0.0 0.0 1.0], I
removed it.
XformVect, written in C, was already in optimized form: every loop was
completely unrolled, it was just a sequence of 9 muls and 9 adds.
As a worst case test, I compiled XformVect with full debugging mode on,
without any optimizations. I used wdisasm to convert the resulting .obj
file into a readable .asm file. The result (M1.ASM) is horrible and takes
98 cycles to execute (still faster than the best 486 code!). No further
comments required.
The second and third test were also compiled C code, with full
optimizations enabled. Both resulted in the same code and would be near
optimal on a 486. The calculations for the X,Y and Z components are
identical, so just duplicate the listing below 2 times, update the offsets
and you get the actual routine (M2.ASM). Next to the assembler
instructions, the stack is listed as it is after execution of the
instruction on the left . The first one being ST(0) and so on...
C code: D->X=M[0][0]*S->X+M[0][1]*S->Y+M[0][2]*S->Z+M[0][3]
EBX: Source Vector
EDX: Matrix
EAX: Destination Vector
ST(0) ST(1)
Asm FLD DWORD PTR [edx+4H] ; M01
FMUL DWORD PTR [ebx+4H] ; M01*S->Y
FLD DWORD PTR [edx] ; M00 M01*S->Y
FMUL DWORD PTR [ebx] ; M00*S->X M01*S->Y
FADDP st(1) ; M00*S->X+M01*S->Y
FLD DWORD PTR [edx+8H] ; M02 M00*S->X+M01*S->Y
FMUL DWORD PTR [ebx+8H] ; M02*S->Z M00*S->X+M01*S->Y
FADDP st(1) ; M02*S->Z+M00*S->X+M01*S->Y
FADD DWORD PTR [edx+0cH] ; D->X
FSTP DWORD PTR [eax] ; <empty>
>From now on, S->X will be noted S0 and so on...
This is very straightforward code and easy to understand. For those who
have never played with floating point assembler: FLD pushes a float on the
stack. FMUL multiplies its operand with the top of the stack and puts the
result at the top of the stack, FADDP adds its operand to the top of the
stack, places the result in the specified element and pops the top of the
stack. FSTP stores the top of the stack and removes it.
Ok. This code (3 times) takes 58 cycles to execute, resulting in nearly 28
MFlops at 90MHz. These are workstation-like numbers! At first, it doesn't
seem a lot can be won by optimizing. However, several bad things happened
in this code: FADDP is executed immediately after FMUL, causing one extra
cycle and it is using the same register, causing another extra cycle.
Please note that FLD after FMUL/FADD never adds an extra
cycle to the FMUL/FADD, because we're not using the arithmetic unit
or the result of a previous calculation. So, the first 4
instructions are optimal.
How to avoid the extra cycles? Well, there is an instruction named FXCH
that switches the top of the stack with its operand. So FXCH ST(2) puts
ST(0) in ST(2) and vice versa. On a 486, FXCH costs about 3 cycles, so it
wasn't used very often on that processor. On the Pentium however, it's the
only floating point instruction that can run in the second pipeline
parallel to a limited set of other instructions. It's no coincidence that
this set consists of the most used instructions: FADD, FSUB, FMUL, FLD,
FCOM, FUCOM, FCHS, FTST, FABS and, most famous of all (except in Australia
?), FDIV.
This means that using FXCH after one of these instructions, no cycle
penalty is generated. It is FREE, use it! This leads us to the first
handcoded assembler version (M4.ASM). Only the code for one component has
been modified.
FLD DWORD PTR [EDX] ; M00
FMUL DWORD PTR [EBX] ; M00*S0
FLD DWORD PTR [EDX+4] ; M01 M00*S0
FMUL DWORD PTR [EBX+4] ; M01*S1 M00*S0
FLD DWORD PTR [EDX+8] ; M02 M01*S1 M00*S0
FMUL DWORD PTR [EBX+8] ; M02*S2 M01*S1 M00*S0
==> FXCH ST(2) ; M00*S0 M01*S1 M02*S2
FADDP ST(1), ST ; M00*S0+M01*S1 M02*S2
FADDP ST(1), ST ; M00*S0+M01*S1+M02*S2
FADD DWORD PTR [EDX+12] ; D0
FSTP DWORD PTR [EAX]
What has changed? After the FMUL, ST(0) is exchanged with ST(2), costing us
nothing. Next, two already calculated values are added, causing no extra
cycle to FMUL, because FADDP isn't executed immediately after FMUL and
FADDP doesn't use a result of FMUL. This code takes 56 cycles, exactly the
number we expected. Using this 'trick' for the 3 components, results in...
52 cycles (M5.ASM).
Looking at each component separately won't help us much: there's just
nothing to move or to load after the first FADDP.
The first FSTP costs 2 cycles and uses the result for the previous
instruction. That's a shame, because it costs us a cycle. We have 8
registers in our copro, so, just leave D[0] on stack and group all the
FSTPs at the end. This is gives us M6.ASM: two FSTP's removed and placed at
the end of XformVect. The last lines of M6.ASM now look like this:
FADD DWORD PTR [EDX+44] ; D2 D1 D0
FSTP DWORD PTR [EAX+8] ; D1 D0
FSTP DWORD PTR [EAX+4] ; D0
FSTP DWORD PTR [EAX]
Execution time of M6.ASM is 46 cycles. 6 less than M5.ASM. That's 2 cycles
for each replaced FSTP ?! Two? Don't ask me why, I'm happy with it. But
wait! We're doing it again: D[2] is stored immediately after it was
calculated. Replace the last 4 lines with this (M7.ASM) ...
FADD DWORD PTR [EDX+44] ; D2 D1 D0
FXCH ST(2) ; D0 D1 D2
FSTP DWORD PTR [EAX] ; D1 D2
FSTP DWORD PTR [EAX+4] ; D2
FSTP DWORD PTR [EAX+8]
... and ze rezultz ov ze Belgian Jury are... 43 cycles! I think that the
trick of moving FSTP to the end of the file also helps for a 486. If
someone can confirm this, please let me know.
At this point, we have done everything to optimize individual calculations
for the separate components and it was relatively easy to follow everything
without writing down a complete stack-trace. We have shaved of 15 cycles
from the initial 58, which is already a substantial improvement. Looking at
the code, we can see that there are two conflicts for each component: two
ADDs are executed after an ADD. If we can remove these conflicts, a 2*3=6
cycle improvement should be possible. These improvements are not as easy as
before: a lot of instructions have to be moved to get the wanted speed.
Let us first remove the conflicts in the first component.
The original code looked like this:
1 FADDP ST(1), ST ; M00*S0+M01*S1 M02*S2
2 FADDP ST(1), ST ; M00*S0+M01*S1+M02*S2
3 FADD DWORD PTR [EDX+12] ; D0
4 FLD DWORD PTR [EDX+16] ; M10 D0
5 FMUL DWORD PTR [EBX] ; M10*S0 D0
Conflicts are at the (2) and (3).
To remove the first conflict, place (4) immediately after (1). Exchange
M[1][0] with M[0][2]*S[2]. There are no more calculations pending, now
execute the FADDP (2). Exchange the result of the add with M[1][0] (hopping
back to ST(0)). We can now safely execute (5). Exchange the result with the
only remaining number on the stack et voile, we've eliminated the first
conflict. Do the same with the second conflict and you get this result
(M8.ASM) :
1 FADDP ST(1), ST ; M00*S0+M01*S1 M02*S2
4 FLD DWORD PTR [EDX+16] ; M10 M00*S0+M01*S1 M02*S2
FXCH ST(2) ; M02*S2 M00*S0+M01*S1 M10
2 FADDP ST(1), ST ; M00*S0+M01*S1+M02*S2 M10
FXCH ST(1) ; M10 M00*S0+M01*S1+M02*S2
5 FMUL DWORD PTR [EBX] ; M10*S0 M00*S0+M01*S1+M02*S2
FXCH ST(1) ; M00*S0+M01*S1+M02*S2 M10*S0
3 FADD DWORD PTR [EDX+12] ; D0 M10*S0
FXCH ST(1) ; M10*S0 D0
After dust had fallen back on the ground, one could time that, as expected,
everything ran in 41 cycles, 2 cycles less.
It is left as an exercise (don't you hate that phrase?) to do the same for
the second component.
Now let's have a look at the third component. Same problem here, but not
the same solution: there isn't anything to load anymore! Let's have a look
at it:
1 FADDP ST(1), ST ; M20*S0+M21*S1 M22*S2 D1 D0
2 FADDP ST(1), ST ; M20*S0+M21*S1+M22*S2 D1 D0
3 FADD DWORD PTR [EDX+44] ; D2 D1 D0
FXCH ST(2) ; D0 D1 D2
4 FSTP DWORD PTR [EAX] ; D1 D2
5 FSTP DWORD PTR [EAX+4] ; D2
6 FSTP DWORD PTR [EAX+8]
Well. When there's nothing to load, let's store!
After the first add, put A1 on top of the stack with FXCH and store it.
This is the result (M9):
1 FADDP ST(1) ; M20*S0+M21*S1 D1 D0 M22*S2
FXCH ST(1) ; D1 M20*S0+M21*S1 D0 M22*S2
5 FSTP DWORD PTR [EAX+4] ; M20*S0+M21*S1 D0 M22*S2
2 FADDP ST(2) ; D0 M22*S2+M20*S0+M21*S1
4 FSTP DWORD PTR [EAX] ; M22*S2+M20*S0+M21*S1
3 FADD DWORD PTR [EDX+44] ; D2
6 FSTP DWORD PTR [EAX+8] <---- Conflict. Aaaargh.
And now for the big disappointment: I've been moving instructions around
and tried various combinations, but I can't eliminate the conflict on the
last line. If someone can resolve it, please send your solution to DemoNews
as soon as possible.
As expected, we have saved (only) one cycle during the last step, giving a
total running time of 38 cycles. On a 90MHz machine, this gives us almost
43 MFlops, or more than 11 000 000 vector transformations/second! These
numbers certainly are comparable to lots of workstations.
It is very important to notice that this kind of optimization is unlike
traditional optimization techniques, used in demos or games: we haven't
replaced calculations by tables or removed mults using a special trick. On
the contrary: we have added instructions and haven't removed a single one!
On a 486, one could suppose there were some RISCy things hidden behind the
surface, now, it is so apparent, you just can't ignore it. Make use of it!
I wasn't able to time my code on a 486, but as we have added 10 FXCH
instructions, I think M9.ASM might be slower than the original, compiler
generated code. Moving FSTP to the end should be beneficial for both
processors, though.
What are the implications of all this:
First, when your program is speed-critical and math-intensive, you can't
just ignore the 486 and are almost forced to create a separate version for
each processor. If you can avoid floating point math but need lots of
multiplications, create an integer version for the 486 and a float point
version for the Pentium.
Secondly, even when you don't hand-optimize your floating point code, the
speed-increase can be big. If you do optimize, it can be Very Big.
Perhaps the most important implication, is that one might win even more by
redesigning the whole algorithm. I have a specific routine of my 3D engine
in mind, but I haven't tested it. I will try it in the future. If I was
right, I'll write about it.
I realize that a lot of people don't have a Pentium yet, and that it will
take some time until it becomes the standard machine at demo parties.
Nevertheless, I think one has to be ready for a big shift in the way we
approach algorithms, code optimization and the use of floating point,
especially in demos.
-Tom Verbeure / Synergy Design
References:
* Pentium Processor User's Manual: Volume 3, Architecture and
programming Manual, Intel 1994, ISBN 1-55512-223-X
* Pentium Optimizations and Numeric Performance, Stephen S. Fried,
Dr. Dobb's Journal, January 1995
* Zen of Code Optimization, Michael Abrash, Coriolis Group Books 1994,
ISBN 1-883577-03-9
* Mijn eerste kompjoeter, Annie M.G. Schmidt
Starting with the "begin 600" is a uuencoded copy of the source code
referred to in this article.
begin 600 vector_t.zip
M4$L#!!0 @ ( %J@.QZJ=8:)"@$ ,8+ & 33$N05--W99+B\(P%(7W
M0O]#E@Y&:$(7,KL98NFBI:$/9T!$^HC@0BR3+OKSI\$9%]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(;>@902P$"% 4 ( " !:H#L>JG6&B0H! #&"P !@ ! "
M 33$N05--4$L! A0 % " @ 9Z ['F/Q*,"< / , 8
M 0 @ +@$ $TR+D%335!+ 0(4 !0 @ ( '2@.QZ9H@$<_P$ !H(
M & $ ( .X! !--"Y!4TU02P$"% 4 ( " ""H#L><!G?
M6&0" "A"@ !@ ! " 1! 338N05--4$L! A0 % " @
MBZ ['F; @VB* @ XPH 8 0 @ F08 $TW+D%335!+ 0(4
M !0 @ ( )6@.Q[K<=OW@ ( .P+ & $ ( $<) !-."Y!
M4TU02P$"% 4 ( " "QH#L>".@2=*0" !]#0 !@ ! " #K
M"P 33DN05--4$L! A0 % " @ SJ ['E_.-C&3 0 ?@0 D
M 0 @ LPX $U!5$U!5$@N0U!+ 0(4 !0 @ ( -.@.QYXU$+:N0$ "<$
M ) $ ( &T0 !-051415-4+D-02P4& D "0#: 0
&31(
end
................................................................continued...