News for hackers. Stuff that matters.
Re:Fortran 2023 by frud on Wednesday November 22, 2023 @12:06PM (#38381865)
One big thing I remember is that it's illegal to have multiple array arguments reference overlapping storage, so storage regions can't alias. This means functions can be optimized more aggressively.

My fingers can't type Fortran anymore, so I'm going to use C as an example.

Imagine you have this function:

    /* Add entries in arg1 to arg2, put result in result */
    void add_vec(int arg1[], int arg2[], int result[], int length) {
        for(int i = 0; i < length; i++) { 
            result[i] = arg1[i] + arg2[i];
        }
    } 
In C, it's perfectly legal to call this like so:

    int array[101];
    // ...pretend array is initialized...
    // for the first 100 elements, set a[i] = a[i] + a[i+1]
    add_vec(array, array+1, array);
The C compiler has no choice but to iterate through the array one element at a time, doing things in the exact order that the source code spells out. No loop unrrolling or vectorization can occur.

In Fortran, the compiler knows that the arrays are not aliased, so it can do much more reordering, unrolling, and vectorization to speed this code up.

Re:Fortran 2023 by phkahler on Wednesday November 22, 2023 @12:49PM (#38382479)
TIL that the restrict keyword is part of C99 but not C++ also that it is not necessary in Fortran.
Re:Fortran 2023 by RantyDave on Thursday November 23, 2023 @05:02AM (#38391191)
And this is why it's faster than C some-days for some-cases etc. but still actually faster.

Is there much going on with Fortran on GPU?

Re:Fortran 2023 by frud on Friday November 24, 2023 @10:37AM (#38404994)
After 30 seconds of furious googling: https://developer.nvidia.com/cuda-fortran