# Fortran has the fastest matmul

**URL:** <https://fortran-lang.discourse.group/t/fortran-has-the-fastest-matmul/7170>\
**Category:** Advocacy\
**Created:** [January 11, 2024, 8:44pm UTC](https://fortran-lang.discourse.group/t/fortran-has-the-fastest-matmul/7170 "2024-01-11T20:44:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fortran4r](https://avatars.discourse-cdn.com/v4/letter/f/9de0a6/32.png) [@fortran4r](https://fortran-lang.discourse.group/u/fortran4r)\
**Post date:** [January 11, 2024, 8:44pm UTC](https://fortran-lang.discourse.group/t/fortran-has-the-fastest-matmul/7170/1 "2024-01-11T20:44:13Z")

</div>

> **[GitHub - attractivechaos/plb2: A programming language benchmark](https://github.com/attractivechaos/plb2)**
>
> A programming language benchmark. Contribute to attractivechaos/plb2 development by creating an account on GitHub.

In this new benchmark, Fortran has the fastest matmul. You guys might want to add the Fortran version of bedcov and further optimize all the Fortran codes.

---

<div class="post-metadata">

**Author:** ![Euler-37](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Euler-37](https://fortran-lang.discourse.group/u/Euler-37)\
**Post date:** [January 12, 2024, 1:58am UTC](https://fortran-lang.discourse.group/t/fortran-has-the-fastest-matmul/7170/2 "2024-01-12T01:58:35Z")

</div>

`ifort`’s “three loops matmul” is soooo fast. But `ifx` slow.

```sh
> ifx -v
ifx version 2024.0.1
> ifx matmul.f90 -O3 -march=native && time ./a.out
  -143.500166666657

________________________________________________________
Executed in 1.04 secs fish external
   usr time 1.04 secs 0.00 micros 1.04 secs
   sys time 0.00 secs 433.00 micros 0.00 secs
> ifort -v
 ifort version 2021.11.1
> ifort matmul.f90 -Ofast -march=native && time ./a.out
  -143.500166666657

________________________________________________________
Executed in 217.17 millis fish external
   usr time 216.92 millis 0.00 micros 216.92 millis
   sys time 0.32 millis 318.00 micros 0.00 millis

```

Maybe ifort has been specifically optimized for matmul benchmark

---

<div class="post-metadata">

**Author:** ![aledinola](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@aledinola](https://fortran-lang.discourse.group/u/aledinola)\
**Post date:** [January 12, 2024, 11:34am UTC](https://fortran-lang.discourse.group/t/fortran-has-the-fastest-matmul/7170/3 "2024-01-12T11:34:20Z")

</div>

Very interesting! It should be noted through that they do not test the matmul intrinsic function but a loop-based implementation of matrix multiplication (three nested loops) (referring to Fortran of course)
