aboutsummaryrefslogtreecommitdiff
path: root/src/main.F90
blob: 2649e1055834417b422cc84bad132b30b2abcd7d (plain)
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
PROGRAM mul
  USE naivmat
  USE bettmat
  USE dotmat
  IMPLICIT none

  real(kind=4), dimension(:,:), allocatable :: mat1, mat2, res
  real :: start, end
  integer :: dim = 10

  DO WHILE (dim < 2000)
     
     call init_random_seed(123456)

     allocate(mat1(dim,dim))
     allocate(mat2(dim,dim))
     allocate(res(dim,dim))

     call random_number(mat1)
     call random_number(mat2)

     call cpu_time(start)

     res = naivmull(mat1, mat2)

     call cpu_time(end)

     print '(I11," ",ES11.5)', dim, end - start

     dim = dim * 2

     deallocate(mat1)
     deallocate(mat2)
     deallocate(res)
     
  END DO

CONTAINS

  SUBROUTINE init_random_seed(seed)
    integer, intent(in) :: seed
    integer :: i, n
    
    call random_seed(size = n)
    
    call random_seed(put = (/ ((seed + i) * 37, i = 1, n) /))
    
  END SUBROUTINE init_random_seed

END PROGRAM mul