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

Alignment of Allocatable Dummy Variable

Ben3
Beginner
622 Views

Hi,

I have a subroutine that allocates a workspace for MKL routines, and I want to specify the alignment of the allocated buffer. I'm using the ATTRIBUTES ALIGN directive. This works for e.g. allocatable automatic variables, but doesn't want to work for allocatable dummy arguments. For example, this fails:

subroutine create_workspace ( this, work )
  class(object),              intent(in)    :: this
  real(kind=DP), allocatable, intent(inout) :: work(:)
  !DIR$ ATTRIBUTES ALIGN:64 :: work
  allocate(work(10))
end subroutine create_workspace

The error is

error #6406: Conflicting attributes or multiple declaration of name.   [WORK]

Am I doing something totally wrong here? Is there better way to accomplish this? I'm looking for something that works on both Windows and Linux. The compiler version is 64-bit, 14.0.1.139.

Cheers,

Ben

0 Kudos
2 Replies
Steven_L_Intel1
Employee
622 Views

Interesting - this is something we didn't consider. I'm not sure how to resolve this because the data could be passed already allocated but not at the specified alignment.

I think the way we'd have to do it is with ASSUME_ALIGNED (this is its own directive, not part of ATTRIBUTES)  and then apply that alignment if the variable gets allocated within the procedure. I will suggest this to the developers.

0 Kudos
Ben3
Beginner
622 Views

Thanks Steve. What about allowing it if the dummy argument is declared INTENT(OUT)? This way, it's guaranteed that it will be unallocated - it will call deallocate if already allocated on entry. It's not a show-stopper, though; it's easy enough to workaround. I'll just use a type-bound function that returns the size of the allocation and do the allocation (and alignment) in the calling routine.

0 Kudos
Reply