This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libmvec simd math functions in fortran


On Thu, Nov 2, 2017 at 2:07 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Nov 2, 2017 at 1:49 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>> On 01/11/17 16:47, Szabolcs Nagy wrote:
>>> On 01/11/17 16:26, Jakub Jelinek wrote:
>>>> On Wed, Nov 01, 2017 at 04:23:11PM +0000, Szabolcs Nagy wrote:
>>>>> is there a way to get vectorized math functions in fortran?
>>>>>
>>>>> in c code there is attribute simd declarations or openmp
>>>>> declare simd pragma to tell the compiler which functions
>>>>> have simd variant, but i see no such thing in fortran.
>>>>
>>>> !$omp declare simd should work fine in fortran (with -fopenmp
>>>> or -fopenmp-simd).
>>>>
>>>
>>> 1) i don't want to change the fortran.
>>>
>>> 2) it does not work for me.
>>>
>>> i want this to call vector powf in libmvec:
>>>
>>> subroutine foo(a,b,c)
>>>   real(4) a(8000),b(8000),c(8000)
>>>   do j=1,8000
>>>     a(j)=b(j)**c(j)
>>>   end do
>>> end
>>>
>>> where do i put
>>>
>>> !$omp declare simd (powf)
>>>
>>> ?
>>
>> to answer my question..
>>
>> it seems fortran cannot express the type signature
>> of mathematical functions because arguments are
>> passed by reference.
>>
>> so there is no way to declare math interfaces
>> and then add omp declare simd to them to get
>> simd versions.
>
> Not even with BIND(C) or so?
>
>> (it's not clear to me how omp declare simd is
>> supposed to work in fortran, but it is not useful
>> for vectorizing loops with math functions.)
>>
>> so gfortran will need a different mechanism to
>> do the vectorization, e.g. an option like
>> -mveclibabi=glibc, but the list of available
>> vector functions need to be specified somewhere.
>
> I think most useful would be if glibc ships with a
> fortran module that provides the appropriate
> declarations and users can simply include such
> module or such module would be automagically
> included like we have that C pre-def header.
>
> Of course first we have to solve the mystery
> of how to actually declare the libm sin() function
> in the appropriate way.  And if there isn't one,
> provide one by means of an extension
> ($! pragma gcc whatever?)

Always good to CC fortran@ for such stuff anyways.

Richard.

> Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]