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

vectorization of a type bound procedure

AThar2
Beginner
270 Views

I will attempt to ask without a working example. In case it requires let me know and I will try to work one out, however, you will realize that it is not straight forward

In my application I have realized that sometimes my !$OMP SIMD loop does not vectorize because of a procedure call to ...

call ptr% PROCEDURE_WITH_PASS(...) 

, this subroutine has a one of its dummy argument declared as "class" since it got the PASS attribute when declared.  i.e.

Subroutine PROCEDURE_WITH_PASS( this , ..., )
class(type_dec), intent(inout) :: this 

If I change the pass to NOPASS and declare the dummy argument as "type" (Because now the compiler allows me to do so) my SIMD LOOP does vectorize.  

Subroutine PROCEDURE_WITH_PASS( this , ..., ) 
type(type_dec), intent(inout) :: this 

 

what puzzles me is that I do have other examples where the the first example call does get vectorized. It is only when the procedure in my case get a bit more lenghty  OpenMP decides not to vectorize my loop when having the CLASS declaration.

 

PS: I do have the subroutines declared with an OMP declare simd.

 

I am not looking for an exact solution to my case, but what is your general experience on using OOP with vectorisation. Should I generally try to keep the lowest level of execution a normal routine. What I mean here is that when saying ` call ptr% proc`, then my proc routine has a call to another routine which is NOT type bounded and all dummy arguments would be explicit arrays?

 

For example

 

call ptr% proc 


subroutine proc (this, ...) 
class(t_da), intent(inout) :: this 


call explicit_routine(this% array1, this% array2) 

end subroutine proc 

subroutine explicit_routine

real, contiguous :: a1(:), a2(:)

end  subroutine

 

 

 

 

 

0 Kudos
2 Replies
Juergen_R_R
Valued Contributor I
270 Views

This might be a safeguard of the compiler/optimizer for the case of DT-TBP because they might be overwritten, and in the vectorized execution the compiler might not be able to determine at compile time that all routines will be of the same type. But this is just a guess. Did you compare with a different compiler?

0 Kudos
FortranFan
Honored Contributor II
270 Views

AT90 wrote:

.. what puzzles me is that I do have other examples where the the first example call does get vectorized. It is only when the procedure in my case get a bit more lenghty  OpenMP decides not to vectorize my loop when having the CLASS declaration. ..

Can you show a working example where the call is not vectorized?  And preferably a case where you think it is (but it actually may not be!).

Thanks,  

0 Kudos
Reply