[racket-dev] Extflonum type for windows

From: Michael Filonenko (mfilonenko at ipa.nw.ru)
Date: Wed Mar 20 08:14:46 EDT 2013

> The 32-bit Windows build does not use SSE for flonum operations, so
> setting the precision at the start to extended mode would affect flonum
> arithmetic.

Sorry that I did not take that into account.

> It's possible that we should switch the build to use SSE, but I worry
> about dropping support for old processors.

> Meanwhile, it happens that switching the precision at the last minute
> allows the 32-bit Windows build to support extflonums without using SSE
> and without affecting flonum arithmetic.

Agreed. But since switching the processor "at last minute" every time
slows things down a bit, it may be useful to have an option to
switch to the extended mode on Win32 just once. That will be useful
for us and other users who have SSE and worry about performance.
Could you please take a look on the updated pull request which now
contains #define-guarded code?

There is a caveat that londgouble.dll should be present in two Win32
versions -- with and without the switching. It is no problem for us to
compile a non-switching londgouble.dll on our own, although other
users may be happier if it the dll had both sets of methods ("SSE" and
"non-SSE") and Racket made the decision which to use when loading the
library, how do you think?

>> It is possible to use long double on win platforms with gcc
>> mingw-w64) compiler. It is also possible to use compiled DLL with
>> Racket FFI. The only one note is that long double data must be 16-byte
>> aligned, therefore you should use gcc command line option

> I don't understand. Which piece of the system requires that `long
> double's are 16-byte aligned? And is this an issue about compiling
> "longdouble.dll", or with other potential DLLs?

Never mind, that was my mistake which I made after I forgot to
clean generated racket3m sources in src/worksp/gc2/xsrc and
data transfer became out of sync. Everything is actually OK
by default -- 12-byte-aliged long doubles on Win32, and
16-byte-aligned long doubles on x64.

Updated pull request:
https://github.com/plt/racket/pull/280

2013/3/19 Matthew Flatt <mflatt at cs.utah.edu>:
> At Tue, 19 Mar 2013 22:08:41 +0400, Michael Filonenko wrote:
>> It seems that your changes with precision switching on every function
>> call is not required on 32-bit windows.
>
> The 32-bit Windows build does not use SSE for flonum operations, so
> setting the precision at the start to extended mode would affect flonum
> arithmetic.
>
> It's possible that we should switch the build to use SSE, but I worry
> about dropping support for old processors.
>
> Meanwhile, it happens that switching the precision at the last minute
> allows the 32-bit Windows build to support extflonums without using SSE
> and without affecting flonum arithmetic.
>
>> Small note about extflonum ffi on win platforms:
>>
>> It is possible to use long double on win platforms with gcc (mingw,
>> mingw-w64) compiler. It is also possible to use compiled DLL with
>> Racket FFI. The only one note is that long double data must be 16-byte
>> aligned, therefore you should use gcc command line option
>> -m128bit-long-double on win32 platform. On win64 platform aligning is
>> 16 byte by default.
>
> I don't understand. Which piece of the system requires that `long
> double's are 16-byte aligned? And is this an issue about compiling
> "longdouble.dll", or with other potential DLLs?
>
> Thanks!
>
>



-- 
With best regards, Michael Filonenko

Posted on the dev mailing list.