Parallel python + ??

T

Thor

Hi,

I am running a program using Parallel Python and I wonder if there is a
way/module to know in which CPU/core the process is running in. Is that
possible?

Ángel
 
G

Gerhard Häring

Thor said:
Hi,

I am running a program using Parallel Python and I wonder if there is a
way/module to know in which CPU/core the process is running in. Is that
possible?

This is of course OS-specific. On Linux, you can parse the proc filesystem:
>>> open("/proc/%i/stat" % os.getpid()).read().split()[39]

You can use the "taskset" utility to query or set CPU affinity on Linux.

-- Gerhard
 
T

Thor

Gerhard said:
This is of course OS-specific. On Linux, you can parse the proc
filesystem:
open("/proc/%i/stat" % os.getpid()).read().split()[39]

You can use the "taskset" utility to query or set CPU affinity on Linux.
It is going to be in Linux (mainly) I was thinking about something like
this:

import Module

def process(self):
print "I am running on processor", Module.cpu,"core", Module.core
....
.....

Checking the raskset right now...:) Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top