Skip to content

Commit

Permalink
[RNG] Fix warnings in device API and example (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelizaro authored Nov 28, 2024
1 parent c0cef0c commit c00154c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions examples/rng/device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ foreach(rng_device_source ${RNG_DEVICE_SOURCES})
)

if(NOT ${ONEMKL_SYCL_IMPLEMENTATION} STREQUAL "hipsycl")
# set strict warning flags for rng device API examples
target_compile_options(example_${domain}_${rng_device_source} PUBLIC -Wall -Werror -Wextra -Wpedantic -Wunreachable-code -Wfloat-conversion -Wextra-semi -Wshadow)
target_link_options(example_${domain}_${rng_device_source} PUBLIC -fsycl -fsycl-device-code-split=per_kernel)
endif()

Expand Down
4 changes: 2 additions & 2 deletions examples/rng/device/include/rng_example_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ auto get_multi_ptr(T acc) {
#else
return acc.get_pointer();
#endif
};
}

template <typename T, typename std::enable_if<!has_member_code_meta<T>::value>::type* = nullptr>
auto get_multi_ptr(T acc) {
Expand All @@ -45,6 +45,6 @@ auto get_multi_ptr(T acc) {
#else
return acc.get_pointer();
#endif
};
}

#endif // _RNG_EXAMPLE_HELPER_HPP__
2 changes: 1 addition & 1 deletion examples/rng/device/uniform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int run_example(sycl::queue& queue) {

int err = 0;
Type res_host;
for (int i = 0; i < n; i++) {
for (std::size_t i = 0; i < n; i++) {
res_host = oneapi::mkl::rng::device::generate(distr, engine);
if (res_host != r_dev[i]) {
std::cout << "error in " << i << " element " << res_host << " " << r_dev[i]
Expand Down
5 changes: 2 additions & 3 deletions include/oneapi/mkl/rng/device/detail/beta_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,8 @@ class distribution_base<oneapi::mkl::rng::device::beta<RealType, Method>> {
flInv = RealType(1.0) / (q_ + flW);
flTmp[0] = flKoef1 * flInv;
flTmp[1] = flU1 * flU1 * flU2;
for (int i = 0; i < 2; i++) {
flTmp[i] = ln_wrapper(flTmp[i]);
}
flTmp[0] = ln_wrapper(flTmp[0]);
flTmp[1] = ln_wrapper(flTmp[1]);

if (flKoef1 * flTmp[0] + flKoef3 * flV - log4<RealType>() >= flTmp[1]) {
z[i] = flW * flInv;
Expand Down
2 changes: 0 additions & 2 deletions include/oneapi/mkl/rng/device/detail/uniform_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class distribution_base<oneapi::mkl::rng::device::uniform<Type, Method>> {
return generate_single_int<FpType, OutType>(engine);

if constexpr (EngineType::vec_size == 1) {
std::uint32_t res_1, res_2;
std::uint64_t res_64, leftover;

generate_leftover<EngineType>(
Expand Down Expand Up @@ -270,7 +269,6 @@ class distribution_base<oneapi::mkl::rng::device::uniform<Type, Method>> {
return res;
}

std::uint32_t res_1, res_2;
std::uint64_t res_64, leftover;

generate_leftover<EngineType>(
Expand Down

0 comments on commit c00154c

Please sign in to comment.