ActivitySim / activitysim

An Open Platform for Activity-Based Travel Modeling
https://activitysim.github.io
BSD 3-Clause "New" or "Revised" License
191 stars 99 forks source link

Test Intel Performance Libraries with Anaconda #202

Closed bstabler closed 6 years ago

bstabler commented 6 years ago

@stefancoe - FYI- a colleague just sent this and I thought many of you might find it useful. Some very easy steps to increase python performance on intel chip sets.

bstabler commented 6 years ago

I tested this on my Windows i7 2.5GHz 4 core 16GB RAM laptop using the activitysim example and a 5000 household sample and the results are below. Unfortunately it doesn't appear to make much difference. It may make more of a difference for larger arrays, but I suspect it won't make a huge difference since we're doing so much more than just core mathematical operations.

Before (with the default Anaconda builds)

After (with the Intel Distribution for Python)

Installation Steps

I installed IDP and activitysim via the following commands:

conda update conda
conda config --add channels intel
conda create -n idp intelpython2_core python=2
activate idp
pip install cytoolz numpy pandas tables pyyaml psutil
pip install orca openmatrix zbox
pip install activitysim

The nice thing about this "upgrade" is that you first create a new conda environment before installing the Intel distribution, which means it can optionally be turned on by activating the environment and then turned off by deactivating it.

Just to make sure

Since my test basically showed no difference, I ran the example in one of the links above, and it does show a speedup of about 8x. Here is the code:

import numpy as np
import time

N = 102400
x = np.linspace(0.0123, 4567.89, N)

def mine(x,Z,func,name):
  print name;
  start = time.time()
  for z in range ( 0, Z ) :
    y = func(x);
  end = time.time()
  print N, Z, end - start
  return

mine(x,10000,np.sin,'np.sin')
mine(x,10000,np.cos,'np.cos')
mine(x,10000,np.tan,'np.tan')

And here are the test results:

C:\projects\software>python test-idp.py
np.sin
102400 10000 17.05
np.cos
102400 10000 17.43
np.tan
102400 10000 22.49

C:\projects\software>activate idp

(idp) C:\projects\software>python test-idp.py
np.sin
102400 10000 2.19
np.cos
102400 10000 2.02
np.tan
102400 10000 2.61