Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

forall and arrays

Ilie__Daniel
Beginner
475 Views
Hello!

I have three arrays of dimension n and same type: a(n), b(n) and c(n). I want to add the a and b and put the result into c.

Could you possibly rank the following implementations from most efficient to least efficient?

1. c = a + b

2. c(1:n) = a(1:n) + b(1:n)

3. forall(i=1:n) c(i) = a(i) + b(i)

Thank you for your input.

Kind regards,
Daniel.
0 Kudos
1 Reply
TimP
Honored Contributor III
475 Views
You may require ifort directive !dir$ ivdep to make #3 as effective as the other two.
0 Kudos
Reply