Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Is it possible to take advantage of a multicore processor for fortran?

  1. Oct 13, 2009 #1

    fluidistic

    User Avatar
    Gold Member

    I have a dual core processor (intel) but I think that fortran programs only uses 1 processor. Can Fortran use both processors to calculate faster?
     
  2. jcsd
  3. Oct 13, 2009 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Yes thats one of the main advantages of Fortran over C/C++
    Wether your particular Fortran compiler can do it depends.
     
  4. Oct 13, 2009 #3

    fluidistic

    User Avatar
    Gold Member

    Thanks for the reply.
    So it all depends on the compiler? Strange that we can't write a compiler that does the same for C/C++.

    By the way, it seems that gfortran (my compiler) doesn't use more than 1 core. Do you know if I'm right?
     
  5. Oct 13, 2009 #4

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    The difficulty in c is that because you have pointers you can't know what memory a function will change without running it - so the compiler can't automatically split say the update of different parts of an array to different CPUs/Cores because they might not be independant. With Fortran you know they are and so can safely run multiple threads each using their own part of an array.

    Sorry I don't know g95.
    You can always use something like MPI to split a calculation across multiple CPUs/machines - but it might be overkill for just a dual core.
     
  6. Oct 13, 2009 #5

    fluidistic

    User Avatar
    Gold Member

    Thanks a lot for the info.
     
  7. Oct 13, 2009 #6
  8. Oct 13, 2009 #7

    rcgldr

    User Avatar
    Homework Helper

    Example mutli-threaded C prograrm (use visual studio to build). It just copies a file, but the basics required for multi-threading, including code for fifo "message" queues is included.

    http://jeffareid.net/misc/mtcopy.zip
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Is it possible to take advantage of a multicore processor for fortran?
  1. 8 bit processor (Replies: 15)

Loading...