Skip to content

common/math fails to compile on linux on ARM #577

@ap2468

Description

@ap2468

The following MWE fails to compile due to a couple issues.

// file test.cpp
#include <iostream>
#include <math/vec3.h>
#include <math/vec3fa.h>

int main() {
    embree::Vec3fa vec(1.0,2.0,3.0);
    std::cout << vec << std::endl;
    return 0;
}

compiled with g++ -I./embree/common -I./embree/include -O3 -DNDEBUG -std=gnu++17 ./test.cpp -o test results in a couple errors:

  1. Missing definitions:
In file included from ./embree/common/math/vec3.h:262,
                 from ./test.cpp:4:
./embree/common/math/vec3fa.h: At global scope:
./embree/common/math/vec3fa.h:52:44: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
   52 |     __forceinline explicit operator const  Vec2fa() const { return Vec2fa(m128); }
      |                                            ^~~~~~
./embree/common/math/vec3fa.h:52:28: error: ‘operator const int’ does not name a type
   52 |     __forceinline explicit operator const  Vec2fa() const { return Vec2fa(m128); }
      |                            ^~~~~~~~
./embree/common/math/vec3fa.h:474:44: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
  474 |     __forceinline explicit operator const  Vec2fa() const { return Vec2fa(m128); }
      |                                            ^~~~~~
./embree/common/math/vec3fa.h:474:28: error: ‘operator const int’ does not name a type
  474 |     __forceinline explicit operator const  Vec2fa() const { return Vec2fa(m128); }
      |                            ^~~~~~~~
  1. some conversion errors, e.g.:
In file included from ./embree/common/math/../sys/../simd/arm/emulation.h:27,
                 from ./embree/common/math/../sys/intrinsics.h:13,
                 from ./embree/common/math/emath.h:7,
                 from ./embree/common/math/vec3.h:6,
                 from ./test.cpp:4:
./embree/common/math/../sys/../simd/arm/avx2neon.h: In function ‘__m256i _mm256_setzero_si256()’:
./embree/common/math/../sys/../simd/arm/avx2neon.h:161:36: note: use ‘-flax-vector-conversions’ to permit conversions between vectors with differing element types or numbers of subparts
  161 |     res.lo = res.hi = vdupq_n_s32(0);
      |                                    ^
./embree/common/math/../sys/../simd/arm/avx2neon.h:161:34: error: cannot convert ‘int32x4_t’ to ‘__m128i’ {aka ‘int64x2_t’} in assignment
  161 |     res.lo = res.hi = vdupq_n_s32(0);
      |                       ~~~~~~~~~~~^~~
      |                                  |
      |                                  int32x4_t
./embree/common/math/../sys/../simd/arm/avx2neon.h: In function ‘__m256i _mm256_castsi128_si256(__m128i)’:
./embree/common/math/../sys/../simd/arm/avx2neon.h:206:25: error: cannot convert ‘int32x4_t’ to ‘__m128i’ {aka ‘int64x2_t’} in assignment
  206 |     res.hi = vdupq_n_s32(0);
      |              ~~~~~~~~~~~^~~
      |                         |
      |                         int32x4_t
./embree/common/math/../sys/../simd/arm/avx2neon.h: In function ‘__m256i _mm256_set1_epi32(int)’:
./embree/common/math/../sys/../simd/arm/avx2neon.h:249:34: error: cannot convert ‘int32x4_t’ to ‘__m128i’ {aka ‘int64x2_t’} in assignment
  249 |     res.lo = res.hi = vdupq_n_s32(a);
      |                       ~~~~~~~~~~~^~~
      |                                  |
      |                                  int32x4_t
./embree/common/math/../sys/../simd/arm/avx2neon.h: In function ‘__m256i _mm256_set1_epi8(int)’:
./embree/common/math/../sys/../simd/arm/avx2neon.h:256:33: error: cannot convert ‘int8x16_t’ to ‘__m128i’ {aka ‘int64x2_t’} in assignment
  256 |     res.lo = res.hi = vdupq_n_s8(a);
      |                       ~~~~~~~~~~^~~
      |                                 |
      |                                 int8x16_t
./embree/common/math/../sys/../simd/arm/avx2neon.h: In function ‘__m256i _mm256_set1_epi16(int)’:
./embree/common/math/../sys/../simd/arm/avx2neon.h:263:34: error: cannot convert ‘int16x8_t’ to ‘__m128i’ {aka ‘int64x2_t’} in assignment
  263 |     res.lo = res.hi = vdupq_n_s16(a);
      |                       ~~~~~~~~~~~^~~
      |                                  |
      |                                  int16x8_t
./embree/common/math/../sys/../simd/arm/avx2neon.h: In function ‘__m256i _mm256_abs_epi32(__m256i)’:
./embree/common/math/../sys/../simd/arm/avx2neon.h:436:25: error: cannot convert ‘__m128i’ {aka ‘int64x2_t’} to ‘int32x4_t’
  436 |    res.lo = vabsq_s32(a.lo);
      |                       ~~^~
      |                         |
      |                         __m128i {aka int64x2_t}

The first error can be fixed by including

#include <math/vec2.h>
#include <math/vec2fa.h>

Should these be included in vec3.h?

The second can be fixed by adding -flax-vector-conversions to the compile flags, but maybe the fixes that were used to address #410 in the main library can also be applied to the code in common?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions