Writing a performance analyzer need really simple help with subroutines

In summary: You might need to declare them in each subroutine or use an implicit statement to have them all declared as a certain type.You also have a few typos, such as "dlange" instead of "dlange". And in your call to dgemm, you're using 'No' instead of "N". These could be causing the "unexpected implicit none" and "expecting end program statement" errors.Lastly, for using abs to compare matrices, you need to use the intrinsic function abs() instead of just abs. This could be causing the syntax error.
  • #1
Machinus
3
0
I am getting a ton of errors trying to compile this. I am including PAPI and ATLAS calls but so far I think those calls are working ok.

For each subroutine, I am getting "unclassifiable statement" for the subroutine definition as well as "unexpected implicit none" and "expecting end program statement" at the end.

It also won't let me use abs to compare the matrices. I am sure my syntax is wrong but I am new to fortran and I am not sure how I am supposed to write it.

Code:
#include /mnt/scratch/sw/papi-3.6.2/include/fpapi.h

program main
implicit none

integer:: i,j,k,M,N
integer:: tinitial,tfinal
real(8):: epsilon
real(8):: r1,r2,r3,r4,r5,r6
real(8):: t1,t2,t3,t4,t5,t6
real(8), allocatable:: A(:,:),B(:,:),C(:,:),D(:,:)

epsilon = 2.22e-16

open(unit=1,file="optimization.dat")
do M=1,100

   N = 10*M

   allocate(A(N,N),B(N,N),C(N,N),D(N,N))

   call random_number(A)
   call random_number(B)
   call random_number(C)
   
   call m1(N,A,B,C,D)
   call m2(N,A,B,C,D)
   call m3(N,A,B,C,D)
   call m4(N,A,B,C,D)
   call m5(N,A,B,C,D)
   call m6(N,A,B,C,D)

   write(*,*) N,r1,r2,r3,r4,r5,r6
   write(1,*) N,t1,t2,t3,t4,t5,t6

end do

subroutine m1 (N,A,B,C,D)
implicit none
tinitial = rtime
do i=1,N
   do j=1,N
      do k=1,N
         C(i,j)=C(i,j)+A(i,k)*B(k,j)
      end do
   end do
end do
D(i,j)=C(i,j)
tfinal = rtime
t1 = tfinal-tinitial
call dgemm('No','No',N,N,N,1.0d0,A(N,N),i,B(N,N),k,1.0d0,C(N,N),i)
r1 = dlange(F,N,N,(C-D(i,j)))/(C*epsilon)
deallocate(A,B,C,D)
return
end subroutine m1

subroutine m2 (N,A,B,C,D)
implicit none
tinitial = rtime
do i=1,N
   do k=1,N
      do j=1,N
         C(i,j)=C(i,j)+A(i,k)*B(k,j)
      end do
   end do
end do
D(i,j)=C(i,j)
tfinal = rtime
t2 = tfinal-tinitial
call dgemm('No','No',N,N,N,1.0d0,A(N,N),i,B(N,N),k,1.0d0,C(N,N),i)
r2 = dlange(F,N,N,(C-D(i,j)))/(C*epsilon)
deallocate(A,B,C,D)
return
end subroutine m2

subroutine m3 (N,A,B,C,D)
implicit none
tinitial = rtime
do j=1,N
   do i=1,N
      do k=1,N
         C(i,j)=C(i,j)+A(i,k)*B(k,j)
      end do
   end do
end do
D(i,j)=C(i,j)
tfinal = rtime
t3 = tfinal-tinitial
call dgemm('No','No',N,N,N,1.0d0,A(N,N),i,B(N,N),k,1.0d0,C(N,N),i)
r3 = dlange(F,N,N,(C-D(i,j)))/(C*epsilon)
deallocate(A,B,C,D)
return
end subroutine m3

