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

External dependency nlohmann/json.hpp fails to build under Intel compiler icpc with warnings as error #9

Open
mlxd opened this issue May 18, 2021 · 6 comments
Labels
bug 🐛 Something isn't working

Comments

@mlxd
Copy link
Member

mlxd commented May 18, 2021

  • Expected behavior: The external library nlohmann/json.hpp should compile and link without any modifications required.

  • Actual behavior: Compiling with the classic intel compiler (icpc) causes several errors to be reported (see below).

  • Reproduces how often: Only when building with icpc (2021.2.0 20210228) on Niagara.

  • System information: Niagara HPC system, using the Jet benchmark for the TBCC.

Source code and backtraces

Please include any additional code snippets and backtraces related to the issue here.

Additional information

Any additional information, configuration or data that might be necessary to reproduce the issue.

[ 50%] Building CXX object CMakeFiles/tbcc.dir/tbcc_benchmark.cpp.o
/cvmfs/restricted.computecanada.ca/easybuild/software/2020/Core/intel/2021.2.0/compiler/2021.2.0/linux/bin/intel64/icpc   -I/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include -I/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/imkl/2021.2.0/mkl/2021.2.0/include -I/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/taskflow-src  -O3 -DNDEBUG   -Wall -Wextra -Werror -march=native -DENABLE_MKL -qopenmp -std=gnu++17 -o CMakeFiles/tbcc.dir/tbcc_benchmark.cpp.o -c /home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/tbcc_benchmark.cpp
/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/external/nlohmann/json.hpp(4697): error #1011: missing return statement at end of non-void function "nlohmann::detail::hash(const BasicJsonType &)"
  }
  ^

/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/external/nlohmann/json.hpp(16141): error #186: pointless comparison of unsigned integer with zero
          const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0); // see issue #755
                                                                                            ^
          detected during:
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump_integer(NumberType) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={__int64_t={signed long}}, uint64_t={__uint64_t={unsigned long}}, double, std::allocator, nlohmann::adl_serializer, std::vector<uint8_t={__uint8_t={unsigned char}}, std::allocator<uint8_t={__uint8_t={unsigned char}}>>>, NumberType=uint8_t={__uint8_t={unsigned char}}, <unnamed>=0]" at line 15703
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType &, bool, bool, unsigned int, unsigned int) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={__int64_t={signed long}}, uint64_t={__uint64_t={unsigned long}}, double, std::allocator, nlohmann::adl_serializer, std::vector<uint8_t={__uint8_t={unsigned char}}, std::allocator<uint8_t={__uint8_t={unsigned char}}>>>]" at line 18769
            instantiation of "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::dump(int, char, bool, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType,
                      NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::error_handler_t={nlohmann::detail::error_handler_t}) const [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool, NumberIntegerType=int64_t={__int64_t={signed long}}, NumberUnsignedType=uint64_t={__uint64_t={unsigned long}}, NumberFloatType=double, AllocatorType=std::allocator, JSONSerializer=nlohmann::adl_serializer,
                      BinaryType=std::vector<uint8_t={__uint8_t={unsigned char}}, std::allocator<uint8_t={__uint8_t={unsigned char}}>>]" at line 254 of "/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/TensorNetworkIO.hpp"
            instantiation of "std::vector<S, std::allocator<S>> Jet::TensorNetworkSerializer<Tensor>::TensorDataFromJSON_<S>(const Jet::json &, size_t={unsigned long}) [with Tensor=Jet::Tensor<std::complex<float>>, S=std::complex<float>]" at line 153 of "/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/TensorNetworkIO.hpp"
            instantiation of "Jet::TensorNetworkFile<Tensor> Jet::TensorNetworkSerializer<Tensor>::operator()(std::string) [with Tensor=Jet::Tensor<std::complex<float>>]" at line 34 of "/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/tbcc_benchmark.cpp"

