Data partioning with threading..

tang3li2

Member
Joined
Mar 2, 2011
Messages
8
Programming Experience
Beginner
Currently i'm stuck up with the algorithm that i'm implementing, it's "lexicographic permutation algorithm", it "LAGS" when it comes to million of number ( 1 million to 9 million ) and sometimes "STUCK UP ( NOT RESPONDING )"

So the idea that i come up is to break it apart, so meaning to say use a partition..
example i have a number to be partition which is: 100, so... square root of (100) i can get 10,
so each process from 1 -10, carries 10 process.. because 100 / 10 = 10, and 10 x 10 = 100.. just to be clear.so

  • loop 1: (carries 10 process )
  • loop 2: (carries 10 process )
  • loop 3: (carries 10 process )
  • loop 4: (carries 10 process )
  • loop 5: (carries 10 process )
  • loop 6: (carries 10 process )
  • loop 7: (carries 10 process )
  • loop 8: (carries 10 process )
  • loop 9: (carries 10 process )
  • loop 10: (carries 10 process )
-------------------------------------
All in all = 100 process,

so using threading i guess i can solve this efficiently, so i did a benchmark between PLAIN LOOP vs. PARTITIONING WITH THREADING but somehow using partitioning with threading it "SLOWS" up the process and the PLAIN LOOP is much faster...

The class that i'm using threading is not implemented by me..

I uploaded the code.. hope someone can point me out what i'm missing and can help me fix up my problem.. any advice is also appreciated and welcome

I use vb.net 2010 in this..

My best regard and thank you :D


 

Attachments

  • partitioning-analysis.zip
    38.2 KB · Views: 15
Last edited by a moderator:
I'm not sure what exactly that code is, but you can increase performance of your loop tenfold by using an indexed control array for your labels:

        For i = 1 To N
            If cnt = 0 Then
                startfrm = 1
                endlimit = process
                'Else
                '    startfrm = ((i * process) + 1) - process
                '    endlimit = (i * (process))
                cnt = 1
            End If
            
            If cnt <= 10 Then Label(cnt) = i
        
            If i Mod process = 0 Then
                cnt += 1
            End If
        Next
 
thank you sir, but doing a indexed control array, will just make the plain loop more faster than the partitioning with threading, what i'm trying to gain is to make partitioning with threading more faster than the plain loop, but it seems that the plain loop is more faster :(... the question is how to make the partition will be successful against plain loop?? thank you sir :D
 
Why don't you explain in your own words what you are trying to accomplish, or post a link to the tutorial you are reading. What is the real world problem you are trying to solve here?

Having 100 threads is useless unless your computer has 100 logical cores available. One logical core can only execute one thread at a time. Normally to gain performance processing a large chunk of data, you split the input data into 4/8/16 subsets, each with a thread executing your loop. Make the loop tight, and you will extract maximum performance from multi-threading.
 
hhmm actually i have no tutorial on this, i'm just guessing if it's possible.. i'll just make more experiment =))
so far i think there's a problem in the threading start.. i'll just need to figure it out what it is making it slow =))
 
Last edited:
Back
Top