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

  • Context: Fortran 
  • Thread starter Thread starter fluidistic
  • Start date Start date
  • Tags Tags
    Fortran Processor
Click For Summary

Discussion Overview

The discussion revolves around the capability of Fortran to utilize multicore processors for improved computational performance, particularly in comparison to C/C++. Participants explore the role of compilers in enabling or limiting this functionality.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions whether Fortran programs can utilize both processors on a dual-core system.
  • Another participant asserts that Fortran has advantages over C/C++ regarding multicore processing, but notes that the capability depends on the specific Fortran compiler used.
  • A participant expresses uncertainty about their compiler, gfortran, and whether it can utilize more than one core.
  • Concerns are raised about C's use of pointers, which complicates the compiler's ability to determine memory changes and safely distribute tasks across multiple cores, unlike Fortran.
  • Suggestions are made regarding the use of MPI for distributing calculations across multiple CPUs, though it may be excessive for a dual-core setup.
  • A participant provides a link to OpenMP documentation for gfortran, indicating potential compiler directives for multicore processing.
  • Another participant shares an example of a multi-threaded C program, highlighting the basics of multi-threading, although it is not directly related to Fortran.

Areas of Agreement / Disagreement

Participants generally agree that the ability of Fortran to utilize multicore processors is dependent on the compiler, but there is no consensus on the specific capabilities of gfortran or other compilers mentioned.

Contextual Notes

Participants note limitations regarding compiler capabilities and the complexities introduced by pointers in C, which may affect the ability to parallelize tasks effectively.

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?
 
Technology 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.
 
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
 

Similar threads

Replies
8
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
11
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
14
Views
2K
  • · Replies 9 ·
Replies
9
Views
7K
  • · Replies 8 ·
Replies
8
Views
4K
Replies
8
Views
6K
  • · Replies 2 ·
Replies
2
Views
3K