The MASM Forum

General => The Campus => Topic started by: daydreamer on May 15, 2021, 05:24:34 AM

Title: using halfs?
Post by: daydreamer on May 15, 2021, 05:24:34 AM
to save space,could I have lots of data in halfs instead of real4's?
are there already conversion macros/proc between them? or I need to do bitfiddling myself?
Title: Re: using halfs?
Post by: jj2007 on May 15, 2021, 06:02:24 AM
Search the forum for REAL2, there are many posts.
Title: Re: using halfs?
Post by: InfiniteLoop on May 20, 2021, 08:27:33 AM
F16C is 16-bit floating point.

VCVTPH2PS ymm1, xmm2/m128
Title: Re: using halfs?
Post by: jj2007 on May 20, 2021, 10:49:13 AM
Nice find, InfiniteLoop :thumbsup:

I've put together a simple example (using plain Masm32 SDK code, see attached source), but I can't test it on my old cpu...

  vcvtps2ph half, xmm0, 0       ; 4 x single to half-precision (https://www.felixcloutier.com/x86/vcvtps2ph); round to nearest even
  vcvtph2ps xmm0, xmm1          ; 4 x half to single-precision (https://www.felixcloutier.com/x86/vcvtph2ps)
Title: Re: using halfs?
Post by: daydreamer on May 20, 2021, 09:04:40 PM
Thanks infiniteloop and jj :thumbsup:
I try 16 bit fixed point storage ->  fimul constant also
Title: Re: using halfs?
Post by: jj2007 on May 20, 2021, 09:09:41 PM
Did my proggie work for you, daydreamer?
Title: Re: using halfs?
Post by: hutch-- on May 20, 2021, 09:28:05 PM
Seems to run here OK.

test 111.125000
test 222.250000
test 333.250000
test 444.500000
ok?
Title: Re: using halfs?
Post by: LiaoMi on May 20, 2021, 09:58:03 PM
Quote from: jj2007 on May 20, 2021, 10:49:13 AM
Nice find, InfiniteLoop :thumbsup:

I've put together a simple example (using plain Masm32 SDK code, see attached source), but I can't test it on my old cpu...

  vcvtps2ph half, xmm0, 0       ; 4 x single to half-precision (https://www.felixcloutier.com/x86/vcvtps2ph); round to nearest even
  vcvtph2ps xmm0, xmm1          ; 4 x half to single-precision (https://www.felixcloutier.com/x86/vcvtph2ps)


test 111.125000
test 222.250000
test 333.250000
test 444.500000
ok?
Title: Re: using halfs?
Post by: daydreamer on May 20, 2021, 10:03:22 PM
Quote from: jj2007 on May 20, 2021, 09:09:41 PM
Did my proggie work for you, daydreamer?
it works
:thumbsup:
Title: Re: using halfs?
Post by: daydreamer on May 20, 2021, 10:41:35 PM
If I have lots of 3d object data, half's would be good to have smaller size data
But even word data = in millimeters might be good alternative
Title: Re: using halfs?
Post by: HSE on May 20, 2021, 11:45:59 PM
Quote from: jj2007 on May 20, 2021, 10:49:13 AM
... but I can't test it on my old cpu...

:biggrin: Wrong, JJ

You can use Intel SDE (I don't have AVX, pretty old machine):
test 111.125000
test 222.250000
test 333.250000
test 444.500000
ok?
Title: Re: using halfs?
Post by: jj2007 on May 20, 2021, 11:51:46 PM
Quote from: HSE on May 20, 2021, 11:45:59 PMYou can use Intel SDE

Never seen. Interesting, how does it work? I saw it's not such a fat download. Is it freeware? Does it really emulate the processor, in the sense: utterly slow but it works correctly?
Title: Re: using halfs?
Post by: daydreamer on May 21, 2021, 12:04:50 AM
Quote from: HSE on May 20, 2021, 11:45:59 PM
Quote from: jj2007 on May 20, 2021, 10:49:13 AM
... but I can't test it on my old cpu...

:biggrin: Wrong, JJ

You can use Intel SDE (I don't have AVX, pretty old machine):
test 111.125000
test 222.250000
test 333.250000
test 444.500000
ok?

Nice
But isn't it bigger chance old gpu have half caps,where I seen its used many years ago,and maybe some shader capable of conversion,or shader compiler running on cpu have caps. To convert half's <>floats?
Title: Re: using halfs?
Post by: HSE on May 21, 2021, 12:22:29 AM
Quote from: jj2007 on May 20, 2021, 11:51:46 PM
how does it work? I saw it's not such a fat download. Is it freeware?
I don't remember if requiere a free subscription, but is free for our use. Nidud posted a test (or something) a year ago.

There is a batch that open a command window. From the prompt you have a AVX machine  :biggrin:

Also work a little batch: path\sde -- halfprecision.exe
Title: Re: using halfs?
Post by: HSE on May 21, 2021, 12:35:39 AM
Quote from: daydreamer on May 21, 2021, 12:04:50 AM
But isn't it bigger chance old gpu have half caps,where I seen its used many years ago,and maybe some shader capable of conversion,or shader compiler running on cpu have caps. To convert half's <>floats?
Have you writed some code to show how that can be maked? That could be interesting  :thumbsup:
Title: Re: using halfs?
Post by: daydreamer on May 22, 2021, 08:48:57 PM
Quote from: HSE on May 21, 2021, 12:35:39 AM
Quote from: daydreamer on May 21, 2021, 12:04:50 AM
But isn't it bigger chance old gpu have half caps,where I seen its used many years ago,and maybe some shader capable of conversion,or shader compiler running on cpu have caps. To convert half's <>floats?
Have you writed some code to show how that can be maked? That could be interesting  :thumbsup:
Sorry, Marinus are the pixelshader expert not me