- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[fortran]MODULE MOD implicit none integer,parameter:: N=1000 type:: myt real(8):: fixed_mat1(N,N) real(8):: fixed_mat2(N,N) real(8),allocatable:: alloc_mat1(:,:) real(8),allocatable:: alloc_mat2(:,:) endtype myt real(8):: fixed_mat1(N,N) real(8):: fixed_mat2(N,N) real(8),allocatable:: alloc_mat1(:,:) real(8),allocatable:: alloc_mat2(:,:) real(8):: resu_mat(N,N) ENDMODULE MOD !!##########main############################ PROGRAM MAIN USE MOD implicit none type(myt):: mytype real(4):: t1,t2 !!#####matrix elements initialize###################### call random_number(fixed_mat1) call random_number(fixed_mat2) mytype.fixed_mat1 = fixed_mat1 mytype.fixed_mat2 = fixed_mat2 allocate(alloc_mat1,source=fixed_mat1) allocate(alloc_mat2,source=fixed_mat2) allocate(mytype.alloc_mat1,source=fixed_mat1) allocate(mytype.alloc_mat2,source=fixed_mat2) !!#####measure the timeand compare them#################### call cpu_time(t1) resu_mat = matmul(fixed_mat1,fixed_mat2) call cpu_time(t2) write(*,'(A,F8.4,A)') 'matmul(fixed,fixed) costs',t2-t1,' sec' !-------------------------------------------------------------------- call cpu_time(t1) resu_mat = matmul(alloc_mat1,alloc_mat2) call cpu_time(t2) write(*,'(A,F8.4,A)') 'matmul(alloc,alloc) costs',t2-t1,' sec' !-------------------------------------------------------------------- call cpu_time(t1) resu_mat = matmul(mytype.fixed_mat1,mytype.fixed_mat2) call cpu_time(t2) write(*,'(A,F8.4,A)') 'matmul(mytype.fixed,mytype.fixed) costs',t2-t1,' sec' !---------------------------------------------------------------------- call cpu_time(t1) resu_mat = matmul(mytype.alloc_mat1,mytype.alloc_mat2) call cpu_time(t2) write(*,'(A,F8.4,A)') 'matmul(mytype.alloc,mytype.alloc) costs',t2-t1,' sec' ENDPROGRAM[/fortran]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have a reason for using non-standard syntax? It runs faster for me when the VAX/VMS structure notation is changed to standard syntax, except that the last case speeds up only when running on an increased stack allocation (not with /heap-arrays).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In addition to TimP's suggestion of deallocation, reverse the order in which you allocate and test the various combinations. This should eliminate virtual memory paging issues (assuming your type can be fully resident in RAM as opposed to in the page file).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
gfortran -O3 -fexternal-blas -L/opt/xeon/composer_xe_2011_sp1.8.273/mkl/lib/intel64/ ar1.f90 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential
(using e.g. gfortran 4.7), but the gfortran 4.5 versions available for Windows are failing, besides not being compatible with MKL.
I thought there should be an equivalent ifort option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you said that the CALCULATION TIME is different (for each case).
i was just wondering, is the "ANSWER" (stored in the matrix RESU_MAT) also different ?
the reason i ask this is :-
years ago, i was using "Visual Fortran" software ("Digital Visual Fortran", i think). it had the MATMUL intrinsic function. anyway, although i "think" all of my fortran code was correct, i would sometimes get incorrect results -- which seemed to be caused by the results calculated by MATMUL. but, at the time, i think the fortran software had a few bugs. anyway, ever since then, i tend to write my own matrix manipulation code (e.g. matrix multiplication) -- just to be safe.
of course, all of this happened long before Intel took over the reigns (of "Visual Fortran"). so, i'm sure the (Intel Visual Fortran) version of MATMUL that you are using works correctly :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page