(no title)
frud | 2 years ago
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.
RantyDave|2 years ago
Is there much going on with Fortran on GPU?
frud|2 years ago
phkahler|2 years ago