Open MPI logo

Hardware Locality Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Users mailing list

Subject: Re: [hwloc-users] Is OSX a supported platform ?
From: Wheeler, Kyle Bruce (kbwheel_at_[hidden])
Date: 2010-06-07 15:00:48

On Jun 7, 2010, at 12:15 PM, Samuel Thibault wrote:

> Wheeler, Kyle Bruce, le Mon 07 Jun 2010 10:10:04 -0600, a écrit :
>> As I'm sure you know, while Apple doesn't provide strict "bind to CPU X" functions, they do at least (on Leopard and later) provide the ability to associate tasks/threads together (or explicitly disassociate them).
> Yes, it's an interesting interface.
>> Would it be a good idea to support these as some sort of make-do? Or would it simply prompt too many complaints along the lines of "hey, I said bind to cpu 0 and my program ran on cpu 3! what gives?!?"
> But how would that work? There is no relation with cpus in that
> interface.

True; but you can make each "cpu" a thread set ID. This is easier to explain in code:

void set_affinity(int cpu) {
        mach_msg_type_number_t count = 1;
        thread_affinity_policy_data_t mask[THREAD_AFFINITY_POLICY_COUNT];

        memset(mask, 0, sizeof(mask));
        mask[0].affinity_tag = cpu+1;
        thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY,
                (thread_policy_t) &mask, count);

Kyle B. Wheeler, PhD
Dept. 1423: Scalable System Software
Sandia National Laboratories