From 6e26358ec3eade9bb35f4dc1ad48b5374cec417d Mon Sep 17 00:00:00 2001 From: Tim Mattox Date: Wed, 1 Mar 2017 11:46:26 -0500 Subject: [PATCH] lib kokkos bugfix: on a CUDA host, the random state wasn't preserved. Random_XorShift*_Pool::free_state() has two purposes: 1) update the state value kept in the pool 2) unlock the state For a CUDA host thread, ONLY skip step 2, not both. --- lib/kokkos/algorithms/src/Kokkos_Random.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kokkos/algorithms/src/Kokkos_Random.hpp b/lib/kokkos/algorithms/src/Kokkos_Random.hpp index d376173bf1..2fb6b553c2 100644 --- a/lib/kokkos/algorithms/src/Kokkos_Random.hpp +++ b/lib/kokkos/algorithms/src/Kokkos_Random.hpp @@ -1204,8 +1204,8 @@ Random_XorShift64 Random_XorShift64_Pool::get_state( template<> KOKKOS_INLINE_FUNCTION void Random_XorShift64_Pool::free_state(const Random_XorShift64 &state) const { -#ifdef __CUDA_ARCH__ state_(state.state_idx_) = state.state_; +#ifdef __CUDA_ARCH__ locks_(state.state_idx_) = 0; return; #endif @@ -1240,9 +1240,9 @@ Random_XorShift1024 Random_XorShift1024_Pool::get_st template<> KOKKOS_INLINE_FUNCTION void Random_XorShift1024_Pool::free_state(const Random_XorShift1024 &state) const { -#ifdef __CUDA_ARCH__ for(int i=0; i<16; i++) state_(state.state_idx_,i) = state.state_[i]; +#ifdef __CUDA_ARCH__ locks_(state.state_idx_) = 0; return; #endif