/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.2.0/library/include/rocrand/rocrand.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.2.0/library/include/rocrand/rocrand.hpp Source File#

API library: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.2.0/library/include/rocrand/rocrand.hpp Source File
API library
rocrand.hpp
1 // Copyright (c) 2017-2024 Advanced Micro Devices, Inc. All rights reserved.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef ROCRAND_HPP_
22 #define ROCRAND_HPP_
23 
24 // At least C++11 required
25 #if defined(__cplusplus) && __cplusplus >= 201103L
26 
27  #include "rocrand/rocrand.h"
28  #include "rocrand/rocrand_kernel.h"
29 
30  #include <exception>
31  #include <limits>
32  #include <random>
33  #include <sstream>
34  #include <string>
35  #include <type_traits>
36 
37  #include <cassert>
38 
39 namespace rocrand_cpp {
40 
43 
49 class error : public std::exception
50 {
51 public:
54 
58  explicit error(error_type error) noexcept
59  : m_error(error),
60  m_error_string(to_string(error))
61  {
62  }
63 
65  error_type error_code() const noexcept
66  {
67  return m_error;
68  }
69 
71  std::string error_string() const noexcept
72  {
73  return m_error_string;
74  }
75 
77  const char* what() const noexcept override
78  {
79  return m_error_string.c_str();
80  }
81 
88  static std::string to_string(error_type error)
89  {
90  switch(error)
91  {
93  return "Success";
95  return "Header file and linked library version do not match";
97  return "Generator was not created using rocrand_create_generator";
99  return "Memory allocation failed during execution";
101  return "Generator type is wrong";
103  return "Argument out of range";
105  return "Length requested is not a multiple of dimension";
107  return "GPU does not have double precision";
109  return "Kernel launch failure";
111  return "Internal library error";
112  default: {
113  std::stringstream s;
114  s << "Unknown rocRAND error (" << error << ")";
115  return s.str();
116  }
117  }
118  }
119 
121  friend
122  bool operator==(const error& l, const error& r)
123  {
124  return l.error_code() == r.error_code();
125  }
126 
128  friend
129  bool operator!=(const error& l, const error& r)
130  {
131  return !(l == r);
132  }
133 
134 private:
135  error_type m_error;
136  std::string m_error_string;
137 };
138 
144 template<class IntType = unsigned int>
146 {
147  static_assert(std::is_same<unsigned char, IntType>::value
148  || std::is_same<unsigned short, IntType>::value
149  || std::is_same<unsigned long long int, IntType>::value
150  || std::is_same<unsigned int, IntType>::value,
151  "Only unsigned char, unsigned short, unsigned int and unsigned long long int "
152  "types are supported in uniform_int_distribution");
153 
154 public:
156  typedef IntType result_type;
157 
160  {
161  }
162 
164  static void reset()
165  {
166  }
167 
169  static constexpr IntType min()
170  {
171  return 0;
172  }
173 
175  static constexpr IntType max()
176  {
177  return std::numeric_limits<IntType>::max();
178  }
179 
197  template<class Generator>
198  void operator()(Generator& g, IntType * output, size_t size)
199  {
200  rocrand_status status;
201  status = this->generate(g, output, size);
202  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
203  }
204 
207  {
208  (void) other;
209  return true;
210  }
211 
214  {
215  return !(*this == other);
216  }
217 
218 private:
219  template<class Generator>
220  static rocrand_status generate(Generator& g, unsigned char * output, size_t size)
221  {
222  return rocrand_generate_char(g.m_generator, output, size);
223  }
224 
225  template<class Generator>
226  static rocrand_status generate(Generator& g, unsigned short * output, size_t size)
227  {
228  return rocrand_generate_short(g.m_generator, output, size);
229  }
230 
231  template<class Generator>
232  static rocrand_status generate(Generator& g, unsigned int * output, size_t size)
233  {
234  return rocrand_generate(g.m_generator, output, size);
235  }
236 
237  template<class Generator>
238  static rocrand_status generate(Generator& g, unsigned long long int* output, size_t size)
239  {
240  return rocrand_generate_long_long(g.m_generator, output, size);
241  }
242 };
243 
249 
250 template<class RealType = float>
252 {
253  static_assert(
254  std::is_same<float, RealType>::value
255  || std::is_same<double, RealType>::value
256  || std::is_same<half, RealType>::value,
257  "Only float, double, and half types are supported in uniform_real_distribution"
258  );
259 
260 public:
262  typedef RealType result_type;
263 
266  {
267  }
268 
270  static void reset()
271  {
272  }
273 
275  static constexpr RealType min()
276  {
277  return static_cast<RealType>(ROCRAND_2POW32_INV_DOUBLE);
278  }
279 
281  static constexpr RealType max()
282  {
283  return 1.0;
284  }
285 
303  template<class Generator>
304  void operator()(Generator& g, RealType * output, size_t size)
305  {
306  rocrand_status status;
307  status = this->generate(g, output, size);
308  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
309  }
310 
313  {
314  (void) other;
315  return true;
316  }
317 
320  {
321  return !(*this == other);
322  }
323 
324 private:
325  template<class Generator>
326  static rocrand_status generate(Generator& g, float * output, size_t size)
327  {
328  return rocrand_generate_uniform(g.m_generator, output, size);
329  }
330 
331  template<class Generator>
332  static rocrand_status generate(Generator& g, double * output, size_t size)
333  {
334  return rocrand_generate_uniform_double(g.m_generator, output, size);
335  }
336 
337  template<class Generator>
338  static rocrand_status generate(Generator& g, half * output, size_t size)
339  {
340  return rocrand_generate_uniform_half(g.m_generator, output, size);
341  }
342 };
343 
349 template<class RealType = float>
351 {
352  static_assert(
353  std::is_same<float, RealType>::value
354  || std::is_same<double, RealType>::value
355  || std::is_same<half, RealType>::value,
356  "Only float, double and half types are supported in normal_distribution"
357  );
358 
359 public:
361  typedef RealType result_type;
362 
366  {
367  public:
370 
375  param_type(RealType mean = 0.0, RealType stddev = 1.0)
376  : m_mean(mean), m_stddev(stddev)
377  {
378  }
379 
381  param_type(const param_type& params) = default;
382 
384  param_type& operator=(const param_type& params) = default;
385 
389  RealType mean() const
390  {
391  return m_mean;
392  }
393 
397  RealType stddev() const
398  {
399  return m_stddev;
400  }
401 
403  bool operator==(const param_type& other) const
404  {
405  return m_mean == other.m_mean && m_stddev == other.m_stddev;
406  }
407 
409  bool operator!=(const param_type& other) const
410  {
411  return !(*this == other);
412  }
413  private:
414  RealType m_mean;
415  RealType m_stddev;
416  };
417 
421  normal_distribution(RealType mean = 0.0, RealType stddev = 1.0)
422  : m_params(mean, stddev)
423  {
424  }
425 
428  explicit normal_distribution(const param_type& params)
429  : m_params(params)
430  {
431  }
432 
434  static void reset()
435  {
436  }
437 
441  RealType mean() const
442  {
443  return m_params.mean();
444  }
445 
449  RealType stddev() const
450  {
451  return m_params.stddev();
452  }
453 
455  static constexpr RealType min()
456  {
457  return std::numeric_limits<RealType>::lowest();
458  }
459 
461  static constexpr RealType max()
462  {
463  return std::numeric_limits<RealType>::max();
464  }
465 
468  {
469  return m_params;
470  }
471 
473  void param(const param_type& params)
474  {
475  m_params = params;
476  }
477 
496  template<class Generator>
497  void operator()(Generator& g, RealType * output, size_t size)
498  {
499  rocrand_status status;
500  status = this->generate(g, output, size);
501  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
502  }
503 
507  bool operator==(const normal_distribution<RealType>& other) const
508  {
509  return this->m_params == other.m_params;
510  }
511 
515  bool operator!=(const normal_distribution<RealType>& other) const
516  {
517  return !(*this == other);
518  }
519 
520 private:
521  template<class Generator>
522  rocrand_status generate(Generator& g, float * output, size_t size)
523  {
525  g.m_generator, output, size, this->mean(), this->stddev()
526  );
527  }
528 
529  template<class Generator>
530  rocrand_status generate(Generator& g, double * output, size_t size)
531  {
533  g.m_generator, output, size, this->mean(), this->stddev()
534  );
535  }
536 
537  template<class Generator>
538  rocrand_status generate(Generator& g, half * output, size_t size)
539  {
541  g.m_generator, output, size, this->mean(), this->stddev()
542  );
543  }
544 
545  param_type m_params;
546 };
547 
553 template<class RealType = float>
555 {
556  static_assert(
557  std::is_same<float, RealType>::value
558  || std::is_same<double, RealType>::value
559  || std::is_same<half, RealType>::value,
560  "Only float, double and half types are supported in lognormal_distribution"
561  );
562 
563 public:
565  typedef RealType result_type;
566 
570  {
571  public:
574 
579  param_type(RealType m = 0.0, RealType s = 1.0)
580  : m_mean(m), m_stddev(s)
581  {
582  }
583 
585  param_type(const param_type& params) = default;
586 
588  param_type& operator=(const param_type& params) = default;
589 
593  RealType m() const
594  {
595  return m_mean;
596  }
597 
601  RealType s() const
602  {
603  return m_stddev;
604  }
605 
607  bool operator==(const param_type& other) const
608  {
609  return m_mean == other.m_mean && m_stddev == other.m_stddev;
610  }
611 
613  bool operator!=(const param_type& other) const
614  {
615  return !(*this == other);
616  }
617  private:
618  RealType m_mean;
619  RealType m_stddev;
620  };
621 
625  lognormal_distribution(RealType m = 0.0, RealType s = 1.0)
626  : m_params(m, s)
627  {
628  }
629 
632  explicit lognormal_distribution(const param_type& params)
633  : m_params(params)
634  {
635  }
636 
638  static void reset()
639  {
640  }
641 
645  RealType m() const
646  {
647  return m_params.m();
648  }
649 
653  RealType s() const
654  {
655  return m_params.s();
656  }
657 
660  {
661  return m_params;
662  }
663 
665  void param(const param_type& params)
666  {
667  m_params = params;
668  }
669 
671  static constexpr RealType min()
672  {
673  return 0;
674  }
675 
677  static RealType max()
678  {
679  return std::numeric_limits<RealType>::max();
680  }
681 
701  template<class Generator>
702  void operator()(Generator& g, RealType * output, size_t size)
703  {
704  rocrand_status status;
705  status = this->generate(g, output, size);
706  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
707  }
708 
713  {
714  return this->m_params == other.m_params;
715  }
716 
721  {
722  return !(*this == other);
723  }
724 
725 private:
726  template<class Generator>
727  rocrand_status generate(Generator& g, float * output, size_t size)
728  {
730  g.m_generator, output, size, this->m(), this->s()
731  );
732  }
733 
734  template<class Generator>
735  rocrand_status generate(Generator& g, double * output, size_t size)
736  {
738  g.m_generator, output, size, this->m(), this->s()
739  );
740  }
741 
742  template<class Generator>
743  rocrand_status generate(Generator& g, half * output, size_t size)
744  {
746  g.m_generator, output, size, this->m(), this->s()
747  );
748  }
749 
750  param_type m_params;
751 };
752 
758 template<class IntType = unsigned int>
760 {
761  static_assert(
762  std::is_same<unsigned int, IntType>::value,
763  "Only unsigned int type is supported in poisson_distribution"
764  );
765 
766 public:
768  typedef IntType result_type;
769 
773  {
774  public:
777 
781  param_type(double mean = 1.0)
782  : m_mean(mean)
783  {
784  }
785 
787  param_type(const param_type& params) = default;
788 
790  param_type& operator=(const param_type& params) = default;
791 
796  double mean() const
797  {
798  return m_mean;
799  }
800 
802  bool operator==(const param_type& other) const
803  {
804  return m_mean == other.m_mean;
805  }
806 
808  bool operator!=(const param_type& other) const
809  {
810  return !(*this == other);
811  }
812 
813  private:
814  double m_mean;
815  };
816 
820  : m_params(mean)
821  {
822  }
823 
826  explicit poisson_distribution(const param_type& params)
827  : m_params(params)
828  {
829  }
830 
832  static void reset()
833  {
834  }
835 
840  double mean() const
841  {
842  return m_params.mean();
843  }
844 
846  static constexpr IntType min()
847  {
848  return 0;
849  }
850 
852  static constexpr IntType max()
853  {
854  return std::numeric_limits<IntType>::max();
855  }
856 
859  {
860  return m_params;
861  }
862 
864  void param(const param_type& params)
865  {
866  m_params = params;
867  }
868 
887  template<class Generator>
888  void operator()(Generator& g, IntType * output, size_t size)
889  {
890  rocrand_status status;
891  status = rocrand_generate_poisson(g.m_generator, output, size, this->mean());
892  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
893  }
894 
898  bool operator==(const poisson_distribution<IntType>& other) const
899  {
900  return this->m_params == other.m_params;
901  }
902 
906  bool operator!=(const poisson_distribution<IntType>& other) const
907  {
908  return !(*this == other);
909  }
910 
911 private:
912  param_type m_params;
913 };
914 
919 template<unsigned long long DefaultSeed = ROCRAND_PHILOX4x32_DEFAULT_SEED>
921 {
922 public:
925  typedef unsigned int result_type;
926  // \typedef order_type
938  typedef unsigned long long offset_type;
943  typedef unsigned long long seed_type;
945  static constexpr seed_type default_seed = DefaultSeed;
946 
954  philox4x32_10_engine(seed_type seed_value = DefaultSeed,
955  offset_type offset_value = 0,
957  {
958  rocrand_status status;
959  status = rocrand_create_generator(&m_generator, this->type());
960  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
961  try
962  {
963  if(offset_value > 0)
964  {
965  this->offset(offset_value);
966  }
967  this->order(order_value);
968  this->seed(seed_value);
969  }
970  catch(...)
971  {
972  (void)rocrand_destroy_generator(m_generator);
973  throw;
974  }
975  }
976 
985  explicit philox4x32_10_engine(rocrand_generator& generator)
986  : m_generator(generator)
987  {
988  if(generator == NULL)
989  {
991  }
992  generator = NULL;
993  }
994 
996 
997  philox4x32_10_engine& operator=(const philox4x32_10_engine&) = delete;
998 
1005  philox4x32_10_engine(philox4x32_10_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1006  {
1007  rhs.m_generator = nullptr;
1008  }
1009 
1017  {
1018  rocrand_status status = rocrand_destroy_generator(m_generator);
1019  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1020  (void)status;
1021 
1022  m_generator = rhs.m_generator;
1023  rhs.m_generator = nullptr;
1024  return *this;
1025  }
1026 
1030  ~philox4x32_10_engine() noexcept(false)
1031  {
1032  rocrand_status status = rocrand_destroy_generator(m_generator);
1033  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1034  throw rocrand_cpp::error(status);
1035  }
1036 
1039  void stream(hipStream_t value)
1040  {
1041  rocrand_status status = rocrand_set_stream(m_generator, value);
1042  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1043  }
1044 
1056  void order(order_type value)
1057  {
1058  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1059  if(status != ROCRAND_STATUS_SUCCESS)
1060  throw rocrand_cpp::error(status);
1061  }
1062 
1074  void offset(offset_type value)
1075  {
1076  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1077  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1078  }
1079 
1090  void seed(seed_type value)
1091  {
1092  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1093  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1094  }
1095 
1109  template<class Generator>
1110  void operator()(result_type * output, size_t size)
1111  {
1112  rocrand_status status;
1113  status = rocrand_generate(m_generator, output, size);
1114  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1115  }
1116 
1118  static constexpr result_type min()
1119  {
1120  return 0;
1121  }
1122 
1124  static constexpr result_type max()
1125  {
1126  return std::numeric_limits<unsigned int>::max();
1127  }
1128 
1130  static constexpr rocrand_rng_type type()
1131  {
1133  }
1134 
1135 private:
1136  rocrand_generator m_generator;
1137 
1139  template<class T>
1140  friend class ::rocrand_cpp::uniform_int_distribution;
1141 
1142  template<class T>
1143  friend class ::rocrand_cpp::uniform_real_distribution;
1144 
1145  template<class T>
1146  friend class ::rocrand_cpp::normal_distribution;
1147 
1148  template<class T>
1149  friend class ::rocrand_cpp::lognormal_distribution;
1150 
1151  template<class T>
1152  friend class ::rocrand_cpp::poisson_distribution;
1154 };
1155 
1157 template<unsigned long long DefaultSeed>
1160 
1166 template<unsigned long long DefaultSeed = ROCRAND_XORWOW_DEFAULT_SEED>
1168 {
1169 public:
1171  typedef unsigned int result_type;
1175  typedef unsigned long long offset_type;
1177  typedef unsigned long long seed_type;
1179  static constexpr seed_type default_seed = DefaultSeed;
1180 
1182  xorwow_engine(seed_type seed_value = DefaultSeed,
1183  offset_type offset_value = 0,
1185  {
1186  rocrand_status status;
1187  status = rocrand_create_generator(&m_generator, this->type());
1188  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1189  try
1190  {
1191  this->order(order_value);
1192  if(offset_value > 0)
1193  {
1194  this->offset(offset_value);
1195  }
1196  this->seed(seed_value);
1197  }
1198  catch(...)
1199  {
1200  (void)rocrand_destroy_generator(m_generator);
1201  throw;
1202  }
1203  }
1204 
1206  explicit xorwow_engine(rocrand_generator& generator)
1207  : m_generator(generator)
1208  {
1209  if(generator == NULL)
1210  {
1212  }
1213  generator = NULL;
1214  }
1215 
1216  xorwow_engine(const xorwow_engine&) = delete;
1217 
1218  xorwow_engine& operator=(const xorwow_engine&) = delete;
1219 
1221  xorwow_engine(xorwow_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1222  {
1223  rhs.m_generator = nullptr;
1224  }
1225 
1228  {
1229  rocrand_status status = rocrand_destroy_generator(m_generator);
1230  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1231  (void)status;
1232 
1233  m_generator = rhs.m_generator;
1234  rhs.m_generator = nullptr;
1235  return *this;
1236  }
1237 
1239  ~xorwow_engine() noexcept(false)
1240  {
1241  rocrand_status status = rocrand_destroy_generator(m_generator);
1242  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1243  throw rocrand_cpp::error(status);
1244  }
1245 
1247  void stream(hipStream_t value)
1248  {
1249  rocrand_status status = rocrand_set_stream(m_generator, value);
1250  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1251  }
1252 
1254  void order(order_type value)
1255  {
1256  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1257  if(status != ROCRAND_STATUS_SUCCESS)
1258  throw rocrand_cpp::error(status);
1259  }
1260 
1262  void offset(offset_type value)
1263  {
1264  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1265  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1266  }
1267 
1269  void seed(seed_type value)
1270  {
1271  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1272  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1273  }
1274 
1276  template<class Generator>
1277  void operator()(result_type * output, size_t size)
1278  {
1279  rocrand_status status;
1280  status = rocrand_generate(m_generator, output, size);
1281  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1282  }
1283 
1285  static constexpr result_type min()
1286  {
1287  return 0;
1288  }
1289 
1291  static constexpr result_type max()
1292  {
1293  return std::numeric_limits<unsigned int>::max();
1294  }
1295 
1297  static constexpr rocrand_rng_type type()
1298  {
1300  }
1301 
1302 private:
1303  rocrand_generator m_generator;
1304 
1306  template<class T>
1307  friend class ::rocrand_cpp::uniform_int_distribution;
1308 
1309  template<class T>
1310  friend class ::rocrand_cpp::uniform_real_distribution;
1311 
1312  template<class T>
1313  friend class ::rocrand_cpp::normal_distribution;
1314 
1315  template<class T>
1316  friend class ::rocrand_cpp::lognormal_distribution;
1317 
1318  template<class T>
1319  friend class ::rocrand_cpp::poisson_distribution;
1321 };
1322 
1324 template<unsigned long long DefaultSeed>
1327 
1333 template<unsigned long long DefaultSeed = ROCRAND_MRG31K3P_DEFAULT_SEED>
1335 {
1336 public:
1338  typedef unsigned int result_type;
1342  typedef unsigned long long offset_type;
1344  typedef unsigned long long seed_type;
1346  static constexpr seed_type default_seed = DefaultSeed;
1347 
1349  mrg31k3p_engine(seed_type seed_value = DefaultSeed,
1350  offset_type offset_value = 0,
1352  {
1353  rocrand_status status;
1354  status = rocrand_create_generator(&m_generator, this->type());
1355  if(status != ROCRAND_STATUS_SUCCESS)
1356  throw rocrand_cpp::error(status);
1357  try
1358  {
1359  this->order(order_value);
1360  if(offset_value > 0)
1361  {
1362  this->offset(offset_value);
1363  }
1364  this->seed(seed_value);
1365  }
1366  catch(...)
1367  {
1368  (void)rocrand_destroy_generator(m_generator);
1369  throw;
1370  }
1371  }
1372 
1374  explicit mrg31k3p_engine(rocrand_generator& generator) : m_generator(generator)
1375  {
1376  if(generator == NULL)
1377  {
1379  }
1380  generator = NULL;
1381  }
1382 
1383  mrg31k3p_engine(const mrg31k3p_engine&) = delete;
1384 
1385  mrg31k3p_engine& operator=(const mrg31k3p_engine&) = delete;
1386 
1388  mrg31k3p_engine(mrg31k3p_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1389  {
1390  rhs.m_generator = nullptr;
1391  }
1392 
1395  {
1396  rocrand_status status = rocrand_destroy_generator(m_generator);
1397  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1398  (void)status;
1399 
1400  m_generator = rhs.m_generator;
1401  rhs.m_generator = nullptr;
1402  return *this;
1403  }
1404 
1406  ~mrg31k3p_engine() noexcept(false)
1407  {
1408  rocrand_status status = rocrand_destroy_generator(m_generator);
1409  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1410  throw rocrand_cpp::error(status);
1411  }
1412 
1414  void stream(hipStream_t value)
1415  {
1416  rocrand_status status = rocrand_set_stream(m_generator, value);
1417  if(status != ROCRAND_STATUS_SUCCESS)
1418  throw rocrand_cpp::error(status);
1419  }
1420 
1422  void order(order_type value)
1423  {
1424  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1425  if(status != ROCRAND_STATUS_SUCCESS)
1426  throw rocrand_cpp::error(status);
1427  }
1428 
1430  void offset(offset_type value)
1431  {
1432  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1433  if(status != ROCRAND_STATUS_SUCCESS)
1434  throw rocrand_cpp::error(status);
1435  }
1436 
1438  void seed(seed_type value)
1439  {
1440  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1441  if(status != ROCRAND_STATUS_SUCCESS)
1442  throw rocrand_cpp::error(status);
1443  }
1444 
1446  template<class Generator>
1447  void operator()(result_type* output, size_t size)
1448  {
1449  rocrand_status status;
1450  status = rocrand_generate(m_generator, output, size);
1451  if(status != ROCRAND_STATUS_SUCCESS)
1452  throw rocrand_cpp::error(status);
1453  }
1454 
1456  static constexpr result_type min()
1457  {
1458  return 1;
1459  }
1460 
1462  static constexpr result_type max()
1463  {
1464  return std::numeric_limits<unsigned int>::max();
1465  }
1466 
1468  static constexpr rocrand_rng_type type()
1469  {
1471  }
1472 
1473 private:
1474  rocrand_generator m_generator;
1475 
1477  template<class T>
1478  friend class ::rocrand_cpp::uniform_int_distribution;
1479 
1480  template<class T>
1481  friend class ::rocrand_cpp::uniform_real_distribution;
1482 
1483  template<class T>
1484  friend class ::rocrand_cpp::normal_distribution;
1485 
1486  template<class T>
1487  friend class ::rocrand_cpp::lognormal_distribution;
1488 
1489  template<class T>
1490  friend class ::rocrand_cpp::poisson_distribution;
1492 };
1493 
1495 template<unsigned long long DefaultSeed>
1496 constexpr
1499 
1505 template<unsigned long long DefaultSeed = ROCRAND_MRG32K3A_DEFAULT_SEED>
1507 {
1508 public:
1510  typedef unsigned int result_type;
1514  typedef unsigned long long offset_type;
1516  typedef unsigned long long seed_type;
1518  static constexpr seed_type default_seed = DefaultSeed;
1519 
1521  mrg32k3a_engine(seed_type seed_value = DefaultSeed,
1522  offset_type offset_value = 0,
1524  {
1525  rocrand_status status;
1526  status = rocrand_create_generator(&m_generator, this->type());
1527  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1528  try
1529  {
1530  this->order(order_value);
1531  if(offset_value > 0)
1532  {
1533  this->offset(offset_value);
1534  }
1535  this->seed(seed_value);
1536  }
1537  catch(...)
1538  {
1539  (void)rocrand_destroy_generator(m_generator);
1540  throw;
1541  }
1542  }
1543 
1545  explicit mrg32k3a_engine(rocrand_generator& generator)
1546  : m_generator(generator)
1547  {
1548  if(generator == NULL)
1549  {
1551  }
1552  generator = NULL;
1553  }
1554 
1555  mrg32k3a_engine(const mrg32k3a_engine&) = delete;
1556 
1557  mrg32k3a_engine& operator=(const mrg32k3a_engine&) = delete;
1558 
1560  mrg32k3a_engine(mrg32k3a_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1561  {
1562  rhs.m_generator = nullptr;
1563  }
1564 
1567  {
1568  rocrand_status status = rocrand_destroy_generator(m_generator);
1569  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1570  (void)status;
1571 
1572  m_generator = rhs.m_generator;
1573  rhs.m_generator = nullptr;
1574  return *this;
1575  }
1576 
1578  ~mrg32k3a_engine() noexcept(false)
1579  {
1580  rocrand_status status = rocrand_destroy_generator(m_generator);
1581  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1582  throw rocrand_cpp::error(status);
1583  }
1584 
1586  void stream(hipStream_t value)
1587  {
1588  rocrand_status status = rocrand_set_stream(m_generator, value);
1589  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1590  }
1591 
1593  void order(order_type value)
1594  {
1595  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1596  if(status != ROCRAND_STATUS_SUCCESS)
1597  throw rocrand_cpp::error(status);
1598  }
1599 
1601  void offset(offset_type value)
1602  {
1603  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1604  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1605  }
1606 
1608  void seed(seed_type value)
1609  {
1610  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1611  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1612  }
1613 
1615  template<class Generator>
1616  void operator()(result_type * output, size_t size)
1617  {
1618  rocrand_status status;
1619  status = rocrand_generate(m_generator, output, size);
1620  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1621  }
1622 
1624  static constexpr result_type min()
1625  {
1626  return 1;
1627  }
1628 
1630  static constexpr result_type max()
1631  {
1632  return std::numeric_limits<unsigned int>::max();
1633  }
1634 
1636  static constexpr rocrand_rng_type type()
1637  {
1639  }
1640 
1641 private:
1642  rocrand_generator m_generator;
1643 
1645  template<class T>
1646  friend class ::rocrand_cpp::uniform_int_distribution;
1647 
1648  template<class T>
1649  friend class ::rocrand_cpp::uniform_real_distribution;
1650 
1651  template<class T>
1652  friend class ::rocrand_cpp::normal_distribution;
1653 
1654  template<class T>
1655  friend class ::rocrand_cpp::lognormal_distribution;
1656 
1657  template<class T>
1658  friend class ::rocrand_cpp::poisson_distribution;
1660 };
1661 
1663 template<unsigned long long DefaultSeed>
1666 
1673 template<unsigned long long DefaultSeed = 0>
1675 {
1676 public:
1678  typedef unsigned int result_type;
1682  typedef unsigned long long offset_type;
1684  typedef unsigned long long seed_type;
1686  static constexpr seed_type default_seed = DefaultSeed;
1687 
1696  mtgp32_engine(seed_type seed_value = DefaultSeed,
1698  {
1699  rocrand_status status;
1700  status = rocrand_create_generator(&m_generator, this->type());
1701  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1702  try
1703  {
1704  this->order(order_value);
1705  this->seed(seed_value);
1706  }
1707  catch(...)
1708  {
1709  (void)rocrand_destroy_generator(m_generator);
1710  throw;
1711  }
1712  }
1713 
1715  explicit mtgp32_engine(rocrand_generator& generator)
1716  : m_generator(generator)
1717  {
1718  if(generator == NULL)
1719  {
1721  }
1722  generator = NULL;
1723  }
1724 
1725  mtgp32_engine(const mtgp32_engine&) = delete;
1726 
1727  mtgp32_engine& operator=(const mtgp32_engine&) = delete;
1728 
1730  mtgp32_engine(mtgp32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1731  {
1732  rhs.m_generator = nullptr;
1733  }
1734 
1737  {
1738  rocrand_status status = rocrand_destroy_generator(m_generator);
1739  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1740  (void)status;
1741 
1742  m_generator = rhs.m_generator;
1743  rhs.m_generator = nullptr;
1744  return *this;
1745  }
1746 
1748  ~mtgp32_engine() noexcept(false)
1749  {
1750  rocrand_status status = rocrand_destroy_generator(m_generator);
1751  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1752  throw rocrand_cpp::error(status);
1753  }
1754 
1756  void stream(hipStream_t value)
1757  {
1758  rocrand_status status = rocrand_set_stream(m_generator, value);
1759  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1760  }
1761 
1763  void order(order_type value)
1764  {
1765  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1766  if(status != ROCRAND_STATUS_SUCCESS)
1767  throw rocrand_cpp::error(status);
1768  }
1769 
1771  void seed(seed_type value)
1772  {
1773  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1774  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1775  }
1776 
1778  template<class Generator>
1779  void operator()(result_type * output, size_t size)
1780  {
1781  rocrand_status status;
1782  status = rocrand_generate(m_generator, output, size);
1783  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1784  }
1785 
1787  static constexpr result_type min()
1788  {
1789  return 0;
1790  }
1791 
1793  static constexpr result_type max()
1794  {
1795  return std::numeric_limits<unsigned int>::max();
1796  }
1797 
1799  static constexpr rocrand_rng_type type()
1800  {
1802  }
1803 
1804 private:
1805  rocrand_generator m_generator;
1806 
1808  template<class T>
1809  friend class ::rocrand_cpp::uniform_int_distribution;
1810 
1811  template<class T>
1812  friend class ::rocrand_cpp::uniform_real_distribution;
1813 
1814  template<class T>
1815  friend class ::rocrand_cpp::normal_distribution;
1816 
1817  template<class T>
1818  friend class ::rocrand_cpp::lognormal_distribution;
1819 
1820  template<class T>
1821  friend class ::rocrand_cpp::poisson_distribution;
1823 };
1824 
1826 template<unsigned long long DefaultSeed>
1829 
1835 template<unsigned int DefaultSeedX = ROCRAND_LFSR113_DEFAULT_SEED_X,
1836  unsigned int DefaultSeedY = ROCRAND_LFSR113_DEFAULT_SEED_Y,
1837  unsigned int DefaultSeedZ = ROCRAND_LFSR113_DEFAULT_SEED_Z,
1838  unsigned int DefaultSeedW = ROCRAND_LFSR113_DEFAULT_SEED_W>
1840 {
1841 public:
1843  typedef unsigned int result_type;
1847  typedef uint4 seed_type;
1849  static constexpr seed_type default_seed
1850  = {DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW};
1851 
1860  lfsr113_engine(seed_type seed_value = {DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW},
1862  {
1863  rocrand_status status;
1864  status = rocrand_create_generator(&m_generator, this->type());
1865  if(status != ROCRAND_STATUS_SUCCESS)
1866  throw rocrand_cpp::error(status);
1867  try
1868  {
1869  this->order(order_value);
1870  this->seed(seed_value);
1871  }
1872  catch(...)
1873  {
1874  (void)rocrand_destroy_generator(m_generator);
1875  throw;
1876  }
1877  }
1878 
1880  lfsr113_engine(unsigned long long seed_value,
1882  {
1883  rocrand_status status;
1884  status = rocrand_create_generator(&m_generator, this->type());
1885  if(status != ROCRAND_STATUS_SUCCESS)
1886  throw rocrand_cpp::error(status);
1887  try
1888  {
1889  this->order(order_value);
1890  this->seed(seed_value);
1891  }
1892  catch(...)
1893  {
1894  (void)rocrand_destroy_generator(m_generator);
1895  throw;
1896  }
1897  }
1898 
1900  explicit lfsr113_engine(rocrand_generator& generator) : m_generator(generator)
1901  {
1902  if(generator == NULL)
1903  {
1905  }
1906  generator = NULL;
1907  }
1908 
1909  lfsr113_engine(const lfsr113_engine&) = delete;
1910 
1911  lfsr113_engine& operator=(const lfsr113_engine&) = delete;
1912 
1914  lfsr113_engine(lfsr113_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1915  {
1916  rhs.m_generator = nullptr;
1917  }
1918 
1921  {
1922  rocrand_status status = rocrand_destroy_generator(m_generator);
1923  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1924  (void)status;
1925 
1926  m_generator = rhs.m_generator;
1927  rhs.m_generator = nullptr;
1928  return *this;
1929  }
1930 
1932  ~lfsr113_engine() noexcept(false)
1933  {
1934  rocrand_status status = rocrand_destroy_generator(m_generator);
1935  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1936  throw rocrand_cpp::error(status);
1937  }
1938 
1940  void stream(hipStream_t value)
1941  {
1942  rocrand_status status = rocrand_set_stream(m_generator, value);
1943  if(status != ROCRAND_STATUS_SUCCESS)
1944  throw rocrand_cpp::error(status);
1945  }
1946 
1948  void order(order_type value)
1949  {
1950  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1951  if(status != ROCRAND_STATUS_SUCCESS)
1952  throw rocrand_cpp::error(status);
1953  }
1954 
1956  void seed(unsigned long long value)
1957  {
1958  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1959  if(status != ROCRAND_STATUS_SUCCESS)
1960  throw rocrand_cpp::error(status);
1961  }
1962 
1964  void seed(seed_type value)
1965  {
1966  rocrand_status status = rocrand_set_seed_uint4(this->m_generator, value);
1967  if(status != ROCRAND_STATUS_SUCCESS)
1968  throw rocrand_cpp::error(status);
1969  }
1970 
1972  template<class Generator>
1973  void operator()(result_type* output, size_t size)
1974  {
1975  rocrand_status status;
1976  status = rocrand_generate(m_generator, output, size);
1977  if(status != ROCRAND_STATUS_SUCCESS)
1978  throw rocrand_cpp::error(status);
1979  }
1980 
1982  static constexpr result_type min()
1983  {
1984  return 0;
1985  }
1986 
1988  static constexpr result_type max()
1989  {
1990  return std::numeric_limits<unsigned int>::max();
1991  }
1992 
1994  static constexpr rocrand_rng_type type()
1995  {
1997  }
1998 
1999 private:
2000  rocrand_generator m_generator;
2001 
2003  template<class T>
2004  friend class ::rocrand_cpp::uniform_int_distribution;
2005 
2006  template<class T>
2007  friend class ::rocrand_cpp::uniform_real_distribution;
2008 
2009  template<class T>
2010  friend class ::rocrand_cpp::normal_distribution;
2011 
2012  template<class T>
2013  friend class ::rocrand_cpp::lognormal_distribution;
2014 
2015  template<class T>
2016  friend class ::rocrand_cpp::poisson_distribution;
2018 };
2019 
2021 template<unsigned int DefaultSeedX,
2022  unsigned int DefaultSeedY,
2023  unsigned int DefaultSeedZ,
2024  unsigned int DefaultSeedW>
2028 
2035 template<unsigned long long DefaultSeed = 0ULL>
2037 {
2038 public:
2040  typedef unsigned int result_type;
2044  typedef unsigned long long seed_type;
2046  static constexpr seed_type default_seed = DefaultSeed;
2047 
2056  mt19937_engine(seed_type seed_value = DefaultSeed,
2058  {
2059  rocrand_status status;
2060  status = rocrand_create_generator(&m_generator, this->type());
2061  if(status != ROCRAND_STATUS_SUCCESS)
2062  throw rocrand_cpp::error(status);
2063  try
2064  {
2065  this->order(order_value);
2066  this->seed(seed_value);
2067  }
2068  catch(...)
2069  {
2070  (void)rocrand_destroy_generator(m_generator);
2071  throw;
2072  }
2073  }
2074 
2076  explicit mt19937_engine(rocrand_generator& generator) : m_generator(generator)
2077  {
2078  if(generator == NULL)
2079  {
2081  }
2082  generator = NULL;
2083  }
2084 
2085  mt19937_engine(const mt19937_engine&) = delete;
2086 
2087  mt19937_engine& operator=(const mt19937_engine&) = delete;
2088 
2090  mt19937_engine(mt19937_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2091  {
2092  rhs.m_generator = nullptr;
2093  }
2094 
2097  {
2098  rocrand_status status = rocrand_destroy_generator(m_generator);
2099  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2100  (void)status;
2101 
2102  m_generator = rhs.m_generator;
2103  rhs.m_generator = nullptr;
2104  return *this;
2105  }
2106 
2108  ~mt19937_engine() noexcept(false)
2109  {
2110  rocrand_status status = rocrand_destroy_generator(m_generator);
2111  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2112  throw rocrand_cpp::error(status);
2113  }
2114 
2116  void stream(hipStream_t value)
2117  {
2118  rocrand_status status = rocrand_set_stream(m_generator, value);
2119  if(status != ROCRAND_STATUS_SUCCESS)
2120  throw rocrand_cpp::error(status);
2121  }
2122 
2124  void order(order_type value)
2125  {
2126  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2127  if(status != ROCRAND_STATUS_SUCCESS)
2128  throw rocrand_cpp::error(status);
2129  }
2130 
2132  void seed(seed_type value)
2133  {
2134  rocrand_status status = rocrand_set_seed(this->m_generator, value);
2135  if(status != ROCRAND_STATUS_SUCCESS)
2136  throw rocrand_cpp::error(status);
2137  }
2138 
2140  template<class Generator>
2141  void operator()(result_type* output, size_t size)
2142  {
2143  rocrand_status status;
2144  status = rocrand_generate(m_generator, output, size);
2145  if(status != ROCRAND_STATUS_SUCCESS)
2146  throw rocrand_cpp::error(status);
2147  }
2148 
2150  static constexpr result_type min()
2151  {
2152  return 0;
2153  }
2154 
2156  static constexpr result_type max()
2157  {
2158  return std::numeric_limits<unsigned int>::max();
2159  }
2160 
2162  static constexpr rocrand_rng_type type()
2163  {
2165  }
2166 
2167 private:
2168  rocrand_generator m_generator;
2169 
2171  template<class T>
2172  friend class ::rocrand_cpp::uniform_int_distribution;
2173 
2174  template<class T>
2175  friend class ::rocrand_cpp::uniform_real_distribution;
2176 
2177  template<class T>
2178  friend class ::rocrand_cpp::normal_distribution;
2179 
2180  template<class T>
2181  friend class ::rocrand_cpp::lognormal_distribution;
2182 
2183  template<class T>
2184  friend class ::rocrand_cpp::poisson_distribution;
2186 };
2187 
2189 template<unsigned long long DefaultSeed>
2192 
2198 template<unsigned int DefaultNumDimensions = 1>
2200 {
2201 public:
2203  typedef unsigned int result_type;
2207  typedef unsigned long long offset_type;
2212  typedef unsigned int dimensions_num_type;
2214  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2215 
2223  sobol32_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2224  offset_type offset_value = 0,
2226  {
2227  rocrand_status status;
2228  status = rocrand_create_generator(&m_generator, this->type());
2229  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2230  try
2231  {
2232  this->order(order_value);
2233  if(offset_value > 0)
2234  {
2235  this->offset(offset_value);
2236  }
2237  this->dimensions(num_of_dimensions);
2238  }
2239  catch(...)
2240  {
2241  (void)rocrand_destroy_generator(m_generator);
2242  throw;
2243  }
2244  }
2245 
2247  explicit sobol32_engine(rocrand_generator& generator)
2248  : m_generator(generator)
2249  {
2250  if(generator == NULL)
2251  {
2253  }
2254  generator = NULL;
2255  }
2256 
2257  sobol32_engine(const sobol32_engine&) = delete;
2258 
2259  sobol32_engine& operator=(const sobol32_engine&) = delete;
2260 
2262  sobol32_engine(sobol32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2263  {
2264  rhs.m_generator = nullptr;
2265  }
2266 
2269  {
2270  rocrand_status status = rocrand_destroy_generator(m_generator);
2271  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2272  (void)status;
2273 
2274  m_generator = rhs.m_generator;
2275  rhs.m_generator = nullptr;
2276  return *this;
2277  }
2278 
2280  ~sobol32_engine() noexcept(false)
2281  {
2282  rocrand_status status = rocrand_destroy_generator(m_generator);
2283  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2284  throw rocrand_cpp::error(status);
2285  }
2286 
2288  void stream(hipStream_t value)
2289  {
2290  rocrand_status status = rocrand_set_stream(m_generator, value);
2291  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2292  }
2293 
2295  void order(order_type value)
2296  {
2297  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2298  if(status != ROCRAND_STATUS_SUCCESS)
2299  throw rocrand_cpp::error(status);
2300  }
2301 
2303  void offset(offset_type value)
2304  {
2305  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2306  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2307  }
2308 
2320  {
2321  rocrand_status status =
2322  rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2323  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2324  }
2325 
2341  template<class Generator>
2342  void operator()(result_type * output, size_t size)
2343  {
2344  rocrand_status status;
2345  status = rocrand_generate(m_generator, output, size);
2346  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2347  }
2348 
2350  static constexpr result_type min()
2351  {
2352  return 0;
2353  }
2354 
2356  static constexpr result_type max()
2357  {
2358  return std::numeric_limits<unsigned int>::max();
2359  }
2360 
2362  static constexpr rocrand_rng_type type()
2363  {
2365  }
2366 
2367 private:
2368  rocrand_generator m_generator;
2369 
2371  template<class T>
2372  friend class ::rocrand_cpp::uniform_int_distribution;
2373 
2374  template<class T>
2375  friend class ::rocrand_cpp::uniform_real_distribution;
2376 
2377  template<class T>
2378  friend class ::rocrand_cpp::normal_distribution;
2379 
2380  template<class T>
2381  friend class ::rocrand_cpp::lognormal_distribution;
2382 
2383  template<class T>
2384  friend class ::rocrand_cpp::poisson_distribution;
2386 };
2387 
2389 template<unsigned int DefaultNumDimensions>
2393 
2399 template<unsigned int DefaultNumDimensions = 1>
2401 {
2402 public:
2404  typedef unsigned int result_type;
2406  typedef unsigned long long offset_type;
2413  typedef unsigned int dimensions_num_type;
2415  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2416 
2424  scrambled_sobol32_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2425  offset_type offset_value = 0,
2427  {
2428  rocrand_status status;
2429  status = rocrand_create_generator(&m_generator, this->type());
2430  if(status != ROCRAND_STATUS_SUCCESS)
2431  throw rocrand_cpp::error(status);
2432  try
2433  {
2434  this->order(order_value);
2435  if(offset_value > 0)
2436  {
2437  this->offset(offset_value);
2438  }
2439  this->dimensions(num_of_dimensions);
2440  }
2441  catch(...)
2442  {
2443  (void)rocrand_destroy_generator(m_generator);
2444  throw;
2445  }
2446  }
2447 
2449  explicit scrambled_sobol32_engine(rocrand_generator& generator) : m_generator(generator)
2450  {
2451  if(generator == NULL)
2452  {
2454  }
2455  generator = NULL;
2456  }
2457 
2459 
2460  scrambled_sobol32_engine& operator=(const scrambled_sobol32_engine&) = delete;
2461 
2463  scrambled_sobol32_engine(scrambled_sobol32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2464  {
2465  rhs.m_generator = nullptr;
2466  }
2467 
2470  {
2471  rocrand_status status = rocrand_destroy_generator(m_generator);
2472  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2473  (void)status;
2474 
2475  m_generator = rhs.m_generator;
2476  rhs.m_generator = nullptr;
2477  return *this;
2478  }
2479 
2481  ~scrambled_sobol32_engine() noexcept(false)
2482  {
2483  rocrand_status status = rocrand_destroy_generator(m_generator);
2484  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2485  throw rocrand_cpp::error(status);
2486  }
2487 
2489  void stream(hipStream_t value)
2490  {
2491  rocrand_status status = rocrand_set_stream(m_generator, value);
2492  if(status != ROCRAND_STATUS_SUCCESS)
2493  throw rocrand_cpp::error(status);
2494  }
2495 
2497  void order(order_type value)
2498  {
2499  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2500  if(status != ROCRAND_STATUS_SUCCESS)
2501  throw rocrand_cpp::error(status);
2502  }
2503 
2505  void offset(offset_type value)
2506  {
2507  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2508  if(status != ROCRAND_STATUS_SUCCESS)
2509  throw rocrand_cpp::error(status);
2510  }
2511 
2523  {
2524  rocrand_status status
2525  = rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2526  if(status != ROCRAND_STATUS_SUCCESS)
2527  throw rocrand_cpp::error(status);
2528  }
2529 
2545  template<class Generator>
2546  void operator()(result_type* output, size_t size)
2547  {
2548  rocrand_status status;
2549  status = rocrand_generate(m_generator, output, size);
2550  if(status != ROCRAND_STATUS_SUCCESS)
2551  throw rocrand_cpp::error(status);
2552  }
2553 
2555  static constexpr result_type min()
2556  {
2557  return 0;
2558  }
2559 
2561  static constexpr result_type max()
2562  {
2563  return std::numeric_limits<unsigned int>::max();
2564  }
2565 
2567  static constexpr rocrand_rng_type type()
2568  {
2570  }
2571 
2572 private:
2573  rocrand_generator m_generator;
2574 
2576  template<class T>
2577  friend class ::rocrand_cpp::uniform_int_distribution;
2578 
2579  template<class T>
2580  friend class ::rocrand_cpp::uniform_real_distribution;
2581 
2582  template<class T>
2583  friend class ::rocrand_cpp::normal_distribution;
2584 
2585  template<class T>
2586  friend class ::rocrand_cpp::lognormal_distribution;
2587 
2588  template<class T>
2589  friend class ::rocrand_cpp::poisson_distribution;
2591 };
2592 
2594 template<unsigned int DefaultNumDimensions>
2598 
2604 template<unsigned int DefaultNumDimensions = 1>
2606 {
2607 public:
2609  typedef unsigned long long int result_type;
2611  typedef unsigned long long int offset_type;
2618  typedef unsigned int dimensions_num_type;
2620  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2621 
2629  sobol64_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2630  offset_type offset_value = 0,
2632  {
2633  rocrand_status status;
2634  status = rocrand_create_generator(&m_generator, this->type());
2635  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2636  try
2637  {
2638  this->order(order_value);
2639  if(offset_value > 0)
2640  {
2641  this->offset(offset_value);
2642  }
2643  this->dimensions(num_of_dimensions);
2644  }
2645  catch(...)
2646  {
2647  (void)rocrand_destroy_generator(m_generator);
2648  throw;
2649  }
2650  }
2651 
2653  explicit sobol64_engine(rocrand_generator& generator)
2654  : m_generator(generator)
2655  {
2656  if(generator == NULL)
2657  {
2659  }
2660  generator = NULL;
2661  }
2662 
2663  sobol64_engine(const sobol64_engine&) = delete;
2664 
2665  sobol64_engine& operator=(const sobol64_engine&) = delete;
2666 
2668  sobol64_engine(sobol64_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2669  {
2670  rhs.m_generator = nullptr;
2671  }
2672 
2675  {
2676  rocrand_status status = rocrand_destroy_generator(m_generator);
2677  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2678  (void)status;
2679 
2680  m_generator = rhs.m_generator;
2681  rhs.m_generator = nullptr;
2682  return *this;
2683  }
2684 
2686  ~sobol64_engine() noexcept(false)
2687  {
2688  rocrand_status status = rocrand_destroy_generator(m_generator);
2689  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2690  throw rocrand_cpp::error(status);
2691  }
2692 
2694  void stream(hipStream_t value)
2695  {
2696  rocrand_status status = rocrand_set_stream(m_generator, value);
2697  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2698  }
2699 
2701  void order(order_type value)
2702  {
2703  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2704  if(status != ROCRAND_STATUS_SUCCESS)
2705  throw rocrand_cpp::error(status);
2706  }
2707 
2709  void offset(offset_type value)
2710  {
2711  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2712  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2713  }
2714 
2726  {
2727  rocrand_status status =
2728  rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2729  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2730  }
2731 
2747  template<class Generator>
2748  void operator()(result_type * output, size_t size)
2749  {
2750  rocrand_status status;
2751  status = rocrand_generate_long_long(m_generator, output, size);
2752  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2753  }
2754 
2756  static constexpr result_type min()
2757  {
2758  return 0;
2759  }
2760 
2762  static constexpr result_type max()
2763  {
2764  return std::numeric_limits<result_type>::max();
2765  }
2766 
2768  static constexpr rocrand_rng_type type()
2769  {
2771  }
2772 
2773 private:
2774  rocrand_generator m_generator;
2775 
2777  template<class T>
2778  friend class ::rocrand_cpp::uniform_int_distribution;
2779 
2780  template<class T>
2781  friend class ::rocrand_cpp::uniform_real_distribution;
2782 
2783  template<class T>
2784  friend class ::rocrand_cpp::normal_distribution;
2785 
2786  template<class T>
2787  friend class ::rocrand_cpp::lognormal_distribution;
2788 
2789  template<class T>
2790  friend class ::rocrand_cpp::poisson_distribution;
2792 };
2793 
2795 template<unsigned int DefaultNumDimensions>
2799 
2805 template<unsigned int DefaultNumDimensions = 1>
2807 {
2808 public:
2810  typedef unsigned long long int result_type;
2814  typedef unsigned long long int offset_type;
2819  typedef unsigned int dimensions_num_type;
2821  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2822 
2830  scrambled_sobol64_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2831  offset_type offset_value = 0,
2833  {
2834  rocrand_status status;
2835  status = rocrand_create_generator(&m_generator, this->type());
2836  if(status != ROCRAND_STATUS_SUCCESS)
2837  throw rocrand_cpp::error(status);
2838  try
2839  {
2840  this->order(order_value);
2841  if(offset_value > 0)
2842  {
2843  this->offset(offset_value);
2844  }
2845  this->dimensions(num_of_dimensions);
2846  }
2847  catch(...)
2848  {
2849  (void)rocrand_destroy_generator(m_generator);
2850  throw;
2851  }
2852  }
2853 
2855  explicit scrambled_sobol64_engine(rocrand_generator& generator) : m_generator(generator)
2856  {
2857  if(generator == NULL)
2858  {
2860  }
2861  generator = NULL;
2862  }
2863 
2865 
2866  scrambled_sobol64_engine& operator=(const scrambled_sobol64_engine&) = delete;
2867 
2869  scrambled_sobol64_engine(scrambled_sobol64_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2870  {
2871  rhs.m_generator = nullptr;
2872  }
2873 
2876  {
2877  rocrand_status status = rocrand_destroy_generator(m_generator);
2878  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2879  (void)status;
2880 
2881  m_generator = rhs.m_generator;
2882  rhs.m_generator = nullptr;
2883  return *this;
2884  }
2885 
2887  ~scrambled_sobol64_engine() noexcept(false)
2888  {
2889  rocrand_status status = rocrand_destroy_generator(m_generator);
2890  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2891  throw rocrand_cpp::error(status);
2892  }
2893 
2895  void stream(hipStream_t value)
2896  {
2897  rocrand_status status = rocrand_set_stream(m_generator, value);
2898  if(status != ROCRAND_STATUS_SUCCESS)
2899  throw rocrand_cpp::error(status);
2900  }
2901 
2903  void order(order_type value)
2904  {
2905  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2906  if(status != ROCRAND_STATUS_SUCCESS)
2907  throw rocrand_cpp::error(status);
2908  }
2909 
2911  void offset(offset_type value)
2912  {
2913  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2914  if(status != ROCRAND_STATUS_SUCCESS)
2915  throw rocrand_cpp::error(status);
2916  }
2917 
2929  {
2930  rocrand_status status
2931  = rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2932  if(status != ROCRAND_STATUS_SUCCESS)
2933  throw rocrand_cpp::error(status);
2934  }
2935 
2951  template<class Generator>
2952  void operator()(result_type* output, size_t size)
2953  {
2954  rocrand_status status;
2955  status = rocrand_generate_long_long(m_generator, output, size);
2956  if(status != ROCRAND_STATUS_SUCCESS)
2957  throw rocrand_cpp::error(status);
2958  }
2959 
2961  static constexpr result_type min()
2962  {
2963  return 0;
2964  }
2965 
2967  static constexpr result_type max()
2968  {
2969  return std::numeric_limits<result_type>::max();
2970  }
2971 
2973  static constexpr rocrand_rng_type type()
2974  {
2976  }
2977 
2978 private:
2979  rocrand_generator m_generator;
2980 
2982  template<class T>
2983  friend class ::rocrand_cpp::uniform_int_distribution;
2984 
2985  template<class T>
2986  friend class ::rocrand_cpp::uniform_real_distribution;
2987 
2988  template<class T>
2989  friend class ::rocrand_cpp::normal_distribution;
2990 
2991  template<class T>
2992  friend class ::rocrand_cpp::lognormal_distribution;
2993 
2994  template<class T>
2995  friend class ::rocrand_cpp::poisson_distribution;
2997 };
2998 
3000 template<unsigned int DefaultNumDimensions>
3004 
3009 template<unsigned long long DefaultSeed = 0>
3011 {
3012 public:
3014  typedef unsigned int result_type;
3018  typedef unsigned long long offset_type;
3020  typedef unsigned long long seed_type;
3022  static constexpr seed_type default_seed = DefaultSeed;
3023 
3025  threefry2x32_20_engine(seed_type seed_value = DefaultSeed,
3026  offset_type offset_value = 0,
3028  {
3029  rocrand_status status;
3030  status = rocrand_create_generator(&m_generator, this->type());
3031  if(status != ROCRAND_STATUS_SUCCESS)
3032  throw rocrand_cpp::error(status);
3033  try
3034  {
3035  if(offset_value > 0)
3036  {
3037  this->offset(offset_value);
3038  }
3039  this->order(order_value);
3040  this->seed(seed_value);
3041  }
3042  catch(...)
3043  {
3044  (void)rocrand_destroy_generator(m_generator);
3045  throw;
3046  }
3047  }
3048 
3050  explicit threefry2x32_20_engine(rocrand_generator& generator) : m_generator(generator)
3051  {
3052  if(generator == NULL)
3053  {
3055  }
3056  generator = NULL;
3057  }
3058 
3060 
3061  threefry2x32_20_engine& operator=(const threefry2x32_20_engine&) = delete;
3062 
3064  threefry2x32_20_engine(threefry2x32_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3065  {
3066  rhs.m_generator = nullptr;
3067  }
3068 
3071  {
3072  rocrand_status status = rocrand_destroy_generator(m_generator);
3073  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3074  (void)status;
3075 
3076  m_generator = rhs.m_generator;
3077  rhs.m_generator = nullptr;
3078  return *this;
3079  }
3080 
3082  ~threefry2x32_20_engine() noexcept(false)
3083  {
3084  rocrand_status status = rocrand_destroy_generator(m_generator);
3085  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3086  throw rocrand_cpp::error(status);
3087  }
3088 
3090  void stream(hipStream_t value)
3091  {
3092  rocrand_status status = rocrand_set_stream(m_generator, value);
3093  if(status != ROCRAND_STATUS_SUCCESS)
3094  throw rocrand_cpp::error(status);
3095  }
3096 
3098  void order(order_type value)
3099  {
3100  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3101  if(status != ROCRAND_STATUS_SUCCESS)
3102  throw rocrand_cpp::error(status);
3103  }
3104 
3106  void offset(offset_type value)
3107  {
3108  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3109  if(status != ROCRAND_STATUS_SUCCESS)
3110  throw rocrand_cpp::error(status);
3111  }
3112 
3114  void seed(seed_type value)
3115  {
3116  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3117  if(status != ROCRAND_STATUS_SUCCESS)
3118  throw rocrand_cpp::error(status);
3119  }
3120 
3122  template<class Generator>
3123  void operator()(result_type* output, size_t size)
3124  {
3125  rocrand_status status;
3126  status = rocrand_generate(m_generator, output, size);
3127  if(status != ROCRAND_STATUS_SUCCESS)
3128  throw rocrand_cpp::error(status);
3129  }
3130 
3132  static constexpr result_type min()
3133  {
3134  return 0;
3135  }
3136 
3138  static constexpr result_type max()
3139  {
3140  return std::numeric_limits<unsigned int>::max();
3141  }
3142 
3144  static constexpr rocrand_rng_type type()
3145  {
3147  }
3148 
3149 private:
3150  rocrand_generator m_generator;
3151 
3153  template<class T>
3154  friend class ::rocrand_cpp::uniform_int_distribution;
3155 
3156  template<class T>
3157  friend class ::rocrand_cpp::uniform_real_distribution;
3158 
3159  template<class T>
3160  friend class ::rocrand_cpp::normal_distribution;
3161 
3162  template<class T>
3163  friend class ::rocrand_cpp::lognormal_distribution;
3164 
3165  template<class T>
3166  friend class ::rocrand_cpp::poisson_distribution;
3168 };
3169 
3171 template<unsigned long long DefaultSeed>
3175 
3180 template<unsigned long long DefaultSeed = 0>
3182 {
3183 public:
3185  typedef unsigned long long result_type;
3189  typedef unsigned long long offset_type;
3191  typedef unsigned long long seed_type;
3193  static constexpr seed_type default_seed = DefaultSeed;
3194 
3196  threefry2x64_20_engine(seed_type seed_value = DefaultSeed,
3197  offset_type offset_value = 0,
3199  {
3200  rocrand_status status;
3201  status = rocrand_create_generator(&m_generator, this->type());
3202  if(status != ROCRAND_STATUS_SUCCESS)
3203  throw rocrand_cpp::error(status);
3204  try
3205  {
3206  if(offset_value > 0)
3207  {
3208  this->offset(offset_value);
3209  }
3210  this->order(order_value);
3211  this->seed(seed_value);
3212  }
3213  catch(...)
3214  {
3215  (void)rocrand_destroy_generator(m_generator);
3216  throw;
3217  }
3218  }
3219 
3221  explicit threefry2x64_20_engine(rocrand_generator& generator) : m_generator(generator)
3222  {
3223  if(generator == NULL)
3224  {
3226  }
3227  generator = NULL;
3228  }
3229 
3231 
3232  threefry2x64_20_engine& operator=(const threefry2x64_20_engine&) = delete;
3233 
3235  threefry2x64_20_engine(threefry2x64_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3236  {
3237  rhs.m_generator = nullptr;
3238  }
3239 
3242  {
3243  rocrand_status status = rocrand_destroy_generator(m_generator);
3244  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3245  (void)status;
3246 
3247  m_generator = rhs.m_generator;
3248  rhs.m_generator = nullptr;
3249  return *this;
3250  }
3251 
3253  ~threefry2x64_20_engine() noexcept(false)
3254  {
3255  rocrand_status status = rocrand_destroy_generator(m_generator);
3256  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3257  throw rocrand_cpp::error(status);
3258  }
3259 
3261  void stream(hipStream_t value)
3262  {
3263  rocrand_status status = rocrand_set_stream(m_generator, value);
3264  if(status != ROCRAND_STATUS_SUCCESS)
3265  throw rocrand_cpp::error(status);
3266  }
3267 
3269  void order(order_type value)
3270  {
3271  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3272  if(status != ROCRAND_STATUS_SUCCESS)
3273  throw rocrand_cpp::error(status);
3274  }
3275 
3277  void offset(offset_type value)
3278  {
3279  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3280  if(status != ROCRAND_STATUS_SUCCESS)
3281  throw rocrand_cpp::error(status);
3282  }
3283 
3285  void seed(seed_type value)
3286  {
3287  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3288  if(status != ROCRAND_STATUS_SUCCESS)
3289  throw rocrand_cpp::error(status);
3290  }
3291 
3293  template<class Generator>
3294  void operator()(result_type* output, size_t size)
3295  {
3296  rocrand_status status;
3297  status = rocrand_generate_long_long(m_generator, output, size);
3298  if(status != ROCRAND_STATUS_SUCCESS)
3299  throw rocrand_cpp::error(status);
3300  }
3301 
3303  static constexpr result_type min()
3304  {
3305  return 0;
3306  }
3307 
3309  static constexpr result_type max()
3310  {
3311  return std::numeric_limits<unsigned int>::max();
3312  }
3313 
3315  static constexpr rocrand_rng_type type()
3316  {
3318  }
3319 
3320 private:
3321  rocrand_generator m_generator;
3322 
3324  template<class T>
3325  friend class ::rocrand_cpp::uniform_int_distribution;
3326 
3327  template<class T>
3328  friend class ::rocrand_cpp::uniform_real_distribution;
3329 
3330  template<class T>
3331  friend class ::rocrand_cpp::normal_distribution;
3332 
3333  template<class T>
3334  friend class ::rocrand_cpp::lognormal_distribution;
3335 
3336  template<class T>
3337  friend class ::rocrand_cpp::poisson_distribution;
3339 };
3340 
3342 template<unsigned long long DefaultSeed>
3346 
3351 template<unsigned long long DefaultSeed = 0>
3353 {
3354 public:
3356  typedef unsigned int result_type;
3360  typedef unsigned long long offset_type;
3362  typedef unsigned long long seed_type;
3364  static constexpr seed_type default_seed = DefaultSeed;
3365 
3367  threefry4x32_20_engine(seed_type seed_value = DefaultSeed,
3368  offset_type offset_value = 0,
3370  {
3371  rocrand_status status;
3372  status = rocrand_create_generator(&m_generator, this->type());
3373  if(status != ROCRAND_STATUS_SUCCESS)
3374  throw rocrand_cpp::error(status);
3375  try
3376  {
3377  if(offset_value > 0)
3378  {
3379  this->offset(offset_value);
3380  }
3381  this->order(order_value);
3382  this->seed(seed_value);
3383  }
3384  catch(...)
3385  {
3386  (void)rocrand_destroy_generator(m_generator);
3387  throw;
3388  }
3389  }
3390 
3392  explicit threefry4x32_20_engine(rocrand_generator& generator) : m_generator(generator)
3393  {
3394  if(generator == NULL)
3395  {
3397  }
3398  generator = NULL;
3399  }
3400 
3402 
3403  threefry4x32_20_engine& operator=(const threefry4x32_20_engine&) = delete;
3404 
3406  threefry4x32_20_engine(threefry4x32_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3407  {
3408  rhs.m_generator = nullptr;
3409  }
3410 
3413  {
3414  rocrand_status status = rocrand_destroy_generator(m_generator);
3415  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3416  (void)status;
3417 
3418  m_generator = rhs.m_generator;
3419  rhs.m_generator = nullptr;
3420  return *this;
3421  }
3422 
3424  ~threefry4x32_20_engine() noexcept(false)
3425  {
3426  rocrand_status status = rocrand_destroy_generator(m_generator);
3427  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3428  throw rocrand_cpp::error(status);
3429  }
3430 
3432  void stream(hipStream_t value)
3433  {
3434  rocrand_status status = rocrand_set_stream(m_generator, value);
3435  if(status != ROCRAND_STATUS_SUCCESS)
3436  throw rocrand_cpp::error(status);
3437  }
3438 
3440  void order(order_type value)
3441  {
3442  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3443  if(status != ROCRAND_STATUS_SUCCESS)
3444  throw rocrand_cpp::error(status);
3445  }
3446 
3448  void offset(offset_type value)
3449  {
3450  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3451  if(status != ROCRAND_STATUS_SUCCESS)
3452  throw rocrand_cpp::error(status);
3453  }
3454 
3456  void seed(seed_type value)
3457  {
3458  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3459  if(status != ROCRAND_STATUS_SUCCESS)
3460  throw rocrand_cpp::error(status);
3461  }
3462 
3464  template<class Generator>
3465  void operator()(result_type* output, size_t size)
3466  {
3467  rocrand_status status;
3468  status = rocrand_generate(m_generator, output, size);
3469  if(status != ROCRAND_STATUS_SUCCESS)
3470  throw rocrand_cpp::error(status);
3471  }
3472 
3474  static constexpr result_type min()
3475  {
3476  return 0;
3477  }
3478 
3480  static constexpr result_type max()
3481  {
3482  return std::numeric_limits<unsigned int>::max();
3483  }
3484 
3486  static constexpr rocrand_rng_type type()
3487  {
3489  }
3490 
3491 private:
3492  rocrand_generator m_generator;
3493 
3495  template<class T>
3496  friend class ::rocrand_cpp::uniform_int_distribution;
3497 
3498  template<class T>
3499  friend class ::rocrand_cpp::uniform_real_distribution;
3500 
3501  template<class T>
3502  friend class ::rocrand_cpp::normal_distribution;
3503 
3504  template<class T>
3505  friend class ::rocrand_cpp::lognormal_distribution;
3506 
3507  template<class T>
3508  friend class ::rocrand_cpp::poisson_distribution;
3510 };
3511 
3513 template<unsigned long long DefaultSeed>
3517 
3522 template<unsigned long long DefaultSeed = 0>
3524 {
3525 public:
3527  typedef unsigned long long result_type;
3531  typedef unsigned long long offset_type;
3533  typedef unsigned long long seed_type;
3535  static constexpr seed_type default_seed = DefaultSeed;
3536 
3538  threefry4x64_20_engine(seed_type seed_value = DefaultSeed,
3539  offset_type offset_value = 0,
3541  {
3542  rocrand_status status;
3543  status = rocrand_create_generator(&m_generator, this->type());
3544  if(status != ROCRAND_STATUS_SUCCESS)
3545  throw rocrand_cpp::error(status);
3546  try
3547  {
3548  if(offset_value > 0)
3549  {
3550  this->offset(offset_value);
3551  }
3552  this->order(order_value);
3553  this->seed(seed_value);
3554  }
3555  catch(...)
3556  {
3557  (void)rocrand_destroy_generator(m_generator);
3558  throw;
3559  }
3560  }
3561 
3563  explicit threefry4x64_20_engine(rocrand_generator& generator) : m_generator(generator)
3564  {
3565  if(generator == NULL)
3566  {
3568  }
3569  generator = NULL;
3570  }
3571 
3573 
3574  threefry4x64_20_engine& operator=(const threefry4x64_20_engine&) = delete;
3575 
3577  threefry4x64_20_engine(threefry4x64_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3578  {
3579  rhs.m_generator = nullptr;
3580  }
3581 
3584  {
3585  rocrand_status status = rocrand_destroy_generator(m_generator);
3586  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3587  (void)status;
3588 
3589  m_generator = rhs.m_generator;
3590  rhs.m_generator = nullptr;
3591  return *this;
3592  }
3593 
3595  ~threefry4x64_20_engine() noexcept(false)
3596  {
3597  rocrand_status status = rocrand_destroy_generator(m_generator);
3598  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3599  throw rocrand_cpp::error(status);
3600  }
3601 
3603  void stream(hipStream_t value)
3604  {
3605  rocrand_status status = rocrand_set_stream(m_generator, value);
3606  if(status != ROCRAND_STATUS_SUCCESS)
3607  throw rocrand_cpp::error(status);
3608  }
3609 
3611  void order(order_type value)
3612  {
3613  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3614  if(status != ROCRAND_STATUS_SUCCESS)
3615  throw rocrand_cpp::error(status);
3616  }
3617 
3619  void offset(offset_type value)
3620  {
3621  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3622  if(status != ROCRAND_STATUS_SUCCESS)
3623  throw rocrand_cpp::error(status);
3624  }
3625 
3627  void seed(seed_type value)
3628  {
3629  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3630  if(status != ROCRAND_STATUS_SUCCESS)
3631  throw rocrand_cpp::error(status);
3632  }
3633 
3635  template<class Generator>
3636  void operator()(result_type* output, size_t size)
3637  {
3638  rocrand_status status;
3639  status = rocrand_generate_long_long(m_generator, output, size);
3640  if(status != ROCRAND_STATUS_SUCCESS)
3641  throw rocrand_cpp::error(status);
3642  }
3643 
3645  static constexpr result_type min()
3646  {
3647  return 0;
3648  }
3649 
3651  static constexpr result_type max()
3652  {
3653  return std::numeric_limits<unsigned int>::max();
3654  }
3655 
3657  static constexpr rocrand_rng_type type()
3658  {
3660  }
3661 
3662 private:
3663  rocrand_generator m_generator;
3664 
3666  template<class T>
3667  friend class ::rocrand_cpp::uniform_int_distribution;
3668 
3669  template<class T>
3670  friend class ::rocrand_cpp::uniform_real_distribution;
3671 
3672  template<class T>
3673  friend class ::rocrand_cpp::normal_distribution;
3674 
3675  template<class T>
3676  friend class ::rocrand_cpp::lognormal_distribution;
3677 
3678  template<class T>
3679  friend class ::rocrand_cpp::poisson_distribution;
3681 };
3682 
3684 template<unsigned long long DefaultSeed>
3688 
3735 
3739 
3768 
3771 inline int version()
3772 {
3773  int x;
3774  rocrand_status status = rocrand_get_version(&x);
3775  if(status != ROCRAND_STATUS_SUCCESS)
3776  {
3777  throw rocrand_cpp::error(status);
3778  }
3779  return x;
3780 }
3781 
3783 
3784 } // end namespace rocrand_cpp
3785 
3786 #endif // #if __cplusplus >= 201103L
3787 #endif // ROCRAND_HPP_
A run-time rocRAND error.
Definition: rocrand.hpp:50
error_type error_code() const noexcept
Returns the numeric error code.
Definition: rocrand.hpp:65
std::string error_string() const noexcept
Returns a string description of the error.
Definition: rocrand.hpp:71
friend bool operator!=(const error &l, const error &r)
Compares two error objects for inequality.
Definition: rocrand.hpp:129
static std::string to_string(error_type error)
Definition: rocrand.hpp:88
const char * what() const noexcept override
Returns a C-string description of the error.
Definition: rocrand.hpp:77
error(error_type error) noexcept
Definition: rocrand.hpp:58
rocrand_status error_type
rocRAND error code type
Definition: rocrand.hpp:53
friend bool operator==(const error &l, const error &r)
Compares two error objects for equality.
Definition: rocrand.hpp:122
Random number engine based on the LFSR113 algorithm.
Definition: rocrand.hpp:1840
lfsr113_engine & operator=(lfsr113_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1920
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1973
lfsr113_engine(lfsr113_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1914
uint4 seed_type
Definition: rocrand.hpp:1847
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1994
void seed(unsigned long long value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1956
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1964
lfsr113_engine(unsigned long long seed_value, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1880
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1850
unsigned int result_type
Definition: rocrand.hpp:1843
lfsr113_engine(seed_type seed_value={DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW}, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1860
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1988
lfsr113_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1900
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1940
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1948
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1982
rocrand_ordering order_type
Definition: rocrand.hpp:1845
~lfsr113_engine() noexcept(false)
Definition: rocrand.hpp:1932
The type of the distribution parameter set.
Definition: rocrand.hpp:570
RealType m() const
Returns the deviation distribution parameter.
Definition: rocrand.hpp:593
param_type(RealType m=0.0, RealType s=1.0)
Constructs a param_type object with the given distribution parameters.
Definition: rocrand.hpp:579
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition: rocrand.hpp:613
RealType s() const
Returns the deviation distribution parameter.
Definition: rocrand.hpp:601
param_type(const param_type &params)=default
Copy constructor.
bool operator==(const param_type &other) const
Returns true if the param_type is the same as other.
Definition: rocrand.hpp:607
param_type & operator=(const param_type &params)=default
Copy assignment operator.
Produces positive random numbers according to a log-normal distribution.
Definition: rocrand.hpp:555
void param(const param_type &params)
Sets the distribution parameter object.
Definition: rocrand.hpp:665
RealType result_type
See description for RealType template parameter.
Definition: rocrand.hpp:561
bool operator==(const lognormal_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:712
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:638
static constexpr RealType min()
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:671
RealType m() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:645
void operator()(Generator &g, RealType *output, size_t size)
Fills output with log-normally distributed random floating-point values.
Definition: rocrand.hpp:702
lognormal_distribution(RealType m=0.0, RealType s=1.0)
Constructs a new distribution object.
Definition: rocrand.hpp:625
static RealType max()
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:677
RealType s() const
Returns the standard deviation distribution parameter.
Definition: rocrand.hpp:653
bool operator!=(const lognormal_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:720
lognormal_distribution(const param_type &params)
Constructs a new distribution object.
Definition: rocrand.hpp:632
param_type param() const
Returns the distribution parameter object.
Definition: rocrand.hpp:659
Pseudorandom number engine based MRG31k3p CMRG.
Definition: rocrand.hpp:1335
mrg31k3p_engine(mrg31k3p_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1388
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1447
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1430
mrg31k3p_engine & operator=(mrg31k3p_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1394
rocrand_ordering order_type
Definition: rocrand.hpp:1340
mrg31k3p_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1349
unsigned long long seed_type
Definition: rocrand.hpp:1344
unsigned long long offset_type
Definition: rocrand.hpp:1342
unsigned int result_type
Definition: rocrand.hpp:1338
~mrg31k3p_engine() noexcept(false)
Definition: rocrand.hpp:1406
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1456
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1422
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1346
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1414
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1462
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1468
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1438
mrg31k3p_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1374
Pseudorandom number engine based MRG32k3a CMRG.
Definition: rocrand.hpp:1507
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1624
mrg32k3a_engine(mrg32k3a_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1560
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1636
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1601
unsigned long long seed_type
Definition: rocrand.hpp:1516
unsigned long long offset_type
Definition: rocrand.hpp:1514
rocrand_ordering order_type
Definition: rocrand.hpp:1512
unsigned int result_type
Definition: rocrand.hpp:1510
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1608
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1593
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1518
~mrg32k3a_engine() noexcept(false)
Definition: rocrand.hpp:1578
mrg32k3a_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1545
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1630
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1586
mrg32k3a_engine & operator=(mrg32k3a_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1566
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1616
mrg32k3a_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1521
Random number engine based on the Mersenne Twister algorithm.
Definition: rocrand.hpp:2037
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2124
mt19937_engine & operator=(mt19937_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2096
rocrand_ordering order_type
Definition: rocrand.hpp:2042
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:2132
~mt19937_engine() noexcept(false)
Definition: rocrand.hpp:2108
unsigned long long seed_type
Definition: rocrand.hpp:2044
mt19937_engine(seed_type seed_value=DefaultSeed, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2056
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2150
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2141
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2116
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2156
mt19937_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2076
mt19937_engine(mt19937_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2090
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2162
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:2046
unsigned int result_type
Definition: rocrand.hpp:2040
Random number engine based on the Mersenne Twister for Graphic Processors algorithm.
Definition: rocrand.hpp:1675
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1793
~mtgp32_engine() noexcept(false)
Definition: rocrand.hpp:1748
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1787
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1771
mtgp32_engine & operator=(mtgp32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1736
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1799
unsigned long long seed_type
Definition: rocrand.hpp:1684
mtgp32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1715
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1756
mtgp32_engine(seed_type seed_value=DefaultSeed, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1696
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1763
unsigned long long offset_type
Definition: rocrand.hpp:1682
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1686
unsigned int result_type
Definition: rocrand.hpp:1678
mtgp32_engine(mtgp32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1730
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1779
rocrand_ordering order_type
Definition: rocrand.hpp:1680
The type of the distribution parameter set.
Definition: rocrand.hpp:366
param_type(const param_type &params)=default
Copy constructor.
param_type & operator=(const param_type &params)=default
Copy assignment operator.
RealType mean() const
Returns the deviation distribution parameter.
Definition: rocrand.hpp:389
param_type(RealType mean=0.0, RealType stddev=1.0)
Constructs a param_type object with the given distribution parameters.
Definition: rocrand.hpp:375
bool operator==(const param_type &other) const
Returns true if the param_type is the same as other.
Definition: rocrand.hpp:403
RealType stddev() const
Returns the standard deviation distribution parameter.
Definition: rocrand.hpp:397
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition: rocrand.hpp:409
Produces random numbers according to a normal distribution.
Definition: rocrand.hpp:351
static constexpr RealType max()
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:461
normal_distribution(const param_type &params)
Constructs a new distribution object.
Definition: rocrand.hpp:428
static constexpr RealType min()
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:455
void param(const param_type &params)
Sets the distribution parameter object.
Definition: rocrand.hpp:473
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:434
param_type param() const
Returns the distribution parameter object.
Definition: rocrand.hpp:467
RealType mean() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:441
void operator()(Generator &g, RealType *output, size_t size)
Fills output with normally distributed random floating-point values.
Definition: rocrand.hpp:497
bool operator==(const normal_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:507
RealType result_type
See description for RealType template parameter.
Definition: rocrand.hpp:357
normal_distribution(RealType mean=0.0, RealType stddev=1.0)
Constructs a new distribution object.
Definition: rocrand.hpp:421
RealType stddev() const
Returns the standard deviation distribution parameter.
Definition: rocrand.hpp:449
bool operator!=(const normal_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:515
Pseudorandom number engine based Philox algorithm.
Definition: rocrand.hpp:921
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1130
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:945
philox4x32_10_engine(philox4x32_10_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1005
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1074
philox4x32_10_engine & operator=(philox4x32_10_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1016
unsigned long long offset_type
Definition: rocrand.hpp:938
philox4x32_10_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:985
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1124
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1039
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1090
unsigned long long seed_type
Definition: rocrand.hpp:943
~philox4x32_10_engine() noexcept(false)
Definition: rocrand.hpp:1030
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1110
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1056
philox4x32_10_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:954
unsigned int result_type
Definition: rocrand.hpp:925
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1118
rocrand_ordering order_type
Definition: rocrand.hpp:931
The type of the distribution parameter set.
Definition: rocrand.hpp:773
param_type & operator=(const param_type &params)=default
Copy assignment operator.
double mean() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:796
param_type(double mean=1.0)
Constructs a param_type object with the given mean.
Definition: rocrand.hpp:781
param_type(const param_type &params)=default
Copy constructor.
bool operator==(const param_type &other) const
Returns true if the param_type is the same as other.
Definition: rocrand.hpp:802
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition: rocrand.hpp:808
Produces random non-negative integer values distributed according to Poisson distribution.
Definition: rocrand.hpp:760
static constexpr IntType min()
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:846
double mean() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:840
bool operator==(const poisson_distribution< IntType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:898
IntType result_type
See description for IntType template parameter.
Definition: rocrand.hpp:764
param_type param()
Returns the distribution parameter object.
Definition: rocrand.hpp:858
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:832
static constexpr IntType max()
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:852
void operator()(Generator &g, IntType *output, size_t size)
Fills output with random non-negative integer values distributed according to Poisson distribution.
Definition: rocrand.hpp:888
poisson_distribution(const param_type &params)
Constructs a new distribution object.
Definition: rocrand.hpp:826
poisson_distribution(double mean=1.0)
Constructs a new distribution object.
Definition: rocrand.hpp:819
void param(const param_type &params)
Sets the distribution parameter object.
Definition: rocrand.hpp:864
bool operator!=(const poisson_distribution< IntType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:906
Sobol's scrambled quasi-random sequence generator.
Definition: rocrand.hpp:2401
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2561
unsigned int result_type
Definition: rocrand.hpp:2404
scrambled_sobol32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2449
unsigned int dimensions_num_type
Definition: rocrand.hpp:2413
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2497
scrambled_sobol32_engine(scrambled_sobol32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2463
scrambled_sobol32_engine(dimensions_num_type num_of_dimensions=DefaultNumDimensions, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_QUASI_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2424
unsigned long long offset_type
Definition: rocrand.hpp:2406
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2489
~scrambled_sobol32_engine() noexcept(false)
Definition: rocrand.hpp:2481
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2505
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2415
rocrand_ordering order_type
Definition: rocrand.hpp:2408
scrambled_sobol32_engine & operator=(scrambled_sobol32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2469
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2567
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2555
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2546
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2522
Sobol's scrambled quasi-random sequence generator.
Definition: rocrand.hpp:2807
unsigned int dimensions_num_type
Definition: rocrand.hpp:2819
scrambled_sobol64_engine(scrambled_sobol64_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2869
scrambled_sobol64_engine(dimensions_num_type num_of_dimensions=DefaultNumDimensions, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_QUASI_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2830
unsigned long long int offset_type
Definition: rocrand.hpp:2814
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2961
unsigned long long int result_type
Definition: rocrand.hpp:2810
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2928
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2967
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2911
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2821
rocrand_ordering order_type
Definition: rocrand.hpp:2812
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2952
scrambled_sobol64_engine & operator=(scrambled_sobol64_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2875
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2903
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2895
~scrambled_sobol64_engine() noexcept(false)
Definition: rocrand.hpp:2887
scrambled_sobol64_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2855
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2973
Sobol's quasi-random sequence generator.
Definition: rocrand.hpp:2200
sobol32_engine(sobol32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2262
unsigned int result_type
Definition: rocrand.hpp:2203
sobol32_engine(dimensions_num_type num_of_dimensions=DefaultNumDimensions, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_QUASI_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2223
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2350
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2319
sobol32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2247
~sobol32_engine() noexcept(false)
Definition: rocrand.hpp:2280
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2295
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2303
unsigned long long offset_type
Definition: rocrand.hpp:2207
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2342
sobol32_engine & operator=(sobol32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2268
unsigned int dimensions_num_type
Definition: rocrand.hpp:2212
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2362
rocrand_ordering order_type
Definition: rocrand.hpp:2205
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2214
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2356
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2288
Sobol's quasi-random sequence generator.
Definition: rocrand.hpp:2606
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2725
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2709
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2701
unsigned long long int result_type
Definition: rocrand.hpp:2609
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2768
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2762
sobol64_engine(dimensions_num_type num_of_dimensions=DefaultNumDimensions, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_QUASI_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2629
unsigned int dimensions_num_type
Definition: rocrand.hpp:2618
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2620
sobol64_engine & operator=(sobol64_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2674
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2694
unsigned long long int offset_type
Definition: rocrand.hpp:2611
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2756
sobol64_engine(sobol64_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2668
sobol64_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2653
rocrand_ordering order_type
Definition: rocrand.hpp:2613
~sobol64_engine() noexcept(false)
Definition: rocrand.hpp:2686
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2748
Pseudorandom number engine based on 2 state ThreeFry.
Definition: rocrand.hpp:3011
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3132
unsigned int result_type
Definition: rocrand.hpp:3014
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3090
threefry2x32_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3050
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3144
threefry2x32_20_engine & operator=(threefry2x32_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3070
threefry2x32_20_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3025
~threefry2x32_20_engine() noexcept(false)
Definition: rocrand.hpp:3082
unsigned long long seed_type
Definition: rocrand.hpp:3020
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3123
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3114
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3106
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3022
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3138
rocrand_ordering order_type
Definition: rocrand.hpp:3016
unsigned long long offset_type
Definition: rocrand.hpp:3018
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3098
threefry2x32_20_engine(threefry2x32_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3064
Pseudorandom number engine based 2 state ThreeFry.
Definition: rocrand.hpp:3182
unsigned long long seed_type
Definition: rocrand.hpp:3191
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3193
threefry2x64_20_engine & operator=(threefry2x64_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3241
unsigned long long result_type
Definition: rocrand.hpp:3185
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3285
~threefry2x64_20_engine() noexcept(false)
Definition: rocrand.hpp:3253
threefry2x64_20_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3196
rocrand_ordering order_type
Definition: rocrand.hpp:3187
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3315
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3277
threefry2x64_20_engine(threefry2x64_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3235
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3294
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3269
unsigned long long offset_type
Definition: rocrand.hpp:3189
threefry2x64_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3221
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3261
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3303
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3309
Pseudorandom number engine based on 2 state ThreeFry.
Definition: rocrand.hpp:3353
threefry4x32_20_engine & operator=(threefry4x32_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3412
~threefry4x32_20_engine() noexcept(false)
Definition: rocrand.hpp:3424
unsigned long long seed_type
Definition: rocrand.hpp:3362
threefry4x32_20_engine(threefry4x32_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3406
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3474
threefry4x32_20_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3367
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3432
unsigned int result_type
Definition: rocrand.hpp:3356
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3448
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3456
rocrand_ordering order_type
Definition: rocrand.hpp:3358
threefry4x32_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3392
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3480
unsigned long long offset_type
Definition: rocrand.hpp:3360
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3465
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3486
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3364
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3440
Pseudorandom number engine based 2 state ThreeFry.
Definition: rocrand.hpp:3524
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3645
threefry4x64_20_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3538
threefry4x64_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3563
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3535
unsigned long long seed_type
Definition: rocrand.hpp:3533
threefry4x64_20_engine & operator=(threefry4x64_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3583
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3619
~threefry4x64_20_engine() noexcept(false)
Definition: rocrand.hpp:3595
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3657
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3603
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3611
unsigned long long offset_type
Definition: rocrand.hpp:3531
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3636
threefry4x64_20_engine(threefry4x64_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3577
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3651
unsigned long long result_type
Definition: rocrand.hpp:3527
rocrand_ordering order_type
Definition: rocrand.hpp:3529
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3627
Produces random integer values uniformly distributed on the interval [0, 2^(sizeof(IntType)*8) - 1].
Definition: rocrand.hpp:146
bool operator!=(const uniform_int_distribution< IntType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:213
void operator()(Generator &g, IntType *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:198
IntType result_type
See description for IntType template parameter.
Definition: rocrand.hpp:152
bool operator==(const uniform_int_distribution< IntType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:206
uniform_int_distribution()
Default constructor.
Definition: rocrand.hpp:159
static constexpr IntType max()
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:175
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:164
static constexpr IntType min()
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:169
Produces random floating-point values uniformly distributed on the interval (0, 1].
Definition: rocrand.hpp:252
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:270
static constexpr RealType min()
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:275
static constexpr RealType max()
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:281
RealType result_type
See description for RealType template parameter.
Definition: rocrand.hpp:258
uniform_real_distribution()
Default constructor.
Definition: rocrand.hpp:265
bool operator!=(const uniform_real_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:319
void operator()(Generator &g, RealType *output, size_t size)
Fills output with uniformly distributed random floating-point values.
Definition: rocrand.hpp:304
bool operator==(const uniform_real_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:312
Pseudorandom number engine based XORWOW algorithm.
Definition: rocrand.hpp:1168
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1254
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1247
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1297
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1269
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1285
rocrand_ordering order_type
Definition: rocrand.hpp:1173
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1291
xorwow_engine(xorwow_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1221
xorwow_engine(seed_type seed_value=DefaultSeed, offset_type offset_value=0, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1182
xorwow_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1206
xorwow_engine & operator=(xorwow_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1227
~xorwow_engine() noexcept(false)
Definition: rocrand.hpp:1239
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1277
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1262
unsigned int result_type
Definition: rocrand.hpp:1171
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1179
unsigned long long seed_type
Definition: rocrand.hpp:1177
unsigned long long offset_type
Definition: rocrand.hpp:1175
#define ROCRAND_LFSR113_DEFAULT_SEED_Y
Default Y seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:36
#define ROCRAND_LFSR113_DEFAULT_SEED_W
Default W seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:42
#define ROCRAND_LFSR113_DEFAULT_SEED_Z
Default Z seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:39
#define ROCRAND_LFSR113_DEFAULT_SEED_X
Default X seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:33
rocrand_status ROCRANDAPI rocrand_generate_short(rocrand_generator generator, unsigned short *output_data, size_t n)
Generates uniformly distributed 16-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_normal(rocrand_generator generator, float *output_data, size_t n, float mean, float stddev)
Generates normally distributed float values.
rocrand_status ROCRANDAPI rocrand_set_offset(rocrand_generator generator, unsigned long long offset)
Sets the offset of a random number generator.
rocrand_status ROCRANDAPI rocrand_generate_normal_double(rocrand_generator generator, double *output_data, size_t n, double mean, double stddev)
Generates normally distributed double values.
rocrand_ordering
rocRAND generator ordering
Definition: rocrand.h:107
rocrand_status ROCRANDAPI rocrand_generate_char(rocrand_generator generator, unsigned char *output_data, size_t n)
Generates uniformly distributed 8-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_log_normal(rocrand_generator generator, float *output_data, size_t n, float mean, float stddev)
Generates log-normally distributed float values.
rocrand_status
rocRAND function call status type
Definition: rocrand.h:59
rocrand_status ROCRANDAPI rocrand_create_generator(rocrand_generator *generator, rocrand_rng_type rng_type)
Creates a new random number generator.
rocrand_rng_type
rocRAND generator type
Definition: rocrand.h:78
rocrand_status ROCRANDAPI rocrand_generate_long_long(rocrand_generator generator, unsigned long long int *output_data, size_t n)
Generates uniformly distributed 64-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_uniform_half(rocrand_generator generator, half *output_data, size_t n)
Generates uniformly distributed half-precision floating-point values.
rocrand_status ROCRANDAPI rocrand_set_stream(rocrand_generator generator, hipStream_t stream)
Sets the current stream for kernel launches.
rocrand_status ROCRANDAPI rocrand_generate_normal_half(rocrand_generator generator, half *output_data, size_t n, half mean, half stddev)
Generates normally distributed half values.
rocrand_status ROCRANDAPI rocrand_generate_uniform_double(rocrand_generator generator, double *output_data, size_t n)
Generates uniformly distributed double-precision floating-point values.
rocrand_status ROCRANDAPI rocrand_generate_uniform(rocrand_generator generator, float *output_data, size_t n)
Generates uniformly distributed float values.
rocrand_status ROCRANDAPI rocrand_set_ordering(rocrand_generator generator, rocrand_ordering order)
Sets the ordering of a random number generator.
rocrand_status ROCRANDAPI rocrand_generate_poisson(rocrand_generator generator, unsigned int *output_data, size_t n, double lambda)
Generates Poisson-distributed 32-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_set_quasi_random_generator_dimensions(rocrand_generator generator, unsigned int dimensions)
Set the number of dimensions of a quasi-random number generator.
rocrand_status ROCRANDAPI rocrand_get_version(int *version)
Returns the version number of the library.
rocrand_status ROCRANDAPI rocrand_set_seed_uint4(rocrand_generator generator, uint4 seed)
Sets the seeds of a pseudo-random number generator.
rocrand_status ROCRANDAPI rocrand_generate(rocrand_generator generator, unsigned int *output_data, size_t n)
Generates uniformly distributed 32-bit unsigned integers.
rocrand_status ROCRANDAPI rocrand_generate_log_normal_double(rocrand_generator generator, double *output_data, size_t n, double mean, double stddev)
Generates log-normally distributed double values.
rocrand_status ROCRANDAPI rocrand_set_seed(rocrand_generator generator, unsigned long long seed)
Sets the seed of a pseudo-random number generator.
rocrand_status ROCRANDAPI rocrand_generate_log_normal_half(rocrand_generator generator, half *output_data, size_t n, half mean, half stddev)
Generates log-normally distributed half values.
rocrand_status ROCRANDAPI rocrand_destroy_generator(rocrand_generator generator)
Destroys random number generator.
@ ROCRAND_ORDERING_PSEUDO_DEFAULT
Default ordering for pseudorandom results.
Definition: rocrand.h:109
@ ROCRAND_ORDERING_QUASI_DEFAULT
n-dimensional ordering for quasirandom results
Definition: rocrand.h:114
@ ROCRAND_STATUS_NOT_CREATED
Generator was not created using rocrand_create_generator.
Definition: rocrand.h:62
@ ROCRAND_STATUS_LAUNCH_FAILURE
Kernel launch failure.
Definition: rocrand.h:70
@ ROCRAND_STATUS_VERSION_MISMATCH
Header file and linked library version do not match.
Definition: rocrand.h:61
@ ROCRAND_STATUS_LENGTH_NOT_MULTIPLE
Definition: rocrand.h:66
@ ROCRAND_STATUS_DOUBLE_PRECISION_REQUIRED
GPU does not have double precision.
Definition: rocrand.h:69
@ ROCRAND_STATUS_SUCCESS
No errors.
Definition: rocrand.h:60
@ ROCRAND_STATUS_INTERNAL_ERROR
Internal library error.
Definition: rocrand.h:71
@ ROCRAND_STATUS_OUT_OF_RANGE
Argument out of range.
Definition: rocrand.h:65
@ ROCRAND_STATUS_ALLOCATION_FAILED
Memory allocation failed during execution.
Definition: rocrand.h:63
@ ROCRAND_STATUS_TYPE_ERROR
Generator type is wrong.
Definition: rocrand.h:64
@ ROCRAND_RNG_QUASI_SOBOL64
Sobol64 quasirandom generator.
Definition: rocrand.h:98
@ ROCRAND_RNG_PSEUDO_LFSR113
LFSR113 pseudorandom generator.
Definition: rocrand.h:85
@ ROCRAND_RNG_PSEUDO_THREEFRY2_64_20
ThreeFry 64 bit state size 2 pseudorandom generator.
Definition: rocrand.h:89
@ ROCRAND_RNG_PSEUDO_XORWOW
XORWOW pseudorandom generator.
Definition: rocrand.h:80
@ ROCRAND_RNG_PSEUDO_THREEFRY4_32_20
ThreeFry 32 bit state size 4 pseudorandom generator.
Definition: rocrand.h:91
@ ROCRAND_RNG_PSEUDO_MRG31K3P
MRG31k3p pseudorandom generator.
Definition: rocrand.h:84
@ ROCRAND_RNG_PSEUDO_MT19937
Mersenne Twister MT19937 pseudorandom generator.
Definition: rocrand.h:86
@ ROCRAND_RNG_PSEUDO_PHILOX4_32_10
PHILOX-4x32-10 pseudorandom generator.
Definition: rocrand.h:83
@ ROCRAND_RNG_PSEUDO_THREEFRY2_32_20
ThreeFry 32 bit state size 2 pseudorandom generator.
Definition: rocrand.h:87
@ ROCRAND_RNG_PSEUDO_THREEFRY4_64_20
ThreeFry 64 bit state size 4 pseudorandom generator.
Definition: rocrand.h:93
@ ROCRAND_RNG_PSEUDO_MTGP32
Mersenne Twister MTGP32 pseudorandom generator.
Definition: rocrand.h:82
@ ROCRAND_RNG_QUASI_SOBOL32
Sobol32 quasirandom generator.
Definition: rocrand.h:96
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL32
Scrambled Sobol32 quasirandom generator.
Definition: rocrand.h:97
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL64
Scrambled Sobol64 quasirandom generator.
Definition: rocrand.h:99
@ ROCRAND_RNG_PSEUDO_MRG32K3A
MRG32k3a pseudorandom generator.
Definition: rocrand.h:81
threefry2x32_20_engine threefry2x32
Typedef of rocrand_cpp::threefry2x32_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3713
mrg31k3p_engine mrg31k3p
Typedef of rocrand_cpp::mrg31k3p_engine PRNG engine with default seed (ROCRAND_MRG31K3P_DEFAULT_SEED)...
Definition: rocrand.hpp:3697
int version()
Returns rocRAND version.
Definition: rocrand.hpp:3771
mrg32k3a_engine mrg32k3a
Typedef of rocrand_cpp::mrg32k3a_engine PRNG engine with default seed (ROCRAND_MRG32K3A_DEFAULT_SEED)...
Definition: rocrand.hpp:3700
scrambled_sobol64_engine scrambled_sobol64
Typedef of rocrand_cpp::scrambled_sobol64_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3734
scrambled_sobol32_engine scrambled_sobol32
Typedef of rocrand_cpp::scrambled_sobol32_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3728
sobol64_engine sobol64
Typedef of rocrand_cpp::sobol64_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3731
mt19937_engine mt19937
Typedef of rocrand_cpp::mt19937_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3710
sobol32_engine sobol32
Typedef of rocrand_cpp::sobol32_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3725
lfsr113_engine lfsr113
Typedef of rocrand_cpp::lfsr113_engine PRNG engine with default seed (ROCRAND_LFSR113_DEFAULT_SEED_X,...
Definition: rocrand.hpp:3707
threefry4x64_20_engine threefry4x64
Typedef of rocrand_cpp::threefry4x64_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3722
xorwow_engine xorwow
Typedef of rocrand_cpp::xorwow_engine PRNG engine with default seed (ROCRAND_XORWOW_DEFAULT_SEED).
Definition: rocrand.hpp:3694
threefry4x32_20_engine threefry4x32
Typedef of rocrand_cpp::threefry4x32_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3719
threefry2x64_20_engine threefry2x64
Typedef of rocrand_cpp::threefry2x64_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3716
xorwow default_random_engine
Default random engine.
Definition: rocrand.hpp:3738
philox4x32_10_engine philox4x32_10
Typedef of rocrand_cpp::philox4x32_10_engine PRNG engine with default seed (ROCRAND_PHILOX4x32_DEFAUL...
Definition: rocrand.hpp:3691
mtgp32_engine mtgp32
Typedef of rocrand_cpp::mtgp32_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3703
std::random_device random_device
A non-deterministic uniform random number generator.
Definition: rocrand.hpp:3767