MMX and/or SSE/2

Hello everyone,

I am developing a routine which xors a chunk of data. This ‘could’ be done
very quickly using mmx or sse instructions.

The actual driver is currently targeted at:
2000
XP

I have just read a bunch of articles on 64bit compilation and
the elimination of support for inline assembly.

I am no big fan of inline asm myself but am a bit bewildered by how I can
safely write cross-compatible code using the specialized instruction sets.
I was
unable to find any mention (on the internet or elsewhere) of compiler
intrinsics for mmx or sse
in regards to the ddk compiler.

I may not care too much about 64bit right now - but I have taken
quite a bit of time to make sure that my code is written in a way that when
I do want to compile for a 64bit platform - it will not require much (if
anything at all) be
re-written.

Any ideas? Is using these technologies for better performance regarded as
taboo in the kernel?

I have pretty much let the compiler have the most control in optimizations -
sticking to maintainability
over questionable optimizations - whenever possible.

In the case of using sse or mmx - I believe I am on solid ground in
believing there is no question - it will
be more efficient.

Thanks in advance,

David Swigger

David Swigger wrote:

I am developing a routine which xors a chunk of data. This ‘could’ be done
very quickly using mmx or sse instructions.

The actual driver is currently targeted at:
2000
XP

I have just read a bunch of articles on 64bit compilation and
the elimination of support for inline assembly.

I am no big fan of inline asm myself but am a bit bewildered by how I can
safely write cross-compatible code using the specialized instruction sets.

I think you answered your own question. MMX and SSE are specific
subsets of the x86 instruction sets. Many of the 64-bit processors use
entirely different instruction sets, where MMX and SSE have no meaning.

I may not care too much about 64bit right now - but I have taken
quite a bit of time to make sure that my code is written in a way that when
I do want to compile for a 64bit platform - it will not require much (if
anything at all) be re-written.

That’s a good goal. Achieving that goal requires that you forget about
MMX and SSE. They are not portable concepts.

Any ideas? Is using these technologies for better performance regarded as
taboo in the kernel?

It depends. Remember that the use of MMX requires that you save and
restore the floating point state.

I have pretty much let the compiler have the most control in optimizations -
sticking to maintainability over questionable optimizations - whenever possible.

A moderately performing driver that never crashes is 100x better than a
speedy one that dies once in a while, unpredictably.

In the case of using sse or mmx - I believe I am on solid ground in
believing there is no question - it will be more efficient.

Perhaps, but does it matter? Do you have a demonstrated bottleneck? If
you xor a big chunk of memory, but you only do it when a new instance is
created, it’s silly to worry about optimizing it. On the other hand, if
your code is chewing up 40% of the CPU on a continuous basis, then it
would clearly be worthwhile to include assembler code to handle that.
For the 64-bit platforms, you will have to include standalone assembler
files for each platform, which is somewhat less convenient than inline
assembler, but still provides the functionality.

“Tim Roberts” wrote in message news:xxxxx@ntdev…>
>>A moderately performing driver that never crashes is 100x better than a
>>speedy one that dies once in a while, unpredictably.

I totally agree here. I can address some of the performance later - I am
early into this phase
of coding. Sometimes I think too far ahead.

Thanks for the help. If later - I do decide to use these instructions then
at least I know the proper way to do it.

-David Swigger

All the points Tim makes are spot on, as usual. But for the archive, I
just wanted to correct one tiny thing…

Tim Roberts wrote:

>

I think you answered your own question. MMX and SSE are specific
subsets of the x86 instruction sets. Many of the 64-bit processors use
entirely different instruction sets, where MMX and SSE have no meaning.

Actually, all the x64 processors do indeed implement SSE/SSE2.

Windows-64 for the x64 (AMD64 and EM64T) does not support traditional
x87 floating point, MMX, or 3D Now! instructions in kernel mode.

Peter
OSR