intel/x86-simd-sort

Benchmarks can't be compiled on older platforms

Closed this issue · 1 comments

When I try to compile the benchmark executable I get the following error from running make meson:

...
FAILED: benchexe
c++  -o benchexe 'benchexe@exe/benchmarks_main.cpp.o' -Wl,--as-needed -Wl,--no-undefined -Wl,--whole-archive -Wl,--start-group benchmarks/libbench_qsort.a utils/libcpuinfo.a -Wl,--no-whole-archive /usr/local/lib/libbenchmark.a -Wl,--end-group
/usr/bin/ld: /usr/local/lib/libbenchmark.a(benchmark_runner.cc.o): in function `benchmark::internal::BenchmarkRunner::DoNIterations()':
benchmark_runner.cc:(.text+0x1418): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
...

This is with v1.8.0 of Google Benchmarks, v1.13.0 of Google's Test Framework. My system is running Ubuntu 20.04 and I have tried both g++-10 and g++-9. Further, the Makefile spits out many errors because my version of GCC can't compile the fp16 files.

I eventually pinned the meson issue down to the fact that my system is running glibc 2.31, where the linker still needs to be explicitly given -pthread or -lpthread to use threading. This flag is present by default for gtest andgtest_main, but Google Benchmark's pkg-config will only expose it when you indicate that it's being linked statically.

The default installation method for both Google's benchmark and testing suite will give a static library, so we should probably be explicitly configuring it as such in the build scripts. As for the Makefile, we could adapt this solution from Stack Overflow to detect when GCC is not new enough for the -march=sapphirerapids flag and exclude the fp16 files.

PR containing the proposed changes is found in #43. Additionally, that PR includes some tweaks to the CI script (don't bother compiling the tests for benchmark) and uses benchmark_main because benchmarks/main.cpp isn't currently doing anything other than that at the moment.