forked from OSchip/llvm-project
[OpenMP] affinity little fix for FreeBSD
- pthread affinity np has different semantic than sched affinity counterpart. On success returns strictly 0. Reviewers: chandlerc, AndreyChurbanov, jdoerfert Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D72132
This commit is contained in:
parent
a17ad3592f
commit
ea99c09963
|
@ -303,8 +303,9 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
int retval =
|
||||
syscall(__NR_sched_getaffinity, 0, __kmp_affin_mask_size, mask);
|
||||
#elif KMP_OS_FREEBSD
|
||||
int retval =
|
||||
int r =
|
||||
pthread_getaffinity_np(pthread_self(), __kmp_affin_mask_size, reinterpret_cast<cpuset_t *>(mask));
|
||||
int retval = (r == 0 ? 0 : -1);
|
||||
#endif
|
||||
if (retval >= 0) {
|
||||
return 0;
|
||||
|
@ -322,8 +323,9 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
int retval =
|
||||
syscall(__NR_sched_setaffinity, 0, __kmp_affin_mask_size, mask);
|
||||
#elif KMP_OS_FREEBSD
|
||||
int retval =
|
||||
int r =
|
||||
pthread_setaffinity_np(pthread_self(), __kmp_affin_mask_size, reinterpret_cast<cpuset_t *>(mask));
|
||||
int retval = (r == 0 ? 0 : -1);
|
||||
#endif
|
||||
if (retval >= 0) {
|
||||
return 0;
|
||||
|
|
|
@ -164,7 +164,7 @@ void __kmp_affinity_determine_capable(const char *env_var) {
|
|||
if (gCode > 0) { // Linux* OS only
|
||||
// The optimal situation: the OS returns the size of the buffer it expects.
|
||||
//
|
||||
// A verification of correct behavior is that Isetaffinity on a NULL
|
||||
// A verification of correct behavior is that setaffinity on a NULL
|
||||
// buffer with the same size fails with errno set to EFAULT.
|
||||
sCode = syscall(__NR_sched_setaffinity, 0, gCode, NULL);
|
||||
KA_TRACE(30, ("__kmp_affinity_determine_capable: "
|
||||
|
@ -286,7 +286,7 @@ void __kmp_affinity_determine_capable(const char *env_var) {
|
|||
if (gCode == 0) {
|
||||
KMP_AFFINITY_ENABLE(KMP_CPU_SET_SIZE_LIMIT);
|
||||
KA_TRACE(10, ("__kmp_affinity_determine_capable: "
|
||||
"affinity supported (mask size %d)\n"<
|
||||
"affinity supported (mask size %d)\n",
|
||||
(int)__kmp_affin_mask_size));
|
||||
KMP_INTERNAL_FREE(buf);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue