Oh right, that's because .5 values round to the nearest even number. So 1.5 and 2.5 round to 2, and 3.5 and 4.5 round to 4. I think this method is designed to reduce the bias introduced by always rounding .5 upwards.Gonzo wrote:ok then, i have a problem explaining this (no compiler flags except gui):output is: 4, 4, 4.5Code: Select all
dim as integer b = 4 dim as integer s1 = csng(b) - 0.5f dim as integer s2 = csng(b) + 0.5f print s1,s2, csng(b + 0.5f)
regardless of c***(something) +/- 0.5 or c***(something +/- 0.5)
is this correct?
fpu SSE thread
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: fpu SSE thread
Re: fpu SSE thread
ok, makes sense (i hope) :)
Re: fpu SSE thread
Gonzo,
Either you are using a very old version of FBC or none of your code is getting vectorized (-vec 1) because I just tried compiling my project with vectorization turned on, and GAS complained about operand sizes.
When I wrote the vectorizer, GAS (Win32) that was included with FBC accepted incorrect operand sizes. It was probably around the time of FBC v0.18.x. It doesn't work anymore... until I fix it! :)
Either you are using a very old version of FBC or none of your code is getting vectorized (-vec 1) because I just tried compiling my project with vectorization turned on, and GAS complained about operand sizes.
When I wrote the vectorizer, GAS (Win32) that was included with FBC accepted incorrect operand sizes. It was probably around the time of FBC v0.18.x. It doesn't work anymore... until I fix it! :)
Re: fpu SSE thread
i see, so.. my head didn't follow that part
but(, but) sse has worked well in other projects for me, very fast too
in fact never any as.exe complaints so far (until the ulongint issue)
i hope i am understanding you correctly, and i do try to keep the latest build.. but right now the wonderful german auto-svn site isn't updating anymore (perhaps due to git move)
http://youtu.be/AviA3f90nHw
example of my current issue! one of thousands on my big list, but currently only one of two that isnt my own doing :)
this is with 0.24.0, and fpu SSE (no vec)
i'll see about getting a newer compiler, since im ultra-familiar with git :) not
but(, but) sse has worked well in other projects for me, very fast too
in fact never any as.exe complaints so far (until the ulongint issue)
i hope i am understanding you correctly, and i do try to keep the latest build.. but right now the wonderful german auto-svn site isn't updating anymore (perhaps due to git move)
http://youtu.be/AviA3f90nHw
example of my current issue! one of thousands on my big list, but currently only one of two that isnt my own doing :)
this is with 0.24.0, and fpu SSE (no vec)
i'll see about getting a newer compiler, since im ultra-familiar with git :) not
Re: fpu SSE thread
If you're using anything 0.20 or newer, you're fine. I had to go back to 0.18.x to get a version of GAS that complained.
Sorry if I wasn't clear. The issue with GAS is only for -vec. It doesn't happen with just -fpu SSE. The problem was when storing a 3 component vector to memory. So, in theory, it might not happen with -vec 2, or if storing 2 or 4 component vector.
Sorry if I wasn't clear. The issue with GAS is only for -vec. It doesn't happen with just -fpu SSE. The problem was when storing a 3 component vector to memory. So, in theory, it might not happen with -vec 2, or if storing 2 or 4 component vector.
Re: fpu SSE thread
i see, i dont know how that works, since there are probably many ways to discover 3-vectors and use them, but i mostly use vec3
i havent been running -vec lately, until you told me to (and got the temp fix for ulongint)
and various functions to normalize, get length, sub, add etc (its quite crap, but it works)
perhaps if im about to do the same operation over again, and theres a slot free, it will just be added in (assuming that the operand is the same)
but, it's awesome to know that you can use simd! i had assumed this code was mostly just using xmm in singular
i think i will hold on figuring out the current issue with fpu SSE, until you have had some time to work on it
so, no more complaints until then :)
i havent been running -vec lately, until you told me to (and got the temp fix for ulongint)
Code: Select all
type vec3
as single x, y, z
end type
perhaps if im about to do the same operation over again, and theres a slot free, it will just be added in (assuming that the operand is the same)
but, it's awesome to know that you can use simd! i had assumed this code was mostly just using xmm in singular
i think i will hold on figuring out the current issue with fpu SSE, until you have had some time to work on it
so, no more complaints until then :)
Re: fpu SSE thread
-fpu SSE without -vec 1 or -vec 2 will emit scalar SSE instructions acting as a replacement for standard x87 instructions. It generally will perform well compared to the x87 instructions. I believe modern processors have multiple SIMD pipelines compared to one x87 FPU pipeline. Don't quote me on that.
The vectorization attempts to find indentical expressions on consecutive memory locations. When it finds 2 or more such expressions, it will flag the first one as 'vector' and remove the consecutive ones, up to 4 for single precision or 2 for double precision. It then emits vector instructions rather than scalar instructions.
It's not particularly smart but does a decent job. It works with fields in a UDT, such as the .x, .y, and .z in your vec3 UDT. It also works with pointers. It does NOT do loop unrolling.
The vectorization attempts to find indentical expressions on consecutive memory locations. When it finds 2 or more such expressions, it will flag the first one as 'vector' and remove the consecutive ones, up to 4 for single precision or 2 for double precision. It then emits vector instructions rather than scalar instructions.
It's not particularly smart but does a decent job. It works with fields in a UDT, such as the .x, .y, and .z in your vec3 UDT. It also works with pointers. It does NOT do loop unrolling.
-
- Posts: 22
- Joined: Nov 04, 2008 21:20
- Location: Germany
- Contact:
Re: fpu SSE thread
Where / whats the wrong declare?Gonzo wrote:... the worst bug was by far the wrong declaration in tsne.bi (socket lib)...
Greet
TPM
Re: fpu SSE thread
i think it was this line:
Declare Sub TSNE_INT_Thread_Master ()
should have been
Declare Sub TSNE_INT_Thread_Master (i_nothing as any ptr)
Declare Sub TSNE_INT_Thread_Master ()
should have been
Declare Sub TSNE_INT_Thread_Master (i_nothing as any ptr)
-
- Posts: 22
- Joined: Nov 04, 2008 21:20
- Location: Germany
- Contact:
Re: fpu SSE thread
whats your tsne version?
pls download the current version, where this was fixed: http://www.freebasic-portal.de/porticul ... -1548.html
btw. u can check the version at the third source-line:
Version: 3.5_20120825
Base-Version: 3.5
Date: 2012.08.25 (yyyy.mm.dd)
Greetings
TPM
pls download the current version, where this was fixed: http://www.freebasic-portal.de/porticul ... -1548.html
btw. u can check the version at the third source-line:
Code: Select all
' TSNE_V3 - TCP Socket Networking [Eventing] Version: 3.5_20120825 (0.18.5 -> 0.20.0 [08-10-2008])
Base-Version: 3.5
Date: 2012.08.25 (yyyy.mm.dd)
Greetings
TPM
Re: fpu SSE thread
yes i have the latest one now :) works great, except every socket i create still causes a segfault.. so its a nightmare to debug when i have to step over 9 segfaults (i need 9 sockets) :P
see: http://www.freebasic.net/forum/viewtopi ... 14&t=20427
it works though
i have no idea why i get segfault, since other people seem to not get it
i think it could be a library (.a) issue, but its hard to tell
see: http://www.freebasic.net/forum/viewtopi ... 14&t=20427
it works though
i have no idea why i get segfault, since other people seem to not get it
i think it could be a library (.a) issue, but its hard to tell
-
- Posts: 22
- Joined: Nov 04, 2008 21:20
- Location: Germany
- Contact:
Re: fpu SSE thread
Can u tell me: CPU and OS?
and, if u have linux try this and report the output:
http://www.freebasic-portal.de/porticul ... -1515.html
Greetings
TPM
and, if u have linux try this and report the output:
http://www.freebasic-portal.de/porticul ... -1515.html
Code: Select all
fbc test_client_en.bas -g && valgrind ./test_client_en
Greetings
TPM
Re: fpu SSE thread
win7 (64-bit), but i dont think it should matter because all the dlls and binaries are 32bit
i dont have any linux distro, sorry :)
if there is something wrong with my computer we can know this way:
http://fbcraft.fwsnet.net/test.exe
anyone can run that .exe with gdb, and if it segfaults the problem is with my compiler
if not, then the problem is with my computer (?)
all you have to do is navigate to test.exe in a command prompt, and run \mingw\bin\gdb.exe test.exe
then run the commands "start" and "cont"
if it segfaults just like in the code snippet, then it must be my compiler setup that's the issue
i dont have any linux distro, sorry :)
Code: Select all
[INIT] Client...
[Connecting]
[New Thread 13272.0x2e94]
Program received signal SIGSEGV, Segmentation fault.
0x718962bc in ?? () from C:\Windows\SysWOW64\mswsock.dll
(gdb) up
#1 0x765c3066 in WSASend () from C:\Windows\syswow64\ws2_32.dll
(gdb) up
#2 0x765c30a6 in WS2_32!SetAddrInfoExA () from C:\Windows\syswow64\ws2_32.dll
(gdb) up
#3 0x00403459 in TSNE_CREATE_CLIENT (R_TSNEID=<error reading variable>,
V_IPA=<error reading variable>, V_PORT=<error reading variable>,
V_EVENT_DISCONPTR=<error reading variable>,
V_EVENT_CONPTR=<error reading variable>,
V_EVENT_NEWDATAPTR=<error reading variable>,
V_TIMEOUTSECS=<error reading variable>,
V_STACKSIZEOVERRIDE=<error reading variable>,
V_WAITTHREADRUNNING=<error reading variable>,
V_CALLBACKBACKPTR=<error reading variable>)
at C:\FBEDIT1068\PROJECTS\TEST\TSNE_V3.BI:1053
1053 Dim XFlag as Integer = ioctlsocket(TSock, FIONBIO, Cast(Any Ptr,
1))
(gdb)
http://fbcraft.fwsnet.net/test.exe
anyone can run that .exe with gdb, and if it segfaults the problem is with my compiler
if not, then the problem is with my computer (?)
all you have to do is navigate to test.exe in a command prompt, and run \mingw\bin\gdb.exe test.exe
then run the commands "start" and "cont"
if it segfaults just like in the code snippet, then it must be my compiler setup that's the issue
Re: fpu SSE thread
the problem has been solved
i went through your code, and i noticed that you dont use any async calls at all
using (void*) 1 for ioctlsocket() is a segfault! it can crash anyone at anytime!
the correct code is:
XMode = 0 '' BLOCKING
Dim XFlag as Integer = ioctlsocket(TSock, FIONBIO, @XMode)
using connect() with FIONBIO flag set, will cause a EWOULDBLOCK error!
so, the correct value is (u_long) 0
it works well now, great library with that annoying error gone :)
i went through your code, and i noticed that you dont use any async calls at all
using (void*) 1 for ioctlsocket() is a segfault! it can crash anyone at anytime!
the correct code is:
XMode = 0 '' BLOCKING
Dim XFlag as Integer = ioctlsocket(TSock, FIONBIO, @XMode)
using connect() with FIONBIO flag set, will cause a EWOULDBLOCK error!
so, the correct value is (u_long) 0
it works well now, great library with that annoying error gone :)