[Openmp-commits] [PATCH] D51944: openmp: Use glibc wrappers for accessing cpu affinity mask
Tom Stellard via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Sep 11 11:03:31 PDT 2018
tstellar created this revision.
tstellar added a reviewer: jlpeyton.
Herald added a subscriber: guansong.
This fixes almost all the lit tests on ppc64 big-endian. Prior to this patch,
the affinity masks were printed like this on a 8-core system:
OMP: Info #154: KMP_AFFINITY: Initial OS proc set respected: {56,57,58,59,60,61,62,63}
The downside of this patch is that it probably won't compile with other
libc implementations as I'm not sure how widely implemented these wrappers are.
Repository:
rOMP OpenMP
https://reviews.llvm.org/D51944
Files:
runtime/src/kmp_affinity.h
Index: runtime/src/kmp_affinity.h
===================================================================
--- runtime/src/kmp_affinity.h
+++ runtime/src/kmp_affinity.h
@@ -248,32 +248,29 @@
__kmp_free(mask);
}
void set(int i) override {
- mask[i / BITS_PER_MASK_T] |= ((mask_t)1 << (i % BITS_PER_MASK_T));
+ CPU_SET(i, (cpu_set_t*)mask);
}
bool is_set(int i) const override {
- return (mask[i / BITS_PER_MASK_T] & ((mask_t)1 << (i % BITS_PER_MASK_T)));
+ return CPU_ISSET(i, (cpu_set_t*)mask);
}
void clear(int i) override {
- mask[i / BITS_PER_MASK_T] &= ~((mask_t)1 << (i % BITS_PER_MASK_T));
+ CPU_CLR(i, (cpu_set_t*)mask);
}
void zero() override {
- for (size_t i = 0; i < __kmp_affin_mask_size; ++i)
- mask[i] = 0;
+ CPU_ZERO((cpu_set_t*)mask);
}
void copy(const KMPAffinity::Mask *src) override {
const Mask *convert = static_cast<const Mask *>(src);
for (size_t i = 0; i < __kmp_affin_mask_size; ++i)
mask[i] = convert->mask[i];
}
void bitwise_and(const KMPAffinity::Mask *rhs) override {
const Mask *convert = static_cast<const Mask *>(rhs);
- for (size_t i = 0; i < __kmp_affin_mask_size; ++i)
- mask[i] &= convert->mask[i];
+ CPU_AND((cpu_set_t*)mask, (cpu_set_t*)mask, (cpu_set_t*)(convert->mask));
}
void bitwise_or(const KMPAffinity::Mask *rhs) override {
const Mask *convert = static_cast<const Mask *>(rhs);
- for (size_t i = 0; i < __kmp_affin_mask_size; ++i)
- mask[i] |= convert->mask[i];
+ CPU_OR((cpu_set_t*)mask, (cpu_set_t*)mask, (cpu_set_t*)(convert->mask));
}
void bitwise_not() override {
for (size_t i = 0; i < __kmp_affin_mask_size; ++i)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51944.164935.patch
Type: text/x-patch
Size: 1775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180911/063e7c31/attachment.bin>
More information about the Openmp-commits
mailing list