March 6 2008 12:13:36.765 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.323700E-02 TARRAY(1) = 0.886000E-03 TARRAY(2) = 0.235100E-02 TEST01 Time the FORTRAN90 RANDOM_NUMBER routine: call random_number ( x(1:n) ) 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.000129 0.000083 0.000083 0.000082 0.000083 2048 0.000212 0.000161 0.000161 0.000160 0.000162 4096 0.000343 0.000319 0.000325 0.000319 0.000318 8192 0.000685 0.000633 0.000633 0.000634 0.000633 16384 0.001367 0.001270 0.001264 0.001264 0.001265 32768 0.002777 0.002526 0.002527 0.002525 0.002528 65536 0.005525 0.005057 0.005040 0.005058 0.005066 131072 0.011124 0.010076 0.010089 0.010074 0.010122 262144 0.022203 0.020151 0.020190 0.020203 0.020218 524288 0.044296 0.040343 0.040349 0.040348 0.040314 1048576 0.088912 0.080660 0.080656 0.080711 0.080738 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.000106 0.000042 0.000041 0.000041 0.000042 8192 0.000140 0.000076 0.000077 0.000077 0.000077 16384 0.000278 0.000148 0.000153 0.000152 0.000148 32768 0.000561 0.000313 0.000330 0.000310 0.000304 65536 0.001189 0.000668 0.000664 0.000665 0.000670 131072 0.002359 0.001308 0.001305 0.001315 0.001326 262144 0.004745 0.002591 0.002667 0.002616 0.002572 524288 0.009595 0.005428 0.005382 0.005323 0.005410 1048576 0.019195 0.010721 0.010830 0.010807 0.010804 2097152 0.037326 0.021608 0.021576 0.021634 0.021652 4194304 0.074297 0.043216 0.043223 0.043220 0.043206 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000082 0.000079 0.000082 0.000082 0.000072 8192 0.000157 0.000158 0.000155 0.000159 0.000157 16384 0.000251 0.000305 0.000306 0.000309 0.000310 32768 0.000626 0.000623 0.000622 0.000619 0.000626 65536 0.001269 0.001157 0.001276 0.001217 0.001276 131072 0.002541 0.002543 0.002534 0.002534 0.002532 262144 0.005063 0.004629 0.003971 0.005041 0.005071 524288 0.010411 0.008390 0.009985 0.010350 0.010303 1048576 0.020222 0.020542 0.020650 0.020388 0.020705 2097152 0.040496 0.030925 0.034729 0.034429 0.041452 4194304 0.075018 0.082045 0.082852 0.075624 0.082171 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000116 0.000098 0.000101 0.000100 0.000101 8192 0.000192 0.000192 0.000192 0.000191 0.000193 16384 0.000381 0.000380 0.000381 0.000381 0.000378 32768 0.000771 0.000768 0.000769 0.000772 0.000772 65536 0.001564 0.001561 0.001566 0.001564 0.001562 131072 0.003127 0.003121 0.003127 0.003117 0.003119 262144 0.006242 0.006256 0.006242 0.006260 0.006254 524288 0.012698 0.012711 0.012715 0.012698 0.012713 1048576 0.025420 0.025465 0.025443 0.025455 0.025442 2097152 0.050854 0.050866 0.050883 0.050850 0.050856 4194304 0.101723 0.101699 0.101771 0.101717 0.101768 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000291 0.000262 0.000262 0.000263 0.000261 8192 0.000518 0.000516 0.000518 0.000523 0.000517 16384 0.001036 0.001027 0.001028 0.001032 0.001036 32768 0.002074 0.002082 0.002083 0.002068 0.002075 65536 0.004167 0.004168 0.004179 0.004169 0.004152 131072 0.008347 0.008320 0.008308 0.008331 0.008379 262144 0.016662 0.016637 0.016648 0.016626 0.016760 524288 0.033519 0.033495 0.033493 0.033623 0.033588 1048576 0.067067 0.067021 0.067037 0.067024 0.066988 2097152 0.134020 0.134032 0.134011 0.133999 0.134098 4194304 0.268140 0.268074 0.268032 0.267950 0.268188 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.000113 0.000050 0.000051 0.000051 0.000051 8192 0.000151 0.000097 0.000095 0.000099 0.000095 16384 0.000305 0.000193 0.000191 0.000196 0.000191 32768 0.000633 0.000389 0.000408 0.000399 0.000391 65536 0.001331 0.000828 0.000820 0.000820 0.000826 131072 0.002604 0.001616 0.001621 0.001644 0.001657 262144 0.005281 0.003227 0.003225 0.003246 0.003237 524288 0.010666 0.006706 0.006784 0.006794 0.006723 1048576 0.020945 0.013313 0.013348 0.013344 0.013500 2097152 0.042261 0.027113 0.026678 0.026741 0.026861 4194304 0.087263 0.053806 0.053234 0.053486 0.054176 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000057 0.000059 0.000059 0.000057 0.000057 8192 0.000107 0.000107 0.000107 0.000109 0.000109 16384 0.000214 0.000214 0.000212 0.000210 0.000210 32768 0.000435 0.000435 0.000444 0.000433 0.000435 65536 0.000904 0.000889 0.000900 0.000916 0.000898 131072 0.001801 0.001780 0.001799 0.001793 0.001793 262144 0.003569 0.003567 0.003590 0.003588 0.003607 524288 0.007391 0.007401 0.007370 0.007418 0.007376 1048576 0.014805 0.014811 0.014797 0.014809 0.014820 2097152 0.029606 0.029596 0.029566 0.029522 0.029566 4194304 0.059114 0.059132 0.059155 0.059013 0.059086 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000137 0.000137 0.000139 0.000139 0.000139 8192 0.000267 0.000267 0.000263 0.000265 0.000267 16384 0.000526 0.000528 0.000551 0.000534 0.000532 32768 0.001066 0.001066 0.001068 0.001064 0.001068 65536 0.002171 0.002165 0.002157 0.002155 0.002195 131072 0.004313 0.004332 0.004347 0.004320 0.004307 262144 0.008612 0.008638 0.008682 0.008648 0.008652 524288 0.017506 0.017494 0.017654 0.017538 0.017525 1048576 0.035023 0.034941 0.035238 0.035099 0.035061 2097152 0.069983 0.070160 0.070606 0.070040 0.070131 4194304 0.140141 0.141092 0.140131 0.140215 0.139980 Timing results: Vector Size Rep #1 Rep #2 Rep #3 Rep #4 Rep #5 4096 0.000288 0.000278 0.000278 0.000278 0.000282 8192 0.000549 0.000553 0.000553 0.000553 0.000553 16384 0.001101 0.001099 0.001099 0.001106 0.001095 32768 0.002209 0.002209 0.002213 0.002209 0.002205 65536 0.004457 0.004444 0.004436 0.004440 0.004456 131072 0.008881 0.008888 0.008892 0.008888 0.008888 262144 0.017746 0.017769 0.017765 0.017765 0.017742 524288 0.035751 0.035759 0.035736 0.035736 0.035751 1048576 0.071484 0.071461 0.071476 0.071491 0.071514 2097152 0.142990 0.142971 0.142967 0.142944 0.143005 4194304 0.285862 0.285976 0.285919 0.285923 0.286007 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.000099 0.000088 0.000084 0.000076 0.000069 2048 0.000156 0.000153 0.000156 0.000164 0.000156 4096 0.000298 0.000259 0.000313 0.000324 0.000298 8192 0.000626 0.000553 0.000557 0.000557 0.000546 16384 0.001141 0.001263 0.001129 0.001083 0.001255 32768 0.002411 0.002182 0.002522 0.002213 0.002228 65536 0.003696 0.003769 0.003963 0.003853 0.003849 131072 0.007385 0.007744 0.007496 0.007641 0.007355 262144 0.014606 0.015488 0.014477 0.014572 0.015774 524288 0.030067 0.030174 0.029068 0.031086 0.029289 1048576 0.058895 0.059982 0.059071 0.060246 0.059265 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.000008 0.000008 0.000008 0.000011 0.000011 16 0.000137 0.000126 0.000126 0.000134 0.000126 64 0.007828 0.007816 0.007820 0.007805 0.007820 256 0.697968 0.699345 0.698528 0.699184 0.698311 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.000053 0.000023 0.000019 0.000015 0.000015 16 0.000011 0.000008 0.000011 0.000008 0.000011 64 0.000423 0.000420 0.000435 0.000420 0.000423 256 0.025490 0.025513 0.025627 0.025829 0.026260 1024 4.496006 4.499371 4.552502 4.497486 4.531471 TIMER_ETIME Normal end of execution. March 6 2008 12:14:42.318 PM