Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- From: "Ian Boyd" <ian.borlandnews008@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 24 Jun 2007 22:31:29 -0400
I would suggest to group the elements, and lock the access to the net forces for a complete group while you're computing the interaction between all the elements of two groups.
For example if you have 1000 bodies, divide them in, say, 40 groups of 25 elements. An individual UOW should then handle all the interactions between two groups of elements. You only need to lock the access once for every group, so you'll be able to compute 25*25 interactions with two sync instruction.
You'll have memory contention at some point (some threads will have to wait for others to release access to a certain group), but my guess is that you should be able to use at least 80% of available CPU in an algorithm that will perform very much like n*(n-1)/2.
i'm sure i'm mis-understanding what you're describing.
Assume there are 9 bodies, put into 3 groups of 3
Group A: 123
Group B: 456
Group C: 789
i then define 6 units of work
UOW1: forces within A
UOW2: forces within B
UOW3: forces within C
UOW4: forces between A and B
UOW5: forces between A and C
UOW6: forces between B and C
And each group is completely locked while the UOW is running. This means that 4,5,6 cannot start until 1,2,3 are done; therefore the possible simultaneous executions are:
1,2,3: A,B,C
4: AB
5: AC
6: BC
So if i work it all out it's
UOW1,2,3:
/-- F12, F13, F23 --\
---+-- F45, F46, F56 --+--->
\-- F78, F79, F89 --/
UOW4:
------ F14,F15,F16,F24,F25,F26,F34,F35,F36 ----->
UOW5:
------ F17,F18,F19,F27,F28,F29,F37,F38,F39 ----->
UOW6:
------ F47,F48,F49,F57,F58,F59,F67,F68,F69 ------> Done
For a total of 36 calculations, but 6 happening in parallel, so effectivly it's 30 calculations; an 8% speed improvement.
i get the sense that if there are more groups, then there's more opportunity for parallelization; and that 9 groups really isn't really a great example case. But do i have your idea right?
.
- Follow-Ups:
- Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- From: Robert Houdart
- Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- References:
- Choose: O(n!) on single core vs O(n^2) on multi-core
- From: Ian Boyd
- Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- From: Robert Houdart
- Choose: O(n!) on single core vs O(n^2) on multi-core
- Prev by Date: Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- Next by Date: Is Borland's MM that bad?
- Previous by thread: Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- Next by thread: Re: Choose: O(n!) on single core vs O(n^2) on multi-core
- Index(es):
Relevant Pages
|