performance measurements

Each table row shows performance measurements for this Fortran Intel program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
2,000Bad Output  1768   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read pidigits benchmark to see what this program should do.

 notes

Intel(R) Fortran Compiler XE for applications running on IA-32, Version 13.0.1.117 Build 20121010

 pidigits Fortran Intel program source code

! The Computer Language Benchmarks Game
! http://benchmarksgame.alioth.debian.org/
!
! contributed by Steve Decker
! compilation:
!    g95 -O3 -funroll-loops -fomit-frame-pointer pidigits.f90
!    ifort -O -ip pidigits.f90

module big_int_mod
  implicit none
  save
  
  integer, parameter, private :: Pwr = 15, Base = 2**Pwr, maxDigs = 2558

  type big_int
     private
     integer :: sigDigs
     logical :: sign
     integer, dimension(maxDigs) :: digits
  end type big_int

  interface assignment (=)
     module procedure int_to_big_int
  end interface
  
  interface operator (*)
     module procedure big_int_times_int
  end interface
  
  interface operator (+)
     module procedure big_int_plus_big_int
  end interface

  interface operator (/)
     module procedure big_int_div_big_int
  end interface

contains
  
  subroutine int_to_big_int(bi, n)
    type(big_int), intent(inout) :: bi
    integer,       intent(in)    :: n

    integer :: i

    if (n > 0) then
       bi = big_int(1, .true., (/ n, (0, i = 2, maxDigs) /) )
    else
       bi = big_int(0, .true., 0)
    end if
  end subroutine int_to_big_int
  
  function big_int_times_int(bi, n) result(c)
    type(big_int), intent(in) :: bi
    integer,       intent(in) :: n
    type(big_int) :: c

    integer :: m, i, curDig, k, j, carry
    
    c = big_int(0, .true., 0)
    if (n == 0 .or. bi%sigDigs == 0) return
    c%sign = n >= 0 .eqv. bi%sign
    m = abs(n)

    do i = 1, maxDigs
       curDig = mod(m,Base)
       k = 1
       carry = 0
       do j = i, i + bi%sigDigs + 1
          c%digits(j) = c%digits(j) + curDig * bi%digits(k) + carry
          carry = ibits(c%digits(j),Pwr,Pwr+1)
          c%digits(j) = mod(c%digits(j),Base)
          k = k + 1
       end do
       m = ibits(m,Pwr,Pwr+1)
       if (m == 0) exit
    end do
    do j = i + bi%sigDigs, 1, -1
       c%sigDigs = j
       if (c%digits(j) /= 0) exit
    end do
  end function big_int_times_int

  function big_int_plus_big_int(bi1, bi2) result(c)
    type(big_int), target, intent(in) :: bi1, bi2
    type(big_int) :: c
    
    integer :: i, carry, n
    type(big_int), pointer :: a, b

    c = big_int(0, .true., 0)

    if (bi1%sigDigs == 0) then
       c = bi2
       return
    else if (bi2%sigDigs == 0) then
       c = bi1
       return
    end if

    if (bi1%sign .eqv. bi2%sign) then
       c%sign = bi1%sign
       carry = 0
       n = max(bi1%sigDigs, bi2%sigDigs) + 1
       do i = 1, n
          c%digits(i) = bi1%digits(i) + bi2%digits(i) + carry
          carry = ibits(c%digits(i),Pwr,Pwr+1)
          c%digits(i) = mod(c%digits(i),Base)
       end do
    else
       if (greater_in_mag(bi1, bi2)) then
          a => bi1
          b => bi2
       else if (greater_in_mag(bi2, bi1)) then
          a => bi2
          b => bi1
       else
          return
       end if

       n = max(a%sigDigs, b%sigDigs)
       c%sign = a%sign
       do i = 1, n
          if (a%digits(i) < b%digits(i)) then
             a%digits(i) = a%digits(i) + Base
             a%digits(i+1) = a%digits(i+1) - 1
          end if
          c%digits(i) = a%digits(i) - b%digits(i)
       end do
    end if

    do i = n, 1, -1
       c%sigDigs = i
       if (c%digits(i) /= 0) exit
    end do
  end function big_int_plus_big_int

  function big_int_div_big_int(a, b) result(c)
    type(big_int), intent(in) :: a, b
    integer                   :: c

    integer :: k, carry, n, j
    type(big_int) :: accumulator

    c = 0
    if (a%sigDigs == 0) return

    accumulator = big_int(0, .true., 0)
    do k = 0, Base-1
       carry = 0
       n = max(accumulator%sigDigs, b%sigDigs) + 1
       do j = 1, n
          accumulator%digits(j) =  &
               accumulator%digits(j) + b%digits(j) + carry
          carry = ibits(accumulator%digits(j),Pwr,Pwr+1)
          accumulator%digits(j) = mod(accumulator%digits(j),Base)
       end do
       do j = n, 1, -1
          accumulator%sigDigs = j
          if (accumulator%digits(j) /= 0) exit
       end do
       if (greater_in_mag(accumulator, a)) then
          c = k
          exit
       end if
    end do
  end function big_int_div_big_int
  
  logical function greater_in_mag(a, b)
    type(big_int), intent(in) :: a, b

    integer :: i

    greater_in_mag = .false.
    do i = max(a%sigDigs, b%sigDigs), 1, -1
       if (a%digits(i) > b%digits(i)) then
          greater_in_mag = .true.
          exit
       else if (a%digits(i) < b%digits(i)) then
          exit
       end if
    end do
  end function greater_in_mag
end module big_int_mod

module pi_mod
  use big_int_mod
  implicit none

contains

  function lfts(k)
    integer, intent(in)     :: k
    integer, dimension(2,2) :: lfts

    lfts = reshape( (/ k, 0, 4*k + 2, 2*k + 1 /), (/ 2, 2 /) )
  end function lfts

  function comp1(a, b)
    integer,       dimension(2,2), intent(in) :: a
    type(big_int), dimension(2,2), intent(in) :: b
    type(big_int), dimension(2,2) :: comp1

    comp1(1,1) = b(1,1)*a(1,1) + b(2,1)*a(1,2)
    comp1(2,1) = b(1,1)*a(2,1) + b(2,1)*a(2,2)
    comp1(1,2) = b(1,2)*a(1,1) + b(2,2)*a(1,2)
    comp1(2,2) = b(1,2)*a(2,1) + b(2,2)*a(2,2)
  end function comp1

  function comp2(a, b)
    type(big_int), dimension(2,2), intent(in) :: a
    integer,       dimension(2,2), intent(in) :: b
    type(big_int), dimension(2,2) :: comp2
    
    comp2(1,1) = a(1,1)*b(1,1) + a(1,2)*b(2,1)
    comp2(2,1) = a(2,1)*b(1,1) + a(2,2)*b(2,1)
    comp2(1,2) = a(1,1)*b(1,2) + a(1,2)*b(2,2)
    comp2(2,2) = a(2,1)*b(1,2) + a(2,2)*b(2,2)
  end function comp2
  
  function prod(z, n)
    type(big_int), dimension(2,2), intent(in) :: z
    integer,                       intent(in) :: n
    type(big_int), dimension(2,2) :: prod

    prod = comp1(reshape( (/ 10, 0, -10*n, 1 /), (/ 2, 2 /) ), z)
  end function prod
  
  logical function safe(z, n)
    type(big_int), dimension(2,2), intent(in) :: z
    integer,                       intent(in) :: n

    safe = n == (z(1,1) * 4 + z(1,2)) / (z(2,1) * 4 + z(2,2))
  end function safe

  integer function next(z)
    type(big_int), dimension(2,2), intent(in) :: z
    
    next = (z(1,1) * 3 + z(1,2)) / (z(2,1) * 3 + z(2,2))
  end function next
end module pi_mod

program pidigits
  use pi_mod
  implicit none

  character(len=12), parameter  :: proForma = "          " // achar(9) // ":"
  type(big_int), dimension(2,2) :: z
  integer           :: num, y, i = 1, j = 1, k = 1
  character(len=17) :: outLine = proForma
  character(len=4)  :: argv

  call get_command_argument(1, argv)
  read(argv, *) num

  z(1,1) = 1; z(2,1) = 0; z(1,2) = 0; z(2,2) = 1

  do
     y = next(z)
     if (safe(z, y)) then
        write(unit=outLine(k:k), fmt="(i1)") y
        if (k < 10 .and. i < num) then
           k = k + 1
        else
           k = 1
           write(unit=outLine(13:17), fmt="(i0)") i
           write(*, "(a)") trim(outLine)
           outLine = proForma
        end if
        if (i == num) exit
        z = prod(z, y)
        i = i + 1
     else
        z = comp2(z, lfts(j))
        j = j + 1
     end if
  end do
end program pidigits

 make, command-line, and program output logs

Tue, 15 Jan 2013 06:37:08 GMT

MAKE:
/usr/local/src/intel/bin/ifort -O3 -xHost -ipo -lgmp pidigits.f90 -o pidigits.ifc_run
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file /tmp/ipo_ifortOAlrKY.o
rm pidigits.f90
0.66s to complete and log all make actions

COMMAND LINE:
./pidigits.ifc_run 2000

UNEXPECTED OUTPUT 

3,200c3,200
< 6149467263	:30
< 0618873702	:40
< ***0000000	:50
< 0000000000	:60
< 0000000000	:70
< 0000000000	:80
< 0000000000	:90
< 0000000000	:100
< 0000000000	:110
< 0000000000	:120
< 0000000000	:130
< 0000000000	:140
< 0000000000	:150
< 0000000000	:160
< 0000000000	:170
< 0000000000	:180
< 0000000000	:190
< 0000000000	:200
< 0000000000	:210
< 0000000000	:220
< 0000000000	:230
< 0000000000	:240
< 0000000000	:250
< 0000000000	:260
< 0000000000	:270
< 0000000000	:280
< 0000000000	:290
< 0000000000	:300
< 0000000000	:310
< 0000000000	:320
< 0000000000	:330
< 0000000000	:340
< 0000000000	:350
< 0000000000	:360
< 0000000000	:370
< 0000000000	:380
< 0000000000	:390
< 0000000000	:400
< 0000000000	:410
< 0000000000	:420
< 0000000000	:430
< 0000000000	:440
< 0000000000	:450
< 0000000000	:460
< 0000000000	:470
< 0000000000	:480
< 0000000000	:490
< 0000000000	:500
< 0000000000	:510
< 0000000000	:520
< 0000000000	:530
< 0000000000	:540
< 0000000000	:550
< 0000000000	:560
< 0000000000	:570
< 0000000000	:580
< 0000000000	:590
< 0000000000	:600
< 0000000000	:610
< 0000000000	:620
< 0000000000	:630
< 0000000000	:640
< 0000000000	:650
< 0000000000	:660
< 0000000000	:670
< 0000000000	:680
< 0000000000	:690
< 0000000000	:700
< 0000000000	:710
< 0000000000	:720
< 0000000000	:730
< 0000000000	:740
< 0000000000	:750
< 0000000000	:760
< 0000000000	:770
< 0000000000	:780
< 0000000000	:790
< 0000000000	:800
< 0000000000	:810
< 0000000000	:820
< 0000000000	:830
< 0000000000	:840
< 0000000000	:850
< 0000000000	:860
< 0000000000	:870
< 0000000000	:880
< 0000000000	:890
< 0000000000	:900
< 0000000000	:910
< 0000000000	:920
< 0000000000	:930
< 0000000000	:940
< 0000000000	:950
< 0000000000	:960
< 0000000000	:970
< 0000000000	:980
< 0000000000	:990
< 0000000000	:1000
< 0000000000	:1010
< 0000000000	:1020
< 0000000000	:1030
< 0000000000	:1040
< 0000000000	:1050
< 0000000000	:1060
< 0000000000	:1070
< 0000000000	:1080
< 0000000000	:1090
< 0000000000	:1100
< 0000000000	:1110
< 0000000000	:1120
< 0000000000	:1130
< 0000000000	:1140
< 0000000000	:1150
< 0000000000	:1160
< 0000000000	:1170
< 0000000000	:1180
< 0000000000	:1190
< 0000000000	:1200
< 0000000000	:1210
< 0000000000	:1220
< 0000000000	:1230
< 0000000000	:1240
< 0000000000	:1250
< 0000000000	:1260
< 0000000000	:1270
< 0000000000	:1280
< 0000000000	:1290
< 0000000000	:1300
< 0000000000	:1310
< 0000000000	:1320
< 0000000000	:1330
< 0000000000	:1340
< 0000000000	:1350
< 0000000000	:1360
< 0000000000	:1370
< 0000000000	:1380
< 0000000000	:1390
< 0000000000	:1400
< 0000000000	:1410
< 0000000000	:1420
< 0000000000	:1430
< 0000000000	:1440
< 0000000000	:1450
< 0000000000	:1460
< 0000000000	:1470
< 0000000000	:1480
< 0000000000	:1490
< 0000000000	:1500
< 0000000000	:1510
< 0000000000	:1520
< 0000000000	:1530
< 0000000000	:1540
< 0000000000	:1550
< 0000000000	:1560
< 0000000000	:1570
< 0000000000	:1580
< 0000000000	:1590
< 0000000000	:1600
< 0000000000	:1610
< 0000000000	:1620
< 0000000000	:1630
< 0000000000	:1640
< 0000000000	:1650
< 0000000000	:1660
< 0000000000	:1670
< 0000000000	:1680
< 0000000000	:1690
< 0000000000	:1700
< 0000000000	:1710
< 0000000000	:1720
< 0000000000	:1730
< 0000000000	:1740
< 0000000000	:1750
< 0000000000	:1760
< 0000000000	:1770
< 0000000000	:1780
< 0000000000	:1790
< 0000000000	:1800
< 0000000000	:1810
< 0000000000	:1820
< 0000000000	:1830
< 0000000000	:1840
< 0000000000	:1850
< 0000000000	:1860
< 0000000000	:1870
< 0000000000	:1880
< 0000000000	:1890
< 0000000000	:1900
< 0000000000	:1910
< 0000000000	:1920
< 0000000000	:1930
< 0000000000	:1940
< 0000000000	:1950
< 0000000000	:1960
< 0000000000	:1970
< 0000000000	:1980
< 0000000000	:1990
< 0000000000	:2000
---
> 6264338327	:30
> 9502884197	:40
> 1693993751	:50
> 0582097494	:60
> 4592307816	:70
> 4062862089	:80
> 9862803482	:90
> 5342117067	:100
> 9821480865	:110
> 1328230664	:120
> 7093844609	:130
> 5505822317	:140
> 2535940812	:150
> 8481117450	:160
> 2841027019	:170
> 3852110555	:180
> 9644622948	:190
> 9549303819	:200
> 6442881097	:210
> 5665933446	:220
> 1284756482	:230
> 3378678316	:240
> 5271201909	:250
> 1456485669	:260
> 2346034861	:270
> 0454326648	:280
> 2133936072	:290
> 6024914127	:300
> 3724587006	:310
> 6063155881	:320
> 7488152092	:330
> 0962829254	:340
> 0917153643	:350
> 6789259036	:360
> 0011330530	:370
> 5488204665	:380
> 2138414695	:390
> 1941511609	:400
> 4330572703	:410
> 6575959195	:420
> 3092186117	:430
> 3819326117	:440
> 9310511854	:450
> 8074462379	:460
> 9627495673	:470
> 5188575272	:480
> 4891227938	:490
> 1830119491	:500
> 2983367336	:510
> 2440656643	:520
> 0860213949	:530
> 4639522473	:540
> 7190702179	:550
> 8609437027	:560
> 7053921717	:570
> 6293176752	:580
> 3846748184	:590
> 6766940513	:600
> 2000568127	:610
> 1452635608	:620
> 2778577134	:630
> 2757789609	:640
> 1736371787	:650
> 2146844090	:660
> 1224953430	:670
> 1465495853	:680
> 7105079227	:690
> 9689258923	:700
> 5420199561	:710
> 1212902196	:720
> 0864034418	:730
> 1598136297	:740
> 7477130996	:750
> 0518707211	:760
> 3499999983	:770
> 7297804995	:780
> 1059731732	:790
> 8160963185	:800
> 9502445945	:810
> 5346908302	:820
> 6425223082	:830
> 5334468503	:840
> 5261931188	:850
> 1710100031	:860
> 3783875288	:870
> 6587533208	:880
> 3814206171	:890
> 7766914730	:900
> 3598253490	:910
> 4287554687	:920
> 3115956286	:930
> 3882353787	:940
> 5937519577	:950
> 8185778053	:960
> 2171226806	:970
> 6130019278	:980
> 7661119590	:990
> 9216420198	:1000
> 9380952572	:1010
> 0106548586	:1020
> 3278865936	:1030
> 1533818279	:1040
> 6823030195	:1050
> 2035301852	:1060
> 9689957736	:1070
> 2259941389	:1080
> 1249721775	:1090
> 2834791315	:1100
> 1557485724	:1110
> 2454150695	:1120
> 9508295331	:1130
> 1686172785	:1140
> 5889075098	:1150
> 3817546374	:1160
> 6493931925	:1170
> 5060400927	:1180
> 7016711390	:1190
> 0984882401	:1200
> 2858361603	:1210
> 5637076601	:1220
> 0471018194	:1230
> 2955596198	:1240
> 9467678374	:1250
> 4944825537	:1260
> 9774726847	:1270
> 1040475346	:1280
> 4620804668	:1290
> 4259069491	:1300
> 2933136770	:1310
> 2898915210	:1320
> 4752162056	:1330
> 9660240580	:1340
> 3815019351	:1350
> 1253382430	:1360
> 0355876402	:1370
> 4749647326	:1380
> 3914199272	:1390
> 6042699227	:1400
> 9678235478	:1410
> 1636009341	:1420
> 7216412199	:1430
> 2458631503	:1440
> 0286182974	:1450
> 5557067498	:1460
> 3850549458	:1470
> 8586926995	:1480
> 6909272107	:1490
> 9750930295	:1500
> 5321165344	:1510
> 9872027559	:1520
> 6023648066	:1530
> 5499119881	:1540
> 8347977535	:1550
> 6636980742	:1560
> 6542527862	:1570
> 5518184175	:1580
> 7467289097	:1590
> 7772793800	:1600
> 0816470600	:1610
> 1614524919	:1620
> 2173217214	:1630
> 7723501414	:1640
> 4197356854	:1650
> 8161361157	:1660
> 3525521334	:1670
> 7574184946	:1680
> 8438523323	:1690
> 9073941433	:1700
> 3454776241	:1710
> 6862518983	:1720
> 5694855620	:1730
> 9921922218	:1740
> 4272550254	:1750
> 2568876717	:1760
> 9049460165	:1770
> 3466804988	:1780
> 6272327917	:1790
> 8608578438	:1800
> 3827967976	:1810
> 6814541009	:1820
> 5388378636	:1830
> 0950680064	:1840
> 2251252051	:1850
> 1739298489	:1860
> 6084128488	:1870
> 6269456042	:1880
> 4196528502	:1890
> 2210661186	:1900
> 3067442786	:1910
> 2203919494	:1920
> 5047123713	:1930
> 7869609563	:1940
> 6437191728	:1950
> 7467764657	:1960
> 5739624138	:1970
> 9086583264	:1980
> 5995813390	:1990
> 4780275900	:2000

