Skip to content

Conversation

JonathanC-ARM
Copy link
Contributor

Description

When compiling with micro-benchmark on Mac Mini M4 I encounter the following build failure

Build command

./build.sh --config Release --build_shared_lib --parallel --skip_tests --osx_arch arm64 --apple_deploy_target 14 --apple_sysroot macosx --build_micro_benchmarks --cmake_generator Ninja --cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON

System Information

-- The C compiler identification is AppleClang 17.0.0.17000013
-- The CXX compiler identification is AppleClang 17.0.0.17000013
-- The ASM compiler identification is AppleClang
Mac Mini M4
Os Version 15.4.1

Build Failure

[1487/1608] Building CXX object CMakeFiles/onnxruntime_benchmark.dir/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc.o
FAILED: [code=1] CMakeFiles/onnxruntime_benchmark.dir/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc.o
/usr/bin/c++ -DBENCHMARK_STATIC_DEFINE -DCPUINFO_SUPPORTED -DCPUINFO_SUPPORTED_PLATFORM=1 -DEIGEN_MPL2_ONLY -DEIGEN_USE_THREADS -DONLY_C_LOCALE=0 -DONNX_ML=1 -DONNX_NAMESPACE=onnx -DONNX_USE_LITE_PROTO=1 -DORT_ENABLE_STREAM -DPLATFORM_POSIX -DUSE_KLEIDIAI -D__ONNX_NO_DOC_STRINGS -I/Users/jonclo01/onnxruntime/include/onnxruntime -I/Users/jonclo01/onnxruntime/include/onnxruntime/core/session -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/pytorch_cpuinfo-src/include -I/Users/jonclo01/onnxruntime/build/MacOS/Release -I/Users/jonclo01/onnxruntime/onnxruntime -I/Users/jonclo01/onnxruntime/onnxruntime/core/mlas/inc -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/google_benchmark-src/include -I/Users/jonclo01/onnxruntime/onnxruntime/test/util/include -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/abseil_cpp-src -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/date-src/include -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/nlohmann_json-src/include -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/onnx-src -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/onnx-build -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/protobuf-src/src -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/re2-src -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/flatbuffers-src/include -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/eigen3-src -I/Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/kleidiai-src -isystem /Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/safeint-src -isystem /Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/gsl-src/include -isystem /Users/jonclo01/onnxruntime/build/MacOS/Release/_deps/mp11-src/include -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -std=gnu++20 -arch arm64 -fPIE -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-copy -Wno-tautological-pointer-compare -Wno-ambiguous-reversed-operator -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-undefined-var-template -Wno-deprecated-builtins -Wno-deprecated-literal-operator -Wshorten-64-to-32 -Wno-error=comment -Werror -MD -MT CMakeFiles/onnxruntime_benchmark.dir/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc.o -MF CMakeFiles/onnxruntime_benchmark.dir/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc.o.d -o CMakeFiles/onnxruntime_benchmark.dir/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc.o -c /Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc
/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc:38:10: error: variable 'sum' set but not used [-Werror,-Wunused-but-set-variable]
   38 |   size_t sum = 0;
      |          ^
/Users/jonclo01/onnxruntime/onnxruntime/test/onnx/microbenchmark/tptest.cc:105:48: error: increment of object of volatile-qualified type 'volatile size_t' (aka 'volatile unsigned long') is deprecated [-Werror,-Wdeprecated-volatile]
  105 |         for (volatile size_t x = 0; x < body; x++) {
      |                                                ^
2 errors generated.

Summary of Changes

  • C++ 20 is the standard CXX version as defined in CMakeLists.txt for Apple Devices. Incrementing of Volatile is no longer supported in this version, removed qualifier and added appropriate substitute.
  • Add [[ maybe_unused ]] to suppress unused variable warning for sum variable

Signed-off-by: Jonathan Clohessy <Jonathan.Clohessy@arm.com>
@hariharans29
Copy link
Member

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

#endif
void SimpleForLoop(ptrdiff_t first, ptrdiff_t last) {
size_t sum = 0;
[[maybe_unused]] size_t sum = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the compiler is warning about it, could it also be "smart" enough to optimize it away? should we also do something similar to the other change in the PR with benchmark::DoNotOptimize()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah possibly worth doing that, its unclear what the compiler will do. Its possible that its optimizing it away in older versions where this warning isn't being thrown. But I will check if benchmark::DoNotOptimize(sum) silences the warning and if so i'll make that change. (I assume it will)

@hariharans29
Copy link
Member

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

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

Successfully merging this pull request may close these issues.

3 participants