79513901

Date: 2025-03-17 07:49:19
Score: 2
Natty:
Report link

I want to thank everyone for useful tips and help.

I am going to answer my question - partially.

I have tried compiling and running the codes for matrix multiplication on my laptop that has AMD Ryzen 8845HS processor and is running Ubuntu 22.04.5.

The compilation commands are the same, i.e.

Fortran: gfortran -O3 -march=native -funroll-all-loops matmul.f90

C: gcc -O3 -march=native -funroll-all-loops matmul.f90

The situation on Ubuntu is now different. Fortran takes 0.13 seconds, while C takes 0.24 seconds. The difference is still quite significant.

However, when I use Intel Fortran and Intel C compiler (that are installed on my Windows 10 PC with i7 6700 processor) things are completely different. For matrices of sizes 1024 by 1024, Fortran compiled code takes 0.079 seconds, while C code takes 0.077 seconds. C code is actually faster.

The compilation options for Intel Fortran compiler that I have used are:

ifx -fast matmul.f90 /heap-arrays

The compilation options for Intel C compiler that I have used are:

ifc -fast matmul.c

It looks like gcc is not that great - as I initially taught. This is strange because I believed it was the best C compiler out there.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Ante Jurčević