Skip to content

Commit

Permalink
Compared float by error tolerance to avoid compiler warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
frobnitzem committed Mar 19, 2021
1 parent 8b68865 commit 70f01ba
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/unit/warp/src/Shfl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ShflSingleThreadWarpTestKernel

ALPAKA_CHECK(*success, alpaka::warp::shfl(acc, 12, 0) == 12);
ALPAKA_CHECK(*success, alpaka::warp::shfl(acc, 42, -1) == 42);
ALPAKA_CHECK(*success, alpaka::warp::shfl(acc, 3.3f, 0) == 3.3f);
float ans = alpaka::warp::shfl(acc, 3.3f, 0);
ALPAKA_CHECK(*success, alpaka::math::abs(acc, ans - 3.3f) < 1e-8f);
}
};

Expand All @@ -48,7 +49,7 @@ class ShflMultipleThreadWarpTestKernel
std::int32_t const warpExtent = alpaka::warp::getSize(acc);
// Test relies on having a single warp per thread block
ALPAKA_CHECK(*success, static_cast<std::int32_t>(blockExtent.prod()) == warpExtent);
int const threadIdxInWarp = alpaka::mapIdx<1u>(localThreadIdx, blockExtent)[0];
auto const threadIdxInWarp = std::int32_t(alpaka::mapIdx<1u>(localThreadIdx, blockExtent)[0]);

ALPAKA_CHECK(*success, warpExtent > 1);

Expand All @@ -66,9 +67,9 @@ class ShflMultipleThreadWarpTestKernel
{
int off = width * (threadIdxInWarp / width);
ALPAKA_CHECK(*success, alpaka::warp::shfl(acc, threadIdxInWarp, idx, width) == idx + off);
ALPAKA_CHECK(
*success,
alpaka::warp::shfl(acc, 4.0f - float(threadIdxInWarp), idx, width) == 4.0f - float(idx + off));
float ans = alpaka::warp::shfl(acc, 4.0f - float(threadIdxInWarp), idx, width);
float expect = 4.0f - float(idx + off);
ALPAKA_CHECK(*success, alpaka::math::abs(acc, ans - expect) < 1e-8f);
}
}

Expand All @@ -80,7 +81,9 @@ class ShflMultipleThreadWarpTestKernel
for(int idx = 0; idx < warpExtent / 2; idx++)
{
ALPAKA_CHECK(*success, alpaka::warp::shfl(acc, threadIdxInWarp, idx) == idx);
ALPAKA_CHECK(*success, alpaka::warp::shfl(acc, 4.0f - float(threadIdxInWarp), idx) == 4.0f - float(idx));
float ans = alpaka::warp::shfl(acc, 4.0f - float(threadIdxInWarp), idx);
float expect = 4.0f - float(idx);
ALPAKA_CHECK(*success, alpaka::math::abs(acc, ans - expect) < 1e-8f);
}
}
};
Expand Down

0 comments on commit 70f01ba

Please sign in to comment.