/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/external/nlohmann/json.hpp(16141): error #186: pointless comparison of unsigned integer with zero
          const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0); // see issue #755
                                                                                            ^
          detected during:
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump_integer(NumberType) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={__int64_t={signed long}}, uint64_t={__uint64_t={unsigned long}}, double, std::allocator, nlohmann::adl_serializer, std::vector<uint8_t={__uint8_t={unsigned char}}, std::allocator<uint8_t={__uint8_t={unsigned char}}>>>, NumberType=uint64_t={__uint64_t={unsigned long}}, <unnamed>=0]" at line 15775
            instantiation of "void nlohmann::detail::serializer<BasicJsonType>::dump(const BasicJsonType &, bool, bool, unsigned int, unsigned int) [with BasicJsonType=nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t={__int64_t={signed long}}, uint64_t={__uint64_t={unsigned long}}, double, std::allocator, nlohmann::adl_serializer, std::vector<uint8_t={__uint8_t={unsigned char}}, std::allocator<uint8_t={__uint8_t={unsigned char}}>>>]" at line 18769
            instantiation of "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::dump(int, char, bool, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType,
                      NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::error_handler_t={nlohmann::detail::error_handler_t}) const [with ObjectType=std::map, ArrayType=std::vector, StringType=std::string, BooleanType=bool, NumberIntegerType=int64_t={__int64_t={signed long}}, NumberUnsignedType=uint64_t={__uint64_t={unsigned long}}, NumberFloatType=double, AllocatorType=std::allocator, JSONSerializer=nlohmann::adl_serializer,
                      BinaryType=std::vector<uint8_t={__uint8_t={unsigned char}}, std::allocator<uint8_t={__uint8_t={unsigned char}}>>]" at line 254 of "/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/TensorNetworkIO.hpp"
            instantiation of "std::vector<S, std::allocator<S>> Jet::TensorNetworkSerializer<Tensor>::TensorDataFromJSON_<S>(const Jet::json &, size_t={unsigned long}) [with Tensor=Jet::Tensor<std::complex<float>>, S=std::complex<float>]" at line 153 of "/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/_deps/jet-src/include/jet/TensorNetworkIO.hpp"
            instantiation of "Jet::TensorNetworkFile<Tensor> Jet::TensorNetworkSerializer<Tensor>::operator()(std::string) [with Tensor=Jet::Tensor<std::complex<float>>]" at line 34 of "/home/s/sipejohn/mlxd/TMP/jet_benchmarks/benchmarks/Jet_TBCC/tbcc_benchmark.cpp"

The Jet benchmark Jet_TBCC was built and failed with the commands:

cmake . -DCMAKE_CXX_COMPILER=icpc -DENABLE_NATIVE=1 -DENABLE_OPENMP=1
make VERBOSE=1

and succeeded with

cmake . -DCMAKE_CXX_COMPILER=icpc -DENABLE_NATIVE=1 -DENABLE_OPENMP=1 -DENABLE_WARNINGS=0
make VERBOSE=1
@mlxd mlxd added the bug 🐛 Something isn't working label May 18, 2021
@Mandrenkov
Copy link
Collaborator

Nice catch! Given that the library is under an MIT license, I think we are allowed to fix these errors in our copy of the header.

@trevor-vincent
Copy link
Contributor

trevor-vincent commented May 19, 2021

Weird I haven't had any problem running the serializer on niagara with the intel compiler, but I usually compile with a one-liner command. I will take more of a look.

@mlxd
Copy link
Member Author

mlxd commented May 19, 2021

Weird I haven't had any problem running the serializer on niagara with the intel compiler, but I usually compile with a one-liner command. I will take more of a look.

Does your build enable warnings as errors? This could also be tied to the version of the Intel compiler I am using, as I did not test it with others available on the system.

@mlxd
Copy link
Member Author

mlxd commented May 19, 2021

Nice catch! Given that the library is under an MIT license, I think we are allowed to fix these errors in our copy of the header.

This may be a good idea. Any thoughts on whether we just fix it locally, or consider creating a PR against the repo?

@Mandrenkov
Copy link
Collaborator

Any thoughts on whether we just fix it locally, or consider creating a PR against the repo?

Ideally, we should do both; however, our first priority is fixing the copy in the Jet repository.

@mlxd
Copy link
Member Author

mlxd commented Aug 11, 2021

Just a note on this, Intel is phasing out the icc compiler in favour of the newer LLVM-backed compiler (icx), and requests all users to port to the newer suite. This issue can likely be ignored when the classica compiler is no longer supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants