summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Moore <connor@hhmoore.ca>2026-01-23 11:05:33 -0500
committerConnor Moore <connor@hhmoore.ca>2026-01-23 11:05:33 -0500
commit98c8a23b00f88de5ef5d5bdb90e170066d5fd0bc (patch)
tree998150470785a871488865ff5b00ea61131206ea
parentc00598136dc7c3d667c83dbb908980af6811cc12 (diff)
Added second loop variation and preliminary results
-rw-r--r--long_runs.cvs22
-rw-r--r--matrixproduct.f9028
-rw-r--r--short_runs.csv36
3 files changed, 83 insertions, 3 deletions
diff --git a/long_runs.cvs b/long_runs.cvs
new file mode 100644
index 0000000..ff060c7
--- /dev/null
+++ b/long_runs.cvs
@@ -0,0 +1,22 @@
+N,matmul,blas_dgemm
+1000,0.10193400E+00,0.58010400E+00
+2000,0.64242800E+00,0.46658950E+01
+3000,0.21485870E+01,0.16550798E+02
+4000,0.50890610E+01,0.38807770E+02
+5000,0.98788060E+01,0.75952624E+02
+6000,0.16943837E+02,0.12970843E+03
+7000,0.27091881E+02,0.20561875E+03
+8000,0.40548225E+02,0.31527694E+03
+9000,0.57014092E+02,0.44617752E+03
+10000,0.78390511E+02,0.61657925E+03
+11000,0.10588242E+03,0.82130777E+03
+12000,0.13627938E+03,0.10666839E+04
+13000,0.17270659E+03,0.13624819E+04
+14000,0.21550922E+03,0.16965049E+04
+15000,0.26559991E+03,0.21014043E+04
+16000,0.32860096E+03,0.25695269E+04
+17000,0.38339895E+03,0.30997033E+04
+18000,0.45901556E+03,0.37488178E+04
+19000,0.53562014E+03,0.45838361E+04
+20000,0.63253852E+03,0.54320727E+04
+
diff --git a/matrixproduct.f90 b/matrixproduct.f90
index feb4cf1..fd15622 100644
--- a/matrixproduct.f90
+++ b/matrixproduct.f90
@@ -11,10 +11,10 @@ program matrixproduct
external :: dgemm !> double-precision general matrix-matrix multiplication
real(real64), allocatable, dimension(:,:) :: A, B, C
- real(real64) :: start, end, loop_time, matmul_time, blas_time
+ real(real64) :: start, end, loop_time, loop_alt_time, matmul_time, blas_time
integer(int32) :: n
- do n = 1000,100000,1000
+ do n = 1000,35000,1000
call prep_mats(A,B,C,n)
call cpu_time(start)
@@ -24,6 +24,12 @@ program matrixproduct
C = 0
call cpu_time(start)
+ !call triple_loop_mul_alt(A,B,C,n)
+ call cpu_time(end)
+ loop_alt_time = end-start
+ C = 0
+
+ call cpu_time(start)
C = matmul(A,B)
call cpu_time(end)
matmul_time = end-start
@@ -34,7 +40,8 @@ program matrixproduct
call cpu_time(end)
blas_time = end-start
- write(*,'((i5),3(e16.8))') n, loop_time, matmul_time, blas_time
+ !write(*,'((i5),4(e16.8))') n, loop_time, loop_alt_time, matmul_time, blas_time
+ write(*,'((i5),2(e16.8))') n, matmul_time, blas_time
enddo
contains
@@ -69,5 +76,20 @@ contains
end subroutine triple_loop_mul
+ subroutine triple_loop_mul_alt(A,B,C,n)
+ real(real64), dimension(:,:), intent(in) :: A,B
+ real(real64), dimension(:,:), intent(out) :: C
+ integer(int32), intent(in) :: n
+ integer(int32) :: i, j, k
+
+ col: do j = 1,n
+ row: do i = 1,n
+ sum: do k = 1,n
+ C(i,j) = C(i,j) + A(i,k)*B(k,j)
+ end do sum
+ end do row
+ end do col
+
+ end subroutine triple_loop_mul_alt
end program matrixproduct
diff --git a/short_runs.csv b/short_runs.csv
new file mode 100644
index 0000000..d20051a
--- /dev/null
+++ b/short_runs.csv
@@ -0,0 +1,36 @@
+N,loop_row_col,loop_col_row,matmul,blas_dgemm
+100,0.59300000E-03,0.56300000E-03,0.31900000E-03,0.90600000E-03
+200,0.48990000E-02,0.50670000E-02,0.12850000E-02,0.52280000E-02
+300,0.11546000E-01,0.12258000E-01,0.32410000E-02,0.13718000E-01
+400,0.46028000E-01,0.45641000E-01,0.67240000E-02,0.32451000E-01
+500,0.82411000E-01,0.87122000E-01,0.12307000E-01,0.62779000E-01
+600,0.15985300E+00,0.15981000E+00,0.21728000E-01,0.10790800E+00
+700,0.24306400E+00,0.25618400E+00,0.34095000E-01,0.17180100E+00
+800,0.51714500E+00,0.47772100E+00,0.50202000E-01,0.25702700E+00
+900,0.62514100E+00,0.75229600E+00,0.74008000E-01,0.37891900E+00
+1000,0.11347540E+01,0.14588680E+01,0.95838000E-01,0.53417100E+00
+1100,0.59069930E+01,0.59634460E+01,0.12902900E+00,0.72982500E+00
+1200,0.10091301E+02,0.10410358E+02,0.16694000E+00,0.10028480E+01
+1300,0.15387643E+02,0.14998313E+02,0.21131600E+00,0.12604330E+01
+1400,0.18312705E+02,0.18748105E+02,0.26171400E+00,0.15952700E+01
+1500,0.22782961E+02,0.23063631E+02,0.31871300E+00,0.19756550E+01
+1600,0.26743603E+02,0.27118118E+02,0.39060700E+00,0.23881740E+01
+1700,0.33753746E+02,0.33749378E+02,0.46649600E+00,0.28914880E+01
+1800,0.40048285E+02,0.40339913E+02,0.55305000E+00,0.33923480E+01
+1900,0.47055393E+02,0.47242679E+02,0.64035200E+00,0.39590110E+01
+2000,0.59399582E+02,0.59914291E+02,0.74202900E+00,0.46979740E+01
+2100,0.64968825E+02,0.65738129E+02,0.87708900E+00,0.54780350E+01
+2200,0.78502911E+02,0.79407814E+02,0.99478900E+00,0.63250410E+01
+2300,0.91680394E+02,0.94567158E+02,0.11410510E+01,0.72776670E+01
+2400,0.10457867E+03,0.10439878E+03,0.12784300E+01,0.83679490E+01
+2500,0.12307907E+03,0.12405015E+03,0.14541440E+01,0.94498140E+01
+2600,0.13987954E+03,0.14206693E+03,0.16377200E+01,0.10724434E+02
+2700,0.16004822E+03,0.16073829E+03,0.18362130E+01,0.11987520E+02
+2800,0.17975253E+03,0.18076746E+03,0.20205060E+01,0.13357210E+02
+2900,0.20810941E+03,0.21055106E+03,0.22729940E+01,0.14782116E+02
+3000,0.23689813E+03,0.24143141E+03,0.25030500E+01,0.16392925E+02
+3100,0.26648284E+03,0.26482139E+03,0.27888030E+01,0.18112838E+02
+3200,0.25087040E+03,0.25230091E+03,0.30511340E+01,0.20086456E+02
+3300,0.32902761E+03,0.34492439E+03,0.34200240E+01,0.23516174E+02
+3400,0.38203689E+03,0.37951516E+03,0.36512380E+01,0.25044592E+02
+3500,0.41389121E+03,0.41692274E+03,0.40134930E+01,0.27029907E+02