Can threads be used for this problem?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • traravind
    New Member
    • Mar 2007
    • 6

    Can threads be used for this problem?

    Hi all,

    I am a newbie to perl programming and am already loving it.. I have a problem with my code in research and am trying to improve the performance by parallel processing some blocks of code.
    I have a perl module where I consecutively process data even though there are not dependent on each other.

    For example,

    my $i= 4;
    .
    .
    for (my $j=0;$j<$i;++$j )
    {
    ## some statements for variable initializations

    open(FH1, "./GraphGen.pm $j $fld stoplist .....## list of arguments##...| ");
    }

    ## block of statements##

    Now my problem is that I need to parallel process the GraphGen.pm module since each run is independent but the threads must wait until execution of all the threads are completed since the block of statements called after the completion of the loop depends on the outputs of the GraphGen module of each run.

    If I can model this using threads and using threads->join() command, can you please tell me how to do it exactly as I am a little confused after reading the perl thread tutorial.

    Thanks in advace!!!

    perl really rocks.......... ....
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Nobody can tell you have to exactly do something based on the vague description you have posted, or at least I don't think so. I never use threads myself so can't help.

    Comment

    • traravind
      New Member
      • Mar 2007
      • 6

      #3
      ok since it seems to be vague let me explain it a little more...

      There is a perl module GraphGen to whom I have to pass in arguments and I have to execute the module for a particular number of times in a loop. Since the loop executes each run consecutively and the output of each run is independent of each other, I would want to do it parallely. There are some more steps to be carried out after the completion of the for loop. So If I have to implement this in threads I would want all the threads to be executed to completion before I take the outputs of each threads to process them .
      I hope this makes it clear

      Comment

      Working...