simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.34k stars 243 forks source link

PGI C Compiler bugs #12

Open nemequ opened 7 years ago

nemequ commented 7 years ago

There are a decent number of issues in PGI we are currently working around in SIMDe, this is a meta-bug for tracking them. I've reported them to PGI, just waiting on fixes.

I'll try to keep this list updated as we add new functions.

General:

MMX:

SSE:

SSE2:

AVX2:

Some of these functions (annotated above with "fixable") can be fixed with trivial changes to the headers in question.

--- emmintrin-orig.h   2017-05-07 20:32:21.726746806 -0700
+++ emmintrin.h   2017-05-08 19:05:51.769286452 -0700
@@ -758,7 +758,7 @@

   __u.__v = __A;

-  return __u.__a[1];
+  return __u.__a[0];
 }

 /* Create the vector [Y Z].  */
@@ -2360,7 +2360,7 @@
 ATTRIBUTE __m128i
 _mm_mulhi_epu16(__m128i __A, __m128i __B)
 {
-  __asm__("PMULHW %1, %0" : "=x"(__A) : "x"(__B), "0"(__A));
+  __asm__("PMULHUW %1, %0" : "=x"(__A) : "x"(__B), "0"(__A));
   return __A;
 }

Some other functions could probably be fixed like this, too, but I haven't checked them all.

nemequ commented 4 years ago

I haven't really been reporting these lately since I can't log in to the PGI forum, but I should probably write them down somewhere… here is another one:

#include <mmintrin.h>
#include <stdint.h>

typedef union {
  int8_t v[8];
  __m64 mmx;
} not_m64;

static_assert(sizeof(not_m64) == sizeof(__m64));
static_assert(alignof(not_m64) == alignof(__m64));

__m64 add_raw_mmx(__m64 a, __m64 b) {
  return _mm_add_pi8(a, b);
}

not_m64 add_mmx(not_m64 a, not_m64 b) {
  not_m64 r;

  r.mmx = _mm_add_pi8(a.mmx, b.mmx);

  return r;
}

pgcc works pgc++ doesn't:

PGCC-F-0000-Internal compiler error. process_formal_arguments: Function argument with mismatched size that is neither integer nor floating-point       0  (df.cpp: 22)
PGCC/x86-64 Linux 19.10-0: compilation aborted

So PGI isn't going to work in C++ until #72 is done.

nemequ commented 4 years ago

Another one: __STDC_HOSTED__ isn't defined. I think it should probably be defined to 1 since AFAICT PGI does meet all the requirements of a hosted implementation, but it definitely shouldn't be undefined.

nemequ commented 4 years ago

Reduced version of the (an?) issue preventing PGI in C++ mode from compiling SIMDe:

#include <emmintrin.h>
typedef struct { __m64 mmx; } simde_int8x8_t;
int fn1(simde_int8x8_t p1) { return 0; }
nemequ@ubuntu:~$ pgc++ -o pgi-ice pgi-ice.cpp
PGCC-F-0000-Internal compiler error. process_formal_arguments: Function argument with mismatched size that is neither integer nor floating-point       0  (pgi-ice.cpp: 3)
PGCC/x86-64 Linux 19.10-0: compilation aborted

Reported