I'm trying to align in memory the following type of data:
type foo
real, allocatable, dimension(:) :: bar1, bar2
!dir$ attributes align:64 :: bar1
!dir$ attributes align:64 :: bar2
end type foo
type(foo), allocatable, dimension(:) :: my_foo
allocate(my_foo(1))
allocate(my_foo(1)%bar1(100))
allocate(my_foo(1)%bar2(100))
! somewhere here I need to tell the compiler that data is aligned
! for a simple array with name `bar` I would just do:
!dir$ assume_aligned bar1: 64
!dir$ assume_aligned bar2: 64
! but what do I do for the data type I have, something like this?
!dir$ assume_aligned my_foo(1)%bar1: 64
!dir$ assume_aligned my_foo(1)%bar2: 64
do i = 1, 100
my_foo(1)%bar1(i) = 10.
my_foo(1)%bar2(i) = 10.
end do
As you can see, it's an array of foo type structures, that has two large arrays bar1 and bar2 as variables that I need to be aligned near cache boundaries in the memory.
I kind of know how to do that for simple arrays (link), but I have no idea how to do that for this sort of complex data structure. And what if my_foo wasn't of size 1, but was of size, say, 100? Do I loop through them?