-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatmul.f90
55 lines (51 loc) · 2.19 KB
/
matmul.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
!!!!
!! File: matmul_serial.f90
!! Description: Matrix multiplication code
!! Author: Bruno R. de Abreu | babreu at illinois dot edu
!! National Center for Supercomputing Applications (NCSA)
!!
!! Creation Date: Tuesday, 17th August 2021, 9:29:08 am
!! Last Modified: Tuesday, 17th August 2021, 9:29:21 am
!!
!! Copyright (c) 2021, Bruno R. de Abreu, National Center for Supercomputing Applications.
!! All rights reserved.
!! License: This program and the accompanying materials are made available to any individual
!! under the citation condition that follows: On the event that the software is
!! used to generate data that is used implicitly or explicitly for research
!! purposes, proper acknowledgment must be provided in the citations section of
!! publications. This includes both the author's name and the National Center
!! for Supercomputing Applications. If you are uncertain about how to do
!! so, please check this page: https://github.com/babreu-ncsa/cite-me.
!! This software cannot be used for commercial purposes in any way whatsoever.
!! Omitting this license when redistributing the code is strongly disencouraged.
!! The software is provided without warranty of any kind. In no event shall the
!! author or copyright holders be liable for any kind of claim in connection to
!! the software and its usage.
!!!!
program matmul
use, intrinsic :: iso_fortran_env
implicit none
integer, parameter :: dp = REAL64 ! double precision
integer, parameter :: i32 = INT32 ! 32-bit int
integer(i32), parameter :: ord=1000_i32
real(dp) :: startT, endT
real(dp), parameter :: zero=0.0_dp
real(dp), dimension(ord,ord) :: m, n, p
integer(i32) :: i, j, k
!! filling up matrices
p = zero
call random_seed()
call random_number(m)
call random_number(n)
!! trivial matrix multiplication
call cpu_time(startT)
do k = 1, ord
do j = 1, ord
do i = 1, ord
p(i,j) = m(i,k) * n(k,j)
enddo
enddo
enddo
call cpu_time(endT)
write(*,*) 'Matrix multiplication took: ', (endT-startT), ' s'
end program matmul