fix for TPasMP.ParallelFor #7

Closed
mariuszmaximus wants to merge 1 commit from master into master
mariuszmaximus commented 2018-01-18 10:00:30 +00:00 (Migrated from github.com)

For my last Issue ;)

For my last Issue ;)
mariuszmaximus commented 2018-01-18 10:34:43 +00:00 (Migrated from github.com)

However, this did not resolve my problem

I have FOR i:= 0 to 1023 do someting

Version with pasmp

GlobalPasMP.Invoke(GlobalPasMP.ParallelFor(self,0,1023,myProcedure,12,4));
or
GlobalPasMP.Invoke(GlobalPasMP.ParallelFor(self,0,1023,myMethod,12,4));

sometimes not all CPU are used and I see Index list [slow version]
FromIndex..ToIndex
0..11 from thread #4
517..528 from thread #10
264..275 from thread #11
776..1023 from thread #6
137..263 from thread #7
529..775 from thread #1
276..516 from thread #9
12..136 from thread #8

sometimes alle CPU are used and I see Index list [fast version]
992..1003 from thread #0
15..26 from thread #6
47..58 from thread #7
7..14 from thread #4
27..31 from thread #8
79..90 from thread #9
64..70 from thread #5
0..6 from thread #2
39..46 from thread #1
32..38 from thread #3
71..78 from thread #10
111..122 from thread #11
103..110 from thread #8
59..63 from thread #2
and more and more ...... ;)

However, this did not resolve my problem I have FOR i:= 0 to 1023 do someting Version with pasmp GlobalPasMP.Invoke(GlobalPasMP.ParallelFor(self,0,1023,myProcedure,12,4)); or GlobalPasMP.Invoke(GlobalPasMP.ParallelFor(self,0,1023,myMethod,12,4)); sometimes not all CPU are used and I see Index list [slow version] FromIndex..ToIndex 0..11 from thread #4 517..528 from thread #10 264..275 from thread #11 776..1023 from thread #6 137..263 from thread #7 529..775 from thread #1 276..516 from thread #9 12..136 from thread #8 sometimes alle CPU are used and I see Index list [fast version] 992..1003 from thread #0 15..26 from thread #6 47..58 from thread #7 7..14 from thread #4 27..31 from thread #8 79..90 from thread #9 64..70 from thread #5 0..6 from thread #2 39..46 from thread #1 32..38 from thread #3 71..78 from thread #10 111..122 from thread #11 103..110 from thread #8 59..63 from thread #2 and more and more ...... ;)
BeRo1985 commented 2018-01-18 10:38:52 +00:00 (Migrated from github.com)

Can you provide a complete prepared test Delphi or FreePascal/Lazarus project for it? Because that would increase the chance that I will debug it later alongside my other activities in the moment.

Can you provide a complete prepared test Delphi or FreePascal/Lazarus project for it? Because that would increase the chance that I will debug it later alongside my other activities in the moment.
mariuszmaximus commented 2018-01-18 11:01:43 +00:00 (Migrated from github.com)

I found where is problem

I called TPasMP.CreateGlobalInstance; and GlobalPasMP.Invoke(GlobalPasMP.ParallelFor
inside Thread1
After finish ParallelFor I free Thread1
Then I call new GlobalPasMP.Invoke(GlobalPasMP.ParallelFor but inside new Thread2

Then function CanSpread() always return FALSE :)

My solution is use
TPasMP.CreateGlobalInstance;
GlobalPasMP.Invoke(GlobalPasMP.ParallelFor ....
TPasMP.DestroyGlobalInstance;

I found where is problem I called TPasMP.CreateGlobalInstance; and GlobalPasMP.Invoke(GlobalPasMP.ParallelFor inside Thread1 After finish ParallelFor I free Thread1 Then I call new GlobalPasMP.Invoke(GlobalPasMP.ParallelFor but inside new Thread2 Then function CanSpread() always return FALSE :) My solution is use TPasMP.CreateGlobalInstance; GlobalPasMP.Invoke(GlobalPasMP.ParallelFor .... TPasMP.DestroyGlobalInstance;

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BeRo1985/pasmp!7
No description provided.