Basic Parallel Programming with OpenMP: A guide to cutting your scientific calculations in smaller pieces. by Thomas la Cour Jansen
Author:Thomas la Cour Jansen [Jansen, Thomas la Cour]
Language: eng
Format: azw3
Tags: Computers & Technology
Publisher: TLC Publishing
Published: 2017-08-25T04:00:00+00:00
program multi
use omp_lib
C Initialize
integer, parameter :: ndim = 8000
real*8 :: ma,mb,mc,aa
common/junk/ ma(ndim,ndim), mb(ndim,ndim), mc(ndim,ndim)
integer, parameter :: fd = 11
integer :: i,j,k,l, myid,t1,t2,count_rate,count_max
integer :: chunk
open(fd,file='TimeInfo',form='formatted')
!$omp parallel
myid = OMP_GET_THREAD_NUM()
if (myid .eq. 0) then
write(fd,"('Number of CPUs is ',i4)") OMP_GET_NUM_THREADS()
endif
!$omp end parallel
chunk=10
C Initialize timing
call system_clock(count_max=count_max, count_rate=count_rate)
call system_clock(t1)
C Loops for constructing matrices
!$omp parallel do shared(ma,mb,mc,chunk) private(i,j)
do i=1,ndim
do j=1,ndim
ma(i,j)=0
mb(i,j)=0
mc(i,j)=0
if (i .ne. j) then
ma(i,j)=1.0/(i-j)
mb(i,j)=1.0/(i-j)**3
end if
enddo
enddo
!$omp end parallel do
C Loop for doing matrix multiplication
!$omp parallel do shared(ma,mb,mc,chunk) private(i,j,k)
do i=1,ndim
do k=1,ndim
aa=ma(i,k)
do j=1,ndim
mc(i,j)=mc(i,j)+aa*mb(k,j)
enddo
enddo
enddo
!$omp end parallel do
C Find wall time usage
call system_clock(t2)
dt = t2-t1
secs = real(dt)/real(count_rate)
write(fd,"('For n=',i6,', time is ',f12.2,' seconds')") ndim,
C secs
close(fd)
end
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12571)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8300)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7084)
Microservices with Go by Alexander Shuiskov(6854)
Practical Design Patterns for Java Developers by Miroslav Wengner(6773)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6713)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Angular Projects - Third Edition by Aristeidis Bampakos(6118)
The Art of Crafting User Stories by The Art of Crafting User Stories(5648)
NetSuite for Consultants - Second Edition by Peter Ries(5582)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5385)
Kotlin in Action by Dmitry Jemerov(5066)
