Hello
I think that I have never commented the Neural API threading in detail here. I got a couple of questions in regards to this recently. I hope that I'm not typing too much.
As an example, assuming that you need to run a procedure 10 times in parallel, you can create 10 thread workers as follows:
FProcs := TNeuralThreadList.Create( 10 );
As an example, this is the procedure that we intend to run in parallel:
procedure MyClassName.RunNNThread(index, threadnum: integer);
begin
WriteLn('This is thread ',index,' out of ',threadnum,' threads.');
end;
Then, to run the procedure RunNNThread passed as parameter 10 times in parallel, do this:
FProcs.StartProc(@RunNNThread);
You can control the blocking mode (waiting threads to finish before the program continues) as per declaration:
procedure StartProc(pProc: TNeuralProc; pBlock: boolean = true);
Or, if you prefer, you can specifically say when to wait for threads to finish as per this example:
FProcs.StartProc(@RunNNThread, false);
// insert your code here
FProcs.WaitForProc(); // waits until all threads are finished.
When you are done, you should call:
neuralthread is the unit that allows parallel processing when using neural fit:
https://github.com/joaopauloschuler/neural-api/blob/master/neural/neuralfit.pas Wish long and prosper life to FPC and Lazarus!