OpenSolaris

Discussions Communities Projects Download Source Browser

Home » OpenSolaris Forums » hpcdev » discuss

Thread: How to assign a task to a specific cpu?

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Oct 29, 2008 10:11 AM by: lololo Threads: [ Previous | Next ]
lololo

Posts: 26
From:

Registered: 10/25/08
How to assign a task to a specific cpu?
Posted: Oct 28, 2008 12:32 PM
To: Communities » hpcdev » discuss
  Click to reply to this thread Reply

In linux, I can use "taskset" to assign a task to whichever cpu I want:
taskset -c 0 a.out
then a.out is assigned to be execute on the first cpu.

In Solaris, I find the command "pbind" can bind pid to some cpu, but it is inconvenient:
SYNOPSIS
pbind -b processor_id pid
if I want to assign a.out to cpu 0,
what should I do?
I don't even know the pid of a.out before it executes.

rugrat

Posts: 650
From: US

Registered: 3/9/05
Re: [hpcdev-discuss] How to assign a task to a specific cpu?
Posted: Oct 28, 2008 12:50 PM   in response to: lololo

  Click to reply to this thread Reply

kevin wrote:
> In linux, I can use "taskset" to assign a task to whichever cpu I want:
> taskset -c 0 a.out
> then a.out is assigned to be execute on the first cpu.
>
> In Solaris, I find the command "pbind" can bind pid to some cpu, but it is inconvenient:
> SYNOPSIS
> pbind -b processor_id pid
> if I want to assign a.out to cpu 0,
> what should I do?
> I don't even know the pid of a.out before it executes.
>
Use processor sets. Example:

// Create a processor set of just CPU #3
# psrset -c 3
created processor set 1
processor 3: was not assigned, now 1
#

// Execute a program on processor set #1
# psrset -e 1 ./a.out

// Verify the binding to CPU #3
# prstat

PID USERNAME SIZE RSS STATE PRI NICE TIME CPU
PROCESS/NLWP
11871 root 52M 51M cpu3 0 0 0:02:22 25% a.out/1


_______________________________________________
hpcdev-discuss mailing list
hpcdev-discuss at opensolaris dot org
http://mail.opensolaris.org/mailman/listinfo/hpcdev-discuss


eugenelo

Posts: 7
From: US

Registered: 10/4/06
Re: [hpcdev-discuss] How to assign a task to a specific cpu?
Posted: Oct 28, 2008 1:00 PM   in response to: rugrat

  Click to reply to this thread Reply

John Martin wrote:
<pre wrap="">kevin wrote: </pre>
<pre wrap="">In linux, I can use "taskset" to assign a task to whichever cpu I want: taskset -c 0 a.out then a.out is assigned to be execute on the first cpu. In Solaris, I find the command "pbind" can bind pid to some cpu, but it is inconvenient: SYNOPSIS pbind -b processor_id pid if I want to assign a.out to cpu 0, what should I do? I don't even know the pid of a.out before it executes. </pre>
<pre wrap=""><!---->Use processor sets.</pre>
I don't know if that requires root privileges or if Kevin has root privileges.

Another alternative is to bind the launching shell.  E.g.,

% pbind -b <whereveryouwant> $$
% ./a.out

The launching shell could move.  E.g.,

% pbind -b 8 $$
% ./a.out &
% pbind -u $$

The launching shell ends up unbound (or rebound somewhere else if you like), but a.out stays on 8.
_______________________________________________ hpcdev-discuss mailing list hpcdev-discuss at opensolaris dot org http://mail.opensolaris.org/mailman/listinfo/hpcdev-discuss


lololo

Posts: 26
From:

Registered: 10/25/08
Re: [hpcdev-discuss] How to assign a task to a specific cpu?
Posted: Oct 28, 2008 7:01 PM   in response to: eugenelo
To: Communities » hpcdev » discuss
  Click to reply to this thread Reply

Thanks John.

Just now I find out "pbind" also need to be a root, and I don't have the privilege.

I want to check the examples on textbook about the difference between shared L2 cache multicore cpu and private L2 cache multicore cpu. The examples are all written for the Linux environment, but machines with Xeon/Opteron/UltraSparc cpus available to me are all run Solaris, and I am just a user without any privilege.

rechabit

Posts: 5
From: AU

Registered: 7/17/06
Re: [hpcdev-discuss] How to assign a task to a specific cpu?
Posted: Oct 28, 2008 7:17 PM   in response to: lololo

  Click to reply to this thread Reply

The pbind(1M) manpage spells out the circumstances when you need to be
root. From
the description given below, this shouldn't be necessary to be root.
When I'm exploring
cache behaviour for example, I routinely use processor_bind(2) to ensure
my thread(s)
and data are where I want them. All of this is done as an ordinary user.
I do give
myself cpc_cpu privilege for when I want to run cpustat, but more
commonly I embed
calls to libcpc functions and use only the virtual counters (e.g.
cpc_bind_curlwp
instead of cpc_bind_cpu).

kevin wrote:
> Thanks John.
>
> Just now I find out "pbind" also need to be a root, and I don't have the privilege.
>
> I want to check the examples on textbook about the difference between shared L2 cache multicore cpu and private L2 cache multicore cpu. The examples are all written for the Linux environment, but machines with Xeon/Opteron/UltraSparc cpus available to me are all run Solaris, and I am just a user without any privilege.


--
============================================================================< br /> ,-_|\ Richard Smith Staff Engineer PAE
/ \ Sun Microsystems Phone : +61 3 9869 6200
richard dot smith at Sun dot COM Direct : +61 3 9869 6224
\_,-._/ 476 St Kilda Road Fax : +61 3 9869 6290
v Melbourne Vic 3004 Australia
===========================================================================
_______________________________________________
hpcdev-discuss mailing list
hpcdev-discuss at opensolaris dot org
http://mail.opensolaris.org/mailman/listinfo/hpcdev-discuss


lololo

Posts: 26
From:

Registered: 10/25/08
Re: [hpcdev-discuss] How to assign a task to a specific cpu?
Posted: Oct 29, 2008 10:11 AM   in response to: rechabit
To: Communities » hpcdev » discuss
  Click to reply to this thread Reply

Thanks a lot, it's really helpful.




Terms of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.
© 2010, Oracle Corporation and/or its affiliates

Oracle