subroutine m4 (N,A,B,C,D)
implicit none
tinitial = rtime
do j=1,N
   do k=1,N
      do i=1,N
         C(i,j)=C(i,j)+A(i,k)*B(k,j)
      end do
   end do
end do
D(i,j)=C(i,j)
tfinal = rtime
t4 = tfinal-tinitial
call dgemm('No','No',N,N,N,1.0d0,A(N,N),i,B(N,N),k,1.0d0,C(N,N),i)
r4 = dlange(F,N,N,(C-D(i,j)))/(C*epsilon)
deallocate(A,B,C,D)
return
end subroutine m4

subroutine m5 (N,A,B,C,D)
implicit none
tinitial = rtime
do k=1,N
   do i=1,N
      do j=1,N
         C(i,j)=C(i,j)+A(i,k)*B(k,j)
      end do
   end do
end do
D(i,j)=C(i,j)
tfinal = rtime
t5 = tfinal-tinitial
call dgemm('No','No',N,N,N,1.0d0,A(N,N),i,B(N,N),k,1.0d0,C(N,N),i)
r5 = dlange(F,N,N,(C-D(i,j)))/(C*epsilon)
deallocate(A,B,C,D)
return
end subroutine m5

subroutine m6 (N,A,B,C,D)
implicit none
tinitial = rtime
do k=1,N
   do j=1,N
      do i=1,N
         C(i,j)=C(i,j)+A(i,k)*B(k,j)
      end do
   end do
end do
D(i,j)=C(i,j)
tfinal = rtime
t6 = tfinal-tinitial
call dgemm('No','No',N,N,N,1.0d0,A(N,N),i,B(N,N),k,1.0d0,C(N,N),i)
r6 = dlange(F,N,N,(C-D(i,j)))/(C*epsilon)
deallocate(A,B,C,D)
return
end subroutine m1

close(1)

end program

What are the obvious syntax problems and errors I am making?
 
Last edited:
Technology news on Phys.org
  • #2
You have your end program in the wrong place. It and the close(1) statement should be at the end of your main program, right after the first end do. This might be what is causing the "unclassifiable statement" error.

For your implicit none statements in your subroutines, the problem might be that you're saying each subroutine has no implicitly typed parameters and variables, yet you're not declaring any of them in the subs.
 
  • Like
Likes Machinus

Related to Writing a performance analyzer need really simple help with subroutines

1. What is a performance analyzer?

A performance analyzer is a tool used to measure and evaluate the performance of a system or a specific component, such as a subroutine. It helps identify areas for improvement and optimization in order to enhance overall performance.

2. Why do I need a performance analyzer for subroutines?

Subroutines are commonly used in programming to perform specific tasks and functions. However, they can greatly impact the overall performance of a system. By using a performance analyzer, you can identify which subroutines are causing delays or consuming too many resources, allowing you to optimize them for better performance.

3. How can I write a performance analyzer for subroutines?

Writing a performance analyzer for subroutines involves creating a tool or program that can measure and track the execution time and resource usage of each subroutine. This can be done by using performance monitoring tools or by implementing custom code to measure and analyze the subroutine performance.

4. What are the benefits of using a performance analyzer for subroutines?

Using a performance analyzer for subroutines can help improve the overall performance of a system by identifying and optimizing inefficient subroutines. It can also help debug and troubleshoot any issues related to subroutine performance, leading to a more stable and efficient system.

5. Are there any tips for writing an effective performance analyzer for subroutines?

Some tips for writing an effective performance analyzer for subroutines include setting clear goals and metrics for measuring performance, using reliable and accurate performance monitoring tools, and regularly analyzing and optimizing the code to improve performance. It is also important to consider the specific requirements and constraints of your system when designing the performance analyzer.

Similar threads

  • Programming and Computer Science
Replies
1
Views
955
Replies
9
Views
1K
  • Programming and Computer Science
Replies
4
Views
667
  • Programming and Computer Science
Replies
12
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
20
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
22
Views
4K
Back
Top