2

I have been considering for a while when to inline or use declare simd in a simd loop. I came across this article which the OP has similar question, but the answer is rather not clear to me.

I have two questions:

1) Is it considered a bug to have both declare simd(function_name) and an inline directive like !DIR$ ATTRIBUTES::FORCEINLINE(function_name).

2) How to know which one to use?

A basic example

!DIR$ ATTRIBUTES :: FORCEINLINE(call_insimd)
!$OMP DECLARE SIMD(call_insimd)
function call_insimd(a,b)  result(res)
implicit none 
real, intent(in) :: a,b 
real, intent(out):: res 
end function

In main loop

do i = 1,10000 
!dir$ forceinline

  ar(i) = call_insimd(gf(i),df(i)) 

enddo
ATK
  • 1,296
  • 10
  • 26
  • Unless you care about the possibility of multiple compilers which don't recognize both, there seems little reason to include both. Inline has potential advantages and disadvantages which you might ignore if you care only about simd. – tim18 May 09 '19 at 11:07
  • when shall I use which. It seems that for simd loops there are two options with regards to function call, one is inlining and the other is declare simd - and I suppose sometimes it is better to use one over the other? – ATK May 09 '19 at 11:10
  • I generally do a !DIR ALIGN, and the compiler and compiler optimisation -02 usually shows with the vector report that the function is SIMD vectorised. Forcing it to be vectorised is also an option, but both ways get to the same result. – Holmz May 10 '19 at 22:53

0 Answers0