[Openmp-commits] [PATCH] D123194: [OpenMP] libomp: fix alignment issue in dist barrier on non-x86
Misono Tomohiro via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Apr 6 02:27:11 PDT 2022
t-msn created this revision.
Herald added subscribers: guansong, kristof.beyls, yaxunl.
Herald added a project: All.
t-msn added a reviewer: tlwilmar.
t-msn added a project: OpenMP.
t-msn added a subscriber: openmp-commits.
t-msn published this revision for review.
t-msn added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
I noticed this when running check-openmp with dist barrier by using https://reviews.llvm.org/D122645
Following tsan warning appears on arm64 when using dist barrier:
1: ==603732==ERROR: ThreadSanitizer: invalid alignment requested in aligned_alloc: 1024,\
alignment must be a power of two and the requested size 0x900 must be a multiple of alignment
As the message says, roundup the size to be passed in alinged_alloc to fix this.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123194
Files:
openmp/runtime/src/kmp_barrier.h
Index: openmp/runtime/src/kmp_barrier.h
===================================================================
--- openmp/runtime/src/kmp_barrier.h
+++ openmp/runtime/src/kmp_barrier.h
@@ -21,7 +21,11 @@
#define KMP_ALIGNED_ALLOCATE(size, alignment) _mm_malloc(size, alignment)
#define KMP_ALIGNED_FREE(ptr) _mm_free(ptr)
#elif KMP_HAVE_ALIGNED_ALLOC
-#define KMP_ALIGNED_ALLOCATE(size, alignment) aligned_alloc(alignment, size)
+static inline size_t roundup(size_t val, size_t to) {
+ return (val + to - 1) / to * to;
+}
+#define KMP_ALIGNED_ALLOCATE(size, alignment) \
+ aligned_alloc(alignment, roundup(size, alignment))
#define KMP_ALIGNED_FREE(ptr) free(ptr)
#elif KMP_HAVE_POSIX_MEMALIGN
static inline void *KMP_ALIGNED_ALLOCATE(size_t size, size_t alignment) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123194.420746.patch
Type: text/x-patch
Size: 806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220406/6adb3b8b/attachment.bin>
More information about the Openmp-commits
mailing list