May 9 2025 9:47:05.719 PM timer_etime(): FORTRAN90 version. Demonstrate the use of the ETIME timer. ETIME is a routine built into most UNIX compilers, in particular, the Gnu GFORTRAN compiler, used as follows: real etime real tarray(2) cpu = etime ( tarray ) returning elapsed CPU time in seconds. ETIME reports: The current CPU time is 0.752000E-03 TARRAY(1) = 0.752000E-03 TARRAY(2) = 0.00000 TEST01 Time the FORTRAN90 RANDOM_NUMBER routine: call random_number ( x(1:n) ) Data vectors will be of minimum size 1 Data vectors will be of maximum size 1048576 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 Min Ave Max 1 0.000007 0.000000 0.000001 0.000000 0.000000 0.000000 0.000002 0.000007 2 0.000001 0.000000 0.000000 0.000001 0.000000 0.000000 0.000000 0.000001 4 0.000000 0.000000 0.000000 0.000001 0.000000 0.000000 0.000000 0.000001 8 0.000000 0.000001 0.000000 0.000000 0.000001 0.000000 0.000000 0.000001 16 0.000000 0.000000 0.000000 0.000000 0.000001 0.000000 0.000000 0.000001 32 0.000000 0.000000 0.000001 0.000000 0.000000 0.000000 0.000000 0.000001 64 0.000001 0.000000 0.000000 0.000001 0.000001 0.000000 0.000001 0.000001 128 0.000001 0.000001 0.000001 0.000000 0.000000 0.000000 0.000001 0.000001 256 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 512 0.000001 0.000001 0.000001 0.000001 0.000002 0.000001 0.000001 0.000002 1024 0.000004 0.000002 0.000002 0.000002 0.000002 0.000002 0.000002 0.000004 2048 0.000004 0.000003 0.000003 0.000003 0.000003 0.000003 0.000003 0.000004 4096 0.000009 0.000007 0.000007 0.000007 0.000007 0.000007 0.000007 0.000009 8192 0.000018 0.000014 0.000014 0.000014 0.000014 0.000014 0.000015 0.000018 16384 0.000037 0.000028 0.000028 0.000028 0.000027 0.000027 0.000030 0.000037 32768 0.000071 0.000055 0.000055 0.000055 0.000056 0.000055 0.000058 0.000071 65536 0.000141 0.000110 0.000168 0.000110 0.000110 0.000110 0.000128 0.000168 131072 0.000282 0.000220 0.000278 0.000219 0.000220 0.000219 0.000244 0.000282 262144 0.000620 0.000439 0.000482 0.000439 0.000439 0.000439 0.000484 0.000620 524288 0.001250 0.000937 0.000919 0.000878 0.000933 0.000878 0.000983 0.001250 1048576 0.002423 0.001874 0.001854 0.001795 0.001855 0.001795 0.001960 0.002423 TEST02 Time vectorized operations: y(1:n) = x(1:n) y(1:n) = PI * x(1:n) y(1:n) = sqrt ( x(1:n) ) y(1:n) = exp ( x(1:n) ) Data vectors will be of minimum size 4096 Data vectors will be of maximum size 4194304 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000010 0.000004 0.000004 0.000003 0.000003 8192 0.000011 0.000008 0.000006 0.000007 0.000007 16384 0.000021 0.000014 0.000013 0.000013 0.000013 32768 0.000073 0.000027 0.000054 0.000026 0.000028 65536 0.000086 0.000052 0.000052 0.000052 0.000052 131072 0.000171 0.000106 0.000105 0.000105 0.000104 262144 0.000343 0.000214 0.000240 0.000212 0.000210 524288 0.000736 0.000480 0.000430 0.000429 0.000427 1048576 0.001523 0.000919 0.000944 0.000894 0.000921 2097152 0.003197 0.001987 0.001830 0.001823 0.001927 4194304 0.006590 0.003842 0.003729 0.003731 0.003828 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000006 0.000006 0.000006 0.000006 0.000006 8192 0.000011 0.000011 0.000011 0.000010 0.000011 16384 0.000022 0.000022 0.000022 0.000022 0.000021 32768 0.000042 0.000043 0.000043 0.000042 0.000043 65536 0.000084 0.000084 0.000084 0.000086 0.000085 131072 0.000170 0.000169 0.000171 0.000169 0.000170 262144 0.000372 0.000341 0.000339 0.000341 0.000339 524288 0.000682 0.000683 0.000684 0.000682 0.000683 1048576 0.001390 0.001389 0.001388 0.001386 0.001393 2097152 0.003121 0.002916 0.002814 0.002814 0.002885 4194304 0.005676 0.005708 0.005703 0.005794 0.005709 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000004 0.000004 0.000004 0.000004 0.000004 8192 0.000007 0.000007 0.000007 0.000006 0.000007 16384 0.000013 0.000013 0.000013 0.000014 0.000013 32768 0.000027 0.000027 0.000027 0.000027 0.000027 65536 0.000054 0.000053 0.000053 0.000053 0.000053 131072 0.000106 0.000106 0.000107 0.000108 0.000106 262144 0.000217 0.000210 0.000213 0.000213 0.000213 524288 0.000431 0.000432 0.000433 0.000431 0.000505 1048576 0.000894 0.000935 0.000904 0.000898 0.000953 2097152 0.001847 0.001849 0.001846 0.001846 0.001841 4194304 0.003733 0.003726 0.003724 0.003721 0.003796 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000027 0.000015 0.000015 0.000015 0.000015 8192 0.000029 0.000030 0.000030 0.000029 0.000029 16384 0.000058 0.000060 0.000059 0.000059 0.000058 32768 0.000116 0.000116 0.000118 0.000117 0.000116 65536 0.000234 0.000232 0.000232 0.000232 0.000271 131072 0.000464 0.000467 0.000467 0.000465 0.000502 262144 0.000930 0.000931 0.001006 0.000946 0.000965 524288 0.001863 0.001937 0.001871 0.001865 0.001994 1048576 0.003784 0.003901 0.003765 0.003764 0.004055 2097152 0.007628 0.007598 0.007584 0.007623 0.007598 4194304 0.015262 0.015343 0.015236 0.015228 0.015971 TEST03 Time the unvectorized loops: do i = 1, n y(i) = x(i) y(i) = PI * x(i) y(i) = sqrt ( x(i) ) y(i) = exp ( x(i) ) end do Data vectors will be of minimum size 4096 Data vectors will be of maximum size 4194304 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000017 0.000008 0.000009 0.000009 0.000008 8192 0.000021 0.000018 0.000016 0.000016 0.000016 16384 0.000041 0.000033 0.000033 0.000033 0.000033 32768 0.000082 0.000068 0.000065 0.000066 0.000066 65536 0.000165 0.000135 0.000132 0.000131 0.000132 131072 0.000327 0.000267 0.000262 0.000264 0.000263 262144 0.000656 0.000537 0.000561 0.000526 0.000525 524288 0.001532 0.001102 0.001091 0.001056 0.001056 1048576 0.002672 0.002157 0.002197 0.002135 0.002138 2097152 0.005471 0.004417 0.004404 0.004342 0.004347 4194304 0.011088 0.008698 0.008733 0.008657 0.008796 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000009 0.000009 0.000008 0.000009 0.000009 8192 0.000017 0.000017 0.000017 0.000017 0.000017 16384 0.000035 0.000034 0.000034 0.000034 0.000034 32768 0.000068 0.000067 0.000067 0.000068 0.000068 65536 0.000135 0.000135 0.000134 0.000135 0.000135 131072 0.000321 0.000268 0.000269 0.000272 0.000269 262144 0.000560 0.000539 0.000540 0.000540 0.000541 524288 0.001119 0.001079 0.001083 0.001084 0.001085 1048576 0.002198 0.002184 0.002192 0.002302 0.002193 2097152 0.004469 0.004497 0.004483 0.004607 0.004458 4194304 0.008961 0.008961 0.008890 0.008995 0.009139 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000008 0.000009 0.000008 0.000009 0.000008 8192 0.000016 0.000016 0.000016 0.000016 0.000016 16384 0.000045 0.000032 0.000031 0.000031 0.000032 32768 0.000063 0.000064 0.000063 0.000063 0.000063 65536 0.000127 0.000126 0.000126 0.000128 0.000126 131072 0.000253 0.000253 0.000253 0.000252 0.000252 262144 0.000506 0.000506 0.000506 0.000507 0.000507 524288 0.001017 0.001015 0.001017 0.001015 0.001032 1048576 0.002058 0.002056 0.002059 0.002057 0.002059 2097152 0.004239 0.004228 0.004152 0.004229 0.004190 4194304 0.008409 0.008464 0.008361 0.008362 0.008617 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000023 0.000022 0.000022 0.000021 0.000022 8192 0.000044 0.000043 0.000045 0.000043 0.000043 16384 0.000086 0.000087 0.000086 0.000088 0.000086 32768 0.000178 0.000175 0.000172 0.000172 0.000171 65536 0.000342 0.000341 0.000343 0.000341 0.000343 131072 0.000686 0.000690 0.000682 0.000770 0.000683 262144 0.001385 0.001383 0.001368 0.001354 0.001382 524288 0.002770 0.002750 0.002759 0.002718 0.002759 1048576 0.005597 0.005553 0.005558 0.005546 0.005580 2097152 0.011070 0.011236 0.011197 0.011601 0.011203 4194304 0.022669 0.022633 0.022593 0.022556 0.022828 TEST04 Time the 2D nearest neighbor problem. Given X(2,N) and Y(2), find X(2,*) closest to Y(2). do i = 1, n if distance ( x(2,i), y ) < minimum so far x_min = x(2,i) end do Data vectors will be of minimum size 1024 Data vectors will be of maximum size 1048576 Number of repetitions of the operation: 5 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 1024 0.000006 0.000004 0.000004 0.000003 0.000004 2048 0.000007 0.000007 0.000007 0.000009 0.000007 4096 0.000013 0.000014 0.000014 0.000014 0.000014 8192 0.000030 0.000027 0.000027 0.000028 0.000027 16384 0.000055 0.000054 0.000054 0.000054 0.000056 32768 0.000110 0.000109 0.000107 0.000107 0.000107 65536 0.000218 0.000217 0.000216 0.000213 0.000214 131072 0.000435 0.000433 0.000431 0.000428 0.000426 262144 0.000873 0.000866 0.000865 0.000861 0.000858 524288 0.001744 0.001736 0.001736 0.001731 0.001729 1048576 0.003566 0.003528 0.003488 0.003482 0.003479 TEST05 Time the matrix multiplication problem. Compute C = A * B where A is an L by M matrix, B is an M by N matrix, and so C is an L by N matrix. Minimum value of L = M = N = 4 Maximum value of L = M = N = 1024 Number of repetitions of the operation: 5 Use nested DO loops for matrix multiplication. Timing results using nested DO loops: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4 0.000001 0.000001 0.000001 0.000001 0.000001 16 0.000016 0.000016 0.000016 0.000016 0.000016 64 0.000972 0.001000 0.001018 0.001000 0.000999 256 0.082942 0.083528 0.080966 0.081119 0.079800 Use the MATMUL routine for matrix multiplication. Timing results using MATMUL: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4 0.000011 0.000004 0.000003 0.000002 0.000002 16 0.000002 0.000003 0.000003 0.000003 0.000003 64 0.000027 0.000028 0.000030 0.000030 0.000028 256 0.001027 0.001019 0.001022 0.001017 0.001017 1024 0.054656 0.054717 0.054073 0.053996 0.054657 TIMER_ETIME Normal end of execution. May 9 2025 9:47:07.866 PM