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

  • Topic: Fortran 
  • Thread starter Thread starter fluidistic
  • Start date Start date
  • Tags Tags
    Fortran Processor
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
6 replies · 12K views
fluidistic
Gold Member
Messages
3,934
Reaction score
286
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?
 
Physics news on Phys.org
Yes that's one of the main advantages of Fortran over C/C++
Wether your particular Fortran compiler can do it depends.
 
mgb_phys said:
Yes that's one of the main advantages of Fortran over C/C++
Wether your particular Fortran compiler can do it depends.

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?
 
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 independent. 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.
 
mgb_phys said:
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 independent. 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.

Thanks a lot for the info.