Okay. I ran into computer trouble yesterday morning, wiped everything, and reinstalled everything.
And…Julia runs a lot slower now. Hmm.
I am not sure why that is.
I let Julia build OpenBLAS with the version I tested with, and also compiled Julia using gcc-trunk. LLVM was dynamically linked.
This time I couldn’t get Julia to build OpenBLAS, so I did it myself and linked it. I compiled Julia with the latest release gcc, and linked LLVM statically. I also just rebuilt Julia and linked dynamically: no difference.
Hmm.
Notebooks:
https://gist.github.com/chriselrod/f30fdfadccd8413000f0703a7cc6f8a5
Anyway, running your scripts:
$ ../../Anaconda/cond/bin/python RBC.py
2018-02-11 18:11:39.366524
2018-02-11 18:11:56.001698
1.6634931039996446
$ julia RBC.jl
2018-02-11T18:13:05.904
2018-02-11T18:13:19.125
1.3220999999999998
$ julia -O3 RBC.jl
2018-02-11T18:13:44.321
2018-02-11T18:13:57.633
1.3312
If Julia slowed down, curious about C++ and Fortran:
$ g++-7 -march=native -O3 RBC.cpp -o RBC_cpp && ./RBC_cpp
Output = 0.562731, Capital = 0.178198, Consumption = 0.384533
Iteration = 1, Sup Diff = 0.0527416
Iteration = 10, Sup Diff = 0.0313469
Iteration = 20, Sup Diff = 0.0187035
Iteration = 30, Sup Diff = 0.0111655
Iteration = 40, Sup Diff = 0.00666854
Iteration = 50, Sup Diff = 0.00398429
Iteration = 60, Sup Diff = 0.00238131
Iteration = 70, Sup Diff = 0.00142366
Iteration = 80, Sup Diff = 0.00085134
Iteration = 90, Sup Diff = 0.000509205
Iteration = 100, Sup Diff = 0.000304623
Iteration = 110, Sup Diff = 0.000182265
Iteration = 120, Sup Diff = 0.00010907
Iteration = 130, Sup Diff = 6.52764e-05
Iteration = 140, Sup Diff = 3.90711e-05
Iteration = 150, Sup Diff = 2.33881e-05
Iteration = 160, Sup Diff = 1.40086e-05
Iteration = 170, Sup Diff = 8.39132e-06
Iteration = 180, Sup Diff = 5.02647e-06
Iteration = 190, Sup Diff = 3.0109e-06
Iteration = 200, Sup Diff = 1.80355e-06
Iteration = 210, Sup Diff = 1.08034e-06
Iteration = 220, Sup Diff = 6.47132e-07
Iteration = 230, Sup Diff = 3.87636e-07
Iteration = 240, Sup Diff = 2.32197e-07
Iteration = 250, Sup Diff = 1.39087e-07
Iteration = 257, Sup Diff = 9.71604e-08
My check = 0.146549
Elapsed time is = 1.37482
$ gfortran-7 -march=native -O3 RBC.f90 -o RBC_f && ./RBC_f
Steady State values
Output: 0.56273142426227074 Capital: 0.17819828742434793 Consumption: 0.38453313683792278
Iteration: 1 Sup Diff: 5.2741607134075871E-002
Iteration: 10 Sup Diff: 3.1346953831200119E-002
Iteration: 20 Sup Diff: 1.8703460152962870E-002
Iteration: 30 Sup Diff: 1.1165510606509832E-002
Iteration: 40 Sup Diff: 6.6685398355890158E-003
Iteration: 50 Sup Diff: 3.9842909760740008E-003
Iteration: 60 Sup Diff: 2.3813103290404314E-003
Iteration: 70 Sup Diff: 1.4236575018528042E-003
Iteration: 80 Sup Diff: 8.5133892789668320E-004
Iteration: 90 Sup Diff: 5.0920456767089561E-004
Iteration: 100 Sup Diff: 3.0462281856569184E-004
Iteration: 110 Sup Diff: 1.8226456357595122E-004
Iteration: 120 Sup Diff: 1.0906931033882739E-004
Iteration: 130 Sup Diff: 6.5276304536676655E-005
Iteration: 140 Sup Diff: 3.9070994080181443E-005
Iteration: 150 Sup Diff: 2.3388019260162096E-005
Iteration: 160 Sup Diff: 1.4008591582403973E-005
Iteration: 170 Sup Diff: 8.3912834882848841E-006
Iteration: 180 Sup Diff: 5.0264531855637173E-006
Iteration: 190 Sup Diff: 3.0108863811051378E-006
Iteration: 200 Sup Diff: 1.8035437576724433E-006
Iteration: 210 Sup Diff: 1.0803355822153193E-006
Iteration: 220 Sup Diff: 6.4712835068370111E-007
Iteration: 230 Sup Diff: 3.8763410215025829E-007
Iteration: 240 Sup Diff: 2.3219527300888387E-007
Iteration: 250 Sup Diff: 1.3908639495685549E-007
Iteration: 257 Sup Diff: 9.7159772005639411E-008
My check: 0.14654914390886931
Elapsed time is 1.38328505
Ofast:
$ g++-7 -march=native -Ofast RBC.cpp -o RBC_ofast_cpp && ./RBC_ofast_cpp
Output = 0.562731, Capital = 0.178198, Consumption = 0.384533
Iteration = 1, Sup Diff = 0.0527416
Iteration = 10, Sup Diff = 0.0313469
Iteration = 20, Sup Diff = 0.0187035
Iteration = 30, Sup Diff = 0.0111655
Iteration = 40, Sup Diff = 0.00666854
Iteration = 50, Sup Diff = 0.00398429
Iteration = 60, Sup Diff = 0.00238131
Iteration = 70, Sup Diff = 0.00142366
Iteration = 80, Sup Diff = 0.00085134
Iteration = 90, Sup Diff = 0.000509205
Iteration = 100, Sup Diff = 0.000304623
Iteration = 110, Sup Diff = 0.000182265
Iteration = 120, Sup Diff = 0.00010907
Iteration = 130, Sup Diff = 6.52764e-05
Iteration = 140, Sup Diff = 3.90711e-05
Iteration = 150, Sup Diff = 2.33881e-05
Iteration = 160, Sup Diff = 1.40086e-05
Iteration = 170, Sup Diff = 8.39132e-06
Iteration = 180, Sup Diff = 5.02647e-06
Iteration = 190, Sup Diff = 3.0109e-06
Iteration = 200, Sup Diff = 1.80355e-06
Iteration = 210, Sup Diff = 1.08034e-06
Iteration = 220, Sup Diff = 6.47132e-07
Iteration = 230, Sup Diff = 3.87636e-07
Iteration = 240, Sup Diff = 2.32197e-07
Iteration = 250, Sup Diff = 1.39087e-07
Iteration = 257, Sup Diff = 9.71604e-08
My check = 0.146549
Elapsed time is = 1.30403
$ gfortran-7 -march=native -Ofast RBC.f90 -o RBC_ofast_f && ./RBC_ofast_f
Steady State values
Output: 0.56273142426227074 Capital: 0.17819828742434793 Consumption: 0.38453313683792278
Iteration: 1 Sup Diff: 5.2741607134075871E-002
Iteration: 10 Sup Diff: 3.1346953831200119E-002
Iteration: 20 Sup Diff: 1.8703460152962870E-002
Iteration: 30 Sup Diff: 1.1165510606509832E-002
Iteration: 40 Sup Diff: 6.6685398355890158E-003
Iteration: 50 Sup Diff: 3.9842909760740008E-003
Iteration: 60 Sup Diff: 2.3813103290404314E-003
Iteration: 70 Sup Diff: 1.4236575018528042E-003
Iteration: 80 Sup Diff: 8.5133892789668320E-004
Iteration: 90 Sup Diff: 5.0920456767089561E-004
Iteration: 100 Sup Diff: 3.0462281856569184E-004
Iteration: 110 Sup Diff: 1.8226456357595122E-004
Iteration: 120 Sup Diff: 1.0906931033882739E-004
Iteration: 130 Sup Diff: 6.5276304536676655E-005
Iteration: 140 Sup Diff: 3.9070994080181443E-005
Iteration: 150 Sup Diff: 2.3388019260162096E-005
Iteration: 160 Sup Diff: 1.4008591582403973E-005
Iteration: 170 Sup Diff: 8.3912834882848841E-006
Iteration: 180 Sup Diff: 5.0264531855637173E-006
Iteration: 190 Sup Diff: 3.0108863811051378E-006
Iteration: 200 Sup Diff: 1.8035437576724433E-006
Iteration: 210 Sup Diff: 1.0803355822153193E-006
Iteration: 220 Sup Diff: 6.4712835068370111E-007
Iteration: 230 Sup Diff: 3.8763410215025829E-007
Iteration: 240 Sup Diff: 2.3219527300888387E-007
Iteration: 250 Sup Diff: 1.3908639495685549E-007
Iteration: 257 Sup Diff: 9.7159772005639411E-008
My check: 0.14654914390886931
Elapsed time is 1.39106107
Ofast, funroll loops:
$ g++-7 -march=native -Ofast -funroll-loops RBC.cpp -o RBC_ofastfunroll_cpp && ./RBC_ofastfunroll_cpp
Output = 0.562731, Capital = 0.178198, Consumption = 0.384533
Iteration = 1, Sup Diff = 0.0527416
Iteration = 10, Sup Diff = 0.0313469
Iteration = 20, Sup Diff = 0.0187035
Iteration = 30, Sup Diff = 0.0111655
Iteration = 40, Sup Diff = 0.00666854
Iteration = 50, Sup Diff = 0.00398429
Iteration = 60, Sup Diff = 0.00238131
Iteration = 70, Sup Diff = 0.00142366
Iteration = 80, Sup Diff = 0.00085134
Iteration = 90, Sup Diff = 0.000509205
Iteration = 100, Sup Diff = 0.000304623
Iteration = 110, Sup Diff = 0.000182265
Iteration = 120, Sup Diff = 0.00010907
Iteration = 130, Sup Diff = 6.52764e-05
Iteration = 140, Sup Diff = 3.90711e-05
Iteration = 150, Sup Diff = 2.33881e-05
Iteration = 160, Sup Diff = 1.40086e-05
Iteration = 170, Sup Diff = 8.39132e-06
Iteration = 180, Sup Diff = 5.02647e-06
Iteration = 190, Sup Diff = 3.0109e-06
Iteration = 200, Sup Diff = 1.80355e-06
Iteration = 210, Sup Diff = 1.08034e-06
Iteration = 220, Sup Diff = 6.47132e-07
Iteration = 230, Sup Diff = 3.87636e-07
Iteration = 240, Sup Diff = 2.32197e-07
Iteration = 250, Sup Diff = 1.39087e-07
Iteration = 257, Sup Diff = 9.71604e-08
My check = 0.146549
Elapsed time is = 1.27788
$ gfortran-7 -march=native -Ofast -funroll-loops RBC.f90 -o RBC_ofastfunroll_f && ./RBC_ofastfunroll_f
Steady State values
Output: 0.56273142426227074 Capital: 0.17819828742434793 Consumption: 0.38453313683792278
Iteration: 1 Sup Diff: 5.2741607134075871E-002
Iteration: 10 Sup Diff: 3.1346953831200119E-002
Iteration: 20 Sup Diff: 1.8703460152962870E-002
Iteration: 30 Sup Diff: 1.1165510606509832E-002
Iteration: 40 Sup Diff: 6.6685398355890158E-003
Iteration: 50 Sup Diff: 3.9842909760740008E-003
Iteration: 60 Sup Diff: 2.3813103290404314E-003
Iteration: 70 Sup Diff: 1.4236575018528042E-003
Iteration: 80 Sup Diff: 8.5133892789668320E-004
Iteration: 90 Sup Diff: 5.0920456767089561E-004
Iteration: 100 Sup Diff: 3.0462281856569184E-004
Iteration: 110 Sup Diff: 1.8226456357595122E-004
Iteration: 120 Sup Diff: 1.0906931033882739E-004
Iteration: 130 Sup Diff: 6.5276304536676655E-005
Iteration: 140 Sup Diff: 3.9070994080181443E-005
Iteration: 150 Sup Diff: 2.3388019260162096E-005
Iteration: 160 Sup Diff: 1.4008591582403973E-005
Iteration: 170 Sup Diff: 8.3912834882848841E-006
Iteration: 180 Sup Diff: 5.0264531855637173E-006
Iteration: 190 Sup Diff: 3.0108863811051378E-006
Iteration: 200 Sup Diff: 1.8035437576724433E-006
Iteration: 210 Sup Diff: 1.0803355822153193E-006
Iteration: 220 Sup Diff: 6.4712835068370111E-007
Iteration: 230 Sup Diff: 3.8763410215025829E-007
Iteration: 240 Sup Diff: 2.3219527300888387E-007
Iteration: 250 Sup Diff: 1.3908639495685549E-007
Iteration: 257 Sup Diff: 9.7159772005639411E-008
My check: 0.14654914390886931
Elapsed time is 1.34112906
So, gcc
seems as fast as before, but my Julia slowed down by a tenth of a second. =/
Still, well ahead of my Numba.
EDIT:
-fprofile-generate
, running the code, then recompiling with -fprofile-use
→ C++ < 1.2 seconds on my computer. Almost as fast as that old Julia time.