Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/xsimd/arch/generic/xsimd_generic_logical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace xsimd
// popcount instruction depending on the arch...
XSIMD_IF_CONSTEXPR(batch_bool<T, A>::size <= 32)
{
uint32_t m32 = m;
uint32_t m32 = static_cast<uint32_t>(m);
// https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
m32 = m32 - ((m32 >> 1) & 0x55555555); // reuse input as temporary
m32 = (m32 & 0x33333333) + ((m32 >> 2) & 0x33333333); // temp
Expand Down
2 changes: 1 addition & 1 deletion include/xsimd/arch/xsimd_sse2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ namespace xsimd
*/
namespace detail
{
XSIMD_INLINE int mask_lut(int mask)
XSIMD_INLINE int mask_lut(uint64_t mask)
{
// clang-format off
static const int mask_lut[256] = {
Expand Down
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ set(TARGET_ARCH "native" CACHE STRING "Target architecture arguments")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
if (NOT WIN32 AND NOT ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32")
endif()
# Users may override the c++ standard:
if(NOT DEFINED CMAKE_CXX_STANDARD OR "${CMAKE_CXX_STANDARD}" STREQUAL "")
if (ENABLE_XTL_COMPLEX)
Expand Down
11 changes: 9 additions & 2 deletions test/test_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,16 @@ struct xsimd_api_test
template <class T>
void test_set_impl(const std::string& name)
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#endif
T v = T(1);
batch_type expected(v);
batch_type res = xsimd::broadcast<value_type>(v);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
INFO(name);
CHECK_BATCH_EQ(res, expected);
}
Expand All @@ -187,8 +194,8 @@ struct xsimd_api_test
{
vec.resize(size);

value_type min = value_type(0);
value_type max = value_type(100);
int min = 0;
int max = 100;

std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(min, max);
Expand Down
2 changes: 1 addition & 1 deletion test/test_basic_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct basic_math_test
{
lhs[i] = value_type(i) / 4 + value_type(1.2) * std::sqrt(value_type(i + 0.25)) + value_type(1.);
rhs[i] = value_type(10.2) / (i + 2) + value_type(0.25) + value_type(1.);
clip_input[i] = i * value_type(0.25);
clip_input[i] = static_cast<value_type>(i) * value_type(0.25);
from_input[i] = rhs[i] - value_type(1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ struct batch_test
{
if (std::is_integral<value_type>::value)
{
return ((long long)l + r) / 2;
return static_cast<value_type>(((long long)l + r) / 2);
}
else
{
Expand All @@ -764,7 +764,7 @@ struct batch_test
{
if (std::is_integral<value_type>::value)
{
return ((long long)l + r) / 2 + ((long long)(l + r) & 1);
return static_cast<value_type>(((long long)l + r) / 2 + ((long long)(l + r) & 1));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion test/test_batch_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct constant_batch_test
{
static constexpr value_type get(size_t index, size_t /*size*/)
{
return index;
return static_cast<value_type>(index);
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/test_batch_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ struct batch_int_test
lhs = batch_type(std::numeric_limits<value_type>::max());
for (int32_t i = 0; i < s; ++i)
{
res = lhs >> value_type(i);
res = lhs >> i;
value_type expected = std::numeric_limits<value_type>::max() >> i;
for (std::size_t j = 0; j < size; ++j)
{
Expand Down
2 changes: 1 addition & 1 deletion test/test_batch_manip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace xsimd
/* Generate input data */
for (std::size_t i = 0; i < N; ++i)
{
lhs_in[i] = 2 * i + 1;
lhs_in[i] = static_cast<T>(2 * i + 1);
}
vects.push_back(std::move(lhs_in));

Expand Down
2 changes: 1 addition & 1 deletion test/test_fp_manipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct fp_manipulation_test
array_type expected;
std::transform(input.cbegin(), input.cend(), expected.begin(),
[this](const value_type& v)
{ return std::ldexp(v, exponent); });
{ return std::ldexp(v, static_cast<int>(exponent)); });
batch_type res = xsimd::ldexp(batch_input(), bexp);
INFO("ldexp");
CHECK_BATCH_EQ(res, expected);
Expand Down
4 changes: 2 additions & 2 deletions test/test_load_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ struct load_store_test
{
vec.resize(size);

value_type min = value_type(0);
value_type max = value_type(100);
int min = 0;
int max = 100;

std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(min, max);
Expand Down
16 changes: 8 additions & 8 deletions test/test_shuffle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace
/* Generate input data: lhs, rhs */
for (size_t i = 0; i < N; ++i)
{
lhs_in[i] = 'A' + 2 * i + 1;
rhs_in[i] = 'A' + 2 * i;
lhs_in[i] = static_cast<T>('A' + 2 * i + 1);
rhs_in[i] = static_cast<T>('A' + 2 * i);
}
vects.push_back(std::move(lhs_in));
vects.push_back(std::move(rhs_in));
Expand Down Expand Up @@ -288,7 +288,7 @@ struct compress_test
{
for (size_t i = 0; i < size; ++i)
{
input[i] = i;
input[i] = static_cast<value_type>(i);
}
}

Expand Down Expand Up @@ -360,11 +360,11 @@ TEST_CASE_TEMPLATE("[compress]", B, BATCH_FLOAT_TYPES, xsimd::batch<uint32_t>, x
}
// SUBCASE("interleave")
//{
// Test.interleave();
// Test.interleave();
// }
// SUBCASE("generic")
//{
// Test.generic();
// Test.generic();
// }
}

Expand All @@ -384,7 +384,7 @@ struct expand_test
{
for (size_t i = 0; i < size; ++i)
{
input[i] = i;
input[i] = static_cast<value_type>(i);
}
}

Expand Down Expand Up @@ -479,8 +479,8 @@ struct shuffle_test
{
for (size_t i = 0; i < size; ++i)
{
lhs[i] = i;
rhs[i] = i + size;
lhs[i] = static_cast<value_type>(i);
rhs[i] = static_cast<value_type>(i + size);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/test_xsimd_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ struct xsimd_api_float_types_functions
{
value_type val0(4);
xsimd::as_integer_t<value_type> val1(2);
CHECK_EQ(extract(xsimd::ldexp(T(val0), xsimd::as_integer_t<T>(val1))), std::ldexp(val0, val1));
using exponent_type = typename std::conditional<std::is_scalar<T>::value, int, xsimd::as_integer_t<T>>::type;
CHECK_EQ(extract(xsimd::ldexp(T(val0), exponent_type(val1))), std::ldexp(val0, static_cast<int>(val1)));
}
void test_lgamma()
{
Expand Down