Hmmm. So that's the error? I knew AB was doing reference counting but thought it would "see through" to the DLL so that sharing pointers with variables passed back to AB would be OK. In an earlier exchange, you had said not to touch pointers going to or from AmiBroker, and it sounds like I misinterpreted this to mean it was OK to let the pointers do a "round trip".
The example which would be causing problems in this case is an IIF() statement. To make sure I've got it: I can't translate IIF(AlmostEqual(a, b), c, d) into the C++ by assigning the pointer returned from the AlmostEqual call to the first argument of the ArgsTable passed to IIF()? Instead, I should pass by value?
I can totally do that with some recoding in my wrappers. I'd avoided it because of the performance cost and thinking AB's reference counting was tracking the shared assignments.
Also, thanks for the heads up on the "fast" setting. I'd read that but "fast" is the default setting and I was nervous about fiddling with the defaults.
---In amibroker@yahoogroups.com, <groups@...> wrote :
Also, thanks for the heads up on the "fast" setting. I'd read that but "fast" is the default setting and I was nervous about fiddling with the defaults.
---In amibroker@yahoogroups.com, <groups@...> wrote :
Hello,
Thank you very much for your e-mail.
One thing: Visual C++ "FAST" setting for floating point simply produces incorrect values for many calculations. Avoid it.
Second thing:
1) The pointer value can be reassigned to an AmiVar and repassed to gSite.CallFunction();
This sounds wrong. You can't share pointers without proper reference counting.
AmiBroker may use pointers in multiple variables but it does reference counting, if you are re-assinging pointers
in DLL you are creating big trouble because all those reference counts are pretty much useless if user messes up with pointers.
Best regards,
Tomasz Janeczko
amibroker.com
Thank you very much for your e-mail.
One thing: Visual C++ "FAST" setting for floating point simply produces incorrect values for many calculations. Avoid it.
Second thing:
1) The pointer value can be reassigned to an AmiVar and repassed to gSite.CallFunction();
This sounds wrong. You can't share pointers without proper reference counting.
AmiBroker may use pointers in multiple variables but it does reference counting, if you are re-assinging pointers
in DLL you are creating big trouble because all those reference counts are pretty much useless if user messes up with pointers.
Best regards,
Tomasz Janeczko
amibroker.com
On 2016-04-06 00:58, rosenberggregg@... [amibroker] wrote:
Hi Tomasz, it turns out I was wrong about the floating point precision. I've printed out the variables to eight decimal places and the AFL and C++ functions agree. For example, at the last step of the calculation both versions of the function produce these coordinates:0.571394384.707252034.707252030.24768575These are passed into another function which is pure AFL running in AmiBroker, but the output from this AFL function when the inputs come from AmiBroker is -1.77987289 and the output when the input comes from C++ is -1.96784937.The kind of behavior above occurs along the whole vector: exact same inputs, different outputs.The companion issue is that in the C++ case, even though the inputs coming from the C++ function are always the same, the outputs from AFL on those inputs may be different in different runs.So, oddly, my DLL isn't unstable but is causing some instability in AmiBroker somehow. Can I be compiling in a configuration which is incompatible with AmiBroker? I am using Visual Studio Community 2015 on Windows 10, with AmiBroker 6.10 64-bit, in Debug mode with optimizations turned off, x64 mode (which uses SSE) and floating point rounding set to the default value of fast. I've tried the rounding value of precise but get the same behavior.The only other thing I can think of now is some new kind of shared pointer issue. However, I've gotten rid of all pointers except the ones I can't avoid because they are float * returned by gSite.CallFunction(). These are handled by a class and very strictly segregated so only two operations are permitted on them: 1) The pointer value can be reassigned to an AmiVar and repassed to gSite.CallFunction(); or 2) The contents of the pointer can be copied to a compiled, local array (no heap activity or pointer transfer). Otherwise, AB pointers are never touched. Could the pointer move in action (1) create instability in AB?
__._,_.___
Posted by: rosenberggregg@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (7) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? The Yahoo Mail app is fast, beautiful and intuitive. Try it today!
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
.
__,_._,___
EmoticonEmoticon