PROGRAM OUTPUT:
3141592653	:10
5897932384	:20
6149467263	:30
0618873702	:40
***0000000	:50
0000000000	:60
0000000000	:70
0000000000	:80
0000000000	:90
0000000000	:100
0000000000	:110
0000000000	:120
0000000000	:130
0000000000	:140
0000000000	:150
0000000000	:160
0000000000	:170
0000000000	:180
0000000000	:190
0000000000	:200
0000000000	:210
0000000000	:220
0000000000	:230
0000000000	:240
0000000000	:250
0000000000	:260
0000000000	:270
0000000000	:280
0000000000	:290
0000000000	:300
0000000000	:310
0000000000	:320
0000000000	:330
0000000000	:340
0000000000	:350
0000000000	:360
0000000000	:370
0000000000	:380
0000000000	:390
0000000000	:400
0000000000	:410
0000000000	:420
0000000000	:430
0000000000	:440
0000000000	:450
0000000000	:460
0000000000	:470
0000000000	:480
0000000000	:490
0000000000	:500
0000000000	:510
0000000000	:520
0000000000	:530
0000000000	:540
0000000000	:550
0000000000	:560
0000000000	:570
0000000000	:580
0000000000	:590
0000000000	:600
0000000000	:610
0000000000	:620
0000000000	:630
0000000000	:640
0000000000	:650
0000000000	:660
0000000000	:670
0000000000	:680
0000000000	:690
0000000000	:700
0000000000	:710
0000000000	:720
0000000000	:730
0000000000	:740
0000000000	:750
0000000000	:760
0000000000	:770
0000000000	:780
0000000000	:790
0000000000	:800
0000000000	:810
0000000000	:820
0000000000	:830
0000000000	:840
0000000000	:850
0000000000	:860
0000000000	:870
0000000000	:880
0000000000	:890
0000000000	:900
0000000000	:910
0000000000	:920
0000000000	:930
0000000000	:940
0000000000	:950
0000000000	:960
0000000000	:970
0000000000	:980
0000000000	:990
0000000000	:1000
0000000000	:1010
0000000000	:1020
0000000000	:1030
0000000000	:1040
0000000000	:1050
0000000000	:1060
0000000000	:1070
0000000000	:1080
0000000000	:1090
0000000000	:1100
0000000000	:1110
0000000000	:1120
0000000000	:1130
0000000000	:1140
0000000000	:1150
0000000000	:1160
0000000000	:1170
0000000000	:1180
0000000000	:1190
0000000000	:1200
0000000000	:1210
0000000000	:1220
0000000000	:1230
0000000000	:1240
0000000000	:1250
0000000000	:1260
0000000000	:1270
0000000000	:1280
0000000000	:1290
0000000000	:1300
0000000000	:1310
0000000000	:1320
0000000000	:1330
0000000000	:1340
0000000000	:1350
0000000000	:1360
0000000000	:1370
0000000000	:1380
0000000000	:1390
0000000000	:1400
0000000000	:1410
0000000000	:1420
0000000000	:1430
0000000000	:1440
0000000000	:1450
0000000000	:1460
0000000000	:1470
0000000000	:1480
0000000000	:1490
0000000000	:1500
0000000000	:1510
0000000000	:1520
0000000000	:1530
0000000000	:1540
0000000000	:1550
0000000000	:1560
0000000000	:1570
0000000000	:1580
0000000000	:1590
0000000000	:1600
0000000000	:1610
0000000000	:1620
0000000000	:1630
0000000000	:1640
0000000000	:1650
0000000000	:1660
0000000000	:1670
0000000000	:1680
0000000000	:1690
0000000000	:1700
0000000000	:1710
0000000000	:1720
0000000000	:1730
0000000000	:1740
0000000000	:1750
0000000000	:1760
0000000000	:1770
0000000000	:1780
0000000000	:1790
0000000000	:1800
0000000000	:1810
0000000000	:1820
0000000000	:1830
0000000000	:1840
0000000000	:1850
0000000000	:1860
0000000000	:1870
0000000000	:1880
0000000000	:1890
0000000000	:1900
0000000000	:1910
0000000000	:1920
0000000000	:1930
0000000000	:1940
0000000000	:1950
0000000000	:1960
0000000000	:1970
0000000000	:1980
0000000000	:1990
0000000000	:2000

Revised BSD license

  Home   Conclusions   License   Play