Wednesday, February 22, 2006

Tussle with Intel compiler

So I got the eval version of icl to try what kind of optimisation speedup it gives to my chess program.
It seemed pretty fancy , with lot of 'extra' options to tweak the compilation , profile guided optimisation ,etc.
But the 'feature' which caught my fancy was code generation for a platform which might actually work : so essentially I wanted to see what sort of speedup I will get if I target for P4 ...
Note , chess programs have branches - lots and lots of them , and are essentially integer math : so cmov and family would give nice speedup. Also , vectorization of loops should be nice too.

I run for the P4 target (I ran for SSE2 actually) and voila - refused to execute on my comp !

"Fatal Error : This program was not built to run on the processor in your system."

Hmm , this is interesting - athlon 4200 supports SSE2 ... google'd and voila , I learn about the law suit between amd and intel , etc , etc. (Yep , old news - but then I never bothered with it until now :-D )
Now , how to make this work ?
I found this , give it a shot - no luck.
So , rolled up my sleeves , tried fixing that program - gave up : it is essentially brute force search for a pattern which has been changed in icc8.0 I guess.

Since I am not used to the PE format , wrote something which interprets the exe and was proceeding to find ways of 'nop'ing all those references to the intel 'checker routine' (__intel_new_proc_init_P btw).
Since I have lost touch with assembly for a while , googled to find out opcode forms for a proc call.
That is when I came across this.
He already has perl scripts to patch the exe !

Got them , tried them - and voila ! It works !!

Moral of the story - search for reuse before reinventing :-)
This is one lesson I keep relearning ;-)

* Update * The perl script breaks executable if I use PGO .... not sure why since the difference are the same. Mailed author and looking at the objdump myself too (I am way too rusty :-( )

1 Comments:

Blogger  said...

"Good programmers know what to write. Great ones know what to rewrite" --ESR.

Always seek to reuse.

On an unrelated note, today's fortune was a long one:

The Fastest Defeat In Chess
The big name for us in the world of chess is Gibaud, a French chess
master. In Paris during 1924 he was beaten after only four moves by a Monsieur Lazard. Happily for posterity, the moves are recorded and so chess enthusiasts may reconstruct this magnificent collapse in the comfort of their own homes.
Lazard was black and Gibaud white:
1: P-Q4, Kt-KB3
2: Kt-Q2, P-K4
3: PxP, Kt-Kt5
4: P-K6, Kt-K6
White then resigns on realizing that a fifth move would involve
either a Q-KR5 check or the loss of his queen.
-- Stephen Pile, "The Book of Heroic Failures"

2/22/2006 11:01:00 AM  

Post a Comment

Links to this post:

Create a Link

<< Home