struct Point3D{ double x,y, z, w; }; struct Mesh { std::vector<Point3D> nodes; }; |
|
double func(const Mesh& mesh, int IP) { return mesh.nodes[IP].x; } |
func(Mesh const&, int): movslq %esi, %rsi # convert IP vom 32bit integer to 64bit integer salq $5, %rsi # rsi = 32*rsi calculate offset in array. sizeof(Point3D) == 32 addq (%rdi), %rsi # add vector base pointer movsd (%rsi), %xmm0 # copy value into return register ret |
double func2(const std::vector<Point3D>& nodes, int IP) { return nodes[IP].x; } |
func2(std::vector<Point3D, std::allocator<Point3D> > const&, int): movslq %esi, %rsi salq $5, %rsi addq (%rdi), %rsi movsd (%rsi), %xmm0 ret |
Fortran
module test_m type Point3D_t real(8) :: xyz(4) end type type Mesh_t type(Point3D_t), allocatable :: nodes(:) end type type Mesh2_t real(8), allocatable :: nodes(:,:) end type end module |
|
function func(mesh, IP) result(x) implicit none type(Mesh_t), intent(in) :: mesh integer, intent(in) :: IP real(8) :: x x = mesh%nodes(IP)%xyz(1) end function |
__test_m_MOD_func: movslq (%rsi), %rax addq 8(%rdi), %rax salq $5, %rax addq (%rdi), %rax movsd (%rax), %xmm0 ret |
function func2(nodes, IP) result(x) implicit none type(Point3D_t), intent(in) :: nodes(:) integer, intent(in) :: IP real(8) :: x x = nodes(IP)%xyz(1) end function |
__test_m_MOD_func2: movq 40(%rdi), %rcx movslq (%rsi), %rdx movl $1, %eax testq %rcx, %rcx cmove %rax, %rcx leaq -1(%rdx), %rax imulq %rcx, %rax salq $5, %rax addq (%rdi), %rax movsd (%rax), %xmm0 ret |
function func3(MNP, nodes, IP) result(x) implicit none integer, intent(in) :: MNP type(Point3D_t), intent(in) :: nodes(MNP) integer, intent(in) :: IP real(8) :: x x = nodes(IP)%xyz(1) end function |
__test_m_MOD_func3: movslq (%rdx), %rax salq $5, %rax movsd -32(%rax,%rsi), %xmm0 ret |
function func4(mesh, IP) result(x) implicit none type(Mesh2_t), intent(in) :: mesh integer, intent(in) :: IP real(8) :: x x = mesh%nodes(1,IP) end function |
__test_m_MOD_func4: movq (%rdi), %rdx movslq (%rsi), %rax imulq 64(%rdi), %rax addq 8(%rdi), %rax movsd 8(%rdx,%rax,8), %xmm0 ret |
function func5(nodes, IP) result(x) implicit none real(8), intent(in) :: nodes(:,:) integer, intent(in) :: IP real(8) :: x x = nodes(1,IP) end function |
__test_m_MOD_func5: movq 40(%rdi), %rax testq %rax, %rax je .L58 movq %rax, %rdx negq %rdx .L57: movq 64(%rdi), %r8 movslq (%rsi), %rcx movq (%rdi), %rdi imulq %r8, %rcx subq %r8, %rdx addq %rcx, %rax addq %rdx, %rax movsd (%rdi,%rax,8), %xmm0 ret .L58: movq $-1, %rdx movl $1, %eax jmp .L57 |
function func6(MNP, nodes, IP) result(x) implicit none integer, intent(in) :: MNP real(8), intent(in) :: nodes(3,MNP) integer, intent(in) :: IP real(8) :: x x = nodes(1,IP) end function |
__test_m_MOD_func6: movslq (%rdx), %rax leaq -3(%rax,%rax,2), %rax movsd (%rsi,%rax,8), %xmm0 ret |
26.03.2021
C++ Fortran - Array & Types
Comments Off on C++ Fortran - Array & Types
No Comments
No comments yet.
RSS feed for comments on this post.
Sorry, the comment form is closed at this time.