Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2004



Tip: Looking for answers? Try searching our database.

Assembly coding and MD5

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PJ - 20 Sep 2004 17:04 GMT
Does anyone know where I can find a MD5 implementation written in ppc
assembly?  I'd try to write it myself if I knew ppc assembly better.
I also searched for altivec implementations but did not find anything
that publicly disclosed the source code.  If anyone knows where I can
find a md5 implementation written in either ppc assembly or altivec
please let me know.  Thanks!

-PJ
David Phillip Oster - 20 Sep 2004 17:34 GMT
> Does anyone know where I can find a MD5 implementation written in ppc
> assembly?  I'd try to write it myself if I knew ppc assembly better.
> I also searched for altivec implementations but did not find anything
> that publicly disclosed the source code.  If anyone knows where I can
> find a md5 implementation written in either ppc assembly or altivec
> please let me know.  Thanks!

Codewarrior ships with a MD5 implementation in C as part of the
PowerPlant internet classes, and it has a "Disassemble" menu command
that shows you the generated code.
PJ - 21 Sep 2004 16:13 GMT
> Codewarrior ships with a MD5 implementation in C as part of the
> PowerPlant internet classes, and it has a "Disassemble" menu command
> that shows you the generated code.

Thanks for the reply!  Do you know of any implementations that make
use of the altivec library?  I'd like it to be able to hash files as
quickly as possible.
Jøhnny Fävòrítê (it means "halo, then resonate") - 22 Sep 2004 00:43 GMT
> Thanks for the reply!  Do you know of any implementations that make
> use of the altivec library?  I'd like it to be able to hash files as
> quickly as possible.

if you're looking to write fast code, you're going about it the wrong
way.  choosing to implement everything in assembler is like building a
ship out of toothpicks.  it can be done, but it's the wrong level of
abstraction, and it will take you so long that you'll never get
finished.

a much more useful strategy is to write the whole app, then profile it.
macosx has shark, a very nice profiler.  i figured out how to use it in
20 minutes.  it doesn't matter how familiar you are with a body of code,
you will guess wrong about where it's spending its time.  if the code is
cross-platform, it's probably spending its time in different places on
each platform.

say you profile your app, and it turns out that your first-try md5
implementation, written in sloppy C, only accounts for .5 percent of the
program's total runtime.  therefore, even if you optimized it to death,
so that its runtime is ZERO, the overall effect on the program is
completely unnoticeable.  all that work for nothing.

if you've never profiled a particular body of code before, chances are
excellent that there will be low-hanging fruit, and that you can make
amazing improvements with very little effort.  for example, the program
i recently used shark on.  it turns out that it was wasting 65 percent
of its time in the system idle loop.  65 percent!  i had been far too
cautious about putting the program to sleep for long-ish periods, afraid
i'd burn up too much cpu time and make the whole system sluggish.  all i
had to do was reduce the length of a single usleep() call to speed up
the program dramatically.
Jack B - 22 Sep 2004 02:25 GMT
In article <PM0003E4A2314DE198@minion.nashville.comcast.net>,
Jøhnny Fävòrítê (it means "halo, then resonate") <this.is@fake.com>
wrote:

> > Thanks for the reply!  Do you know of any implementations that make
> > use of the altivec library?  I'd like it to be able to hash files as
> > quickly as possible.
> ...
>
> a much more useful strategy is to write the whole app, then profile it.

This is very good advice, on any platform.

But you need a decent profiler. I've never used shark.

Signature

Jack

Michael Ash - 22 Sep 2004 21:35 GMT
> In article <PM0003E4A2314DE198@minion.nashville.comcast.net>,
> Jøhnny Fävòrítê (it means "halo, then resonate") <this.is@fake.com>
[quoted text clipped - 10 lines]
>
> But you need a decent profiler. I've never used shark.

I haven't used a lot of different profilers, but Shark is superb. It gives
a great overview of where your program spends time, and you can take it
all the way down to individual assembly instructions, where it will
actually give advice on how to improve matters. I've used it a fair amount
to help me improve my code's speed, and it's always great to use
Simon Slavin - 24 Sep 2004 22:17 GMT
On 21/09/2004, Jack B wrote in message <jackspam-
CEEB2B.20250221092004@news.mpls.visi.com>:

> But you need a decent profiler. I've never used shark.

The CHUD tools that come with the Developer Tools kick a.s.
But I had to learn how to use them to figure out what I should
have been caring about.  Then once I knew that I had to learn
how to use the tools again to fix the problem.

Simon.
Signature

Using pre-release version of newsreader.
Please tell me if it does weird things.

Mike Kluev - 23 Sep 2004 00:33 GMT
>> Codewarrior ships with a MD5 implementation in C as part of the
>> PowerPlant internet classes, and it has a "Disassemble" menu command
[quoted text clipped - 3 lines]
> use of the altivec library?  I'd like it to be able to hash files as
> quickly as possible.

MD5 calculation would be o-small compared to file i/o, you will
gain little converting to asm or even altivec. For quickest
calculation interleave file i/o and MD5 calculation.

Signature

Mike Kluev

PS. Remove "-DELETE-." part of my e-mail address to reply.

David Phillip Oster - 23 Sep 2004 05:33 GMT
> >> Codewarrior ships with a MD5 implementation in C as part of the
> >> PowerPlant internet classes, and it has a "Disassemble" menu command
[quoted text clipped - 7 lines]
> gain little converting to asm or even altivec. For quickest
> calculation interleave file i/o and MD5 calculation.

On OS X, consider using mmap() for file reading. The virtual memory
subsystem is already heavily optimized. I beleive there is a way of
hinting that you are doing sequential access, so the O.S. can schedule
reads, so the data is in RAM before you get to them.
Mike Kluev - 23 Sep 2004 10:56 GMT
>> MD5 calculation would be o-small compared to file i/o, you will
>> gain little converting to asm or even altivec. For quickest
[quoted text clipped - 4 lines]
> hinting that you are doing sequential access, so the O.S. can schedule
> reads, so the data is in RAM before you get to them.

madvise

Signature

Mike Kluev

PS. Remove "-DELETE-." part of my e-mail address to reply.

David Phillip Oster - 23 Sep 2004 17:32 GMT
> madvise

Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.