Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: inlining failed in call to always_inline ‘long long int _mm_popcnt_u64(long long unsigned int)’: target specific option mismatch #359

Closed
ckorn opened this issue Jun 29, 2017 · 13 comments

Comments

@ckorn
Copy link

ckorn commented Jun 29, 2017

Hi,

on Ubuntu 17.04 there is this compilation error:

g++ -g -O2 -fdebug-prefix-map=/home/korn/packages/mve/mve-0.0.0+git20170629=. -fstack-protector-strong -Wformat -Werror=format-security -pthread -I../../libs -fopenmp -Wdate-time -D_FORTIFY_SOURCE=2 -c -o pose_p3p.o pose_p3p.cc
In file included from ../../libs/sfm/cascade_hashing.h:20:0,
                 from cascade_hashing.cc:14:
/usr/lib/gcc/x86_64-linux-gnu/6/include/popcntintrin.h: In member function ‘void sfm::CascadeHashing::collect_features_from_buckets(std::vector<std::vector<unsigned int> >*, size_t, std::vector<bool>*, const BucketGroupsBuckets&, const BucketGroupsFeatures&, const uint64_t*, const std::vector<long unsigned int, std::allocator<long unsigned int> >&) const [with int DIMHASH = 128]’:
/usr/lib/gcc/x86_64-linux-gnu/6/include/popcntintrin.h:42:1: error: inlining failed in call to always_inline ‘long long int _mm_popcnt_u64(long long unsigned int)’: target specific option mismatch
 _mm_popcnt_u64 (unsigned long long __X)
 ^~~~~~~~~~~~~~
In file included from cascade_hashing.cc:14:0:
../../libs/sfm/cascade_hashing.h:452:47: note: called from here
                 hamming_dist += _mm_popcnt_u64(comp_hash_data1[k] ^ ptr2[k]);
                                 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../libs/sfm/cascade_hashing.h:20:0,
                 from cascade_hashing.cc:14:
/usr/lib/gcc/x86_64-linux-gnu/6/include/popcntintrin.h:42:1: error: inlining failed in call to always_inline ‘long long int _mm_popcnt_u64(long long unsigned int)’: target specific option mismatch
@flanggut
Copy link
Collaborator

The compile command doesn't activate the popcount intrinsic. What build system do you use?

@ckorn
Copy link
Author

ckorn commented Jun 29, 2017

This is with the make build system.

Here, should have provided the entire build log.
build_log.txt

@flanggut
Copy link
Collaborator

If you use the Makefile provided by MVE this should be the compiler call:

g++ -Wall -Wextra -Wundef -pedantic -msse2 -msse3 -mpopcnt -funsafe-math-optimizations -fno-math-errno -std=c++11 -g -O3 -pthread -I../../libs   -c -o cascade_hashing.o cascade_hashing.cc

There's definitely something wrong with your build system.

@simonfuhrmann
Copy link
Owner

Are you compiling on a 32 bit system? What does uname -m say?

@HelliceSaouli
Copy link

Out of topic but Ubuntu 17.04 is not LTS and it will never be stable thus you will straggle using it a specially if you are working on computer graphics and vision problem ( lack of good gpu drivers) i suggest you use 14.04 LTS so stable version of Ubuntu

@ckorn
Copy link
Author

ckorn commented Jun 30, 2017

Ok, seems the build system has overridden the defaults in Makefile.inc. Had to apply this patch to make it work:
http://sprunge.us/jMfg

Thanks for your hints.

Now the build succeeds on amd64. But there is this build error now on i386:

../../libs/sfm/cascade_hashing.h:452:47: error: ‘_mm_popcnt_u64’ was not declared in this scope

Could you please have a look? Here is the build log:
build_log.txt

@simonfuhrmann
Copy link
Owner

@andre-schulz

@flanggut
Copy link
Collaborator

flanggut commented Jul 6, 2017

just a guess but this is the only thing I could find: _mm_popcnt_u64 is only available on 64bit systems. how old is your machine?

@andre-schulz
Copy link
Collaborator

As @flanggut guessed correctly, _mm_popcnt_u64() is only available when compiling a 64-bit binary (see popcntintrin.h). AFAIK, compiling MVE in 32-bit mode is not supported. Is that correct, @simonfuhrmann?

@simonfuhrmann
Copy link
Owner

It was never explicitly unsupported, as we were not aware that it doesn't compile on 32 bit anymore. But using it on a 32 bit system is somewhat useless, since it allows you to make use of 4 GB of memory only. Which is usually not enough. It would be nice if we could replace (or ifdef) this function to make it work on 32 bit machines, but if it's not possible, it's not the worst thing in the world to drop 32 bit support.

@simonfuhrmann
Copy link
Owner

@andre-schulz, can we make this work on 32 bit machines?

@andre-schulz
Copy link
Collaborator

Yes, I just have to find a way to do this cleanly.

@LinusVanElswijk
Copy link
Contributor

You could use std::bitset::count. It should automatically use the best popcount instruction available.

/** Returns the number of one bits of an integer. */
template <typename T>
inline std::size_t
popcount (T const& x)
{
    static_assert(std::is_integral<T>::value, "T must be an integral type.");
    const std::bitset<sizeof(T) * 8> bits(x);
    return bits.count();
}

You can explore resulting binaries here: https://godbolt.org/g/McZWwU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants