-
February 24th, 2012, 01:49 AM
#1
VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe builds
There is a situation here where the exe generated with options being set to "No Optimization" produces output which differs from the output of the exe generated with options being set to "Optimize for Fast Code".
There are lot of calculations, iterations, probability and std deviation calculations involved but we cant figure out how and where VB Calculation differs in "No Optimize" build and "Optimize for fast Code" build.
The code is too big to include it in here. Would be really helpful if someone can explain what exactly VB 6 does during "Optimize for Fast Code" that is different from 'No Optimization'
Thanks,
Arun
-
February 24th, 2012, 02:09 AM
#2
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
Should be no different, only FASTER...
-
February 24th, 2012, 02:16 AM
#3
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
Yes, ideally it should be. But the output actually differs. As I said its kind of a forecasting application which involves lots of calculations on probability and std.deviations. I am trying to figure out where the difference happens but no luck until now.
-
February 24th, 2012, 07:04 AM
#4
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
What hardware, especially CPU and which OS are you running?
I also never heared about differing calc results...
-
February 24th, 2012, 09:54 AM
#5
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
I do not think the OP means that calculations have different results in your exe but rather that the way the compiler creates the output is different which it is of course. I do not know exactly what the compiler does at compile time with the various options set. Never really had a need to know.
Always use [code][/code] tags when posting code.
-
February 24th, 2012, 11:49 AM
#6
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
One compiles to P-Code by default. Operates slower. Mostly, no string optimization
-
February 24th, 2012, 12:20 PM
#7
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
I think this site put's it appropriately...visualbasic freetutes
think about what it takes to develop an optimizing compiler. It isn’t easy to determine precisely how to handle every conceivable combination of factors governing the use of an optimization. Detecting when it is safe to move an instruction out of a loop or when a particular register value ought to be retained is no mean feat, and it is possible that the optimizer may make a mistake.
In other words, the opportunity to optimize one’s code is also another opportunity to introduce a bug.
You Calculations obviously pushed the Code optimizer to the limit and it's failed..
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
February 26th, 2012, 12:49 AM
#8
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
Originally Posted by WoF
What hardware, especially CPU and which OS are you running?
Intel Core2DUO and Win7
@GremlinSA
thanks for the link
----------------------------------------------
We are now logging the calculations in a file and could see some differences in rounding of 'double' datatypes during auto type casting.
I will update once we are conclusive on what makes the difference in output.
Thanks,
Arun
Last edited by arunchristopher; February 26th, 2012 at 12:53 AM.
-
August 28th, 2012, 08:29 AM
#9
Re: VB 6 calculates differently for 'No Optimiza' and 'Optimize for Fast Code' exe bu
I have a similar problem with Compile for Fast Code versus Compile with No Optimization.
The following code reproduces the problem -
Can anyone else try this program on their computer to see if they get the same results?
Code:
Option Explicit
Const COL_FLTS = 1
Const COL_FTIME = 2
Public FltData(100, 7, 1) As Long
Public xCOL_FTIME As Long, xCOL_FLTS As Long
Sub Main()
Dim x As Long, j As Long
Dim rw As Long, mon As Long, comment As String
rw = 1
mon = 0
comment = "main "
xCOL_FLTS = 1: xCOL_FTIME = 2
Call testLongArray(rw, mon, "testlong #1")
'Call testLongArray(rw, mon, "testlong #2")
FltData(rw, COL_FLTS, mon) = FltData(rw, COL_FLTS, mon) + 1000
x = FltData(rw, COL_FTIME, mon) + 100
FltData(rw, COL_FTIME, mon) = x
For j = 1 To 12
Next j
If x <> FltData(rw, COL_FTIME, mon) Then
MsgBox (comment & " no joy " + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
Else
MsgBox (comment & " OK " + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
End If
Call testLongArray(rw, mon, "testlong #3 ")
End Sub
Function testLongArray(ByVal rw As Long, ByVal mon As Long, ByVal comment As String)
Dim j As Long, x As Long
FltData(rw, COL_FLTS, mon) = FltData(rw, COL_FLTS, mon) + 10
x = FltData(rw, COL_FTIME, mon) + 100
FltData(rw, COL_FTIME, mon) = x
For j = 1 To 12
Next j
If x <> FltData(rw, COL_FTIME, mon) Then
MsgBox (comment & " no joy" + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
Else
MsgBox (comment & " OK " + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
End If
End Function
Last edited by GremlinSA; August 30th, 2012 at 02:03 AM.
Reason: Changed Font tags to Code tags
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|