/* TODO: seems to be right, but doesn't seem to be working (EINVAL), even after * aligning the range on 64K... */ static int hwloc_aix_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) { subrange_t subrange; rsid_t rsid = { .at_subrange = &subrange }; uint_t aix_policy; int ret; fprintf(stderr,"yop\n"); if ((flags & (HWLOC_MEMBIND_MIGRATE|HWLOC_MEMBIND_STRICT)) == (HWLOC_MEMBIND_MIGRATE|HWLOC_MEMBIND_STRICT)) { errno = ENOSYS; return -1; } subrange.su_offset = (uintptr_t) addr; subrange.su_length = len; subrange.su_rstype = R_RSET; if (hwloc_aix_membind_policy_from_hwloc(&aix_policy, policy)) return -1; if (hwloc_aix_prepare_membind(topology, &subrange.su_rsid.at_rset, nodeset, flags)) return -1; subrange.su_policy = aix_policy; ret = ra_attachrset(R_SUBRANGE, rsid, subrange.su_rsid.at_rset, 0); rs_free(subrange.su_rsid.at_rset); return ret; }
static int hwloc_aix_set_sth_cpubind(hwloc_topology_t topology, rstype_t what, rsid_t who, hwloc_const_bitmap_t hwloc_set, int flags __hwloc_attribute_unused) { rsethandle_t rad; int res; unsigned cpu; if (flags & HWLOC_CPUBIND_NOMEMBIND) { errno = ENOSYS; return -1; } /* The resulting binding is always strict */ if (hwloc_bitmap_isequal(hwloc_set, hwloc_topology_get_complete_cpuset(topology))) { if (ra_detachrset(what, who, 0)) return -1; return 0; } rad = rs_alloc(RS_EMPTY); hwloc_bitmap_foreach_begin(cpu, hwloc_set) rs_op(RS_ADDRESOURCE, rad, NULL, R_PROCS, cpu); hwloc_bitmap_foreach_end(); res = ra_attachrset(what, who, rad, 0); rs_free(rad); return res; }
static int hwloc_aix_set_sth_membind(hwloc_topology_t topology, rstype_t what, rsid_t who, hwloc_const_bitmap_t nodeset, hwloc_membind_policy_t policy, int flags) { rsethandle_t rad; int res; if (flags & HWLOC_MEMBIND_NOCPUBIND) { errno = ENOSYS; return -1; } switch (policy) { case HWLOC_MEMBIND_DEFAULT: case HWLOC_MEMBIND_BIND: break; default: errno = ENOSYS; return -1; } if (hwloc_aix_prepare_membind(topology, &rad, nodeset, flags)) return -1; res = ra_attachrset(what, who, rad, 0); rs_free(rad); return res; }
/* TODO: seems to be right, but doesn't seem to be working (EINVAL), even after * aligning the range on 64K... */ static int hwloc_aix_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) { subrange_t subrange; rsid_t rsid = { .at_subrange = &subrange }; uint_t aix_policy; int ret; fprintf(stderr,"yop\n"); if ((flags & (HWLOC_MEMBIND_MIGRATE|HWLOC_MEMBIND_STRICT)) == (HWLOC_MEMBIND_MIGRATE|HWLOC_MEMBIND_STRICT)) { errno = ENOSYS; return -1; } subrange.su_offset = (uintptr_t) addr; subrange.su_length = len; subrange.su_rstype = R_RSET; if (hwloc_aix_membind_policy_from_hwloc(&aix_policy, policy)) return -1; if (hwloc_aix_prepare_membind(topology, &subrange.su_rsid.at_rset, nodeset, flags)) return -1; subrange.su_policy = aix_policy; res = ra_attachrset(R_SUBRANGE, rsid, subrange.su_rsid.at_rset, 0); if (res < 0 && errno == EPERM) { /* EPERM may mean that one thread has ben bound with bindprocessor(). * Unbind the entire process (we can't unbind individual threads) * and try again. * FIXME: actually check that this EPERM can happen */ bindprocessor(BINDPROCESS, getpid(), PROCESSOR_CLASS_ANY); res = ra_attachrset(R_SUBRANGE, rsid, subrange.su_rsid.at_rset, 0); } rs_free(subrange.su_rsid.at_rset); return ret; }
static int hwloc_aix_set_sth_cpubind(hwloc_topology_t topology, rstype_t what, rsid_t who, pid_t pid, hwloc_const_bitmap_t hwloc_set, int flags __hwloc_attribute_unused) { rsethandle_t rad; int res; unsigned cpu; if (flags & HWLOC_CPUBIND_NOMEMBIND) { errno = ENOSYS; return -1; } /* The resulting binding is always strict */ if (hwloc_bitmap_isequal(hwloc_set, hwloc_topology_get_complete_cpuset(topology))) { if (ra_detachrset(what, who, 0)) return -1; return 0; } rad = rs_alloc(RS_EMPTY); hwloc_bitmap_foreach_begin(cpu, hwloc_set) rs_op(RS_ADDRESOURCE, rad, NULL, R_PROCS, cpu); hwloc_bitmap_foreach_end(); res = ra_attachrset(what, who, rad, 0); if (res < 0 && errno == EPERM) { /* EPERM may mean that one thread has ben bound with bindprocessor(). * Unbind the entire process (we can't unbind individual threads) * and try again. */ bindprocessor(BINDPROCESS, pid, PROCESSOR_CLASS_ANY); res = ra_attachrset(what, who, rad, 0); } rs_free(rad); return res; }
static int hwloc_aix_set_sth_membind(hwloc_topology_t topology, rstype_t what, rsid_t who, pid_t pid, hwloc_const_bitmap_t nodeset, hwloc_membind_policy_t policy, int flags) { rsethandle_t rad; int res; if (flags & HWLOC_MEMBIND_NOCPUBIND) { errno = ENOSYS; return -1; } switch (policy) { case HWLOC_MEMBIND_DEFAULT: case HWLOC_MEMBIND_BIND: break; default: errno = ENOSYS; return -1; } if (hwloc_aix_prepare_membind(topology, &rad, nodeset, flags)) return -1; res = ra_attachrset(what, who, rad, 0); if (res < 0 && errno == EPERM) { /* EPERM may mean that one thread has ben bound with bindprocessor(). * Unbind the entire process (we can't unbind individual threads) * and try again. */ bindprocessor(BINDPROCESS, pid, PROCESSOR_CLASS_ANY); res = ra_attachrset(what, who, rad, 0); } rs_free(rad); return res; }