libmvec simd math functions in fortran

Jakub Jelinek jakub@redhat.com
Thu Nov 2 13:07:00 GMT 2017


On Thu, Nov 02, 2017 at 12:49:18PM +0000, Szabolcs Nagy wrote:
> to answer my question..
> 
> it seems fortran cannot express the type signature
> of mathematical functions because arguments are
> passed by reference.

Fortran indeed normally does pass by reference, and you can vectorize it
that way (you can use various declare simd clauses to express in detail
how the arguments should be handled), or pass by reference:

interface
  double precision function foo (x, y)
    double precision, value :: x, y
    !$omp declare simd (foo)
  end function
end interface

and/or using bind(c):

interface
  function bar (x, y) bind(C)
    use, intrinsic :: iso_c_binding
    real(c_double), value :: x, y
    real(c_double) :: bar
    !$omp declare simd (bar)
  end function
end interface

etc.

	Jakub



More information about the Gcc mailing list