p12tic / libsimdpp

Portable header-only C++ low level SIMD library
Boost Software License 1.0
1.24k stars 129 forks source link

Does not compile without warnings MSVC2013, AVX2 #54

Closed sphet closed 7 years ago

sphet commented 7 years ago

Simply including simd.h causing a bunch of warnings; we compile with warnings as errors so we can't use this library:

C:\playground\test\libsimdpp\simdpp/detail/expr/scalar.h(48): warning C4244: '=' : conversion from 'const double' to 'simdpp::arch_avx::any_float32<4,simdpp::arch_avx::float32<4,void>>::element

C:\playground\test\libsimdpp\simdpp/detail/insn/shuffle2x2.h(318): warning C4556: value of intrinsic immediate argument '334' is out of range '0 - 255'

And on and on. Any plans to make this library compile without warnings? Some of the overflow values are worrisome.

Repro:

arch:avx2, MSVC2013

include "stdafx.h"

define SIMDPP_ARCH_X86_AVX

include "simdpp/simd.h"

int main(int argc, _TCHAR* argv[]) { return 0; }

doomtr666 commented 7 years ago

Hello, With VS2017 (x86_64):

`

define SIMDPP_ARCH_X86_SSE2

include

include "simdpp/simd.h"

using namespace simdpp;

int main() { float32x4 v1 = make_float(1.0f, 2.0f, 3.0f, 4.0f); float32x4 v2 = make_float(5.0f, 6.0f, 7.0f, 8.0f);

float r[4];
store_u(r, v1 + v2);
std::cout << "[" << r[0] << ", " << r[1] << ", " <<  r[2] << ", " << r[3] << "]" << std::endl;

return 0;

} `

I get 15 warnings, mostly in shuffle2x2.h. I wonder if some of them are not so harmless ? Christophe

1>------ Build started: Project: libsimdpp_tests, Configuration: Release x64 ------ 1>libsimdpptests.cpp 1>D:\Dev\libsimdpp\simdpp/detail/expr/scalar.h(48): warning C4244: '=': conversion from 'const double' to 'simdpp::arch_sse2::any_float32<4,simdpp::arch_sse2::float32<4,void>>::element_type', possible loss of data 1>D:\Dev\libsimdpp\simdpp/types/generic.inl(18): note: see reference to function template instantiation 'R simdpp::arch_sse2::detail::expr_eval<simdpp::arch_sse2::float32<4,void>,double>(const simdpp::arch_sse2::expr_scalar<double> &)' being compiled 1> with 1> [ 1> R=simdpp::arch_sse2::float32<4,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/types/generic.inl(18): note: while compiling class template member function 'simdpp::arch_sse2::float32<4,void> simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_scalar<double>>::eval(void) const' 1>D:\Dev\libsimdpp\simdpp/detail/expr/f_sub.h(26): note: see reference to function template instantiation 'simdpp::arch_sse2::float32<4,void> simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_scalar<double>>::eval(void) const' being compiled 1>D:\Dev\libsimdpp\simdpp/types/generic.inl(18): note: see reference to function template instantiation 'simdpp::arch_sse2::float32<4,void> simdpp::arch_sse2::detail::expr_eval<simdpp::arch_sse2::float32<4,void>,simdpp::arch_sse2::expr_scalar<double>,void>(const simdpp::arch_sse2::expr_sub<simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_scalar<double>>,simdpp::arch_sse2::float32<4,void>> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/types/generic.inl(18): note: while compiling class template member function 'simdpp::arch_sse2::float32<4,void> simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_sub<simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_scalar<double>>,simdpp::arch_sse2::float32<4,void>>>::eval(void) const' 1>D:\Dev\libsimdpp\simdpp/types/float32x4.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::float32<4,void> simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_sub<simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_scalar<double>>,simdpp::arch_sse2::float32<4,void>>>::eval(void) const' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/f_rcp_rh.h(45): note: see reference to function template instantiation 'simdpp::arch_sse2::float32<4,void> &simdpp::arch_sse2::float32<4,void>::operator =<V>(const simdpp::arch_sse2::any_vec<16,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_sub<simdpp::arch_sse2::float32<4,simdpp::arch_sse2::expr_scalar<double>>,simdpp::arch_sse2::float32<4,void>>> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(344): warning C4556: value of intrinsic immediate argument '334' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/core/shuffle1.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,void> simdpp::arch_sse2::detail::insn::i_shuffle2x2<1,2>(const simdpp::arch_sse2::uint64<2,void> &,const simdpp::arch_sse2::uint64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(213): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,simdpp::arch_sse2::expr_empty> simdpp::arch_sse2::shuffle1<1,0,2,V,V>(const simdpp::arch_sse2::any_vec64<2,V> &,const simdpp::arch_sse2::any_vec64<2,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(362): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v_mem_unpack3_impl16_128<simdpp::arch_sse2::uint16<8,void>>(T &,T &,T &)' being compiled 1> with 1> [ 1> T=simdpp::arch_sse2::uint16<8,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/load_packed3.h(254): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::mem_unpack3<8>(simdpp::arch_sse2::uint16<8,void> &,simdpp::arch_sse2::uint16<8,void> &,simdpp::arch_sse2::uint16<8,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/load_packed3.h(76): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v128_load_packed3<simdpp::arch_sse2::uint16x8>(V &,V &,V &,const char *)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint16x8 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(346): warning C4556: value of intrinsic immediate argument '334' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(372): warning C4556: value of intrinsic immediate argument '-2' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(141): warning C4556: value of intrinsic immediate argument '-1' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/core/shuffle1.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::float64<2,void> simdpp::arch_sse2::detail::insn::i_shuffle2x2<1,2>(const simdpp::arch_sse2::float64<2,void> &,const simdpp::arch_sse2::float64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(284): note: see reference to function template instantiation 'simdpp::arch_sse2::float64<2,simdpp::arch_sse2::expr_empty> simdpp::arch_sse2::shuffle1<1,0,2,V,V>(const simdpp::arch_sse2::any_vec64<2,V> &,const simdpp::arch_sse2::any_vec64<2,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::float64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(390): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v_mem_unpack3_impl64_128<simdpp::arch_sse2::float64<2,void>>(T &,T &,T &)' being compiled 1> with 1> [ 1> T=simdpp::arch_sse2::float64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/load_packed3.h(254): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::mem_unpack3<2>(simdpp::arch_sse2::float64<2,void> &,simdpp::arch_sse2::float64<2,void> &,simdpp::arch_sse2::float64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/load_packed3.h(223): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v128_load_packed3<simdpp::arch_sse2::float64x2>(V &,V &,V &,const char *)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::float64x2 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(151): warning C4556: value of intrinsic immediate argument '-2' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(344): warning C4556: value of intrinsic immediate argument '484' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/core/shuffle1.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,void> simdpp::arch_sse2::detail::insn::i_shuffle2x2<0,3>(const simdpp::arch_sse2::uint64<2,void> &,const simdpp::arch_sse2::uint64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(283): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,simdpp::arch_sse2::expr_empty> simdpp::arch_sse2::shuffle1<0,1,2,V,V>(const simdpp::arch_sse2::any_vec64<2,V> &,const simdpp::arch_sse2::any_vec64<2,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(376): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v_mem_unpack3_impl64_128<simdpp::arch_sse2::uint64<2,void>>(T &,T &,T &)' being compiled 1> with 1> [ 1> T=simdpp::arch_sse2::uint64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/load_packed3.h(254): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::mem_unpack3<2>(simdpp::arch_sse2::uint64<2,void> &,simdpp::arch_sse2::uint64<2,void> &,simdpp::arch_sse2::uint64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/load_packed3.h(138): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v128_load_packed3<simdpp::arch_sse2::uint64x2>(V &,V &,V &,const char *)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint64x2 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(346): warning C4556: value of intrinsic immediate argument '484' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(372): warning C4556: value of intrinsic immediate argument '-1' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(141): warning C4556: value of intrinsic immediate argument '-2' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/core/shuffle1.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::float64<2,void> simdpp::arch_sse2::detail::insn::i_shuffle2x2<0,3>(const simdpp::arch_sse2::float64<2,void> &,const simdpp::arch_sse2::float64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_unpack.h(283): note: see reference to function template instantiation 'simdpp::arch_sse2::float64<2,simdpp::arch_sse2::expr_empty> simdpp::arch_sse2::shuffle1<0,1,2,V,V>(const simdpp::arch_sse2::any_vec64<2,V> &,const simdpp::arch_sse2::any_vec64<2,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::float64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(151): warning C4556: value of intrinsic immediate argument '-1' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(344): warning C4556: value of intrinsic immediate argument '324' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/core/shuffle1.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,void> simdpp::arch_sse2::detail::insn::i_shuffle2x2<0,2>(const simdpp::arch_sse2::uint64<2,void> &,const simdpp::arch_sse2::uint64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_pack.h(355): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,simdpp::arch_sse2::expr_empty> simdpp::arch_sse2::shuffle1<0,0,2,V,V>(const simdpp::arch_sse2::any_vec64<2,V> &,const simdpp::arch_sse2::any_vec64<2,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_pack.h(443): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v_mem_pack3_impl64_128<simdpp::arch_sse2::uint64<2,void>>(T &,T &,T &)' being compiled 1> with 1> [ 1> T=simdpp::arch_sse2::uint64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/store_packed3.h(259): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::mem_pack3<2>(simdpp::arch_sse2::uint64<2,void> &,simdpp::arch_sse2::uint64<2,void> &,simdpp::arch_sse2::uint64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/store_packed3.h(146): note: see reference to function template instantiation 'void simdpp::arch_sse2::detail::insn::v128_store_pack3<simdpp::arch_sse2::uint64x2>(char *,const V &,const V &,const V &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint64x2 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(346): warning C4556: value of intrinsic immediate argument '324' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(344): warning C4556: value of intrinsic immediate argument '494' is out of range '0 - 255' 1>D:\Dev\libsimdpp\simdpp/core/shuffle1.h(58): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,void> simdpp::arch_sse2::detail::insn::i_shuffle2x2<1,3>(const simdpp::arch_sse2::uint64<2,void> &,const simdpp::arch_sse2::uint64<2,void> &)' being compiled 1>D:\Dev\libsimdpp\simdpp/detail/insn/mem_pack.h(357): note: see reference to function template instantiation 'simdpp::arch_sse2::uint64<2,simdpp::arch_sse2::expr_empty> simdpp::arch_sse2::shuffle1<1,1,2,V,V>(const simdpp::arch_sse2::any_vec64<2,V> &,const simdpp::arch_sse2::any_vec64<2,V> &)' being compiled 1> with 1> [ 1> V=simdpp::arch_sse2::uint64<2,void> 1> ] 1>D:\Dev\libsimdpp\simdpp/detail/insn/shuffle2x2.h(346): warning C4556: value of intrinsic immediate argument '494' is out of range '0 - 255' 1>Generating code 1>All 32 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. 1>Finished generating code 1>libsimdpp_tests.vcxproj -> D:\Dev\libsimdpp_tests\x64\Release\libsimdpp_tests.exe 1>libsimdpp_tests.vcxproj -> D:\Dev\libsimdpp_tests\x64\Release\libsimdpp_tests.pdb (Full PDB) 1>Done building project "libsimdpp_tests.vcxproj". ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

p12tic commented 7 years ago

Thanks for reporting the issue.

The warnings were in code paths that were never actually executed and optimized out. A workaround to enforce expected ranges of immediate arguments has been applied in 1bfaed15e4d12f288de1478b9287b8bef987355b.

doomtr666 commented 7 years ago

Thanks for the fix !