Mandatory/Default Seed

Force use to seed the RNG when instantiate ArrayHandlePhiloxURBG, default
to std::random_device when using make_ArrayHandlePhiloxURBG.
This commit is contained in:
Li-Ta Lo 2020-03-18 14:36:09 -06:00
parent 130a11c3b0
commit c7e57e2fe0
3 changed files with 5 additions and 7 deletions

@ -1,6 +1,3 @@
//
// Created by ollie on 3/12/20.
//
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
@ -13,6 +10,7 @@
#ifndef vtk_m_cont_ArrayHandlePhiloxURBG_h
#define vtk_m_cont_ArrayHandlePhiloxURBG_h
#include <random>
#include <vtkm/cont/ArrayHandleImplicit.h>
#include <vtkm/prng/Philox.h>
@ -63,7 +61,7 @@ public:
VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandlePhiloxURBG,
(vtkm::cont::ArrayHandleImplicit<detail::PhiloxFunctor>));
explicit ArrayHandlePhiloxURBG(vtkm::Id length, SeedType seed = {})
explicit ArrayHandlePhiloxURBG(vtkm::Id length, SeedType seed)
: Superclass(detail::PhiloxFunctor(seed), length)
{
}
@ -76,7 +74,7 @@ public:
/// type safety for the parameters so user will not transpose two integer parameters.
VTKM_CONT vtkm::cont::ArrayHandlePhiloxURBG make_ArrayHandlePhiloxURBG(
vtkm::Id length,
vtkm::Vec<vtkm::UInt32, 1> seed = { 0 })
vtkm::Vec<vtkm::UInt32, 1> seed = { std::random_device{}() })
{
return vtkm::cont::ArrayHandlePhiloxURBG(length, seed);
}

@ -13,7 +13,7 @@
void TestArrayHandlePhiloxURBG()
{
auto actual0 = vtkm::cont::make_ArrayHandlePhiloxURBG(10);
auto actual0 = vtkm::cont::make_ArrayHandlePhiloxURBG(10, { 0 });
// result from Random123 sample implementation of philox2x32x10
std::vector<vtkm::UInt64> expected0{ 0x6cd10df2ff1dae59, 0x5f3adb6bdcdce855, 0x3fbb6394049f6998,
0xbd592d1202a74512, 0x8a115b62c08084ef, 0x1411803b3bb7eefa,

@ -26,7 +26,7 @@ VTKM_EXEC_CONT vtkm::Vec<vtkm::UInt32, 2> mulhilo(vtkm::UInt32 a, vtkm::UInt32 b
return { lo, hi };
}
constexpr VTKM_EXEC_CONT vtkm::Vec<vtkm::UInt64, 2> mulhilo(vtkm::UInt64 a, vtkm::UInt64 b)
VTKM_EXEC_CONT vtkm::Vec<vtkm::UInt64, 2> mulhilo(vtkm::UInt64 a, vtkm::UInt64 b)
{
#ifdef VTKM_CUDA
vtkm::UInt64 lo = a * b;