Forum > Windows
Problem with multi-thread in newer FPC
fdsingleton:
I have a general simulation system which runs as Win32 and uses FPC/LCL to compile & run the user-generated problem code. Much of it was developed in Delphi 3 many years ago, and I switched to FPC so users would not have to have Delphi. I have attempted to update from FPC 2.6.4 to 3.0.2 or 3.0.4. I can run simulations with 3.0.4 but the answers are clearly wrong in various unusual ways compared to 2.6.4 which always seemed totally correct on various test problems. I am at a loss to know what to do.
The FPC program has the initial Windows thread plus 2 computational threads. I see that the thread programming approach in the manual no longer resembles the traditional Delphi method which remains in my code. What are the chances that this causes the computational errors?
Thaddy:
--- Quote from: fdsingleton on January 30, 2018, 07:14:49 am ---I have a general simulation system which runs as Win32 and uses FPC/LCL to compile & run the user-generated problem code. Much of it was developed in Delphi 3 many years ago, and I switched to FPC so users would not have to have Delphi. I have attempted to update from FPC 2.6.4 to 3.0.2 or 3.0.4. I can run simulations with 3.0.4 but the answers are clearly wrong in various unusual ways compared to 2.6.4 which always seemed totally correct on various test problems. I am at a loss to know what to do.
--- End quote ---
There should be no difference. Can you provide example code?
--- Quote ---The FPC program has the initial Windows thread plus 2 computational threads. I see that the thread programming approach in the manual no longer resembles the traditional Delphi method which remains in my code. What are the chances that this causes the computational errors?
--- End quote ---
Even Delphi itself changed a lot from Delphi 3 on the subject of threading. Current thread handling is in line with current Delphi too...
If your code used to work it should still work, though, unless there was always a hidden bug in your code that now manifests itself. I have seen that many times!
More specific regarding assuming I/O buffers are always clean and always synchronized, which technically has never been the case and worked by accident..
Again, we need some simple but complete example code that reproduces the issue. (Note I can still test against Delphi 3 if required)
taazz:
--- Quote from: fdsingleton on January 30, 2018, 07:14:49 am ---I have a general simulation system which runs as Win32 and uses FPC/LCL to compile & run the user-generated problem code. Much of it was developed in Delphi 3 many years ago, and I switched to FPC so users would not have to have Delphi. I have attempted to update from FPC 2.6.4 to 3.0.2 or 3.0.4. I can run simulations with 3.0.4 but the answers are clearly wrong in various unusual ways compared to 2.6.4 which always seemed totally correct on various test problems. I am at a loss to know what to do.
The FPC program has the initial Windows thread plus 2 computational threads. I see that the thread programming approach in the manual no longer resembles the traditional Delphi method which remains in my code. What are the chances that this causes the computational errors?
--- End quote ---
there are two main ways to get different results from multithreading.
1) the data are not properly protected and at some point they get corrupted.
2) the algorithm has problems serializing the calculations, and some calculation occur out of order..
As to why it works on older and not newer versions I have no idea, I'm still on lazarus 1.4, but I would start comparing the locking primitives that I use (critical section, multiread, etc.) before delving in to algorithm land.
Thaddy:
Indeed, posts crossed while I was editing.
fdsingleton:
Thank you all for answering. One of my problems is I have very little time to spend on this project (and do not make any money from it). I put in a previous post about it last Oct.!
Navigation
[0] Message Index
[#] Next page