caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pointers needed for optimization problem.
@ 2002-08-22  2:33 Pal-Kristian Engstad
  2002-08-23 11:46 ` Xavier Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Pal-Kristian Engstad @ 2002-08-22  2:33 UTC (permalink / raw)
  To: caml-list

Hi,

I'm interested in solving a problem I have with automatically generating 
optimal (vector) floating point code. In other words, I want to code a caml 
program that transforms the input description into assembly instructions. For 
regular floating point operations, a good compiler should be able to optimize 
the code:
	
	r := A * x * x + B * x + C

into (if multiplication is more expensive than adds):

	t := A * x
	t := t + B
	t := t * x
	t := t + B
since
	r := (A * x + B) * x + C

Now, this is fairly trivial to do, but if you have an architecture with SIMD 
vector floating point registers and opcodes, a whole range of new interesting 
optimizations can be done. With vector registers, I mean registers that have 
up to 4 floating point values. For instance, a 4-vector times a 4-by-4 matrix 
operation can be coded as:

	acc.xyzw := mtxrow[0].xyzw * vec.x
	acc.xyzw += mtxrow[1].xyzw * vec.y
	acc.xyzw += mtxrow[2].xyzw * vec.z
	res.xyzw = acc.xyzw + mtxrow[3].xyzw * vec.w

Here, each line represent one assembly instruction.

So, what I am looking for is basically pointers to literature that deal with 
issues like these, and since OCaml is a great language for language 
transformations I thought someone on this list would be able to point me in 
the right direction. I _have_ been searching on the net, but I guess I don't 
know the right keywords to search on.

PKE.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread
* RE: [Caml-list] Pointers needed for optimization problem.
@ 2002-08-22  4:01 Gurr, David (MED, self)
  0 siblings, 0 replies; 4+ messages in thread
From: Gurr, David (MED, self) @ 2002-08-22  4:01 UTC (permalink / raw)
  To: Pal-Kristian Engstad, caml-list

[-- Attachment #1: Type: text/plain, Size: 2574 bytes --]

>From the FFTW web page <<http://www.fftw.org/download.html>>:

fftwgel
fftwgel <<http://www.complang.tuwien.ac.at/skral/fftwgel.html>> is an
experimental version of fftw with support for the SIMD instructions of
the AMD K6-2 and K7 processors as well as the Intel Pentium IV, written
by our colleague Stefan Kral at the Vienna University of Technology. We
hope to incorporate a generalization of this work into a future version
of FFTW. 

fftwgel has ocaml code for generating SIMD code for x86 machines.  Other
key words
are SWAR and Atlas.  Plus the intel and amd web pages have lots of info.
-D

> -----Original Message-----
> From: Pal-Kristian Engstad [mailto:engstad@naughtydog.com]
> Sent: Wednesday, August 21, 2002 7:33 PM
> To: caml-list@inria.fr
> Subject: [Caml-list] Pointers needed for optimization problem.
> 
> 
> Hi,
> 
> I'm interested in solving a problem I have with automatically 
> generating 
> optimal (vector) floating point code. In other words, I want 
> to code a caml 
> program that transforms the input description into assembly 
> instructions. For 
> regular floating point operations, a good compiler should be 
> able to optimize 
> the code:
> 	
> 	r := A * x * x + B * x + C
> 
> into (if multiplication is more expensive than adds):
> 
> 	t := A * x
> 	t := t + B
> 	t := t * x
> 	t := t + B
> since
> 	r := (A * x + B) * x + C
> 
> Now, this is fairly trivial to do, but if you have an 
> architecture with SIMD 
> vector floating point registers and opcodes, a whole range of 
> new interesting 
> optimizations can be done. With vector registers, I mean 
> registers that have 
> up to 4 floating point values. For instance, a 4-vector times 
> a 4-by-4 matrix 
> operation can be coded as:
> 
> 	acc.xyzw := mtxrow[0].xyzw * vec.x
> 	acc.xyzw += mtxrow[1].xyzw * vec.y
> 	acc.xyzw += mtxrow[2].xyzw * vec.z
> 	res.xyzw = acc.xyzw + mtxrow[3].xyzw * vec.w
> 
> Here, each line represent one assembly instruction.
> 
> So, what I am looking for is basically pointers to literature 
> that deal with 
> issues like these, and since OCaml is a great language for language 
> transformations I thought someone on this list would be able 
> to point me in 
> the right direction. I _have_ been searching on the net, but 
> I guess I don't 
> know the right keywords to search on.
> 
> PKE.
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: 
http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

[Filename: fftwgel.url, Content-Type: application/octet-stream]
This e-Mail had an attachment that was removed in order to meet GE Security guidelines.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-23 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-22  2:33 [Caml-list] Pointers needed for optimization problem Pal-Kristian Engstad
2002-08-23 11:46 ` Xavier Leroy
2002-08-23 12:18   ` Markus Mottl
2002-08-22  4:01 Gurr, David (MED, self)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).