__builtin_assume_aligned is not portable, breaking IBM XL

Issue #248 resolved
Paul Hargrove created an issue

I tried the IBM XL compilers on Summit, now that PGI support has been merged.
I hit the following:

/autofs/nccs-svm1_home1/hargrove/upcxx/.nobs/art/2962a4074e7b6322fe5e6784d65e5fabfd0e55f7/upcxx/utility.hpp:77:17: error: 1540-2993 The builtin "__builtin_assume_aligned" is not supported.
    std::memcpy(__builtin_assume_aligned(dst, align),
                ^

That appears to be the only problem preventing at least rudimentary support for IBM's compilers!

I apply the following change (Yes, I know it defeats the purpose of the function):

--- a/src/utility.hpp
+++ b/src/utility.hpp
@@ -74,8 +74,8 @@ namespace detail {

   template<std::size_t align>
   inline void memcpy_aligned(void *dst, void const *src, std::size_t sz) noexcept {
-    std::memcpy(__builtin_assume_aligned(dst, align),
-                __builtin_assume_aligned(src, align), sz);
+    std::memcpy(dst,
+                src, sz);
   }

   //////////////////////////////////////////////////////////////////////////////

Then the following works on Summit!

$ module load xl/16.1.1-1
$ export CC='xlc -F/ccs/home/hargrove/xlc.cfg.gcc.6.4.0'
$ export CXX='xlC -F/ccs/home/hargrove/xlc.cfg.gcc.6.4.0'
$ UPCXX_INSTALL_NOCHECK=1 ./install inst-xlc
[... lots of unknown Pragma warnings ...]
UPC++ successfully installed

I've not attempted to build or run any tests with the XL compilers, but that's not really the point of this issue.

Comments (5)

  1. Paul Hargrove reporter

    Resolve issue 248 with __builtin_assume_aligned

    This commit adds a configure-time probe for compiler support for __builtin_assume_aligned() and uses it to avoid use of this builtin when it is not supported.

    → <<cset 42ce1919c308>>

  2. Log in to comment