Parallel execution

Discussion in 'Mac Programming' started by TheBrazilianGuy, May 27, 2007.

  1. TheBrazilianGuy macrumors regular

    Joined:
    Jul 26, 2006
    #1
    We have a executable file that compiles independent pieces of code (in this case fortran) :

    g77 -O2 code1.f
    g77 -O2 code2.f
    ...
    g77 -O2 codeN.f

    Does someone know how to execute this file using all possible cores in a Macpro ? I mean, splitting and executing this file in 8 would be a nice speed up.

    Thxs!
     
  2. cube macrumors G5

    Joined:
    May 10, 2004
  3. TheBrazilianGuy thread starter macrumors regular

    Joined:
    Jul 26, 2006
    #3
    Oh, my fault. This is something we came up to avoid typing all
    N commands over and over. All g77 commands are inside a single
    file we call "CompileAll". After setting this file as executable,
    we just type :

    ./CompileAll

    and everything is done after a mug of coffee.

    Being all N codes independent, I was going to split CompileAll and execute
    it in all cores at the same time. That's when I decided to see if someone
    has a better idea...(actually, the best solution might well be to
    use "make" with the option "-j")
     
  4. cube macrumors G5

    Joined:
    May 10, 2004
    #4
    That's what I wanted to hear. Yes, replace this CompileAll script with "make -j 8"
     
  5. TheBrazilianGuy thread starter macrumors regular

    Joined:
    Jul 26, 2006
    #5
    If this works I will have to replace those two mugs of coffee by a sip of water :p
    I will check it out. Thanks a bunch !!!
     
  6. cube macrumors G5

    Joined:
    May 10, 2004
    #6
    Just make it so that there are several matches at the same time. Don't write g77 commands for each file one below the other in one rule.
     

Share This Page