Sign in to follow this  
jameszhao00

HLSL Multiply High

Recommended Posts

jameszhao00    271
Can you do something similar to a multiply-high in HLSL?

mul_hi in opencl

What it is:
[url="http://stackoverflow.com/questions/3234875/question-about-multiply-high-signed"]http://stackoverflow...ply-high-signed[/url] Edited by jameszhao00

Share this post


Link to post
Share on other sites
Nik02    4348
SM5 hardware does support integer instructions, but there are no 64-bit ints available in HLSL.

The code in the linked article seems to multiply the first 16 bits of the parameters to 32-bit, so that particular function would work on the SM5 GPU with only minor modification (change "unsigned" to "uint" and you're good to go).

Note that integer instructions can be slower than float ops in GPU, because there are generally fewer integer-capable computation units available. The instructions themselves are simple in this case, though. Edited by Nik02

Share this post


Link to post
Share on other sites
jameszhao00    271
I wrote some test stuff in OpenCL, and it seems to emit 64 bit multiplies on my GPU.

I went and read the HLSL assembly reference, and the instruction umul

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/hh447250(v=vs.85).aspx"]http://msdn.microsof...0(v=vs.85).aspx[/url]

does exactly what I want. Is there a way to 'get at' instruction function? Edited by jameszhao00

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this