Kobzol / hardware-effects

Demonstration of various hardware effects.
MIT License
2.83k stars 159 forks source link

taskset? #16

Closed VictorEijkhout closed 5 years ago

VictorEijkhout commented 5 years ago

I'm not sure if I'm calling stuff the right way. Is there an outer script that I need to call to get the setup done correctly?

[prefetching:118] python3 software-prefetching.py ../../build/prefetching/software-prefetching 
Traceback (most recent call last):
  File "software-prefetching.py", line 18, in <module>
    frame = benchmark(data, pin_to_cpu=True, repeat=2)
  File "/Users/eijkhout/Current/istc/hpc-book-private/hardware/hardware-effects/utils.py", line 53, in benchmark
    times = [float(res) for res in run_repeatable(executable, repeat, values, pin_to_cpu)]
  File "/Users/eijkhout/Current/istc/hpc-book-private/hardware/hardware-effects/utils.py", line 53, in <listcomp>
    times = [float(res) for res in run_repeatable(executable, repeat, values, pin_to_cpu)]
  File "/Users/eijkhout/Current/istc/hpc-book-private/hardware/hardware-effects/utils.py", line 36, in run_repeatable
    stderr=subprocess.PIPE)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'taskset': 'taskset'
Kobzol commented 5 years ago

Hi, my Python benchmark scripts use taskset on Linux and start /affinity on Windows (https://github.com/Kobzol/hardware-effects/blob/master/utils.py#L18) to pin threads to a single CPU core. A quick Google search didn't yield any way of using something similar from a command line on OS X, so I disabled this "feature" on OS X for now (try with the latest master). If you know how to do this simply, please let me know.

VictorEijkhout commented 5 years ago

Thanks. It looks like OS X has an affinity API, but not a commandline utility. Btw, I'm used to numactl on Linux. Will look at taskset.

Kobzol commented 5 years ago

I think that numactl in general is more powerful, but taskset should be built-in on common distros, that's why I used it.