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

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

API library: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.1.2/library/include/rocrand/rocrand.hpp Source File
API library
rocrand.hpp
1 // Copyright (c) 2017-2023 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  // cppcheck-suppress functionStatic
170  IntType min() const
171  {
172  return 0;
173  }
174 
176  IntType max() const
177  {
178  return std::numeric_limits<IntType>::max();
179  }
180 
198  template<class Generator>
199  void operator()(Generator& g, IntType * output, size_t size)
200  {
201  rocrand_status status;
202  status = this->generate(g, output, size);
203  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
204  }
205 
208  {
209  (void) other;
210  return true;
211  }
212 
215  {
216  return !(*this == other);
217  }
218 
219 private:
220  template<class Generator>
221  static rocrand_status generate(Generator& g, unsigned char * output, size_t size)
222  {
223  return rocrand_generate_char(g.m_generator, output, size);
224  }
225 
226  template<class Generator>
227  static rocrand_status generate(Generator& g, unsigned short * output, size_t size)
228  {
229  return rocrand_generate_short(g.m_generator, output, size);
230  }
231 
232  template<class Generator>
233  static rocrand_status generate(Generator& g, unsigned int * output, size_t size)
234  {
235  return rocrand_generate(g.m_generator, output, size);
236  }
237 
238  template<class Generator>
239  static rocrand_status generate(Generator& g, unsigned long long int* output, size_t size)
240  {
241  return rocrand_generate_long_long(g.m_generator, output, size);
242  }
243 };
244 
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  // cppcheck-suppress functionStatic
276  RealType min() const
277  {
278  if(std::is_same<float, RealType>::value)
279  {
280  return static_cast<RealType>(ROCRAND_2POW32_INV);
281  }
282  return static_cast<RealType>(ROCRAND_2POW32_INV_DOUBLE);
283  }
284 
286  // cppcheck-suppress functionStatic
287  RealType max() const
288  {
289  return 1.0;
290  }
291 
309  template<class Generator>
310  void operator()(Generator& g, RealType * output, size_t size)
311  {
312  rocrand_status status;
313  status = this->generate(g, output, size);
314  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
315  }
316 
319  {
320  (void) other;
321  return true;
322  }
323 
326  {
327  return !(*this == other);
328  }
329 
330 private:
331  template<class Generator>
332  static rocrand_status generate(Generator& g, float * output, size_t size)
333  {
334  return rocrand_generate_uniform(g.m_generator, output, size);
335  }
336 
337  template<class Generator>
338  static rocrand_status generate(Generator& g, double * output, size_t size)
339  {
340  return rocrand_generate_uniform_double(g.m_generator, output, size);
341  }
342 
343  template<class Generator>
344  static rocrand_status generate(Generator& g, half * output, size_t size)
345  {
346  return rocrand_generate_uniform_half(g.m_generator, output, size);
347  }
348 };
349 
355 template<class RealType = float>
357 {
358  static_assert(
359  std::is_same<float, RealType>::value
360  || std::is_same<double, RealType>::value
361  || std::is_same<half, RealType>::value,
362  "Only float, double and half types are supported in normal_distribution"
363  );
364 
365 public:
367  typedef RealType result_type;
368 
372  {
373  public:
376 
381  param_type(RealType mean = 0.0, RealType stddev = 1.0)
382  : m_mean(mean), m_stddev(stddev)
383  {
384  }
385 
387  param_type(const param_type& params) = default;
388 
392  RealType mean() const
393  {
394  return m_mean;
395  }
396 
400  RealType stddev() const
401  {
402  return m_stddev;
403  }
404 
406  bool operator==(const param_type& other) const
407  {
408  return m_mean == other.m_mean && m_stddev == other.m_stddev;
409  }
410 
412  bool operator!=(const param_type& other) const
413  {
414  return !(*this == other);
415  }
416  private:
417  RealType m_mean;
418  RealType m_stddev;
419  };
420 
424  normal_distribution(RealType mean = 0.0, RealType stddev = 1.0)
425  : m_params(mean, stddev)
426  {
427  }
428 
431  explicit normal_distribution(const param_type& params)
432  : m_params(params)
433  {
434  }
435 
437  static void reset()
438  {
439  }
440 
444  RealType mean() const
445  {
446  return m_params.mean();
447  }
448 
452  RealType stddev() const
453  {
454  return m_params.stddev();
455  }
456 
458  // cppcheck-suppress functionStatic
459  RealType min() const
460  {
461  return std::numeric_limits<RealType>::lowest();
462  }
463 
465  RealType max() const
466  {
467  return std::numeric_limits<RealType>::max();
468  }
469 
472  {
473  return m_params;
474  }
475 
477  void param(const param_type& params)
478  {
479  m_params = params;
480  }
481 
500  template<class Generator>
501  void operator()(Generator& g, RealType * output, size_t size)
502  {
503  rocrand_status status;
504  status = this->generate(g, output, size);
505  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
506  }
507 
511  bool operator==(const normal_distribution<RealType>& other) const
512  {
513  return this->m_params == other.m_params;
514  }
515 
519  bool operator!=(const normal_distribution<RealType>& other) const
520  {
521  return !(*this == other);
522  }
523 
524 private:
525  template<class Generator>
526  rocrand_status generate(Generator& g, float * output, size_t size)
527  {
529  g.m_generator, output, size, this->mean(), this->stddev()
530  );
531  }
532 
533  template<class Generator>
534  rocrand_status generate(Generator& g, double * output, size_t size)
535  {
537  g.m_generator, output, size, this->mean(), this->stddev()
538  );
539  }
540 
541  template<class Generator>
542  rocrand_status generate(Generator& g, half * output, size_t size)
543  {
545  g.m_generator, output, size, this->mean(), this->stddev()
546  );
547  }
548 
549  param_type m_params;
550 };
551 
557 template<class RealType = float>
559 {
560  static_assert(
561  std::is_same<float, RealType>::value
562  || std::is_same<double, RealType>::value
563  || std::is_same<half, RealType>::value,
564  "Only float, double and half types are supported in lognormal_distribution"
565  );
566 
567 public:
569  typedef RealType result_type;
570 
574  {
575  public:
578 
583  param_type(RealType m = 0.0, RealType s = 1.0)
584  : m_mean(m), m_stddev(s)
585  {
586  }
587 
589  param_type(const param_type& params) = default;
590 
594  RealType m() const
595  {
596  return m_mean;
597  }
598 
602  RealType s() const
603  {
604  return m_stddev;
605  }
606 
608  bool operator==(const param_type& other) const
609  {
610  return m_mean == other.m_mean && m_stddev == other.m_stddev;
611  }
612 
614  bool operator!=(const param_type& other) const
615  {
616  return !(*this == other);
617  }
618  private:
619  RealType m_mean;
620  RealType m_stddev;
621  };
622 
626  lognormal_distribution(RealType m = 0.0, RealType s = 1.0)
627  : m_params(m, s)
628  {
629  }
630 
633  explicit lognormal_distribution(const param_type& params)
634  : m_params(params)
635  {
636  }
637 
639  static void reset()
640  {
641  }
642 
646  RealType m() const
647  {
648  return m_params.m();
649  }
650 
654  RealType s() const
655  {
656  return m_params.s();
657  }
658 
661  {
662  return m_params;
663  }
664 
666  void param(const param_type& params)
667  {
668  m_params = params;
669  }
670 
672  // cppcheck-suppress functionStatic
673  RealType min() const
674  {
675  return 0;
676  }
677 
679  RealType max() const
680  {
681  return std::numeric_limits<RealType>::max();
682  }
683 
703  template<class Generator>
704  void operator()(Generator& g, RealType * output, size_t size)
705  {
706  rocrand_status status;
707  status = this->generate(g, output, size);
708  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
709  }
710 
715  {
716  return this->m_params == other.m_params;
717  }
718 
723  {
724  return !(*this == other);
725  }
726 
727 private:
728  template<class Generator>
729  rocrand_status generate(Generator& g, float * output, size_t size)
730  {
732  g.m_generator, output, size, this->m(), this->s()
733  );
734  }
735 
736  template<class Generator>
737  rocrand_status generate(Generator& g, double * output, size_t size)
738  {
740  g.m_generator, output, size, this->m(), this->s()
741  );
742  }
743 
744  template<class Generator>
745  rocrand_status generate(Generator& g, half * output, size_t size)
746  {
748  g.m_generator, output, size, this->m(), this->s()
749  );
750  }
751 
752  param_type m_params;
753 };
754 
760 template<class IntType = unsigned int>
762 {
763  static_assert(
764  std::is_same<unsigned int, IntType>::value,
765  "Only unsigned int type is supported in poisson_distribution"
766  );
767 
768 public:
770  typedef IntType result_type;
771 
775  {
776  public:
779 
783  param_type(double mean = 1.0)
784  : m_mean(mean)
785  {
786  }
787 
789  param_type(const param_type& params) = default;
790 
795  double mean() const
796  {
797  return m_mean;
798  }
799 
801  bool operator==(const param_type& other) const
802  {
803  return m_mean == other.m_mean;
804  }
805 
807  bool operator!=(const param_type& other) const
808  {
809  return !(*this == other);
810  }
811 
812  private:
813  double m_mean;
814  };
815 
819  : m_params(mean)
820  {
821  }
822 
825  explicit poisson_distribution(const param_type& params)
826  : m_params(params)
827  {
828  }
829 
831  static void reset()
832  {
833  }
834 
839  double mean() const
840  {
841  return m_params.mean();
842  }
843 
845  // cppcheck-suppress functionStatic
846  IntType min() const
847  {
848  return 0;
849  }
850 
852  IntType max() const
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  // cppcheck-suppress functionStatic
1120  {
1121  return 0;
1122  }
1123 
1126  {
1127  return std::numeric_limits<unsigned int>::max();
1128  }
1129 
1131  static constexpr rocrand_rng_type type()
1132  {
1134  }
1135 
1136 private:
1137  rocrand_generator m_generator;
1138 
1140  template<class T>
1141  friend class ::rocrand_cpp::uniform_int_distribution;
1142 
1143  template<class T>
1144  friend class ::rocrand_cpp::uniform_real_distribution;
1145 
1146  template<class T>
1147  friend class ::rocrand_cpp::normal_distribution;
1148 
1149  template<class T>
1150  friend class ::rocrand_cpp::lognormal_distribution;
1151 
1152  template<class T>
1153  friend class ::rocrand_cpp::poisson_distribution;
1155 };
1156 
1158 template<unsigned long long DefaultSeed>
1161 
1167 template<unsigned long long DefaultSeed = ROCRAND_XORWOW_DEFAULT_SEED>
1169 {
1170 public:
1172  typedef unsigned int result_type;
1176  typedef unsigned long long offset_type;
1178  typedef unsigned long long seed_type;
1180  static constexpr seed_type default_seed = DefaultSeed;
1181 
1183  xorwow_engine(seed_type seed_value = DefaultSeed,
1184  offset_type offset_value = 0,
1186  {
1187  rocrand_status status;
1188  status = rocrand_create_generator(&m_generator, this->type());
1189  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1190  try
1191  {
1192  this->order(order_value);
1193  if(offset_value > 0)
1194  {
1195  this->offset(offset_value);
1196  }
1197  this->seed(seed_value);
1198  }
1199  catch(...)
1200  {
1201  (void)rocrand_destroy_generator(m_generator);
1202  throw;
1203  }
1204  }
1205 
1207  explicit xorwow_engine(rocrand_generator& generator)
1208  : m_generator(generator)
1209  {
1210  if(generator == NULL)
1211  {
1213  }
1214  generator = NULL;
1215  }
1216 
1217  xorwow_engine(const xorwow_engine&) = delete;
1218 
1219  xorwow_engine& operator=(const xorwow_engine&) = delete;
1220 
1222  xorwow_engine(xorwow_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1223  {
1224  rhs.m_generator = nullptr;
1225  }
1226 
1229  {
1230  rocrand_status status = rocrand_destroy_generator(m_generator);
1231  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1232  (void)status;
1233 
1234  m_generator = rhs.m_generator;
1235  rhs.m_generator = nullptr;
1236  return *this;
1237  }
1238 
1240  ~xorwow_engine() noexcept(false)
1241  {
1242  rocrand_status status = rocrand_destroy_generator(m_generator);
1243  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1244  throw rocrand_cpp::error(status);
1245  }
1246 
1248  void stream(hipStream_t value)
1249  {
1250  rocrand_status status = rocrand_set_stream(m_generator, value);
1251  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1252  }
1253 
1255  void order(order_type value)
1256  {
1257  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1258  if(status != ROCRAND_STATUS_SUCCESS)
1259  throw rocrand_cpp::error(status);
1260  }
1261 
1263  void offset(offset_type value)
1264  {
1265  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1266  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1267  }
1268 
1270  void seed(seed_type value)
1271  {
1272  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1273  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1274  }
1275 
1277  template<class Generator>
1278  void operator()(result_type * output, size_t size)
1279  {
1280  rocrand_status status;
1281  status = rocrand_generate(m_generator, output, size);
1282  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1283  }
1284 
1286  // cppcheck-suppress functionStatic
1288  {
1289  return 0;
1290  }
1291 
1294  {
1295  return std::numeric_limits<unsigned int>::max();
1296  }
1297 
1299  static constexpr rocrand_rng_type type()
1300  {
1302  }
1303 
1304 private:
1305  rocrand_generator m_generator;
1306 
1308  template<class T>
1309  friend class ::rocrand_cpp::uniform_int_distribution;
1310 
1311  template<class T>
1312  friend class ::rocrand_cpp::uniform_real_distribution;
1313 
1314  template<class T>
1315  friend class ::rocrand_cpp::normal_distribution;
1316 
1317  template<class T>
1318  friend class ::rocrand_cpp::lognormal_distribution;
1319 
1320  template<class T>
1321  friend class ::rocrand_cpp::poisson_distribution;
1323 };
1324 
1326 template<unsigned long long DefaultSeed>
1329 
1335 template<unsigned long long DefaultSeed = ROCRAND_MRG31K3P_DEFAULT_SEED>
1337 {
1338 public:
1340  typedef unsigned int result_type;
1344  typedef unsigned long long offset_type;
1346  typedef unsigned long long seed_type;
1348  static constexpr seed_type default_seed = DefaultSeed;
1349 
1351  mrg31k3p_engine(seed_type seed_value = DefaultSeed,
1352  offset_type offset_value = 0,
1354  {
1355  rocrand_status status;
1356  status = rocrand_create_generator(&m_generator, this->type());
1357  if(status != ROCRAND_STATUS_SUCCESS)
1358  throw rocrand_cpp::error(status);
1359  try
1360  {
1361  this->order(order_value);
1362  if(offset_value > 0)
1363  {
1364  this->offset(offset_value);
1365  }
1366  this->seed(seed_value);
1367  }
1368  catch(...)
1369  {
1370  (void)rocrand_destroy_generator(m_generator);
1371  throw;
1372  }
1373  }
1374 
1376  explicit mrg31k3p_engine(rocrand_generator& generator) : m_generator(generator)
1377  {
1378  if(generator == NULL)
1379  {
1381  }
1382  generator = NULL;
1383  }
1384 
1385  mrg31k3p_engine(const mrg31k3p_engine&) = delete;
1386 
1387  mrg31k3p_engine& operator=(const mrg31k3p_engine&) = delete;
1388 
1390  mrg31k3p_engine(mrg31k3p_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1391  {
1392  rhs.m_generator = nullptr;
1393  }
1394 
1397  {
1398  rocrand_status status = rocrand_destroy_generator(m_generator);
1399  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1400  (void)status;
1401 
1402  m_generator = rhs.m_generator;
1403  rhs.m_generator = nullptr;
1404  return *this;
1405  }
1406 
1408  ~mrg31k3p_engine() noexcept(false)
1409  {
1410  rocrand_status status = rocrand_destroy_generator(m_generator);
1411  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1412  throw rocrand_cpp::error(status);
1413  }
1414 
1416  void stream(hipStream_t value)
1417  {
1418  rocrand_status status = rocrand_set_stream(m_generator, value);
1419  if(status != ROCRAND_STATUS_SUCCESS)
1420  throw rocrand_cpp::error(status);
1421  }
1422 
1424  void order(order_type value)
1425  {
1426  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1427  if(status != ROCRAND_STATUS_SUCCESS)
1428  throw rocrand_cpp::error(status);
1429  }
1430 
1432  void offset(offset_type value)
1433  {
1434  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1435  if(status != ROCRAND_STATUS_SUCCESS)
1436  throw rocrand_cpp::error(status);
1437  }
1438 
1440  void seed(seed_type value)
1441  {
1442  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1443  if(status != ROCRAND_STATUS_SUCCESS)
1444  throw rocrand_cpp::error(status);
1445  }
1446 
1448  template<class Generator>
1449  void operator()(result_type* output, size_t size)
1450  {
1451  rocrand_status status;
1452  status = rocrand_generate(m_generator, output, size);
1453  if(status != ROCRAND_STATUS_SUCCESS)
1454  throw rocrand_cpp::error(status);
1455  }
1456 
1458  // cppcheck-suppress functionStatic
1460  {
1461  return 1;
1462  }
1463 
1466  {
1467  return std::numeric_limits<unsigned int>::max();
1468  }
1469 
1471  static constexpr rocrand_rng_type type()
1472  {
1474  }
1475 
1476 private:
1477  rocrand_generator m_generator;
1478 
1480  template<class T>
1481  friend class ::rocrand_cpp::uniform_int_distribution;
1482 
1483  template<class T>
1484  friend class ::rocrand_cpp::uniform_real_distribution;
1485 
1486  template<class T>
1487  friend class ::rocrand_cpp::normal_distribution;
1488 
1489  template<class T>
1490  friend class ::rocrand_cpp::lognormal_distribution;
1491 
1492  template<class T>
1493  friend class ::rocrand_cpp::poisson_distribution;
1495 };
1496 
1498 template<unsigned long long DefaultSeed>
1499 constexpr
1502 
1508 template<unsigned long long DefaultSeed = ROCRAND_MRG32K3A_DEFAULT_SEED>
1510 {
1511 public:
1513  typedef unsigned int result_type;
1517  typedef unsigned long long offset_type;
1519  typedef unsigned long long seed_type;
1521  static constexpr seed_type default_seed = DefaultSeed;
1522 
1524  mrg32k3a_engine(seed_type seed_value = DefaultSeed,
1525  offset_type offset_value = 0,
1527  {
1528  rocrand_status status;
1529  status = rocrand_create_generator(&m_generator, this->type());
1530  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1531  try
1532  {
1533  this->order(order_value);
1534  if(offset_value > 0)
1535  {
1536  this->offset(offset_value);
1537  }
1538  this->seed(seed_value);
1539  }
1540  catch(...)
1541  {
1542  (void)rocrand_destroy_generator(m_generator);
1543  throw;
1544  }
1545  }
1546 
1548  explicit mrg32k3a_engine(rocrand_generator& generator)
1549  : m_generator(generator)
1550  {
1551  if(generator == NULL)
1552  {
1554  }
1555  generator = NULL;
1556  }
1557 
1558  mrg32k3a_engine(const mrg32k3a_engine&) = delete;
1559 
1560  mrg32k3a_engine& operator=(const mrg32k3a_engine&) = delete;
1561 
1563  mrg32k3a_engine(mrg32k3a_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1564  {
1565  rhs.m_generator = nullptr;
1566  }
1567 
1570  {
1571  rocrand_status status = rocrand_destroy_generator(m_generator);
1572  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1573  (void)status;
1574 
1575  m_generator = rhs.m_generator;
1576  rhs.m_generator = nullptr;
1577  return *this;
1578  }
1579 
1581  ~mrg32k3a_engine() noexcept(false)
1582  {
1583  rocrand_status status = rocrand_destroy_generator(m_generator);
1584  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1585  throw rocrand_cpp::error(status);
1586  }
1587 
1589  void stream(hipStream_t value)
1590  {
1591  rocrand_status status = rocrand_set_stream(m_generator, value);
1592  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1593  }
1594 
1596  void order(order_type value)
1597  {
1598  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1599  if(status != ROCRAND_STATUS_SUCCESS)
1600  throw rocrand_cpp::error(status);
1601  }
1602 
1604  void offset(offset_type value)
1605  {
1606  rocrand_status status = rocrand_set_offset(this->m_generator, value);
1607  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1608  }
1609 
1611  void seed(seed_type value)
1612  {
1613  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1614  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1615  }
1616 
1618  template<class Generator>
1619  void operator()(result_type * output, size_t size)
1620  {
1621  rocrand_status status;
1622  status = rocrand_generate(m_generator, output, size);
1623  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1624  }
1625 
1627  // cppcheck-suppress functionStatic
1629  {
1630  return 1;
1631  }
1632 
1635  {
1636  return std::numeric_limits<unsigned int>::max();
1637  }
1638 
1640  static constexpr rocrand_rng_type type()
1641  {
1643  }
1644 
1645 private:
1646  rocrand_generator m_generator;
1647 
1649  template<class T>
1650  friend class ::rocrand_cpp::uniform_int_distribution;
1651 
1652  template<class T>
1653  friend class ::rocrand_cpp::uniform_real_distribution;
1654 
1655  template<class T>
1656  friend class ::rocrand_cpp::normal_distribution;
1657 
1658  template<class T>
1659  friend class ::rocrand_cpp::lognormal_distribution;
1660 
1661  template<class T>
1662  friend class ::rocrand_cpp::poisson_distribution;
1664 };
1665 
1667 template<unsigned long long DefaultSeed>
1670 
1677 template<unsigned long long DefaultSeed = 0>
1679 {
1680 public:
1682  typedef unsigned int result_type;
1686  typedef unsigned long long offset_type;
1688  typedef unsigned long long seed_type;
1690  static constexpr seed_type default_seed = DefaultSeed;
1691 
1700  mtgp32_engine(seed_type seed_value = DefaultSeed,
1702  {
1703  rocrand_status status;
1704  status = rocrand_create_generator(&m_generator, this->type());
1705  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1706  try
1707  {
1708  this->order(order_value);
1709  this->seed(seed_value);
1710  }
1711  catch(...)
1712  {
1713  (void)rocrand_destroy_generator(m_generator);
1714  throw;
1715  }
1716  }
1717 
1719  explicit mtgp32_engine(rocrand_generator& generator)
1720  : m_generator(generator)
1721  {
1722  if(generator == NULL)
1723  {
1725  }
1726  generator = NULL;
1727  }
1728 
1729  mtgp32_engine(const mtgp32_engine&) = delete;
1730 
1731  mtgp32_engine& operator=(const mtgp32_engine&) = delete;
1732 
1734  mtgp32_engine(mtgp32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1735  {
1736  rhs.m_generator = nullptr;
1737  }
1738 
1741  {
1742  rocrand_status status = rocrand_destroy_generator(m_generator);
1743  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1744  (void)status;
1745 
1746  m_generator = rhs.m_generator;
1747  rhs.m_generator = nullptr;
1748  return *this;
1749  }
1750 
1752  ~mtgp32_engine() noexcept(false)
1753  {
1754  rocrand_status status = rocrand_destroy_generator(m_generator);
1755  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1756  throw rocrand_cpp::error(status);
1757  }
1758 
1760  void stream(hipStream_t value)
1761  {
1762  rocrand_status status = rocrand_set_stream(m_generator, value);
1763  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1764  }
1765 
1767  void order(order_type value)
1768  {
1769  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1770  if(status != ROCRAND_STATUS_SUCCESS)
1771  throw rocrand_cpp::error(status);
1772  }
1773 
1775  void seed(seed_type value)
1776  {
1777  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1778  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1779  }
1780 
1782  template<class Generator>
1783  void operator()(result_type * output, size_t size)
1784  {
1785  rocrand_status status;
1786  status = rocrand_generate(m_generator, output, size);
1787  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1788  }
1789 
1791  // cppcheck-suppress functionStatic
1793  {
1794  return 0;
1795  }
1796 
1799  {
1800  return std::numeric_limits<unsigned int>::max();
1801  }
1802 
1804  static constexpr rocrand_rng_type type()
1805  {
1807  }
1808 
1809 private:
1810  rocrand_generator m_generator;
1811 
1813  template<class T>
1814  friend class ::rocrand_cpp::uniform_int_distribution;
1815 
1816  template<class T>
1817  friend class ::rocrand_cpp::uniform_real_distribution;
1818 
1819  template<class T>
1820  friend class ::rocrand_cpp::normal_distribution;
1821 
1822  template<class T>
1823  friend class ::rocrand_cpp::lognormal_distribution;
1824 
1825  template<class T>
1826  friend class ::rocrand_cpp::poisson_distribution;
1828 };
1829 
1831 template<unsigned long long DefaultSeed>
1834 
1840 template<unsigned int DefaultSeedX = ROCRAND_LFSR113_DEFAULT_SEED_X,
1841  unsigned int DefaultSeedY = ROCRAND_LFSR113_DEFAULT_SEED_Y,
1842  unsigned int DefaultSeedZ = ROCRAND_LFSR113_DEFAULT_SEED_Z,
1843  unsigned int DefaultSeedW = ROCRAND_LFSR113_DEFAULT_SEED_W>
1845 {
1846 public:
1848  typedef unsigned int result_type;
1852  typedef uint4 seed_type;
1854  static constexpr seed_type default_seed
1855  = {DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW};
1856 
1865  lfsr113_engine(seed_type seed_value = {DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW},
1867  {
1868  rocrand_status status;
1869  status = rocrand_create_generator(&m_generator, this->type());
1870  if(status != ROCRAND_STATUS_SUCCESS)
1871  throw rocrand_cpp::error(status);
1872  try
1873  {
1874  this->order(order_value);
1875  this->seed(seed_value);
1876  }
1877  catch(...)
1878  {
1879  (void)rocrand_destroy_generator(m_generator);
1880  throw;
1881  }
1882  }
1883 
1885  explicit lfsr113_engine(rocrand_generator& generator) : m_generator(generator)
1886  {
1887  if(generator == NULL)
1888  {
1890  }
1891  generator = NULL;
1892  }
1893 
1894  lfsr113_engine(const lfsr113_engine&) = delete;
1895 
1896  lfsr113_engine& operator=(const lfsr113_engine&) = delete;
1897 
1899  lfsr113_engine(lfsr113_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1900  {
1901  rhs.m_generator = nullptr;
1902  }
1903 
1906  {
1907  rocrand_status status = rocrand_destroy_generator(m_generator);
1908  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1909  (void)status;
1910 
1911  m_generator = rhs.m_generator;
1912  rhs.m_generator = nullptr;
1913  return *this;
1914  }
1915 
1917  ~lfsr113_engine() noexcept(false)
1918  {
1919  rocrand_status status = rocrand_destroy_generator(m_generator);
1920  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1921  throw rocrand_cpp::error(status);
1922  }
1923 
1925  void stream(hipStream_t value)
1926  {
1927  rocrand_status status = rocrand_set_stream(m_generator, value);
1928  if(status != ROCRAND_STATUS_SUCCESS)
1929  throw rocrand_cpp::error(status);
1930  }
1931 
1933  void order(order_type value)
1934  {
1935  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1936  if(status != ROCRAND_STATUS_SUCCESS)
1937  throw rocrand_cpp::error(status);
1938  }
1939 
1941  void seed(unsigned long long value)
1942  {
1943  rocrand_status status = rocrand_set_seed(this->m_generator, value);
1944  if(status != ROCRAND_STATUS_SUCCESS)
1945  throw rocrand_cpp::error(status);
1946  }
1947 
1949  void seed(seed_type value)
1950  {
1951  rocrand_status status = rocrand_set_seed_uint4(this->m_generator, value);
1952  if(status != ROCRAND_STATUS_SUCCESS)
1953  throw rocrand_cpp::error(status);
1954  }
1955 
1957  template<class Generator>
1958  void operator()(result_type* output, size_t size)
1959  {
1960  rocrand_status status;
1961  status = rocrand_generate(m_generator, output, size);
1962  if(status != ROCRAND_STATUS_SUCCESS)
1963  throw rocrand_cpp::error(status);
1964  }
1965 
1967  // cppcheck-suppress functionStatic
1969  {
1970  return 0;
1971  }
1972 
1975  {
1976  return std::numeric_limits<unsigned int>::max();
1977  }
1978 
1980  static constexpr rocrand_rng_type type()
1981  {
1983  }
1984 
1985 private:
1986  rocrand_generator m_generator;
1987 
1989  template<class T>
1990  friend class ::rocrand_cpp::uniform_int_distribution;
1991 
1992  template<class T>
1993  friend class ::rocrand_cpp::uniform_real_distribution;
1994 
1995  template<class T>
1996  friend class ::rocrand_cpp::normal_distribution;
1997 
1998  template<class T>
1999  friend class ::rocrand_cpp::lognormal_distribution;
2000 
2001  template<class T>
2002  friend class ::rocrand_cpp::poisson_distribution;
2004 };
2005 
2007 template<unsigned int DefaultSeedX,
2008  unsigned int DefaultSeedY,
2009  unsigned int DefaultSeedZ,
2010  unsigned int DefaultSeedW>
2014 
2021 template<unsigned long long DefaultSeed = 0ULL>
2023 {
2024 public:
2026  typedef unsigned int result_type;
2028  typedef unsigned long long seed_type;
2030  static constexpr seed_type default_seed = DefaultSeed;
2031 
2035  mt19937_engine(seed_type seed_value = DefaultSeed)
2036  {
2037  rocrand_status status;
2038  status = rocrand_create_generator(&m_generator, this->type());
2039  if(status != ROCRAND_STATUS_SUCCESS)
2040  throw rocrand_cpp::error(status);
2041  try
2042  {
2043  this->seed(seed_value);
2044  }
2045  catch(...)
2046  {
2047  (void)rocrand_destroy_generator(m_generator);
2048  throw;
2049  }
2050  }
2051 
2053  explicit mt19937_engine(rocrand_generator& generator) : m_generator(generator)
2054  {
2055  if(generator == NULL)
2056  {
2058  }
2059  generator = NULL;
2060  }
2061 
2062  mt19937_engine(const mt19937_engine&) = delete;
2063 
2064  mt19937_engine& operator=(const mt19937_engine&) = delete;
2065 
2067  mt19937_engine(mt19937_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2068  {
2069  rhs.m_generator = nullptr;
2070  }
2071 
2074  {
2075  rocrand_status status = rocrand_destroy_generator(m_generator);
2076  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2077  (void)status;
2078 
2079  m_generator = rhs.m_generator;
2080  rhs.m_generator = nullptr;
2081  return *this;
2082  }
2083 
2085  ~mt19937_engine() noexcept(false)
2086  {
2087  rocrand_status status = rocrand_destroy_generator(m_generator);
2088  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2089  throw rocrand_cpp::error(status);
2090  }
2091 
2093  void stream(hipStream_t value)
2094  {
2095  rocrand_status status = rocrand_set_stream(m_generator, value);
2096  if(status != ROCRAND_STATUS_SUCCESS)
2097  throw rocrand_cpp::error(status);
2098  }
2099 
2101  void seed(seed_type value)
2102  {
2103  rocrand_status status = rocrand_set_seed(this->m_generator, value);
2104  if(status != ROCRAND_STATUS_SUCCESS)
2105  throw rocrand_cpp::error(status);
2106  }
2107 
2109  template<class Generator>
2110  void operator()(result_type* output, size_t size)
2111  {
2112  rocrand_status status;
2113  status = rocrand_generate(m_generator, output, size);
2114  if(status != ROCRAND_STATUS_SUCCESS)
2115  throw rocrand_cpp::error(status);
2116  }
2117 
2119  // cppcheck-suppress functionStatic
2121  {
2122  return 0;
2123  }
2124 
2127  {
2128  return std::numeric_limits<unsigned int>::max();
2129  }
2130 
2132  static constexpr rocrand_rng_type type()
2133  {
2135  }
2136 
2137 private:
2138  rocrand_generator m_generator;
2139 
2141  template<class T>
2142  friend class ::rocrand_cpp::uniform_int_distribution;
2143 
2144  template<class T>
2145  friend class ::rocrand_cpp::uniform_real_distribution;
2146 
2147  template<class T>
2148  friend class ::rocrand_cpp::normal_distribution;
2149 
2150  template<class T>
2151  friend class ::rocrand_cpp::lognormal_distribution;
2152 
2153  template<class T>
2154  friend class ::rocrand_cpp::poisson_distribution;
2156 };
2157 
2159 template<unsigned long long DefaultSeed>
2162 
2168 template<unsigned int DefaultNumDimensions = 1>
2170 {
2171 public:
2173  typedef unsigned int result_type;
2177  typedef unsigned long long offset_type;
2182  typedef unsigned int dimensions_num_type;
2184  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2185 
2193  sobol32_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2194  offset_type offset_value = 0,
2196  {
2197  rocrand_status status;
2198  status = rocrand_create_generator(&m_generator, this->type());
2199  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2200  try
2201  {
2202  this->order(order_value);
2203  if(offset_value > 0)
2204  {
2205  this->offset(offset_value);
2206  }
2207  this->dimensions(num_of_dimensions);
2208  }
2209  catch(...)
2210  {
2211  (void)rocrand_destroy_generator(m_generator);
2212  throw;
2213  }
2214  }
2215 
2217  explicit sobol32_engine(rocrand_generator& generator)
2218  : m_generator(generator)
2219  {
2220  if(generator == NULL)
2221  {
2223  }
2224  generator = NULL;
2225  }
2226 
2227  sobol32_engine(const sobol32_engine&) = delete;
2228 
2229  sobol32_engine& operator=(const sobol32_engine&) = delete;
2230 
2232  sobol32_engine(sobol32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2233  {
2234  rhs.m_generator = nullptr;
2235  }
2236 
2239  {
2240  rocrand_status status = rocrand_destroy_generator(m_generator);
2241  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2242  (void)status;
2243 
2244  m_generator = rhs.m_generator;
2245  rhs.m_generator = nullptr;
2246  return *this;
2247  }
2248 
2250  ~sobol32_engine() noexcept(false)
2251  {
2252  rocrand_status status = rocrand_destroy_generator(m_generator);
2253  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2254  throw rocrand_cpp::error(status);
2255  }
2256 
2258  void stream(hipStream_t value)
2259  {
2260  rocrand_status status = rocrand_set_stream(m_generator, value);
2261  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2262  }
2263 
2265  void order(order_type value)
2266  {
2267  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2268  if(status != ROCRAND_STATUS_SUCCESS)
2269  throw rocrand_cpp::error(status);
2270  }
2271 
2273  void offset(offset_type value)
2274  {
2275  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2276  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2277  }
2278 
2290  {
2291  rocrand_status status =
2292  rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2293  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2294  }
2295 
2311  template<class Generator>
2312  void operator()(result_type * output, size_t size)
2313  {
2314  rocrand_status status;
2315  status = rocrand_generate(m_generator, output, size);
2316  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2317  }
2318 
2320  // cppcheck-suppress functionStatic
2322  {
2323  return 0;
2324  }
2325 
2328  {
2329  return std::numeric_limits<unsigned int>::max();
2330  }
2331 
2333  static constexpr rocrand_rng_type type()
2334  {
2336  }
2337 
2338 private:
2339  rocrand_generator m_generator;
2340 
2342  template<class T>
2343  friend class ::rocrand_cpp::uniform_int_distribution;
2344 
2345  template<class T>
2346  friend class ::rocrand_cpp::uniform_real_distribution;
2347 
2348  template<class T>
2349  friend class ::rocrand_cpp::normal_distribution;
2350 
2351  template<class T>
2352  friend class ::rocrand_cpp::lognormal_distribution;
2353 
2354  template<class T>
2355  friend class ::rocrand_cpp::poisson_distribution;
2357 };
2358 
2360 template<unsigned int DefaultNumDimensions>
2364 
2370 template<unsigned int DefaultNumDimensions = 1>
2372 {
2373 public:
2375  typedef unsigned int result_type;
2377  typedef unsigned long long offset_type;
2384  typedef unsigned int dimensions_num_type;
2386  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2387 
2395  scrambled_sobol32_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2396  offset_type offset_value = 0,
2398  {
2399  rocrand_status status;
2400  status = rocrand_create_generator(&m_generator, this->type());
2401  if(status != ROCRAND_STATUS_SUCCESS)
2402  throw rocrand_cpp::error(status);
2403  try
2404  {
2405  this->order(order_value);
2406  if(offset_value > 0)
2407  {
2408  this->offset(offset_value);
2409  }
2410  this->dimensions(num_of_dimensions);
2411  }
2412  catch(...)
2413  {
2414  (void)rocrand_destroy_generator(m_generator);
2415  throw;
2416  }
2417  }
2418 
2420  explicit scrambled_sobol32_engine(rocrand_generator& generator) : m_generator(generator)
2421  {
2422  if(generator == NULL)
2423  {
2425  }
2426  generator = NULL;
2427  }
2428 
2430 
2431  scrambled_sobol32_engine& operator=(const scrambled_sobol32_engine&) = delete;
2432 
2434  scrambled_sobol32_engine(scrambled_sobol32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2435  {
2436  rhs.m_generator = nullptr;
2437  }
2438 
2441  {
2442  rocrand_status status = rocrand_destroy_generator(m_generator);
2443  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2444  (void)status;
2445 
2446  m_generator = rhs.m_generator;
2447  rhs.m_generator = nullptr;
2448  return *this;
2449  }
2450 
2452  ~scrambled_sobol32_engine() noexcept(false)
2453  {
2454  rocrand_status status = rocrand_destroy_generator(m_generator);
2455  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2456  throw rocrand_cpp::error(status);
2457  }
2458 
2460  void stream(hipStream_t value)
2461  {
2462  rocrand_status status = rocrand_set_stream(m_generator, value);
2463  if(status != ROCRAND_STATUS_SUCCESS)
2464  throw rocrand_cpp::error(status);
2465  }
2466 
2468  void order(order_type value)
2469  {
2470  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2471  if(status != ROCRAND_STATUS_SUCCESS)
2472  throw rocrand_cpp::error(status);
2473  }
2474 
2476  void offset(offset_type value)
2477  {
2478  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2479  if(status != ROCRAND_STATUS_SUCCESS)
2480  throw rocrand_cpp::error(status);
2481  }
2482 
2494  {
2495  rocrand_status status
2496  = rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2497  if(status != ROCRAND_STATUS_SUCCESS)
2498  throw rocrand_cpp::error(status);
2499  }
2500 
2516  template<class Generator>
2517  void operator()(result_type* output, size_t size)
2518  {
2519  rocrand_status status;
2520  status = rocrand_generate(m_generator, output, size);
2521  if(status != ROCRAND_STATUS_SUCCESS)
2522  throw rocrand_cpp::error(status);
2523  }
2524 
2526  // cppcheck-suppress functionStatic
2528  {
2529  return 0;
2530  }
2531 
2534  {
2535  return std::numeric_limits<unsigned int>::max();
2536  }
2537 
2539  static constexpr rocrand_rng_type type()
2540  {
2542  }
2543 
2544 private:
2545  rocrand_generator m_generator;
2546 
2548  template<class T>
2549  friend class ::rocrand_cpp::uniform_int_distribution;
2550 
2551  template<class T>
2552  friend class ::rocrand_cpp::uniform_real_distribution;
2553 
2554  template<class T>
2555  friend class ::rocrand_cpp::normal_distribution;
2556 
2557  template<class T>
2558  friend class ::rocrand_cpp::lognormal_distribution;
2559 
2560  template<class T>
2561  friend class ::rocrand_cpp::poisson_distribution;
2563 };
2564 
2566 template<unsigned int DefaultNumDimensions>
2570 
2576 template<unsigned int DefaultNumDimensions = 1>
2578 {
2579 public:
2581  typedef unsigned long long int result_type;
2583  typedef unsigned long long int offset_type;
2590  typedef unsigned int dimensions_num_type;
2592  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2593 
2601  sobol64_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2602  offset_type offset_value = 0,
2604  {
2605  rocrand_status status;
2606  status = rocrand_create_generator(&m_generator, this->type());
2607  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2608  try
2609  {
2610  this->order(order_value);
2611  if(offset_value > 0)
2612  {
2613  this->offset(offset_value);
2614  }
2615  this->dimensions(num_of_dimensions);
2616  }
2617  catch(...)
2618  {
2619  (void)rocrand_destroy_generator(m_generator);
2620  throw;
2621  }
2622  }
2623 
2625  explicit sobol64_engine(rocrand_generator& generator)
2626  : m_generator(generator)
2627  {
2628  if(generator == NULL)
2629  {
2631  }
2632  generator = NULL;
2633  }
2634 
2635  sobol64_engine(const sobol64_engine&) = delete;
2636 
2637  sobol64_engine& operator=(const sobol64_engine&) = delete;
2638 
2640  sobol64_engine(sobol64_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2641  {
2642  rhs.m_generator = nullptr;
2643  }
2644 
2647  {
2648  rocrand_status status = rocrand_destroy_generator(m_generator);
2649  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2650  (void)status;
2651 
2652  m_generator = rhs.m_generator;
2653  rhs.m_generator = nullptr;
2654  return *this;
2655  }
2656 
2658  ~sobol64_engine() noexcept(false)
2659  {
2660  rocrand_status status = rocrand_destroy_generator(m_generator);
2661  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2662  throw rocrand_cpp::error(status);
2663  }
2664 
2666  void stream(hipStream_t value)
2667  {
2668  rocrand_status status = rocrand_set_stream(m_generator, value);
2669  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2670  }
2671 
2673  void order(order_type value)
2674  {
2675  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2676  if(status != ROCRAND_STATUS_SUCCESS)
2677  throw rocrand_cpp::error(status);
2678  }
2679 
2681  void offset(offset_type value)
2682  {
2683  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2684  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2685  }
2686 
2698  {
2699  rocrand_status status =
2700  rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2701  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2702  }
2703 
2719  template<class Generator>
2720  void operator()(result_type * output, size_t size)
2721  {
2722  rocrand_status status;
2723  status = rocrand_generate_long_long(m_generator, output, size);
2724  if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2725  }
2726 
2728  // cppcheck-suppress functionStatic
2730  {
2731  return 0;
2732  }
2733 
2736  {
2737  return std::numeric_limits<result_type>::max();
2738  }
2739 
2741  static constexpr rocrand_rng_type type()
2742  {
2744  }
2745 
2746 private:
2747  rocrand_generator m_generator;
2748 
2750  template<class T>
2751  friend class ::rocrand_cpp::uniform_int_distribution;
2752 
2753  template<class T>
2754  friend class ::rocrand_cpp::uniform_real_distribution;
2755 
2756  template<class T>
2757  friend class ::rocrand_cpp::normal_distribution;
2758 
2759  template<class T>
2760  friend class ::rocrand_cpp::lognormal_distribution;
2761 
2762  template<class T>
2763  friend class ::rocrand_cpp::poisson_distribution;
2765 };
2766 
2768 template<unsigned int DefaultNumDimensions>
2772 
2778 template<unsigned int DefaultNumDimensions = 1>
2780 {
2781 public:
2783  typedef unsigned long long int result_type;
2787  typedef unsigned long long int offset_type;
2792  typedef unsigned int dimensions_num_type;
2794  static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2795 
2803  scrambled_sobol64_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2804  offset_type offset_value = 0,
2806  {
2807  rocrand_status status;
2808  status = rocrand_create_generator(&m_generator, this->type());
2809  if(status != ROCRAND_STATUS_SUCCESS)
2810  throw rocrand_cpp::error(status);
2811  try
2812  {
2813  this->order(order_value);
2814  if(offset_value > 0)
2815  {
2816  this->offset(offset_value);
2817  }
2818  this->dimensions(num_of_dimensions);
2819  }
2820  catch(...)
2821  {
2822  (void)rocrand_destroy_generator(m_generator);
2823  throw;
2824  }
2825  }
2826 
2828  explicit scrambled_sobol64_engine(rocrand_generator& generator) : m_generator(generator)
2829  {
2830  if(generator == NULL)
2831  {
2833  }
2834  generator = NULL;
2835  }
2836 
2838 
2839  scrambled_sobol64_engine& operator=(const scrambled_sobol64_engine&) = delete;
2840 
2842  scrambled_sobol64_engine(scrambled_sobol64_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2843  {
2844  rhs.m_generator = nullptr;
2845  }
2846 
2849  {
2850  rocrand_status status = rocrand_destroy_generator(m_generator);
2851  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2852  (void)status;
2853 
2854  m_generator = rhs.m_generator;
2855  rhs.m_generator = nullptr;
2856  return *this;
2857  }
2858 
2860  ~scrambled_sobol64_engine() noexcept(false)
2861  {
2862  rocrand_status status = rocrand_destroy_generator(m_generator);
2863  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2864  throw rocrand_cpp::error(status);
2865  }
2866 
2868  void stream(hipStream_t value)
2869  {
2870  rocrand_status status = rocrand_set_stream(m_generator, value);
2871  if(status != ROCRAND_STATUS_SUCCESS)
2872  throw rocrand_cpp::error(status);
2873  }
2874 
2876  void order(order_type value)
2877  {
2878  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2879  if(status != ROCRAND_STATUS_SUCCESS)
2880  throw rocrand_cpp::error(status);
2881  }
2882 
2884  void offset(offset_type value)
2885  {
2886  rocrand_status status = rocrand_set_offset(this->m_generator, value);
2887  if(status != ROCRAND_STATUS_SUCCESS)
2888  throw rocrand_cpp::error(status);
2889  }
2890 
2902  {
2903  rocrand_status status
2904  = rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2905  if(status != ROCRAND_STATUS_SUCCESS)
2906  throw rocrand_cpp::error(status);
2907  }
2908 
2924  template<class Generator>
2925  void operator()(result_type* output, size_t size)
2926  {
2927  rocrand_status status;
2928  status = rocrand_generate_long_long(m_generator, output, size);
2929  if(status != ROCRAND_STATUS_SUCCESS)
2930  throw rocrand_cpp::error(status);
2931  }
2932 
2934  // cppcheck-suppress functionStatic
2936  {
2937  return 0;
2938  }
2939 
2942  {
2943  return std::numeric_limits<result_type>::max();
2944  }
2945 
2947  static constexpr rocrand_rng_type type()
2948  {
2950  }
2951 
2952 private:
2953  rocrand_generator m_generator;
2954 
2956  template<class T>
2957  friend class ::rocrand_cpp::uniform_int_distribution;
2958 
2959  template<class T>
2960  friend class ::rocrand_cpp::uniform_real_distribution;
2961 
2962  template<class T>
2963  friend class ::rocrand_cpp::normal_distribution;
2964 
2965  template<class T>
2966  friend class ::rocrand_cpp::lognormal_distribution;
2967 
2968  template<class T>
2969  friend class ::rocrand_cpp::poisson_distribution;
2971 };
2972 
2974 template<unsigned int DefaultNumDimensions>
2978 
2983 template<unsigned long long DefaultSeed = 0>
2985 {
2986 public:
2988  typedef unsigned int result_type;
2992  typedef unsigned long long offset_type;
2994  typedef unsigned long long seed_type;
2996  static constexpr seed_type default_seed = DefaultSeed;
2997 
2999  threefry2x32_20_engine(seed_type seed_value = DefaultSeed,
3000  offset_type offset_value = 0,
3002  {
3003  rocrand_status status;
3004  status = rocrand_create_generator(&m_generator, this->type());
3005  if(status != ROCRAND_STATUS_SUCCESS)
3006  throw rocrand_cpp::error(status);
3007  try
3008  {
3009  if(offset_value > 0)
3010  {
3011  this->offset(offset_value);
3012  }
3013  this->order(order_value);
3014  this->seed(seed_value);
3015  }
3016  catch(...)
3017  {
3018  (void)rocrand_destroy_generator(m_generator);
3019  throw;
3020  }
3021  }
3022 
3024  explicit threefry2x32_20_engine(rocrand_generator& generator) : m_generator(generator)
3025  {
3026  if(generator == NULL)
3027  {
3029  }
3030  generator = NULL;
3031  }
3032 
3034 
3035  threefry2x32_20_engine& operator=(const threefry2x32_20_engine&) = delete;
3036 
3038  threefry2x32_20_engine(threefry2x32_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3039  {
3040  rhs.m_generator = nullptr;
3041  }
3042 
3045  {
3046  rocrand_status status = rocrand_destroy_generator(m_generator);
3047  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3048  (void)status;
3049 
3050  m_generator = rhs.m_generator;
3051  rhs.m_generator = nullptr;
3052  return *this;
3053  }
3054 
3056  ~threefry2x32_20_engine() noexcept(false)
3057  {
3058  rocrand_status status = rocrand_destroy_generator(m_generator);
3059  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3060  throw rocrand_cpp::error(status);
3061  }
3062 
3064  void stream(hipStream_t value)
3065  {
3066  rocrand_status status = rocrand_set_stream(m_generator, value);
3067  if(status != ROCRAND_STATUS_SUCCESS)
3068  throw rocrand_cpp::error(status);
3069  }
3070 
3072  void order(order_type value)
3073  {
3074  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3075  if(status != ROCRAND_STATUS_SUCCESS)
3076  throw rocrand_cpp::error(status);
3077  }
3078 
3080  void offset(offset_type value)
3081  {
3082  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3083  if(status != ROCRAND_STATUS_SUCCESS)
3084  throw rocrand_cpp::error(status);
3085  }
3086 
3088  void seed(seed_type value)
3089  {
3090  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3091  if(status != ROCRAND_STATUS_SUCCESS)
3092  throw rocrand_cpp::error(status);
3093  }
3094 
3096  template<class Generator>
3097  void operator()(result_type* output, size_t size)
3098  {
3099  rocrand_status status;
3100  status = rocrand_generate(m_generator, output, size);
3101  if(status != ROCRAND_STATUS_SUCCESS)
3102  throw rocrand_cpp::error(status);
3103  }
3104 
3106  // cppcheck-suppress functionStatic
3108  {
3109  return 0;
3110  }
3111 
3114  {
3115  return std::numeric_limits<unsigned int>::max();
3116  }
3117 
3119  static constexpr rocrand_rng_type type()
3120  {
3122  }
3123 
3124 private:
3125  rocrand_generator m_generator;
3126 
3128  template<class T>
3129  friend class ::rocrand_cpp::uniform_int_distribution;
3130 
3131  template<class T>
3132  friend class ::rocrand_cpp::uniform_real_distribution;
3133 
3134  template<class T>
3135  friend class ::rocrand_cpp::normal_distribution;
3136 
3137  template<class T>
3138  friend class ::rocrand_cpp::lognormal_distribution;
3139 
3140  template<class T>
3141  friend class ::rocrand_cpp::poisson_distribution;
3143 };
3144 
3146 template<unsigned long long DefaultSeed>
3150 
3155 template<unsigned long long DefaultSeed = 0>
3157 {
3158 public:
3160  typedef unsigned long long result_type;
3164  typedef unsigned long long offset_type;
3166  typedef unsigned long long seed_type;
3168  static constexpr seed_type default_seed = DefaultSeed;
3169 
3171  threefry2x64_20_engine(seed_type seed_value = DefaultSeed,
3172  offset_type offset_value = 0,
3174  {
3175  rocrand_status status;
3176  status = rocrand_create_generator(&m_generator, this->type());
3177  if(status != ROCRAND_STATUS_SUCCESS)
3178  throw rocrand_cpp::error(status);
3179  try
3180  {
3181  if(offset_value > 0)
3182  {
3183  this->offset(offset_value);
3184  }
3185  this->order(order_value);
3186  this->seed(seed_value);
3187  }
3188  catch(...)
3189  {
3190  (void)rocrand_destroy_generator(m_generator);
3191  throw;
3192  }
3193  }
3194 
3196  explicit threefry2x64_20_engine(rocrand_generator& generator) : m_generator(generator)
3197  {
3198  if(generator == NULL)
3199  {
3201  }
3202  generator = NULL;
3203  }
3204 
3206 
3207  threefry2x64_20_engine& operator=(const threefry2x64_20_engine&) = delete;
3208 
3210  threefry2x64_20_engine(threefry2x64_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3211  {
3212  rhs.m_generator = nullptr;
3213  }
3214 
3217  {
3218  rocrand_status status = rocrand_destroy_generator(m_generator);
3219  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3220  (void)status;
3221 
3222  m_generator = rhs.m_generator;
3223  rhs.m_generator = nullptr;
3224  return *this;
3225  }
3226 
3228  ~threefry2x64_20_engine() noexcept(false)
3229  {
3230  rocrand_status status = rocrand_destroy_generator(m_generator);
3231  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3232  throw rocrand_cpp::error(status);
3233  }
3234 
3236  void stream(hipStream_t value)
3237  {
3238  rocrand_status status = rocrand_set_stream(m_generator, value);
3239  if(status != ROCRAND_STATUS_SUCCESS)
3240  throw rocrand_cpp::error(status);
3241  }
3242 
3244  void order(order_type value)
3245  {
3246  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3247  if(status != ROCRAND_STATUS_SUCCESS)
3248  throw rocrand_cpp::error(status);
3249  }
3250 
3252  void offset(offset_type value)
3253  {
3254  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3255  if(status != ROCRAND_STATUS_SUCCESS)
3256  throw rocrand_cpp::error(status);
3257  }
3258 
3260  void seed(seed_type value)
3261  {
3262  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3263  if(status != ROCRAND_STATUS_SUCCESS)
3264  throw rocrand_cpp::error(status);
3265  }
3266 
3268  template<class Generator>
3269  void operator()(result_type* output, size_t size)
3270  {
3271  rocrand_status status;
3272  status = rocrand_generate_long_long(m_generator, output, size);
3273  if(status != ROCRAND_STATUS_SUCCESS)
3274  throw rocrand_cpp::error(status);
3275  }
3276 
3278  // cppcheck-suppress functionStatic
3280  {
3281  return 0;
3282  }
3283 
3286  {
3287  return std::numeric_limits<unsigned int>::max();
3288  }
3289 
3291  static constexpr rocrand_rng_type type()
3292  {
3294  }
3295 
3296 private:
3297  rocrand_generator m_generator;
3298 
3300  template<class T>
3301  friend class ::rocrand_cpp::uniform_int_distribution;
3302 
3303  template<class T>
3304  friend class ::rocrand_cpp::uniform_real_distribution;
3305 
3306  template<class T>
3307  friend class ::rocrand_cpp::normal_distribution;
3308 
3309  template<class T>
3310  friend class ::rocrand_cpp::lognormal_distribution;
3311 
3312  template<class T>
3313  friend class ::rocrand_cpp::poisson_distribution;
3315 };
3316 
3318 template<unsigned long long DefaultSeed>
3322 
3327 template<unsigned long long DefaultSeed = 0>
3329 {
3330 public:
3332  typedef unsigned int result_type;
3336  typedef unsigned long long offset_type;
3338  typedef unsigned long long seed_type;
3340  static constexpr seed_type default_seed = DefaultSeed;
3341 
3343  threefry4x32_20_engine(seed_type seed_value = DefaultSeed,
3344  offset_type offset_value = 0,
3346  {
3347  rocrand_status status;
3348  status = rocrand_create_generator(&m_generator, this->type());
3349  if(status != ROCRAND_STATUS_SUCCESS)
3350  throw rocrand_cpp::error(status);
3351  try
3352  {
3353  if(offset_value > 0)
3354  {
3355  this->offset(offset_value);
3356  }
3357  this->order(order_value);
3358  this->seed(seed_value);
3359  }
3360  catch(...)
3361  {
3362  (void)rocrand_destroy_generator(m_generator);
3363  throw;
3364  }
3365  }
3366 
3368  explicit threefry4x32_20_engine(rocrand_generator& generator) : m_generator(generator)
3369  {
3370  if(generator == NULL)
3371  {
3373  }
3374  generator = NULL;
3375  }
3376 
3378 
3379  threefry4x32_20_engine& operator=(const threefry4x32_20_engine&) = delete;
3380 
3382  threefry4x32_20_engine(threefry4x32_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3383  {
3384  rhs.m_generator = nullptr;
3385  }
3386 
3389  {
3390  rocrand_status status = rocrand_destroy_generator(m_generator);
3391  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3392  (void)status;
3393 
3394  m_generator = rhs.m_generator;
3395  rhs.m_generator = nullptr;
3396  return *this;
3397  }
3398 
3400  ~threefry4x32_20_engine() noexcept(false)
3401  {
3402  rocrand_status status = rocrand_destroy_generator(m_generator);
3403  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3404  throw rocrand_cpp::error(status);
3405  }
3406 
3408  void stream(hipStream_t value)
3409  {
3410  rocrand_status status = rocrand_set_stream(m_generator, value);
3411  if(status != ROCRAND_STATUS_SUCCESS)
3412  throw rocrand_cpp::error(status);
3413  }
3414 
3416  void order(order_type value)
3417  {
3418  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3419  if(status != ROCRAND_STATUS_SUCCESS)
3420  throw rocrand_cpp::error(status);
3421  }
3422 
3424  void offset(offset_type value)
3425  {
3426  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3427  if(status != ROCRAND_STATUS_SUCCESS)
3428  throw rocrand_cpp::error(status);
3429  }
3430 
3432  void seed(seed_type value)
3433  {
3434  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3435  if(status != ROCRAND_STATUS_SUCCESS)
3436  throw rocrand_cpp::error(status);
3437  }
3438 
3440  template<class Generator>
3441  void operator()(result_type* output, size_t size)
3442  {
3443  rocrand_status status;
3444  status = rocrand_generate(m_generator, output, size);
3445  if(status != ROCRAND_STATUS_SUCCESS)
3446  throw rocrand_cpp::error(status);
3447  }
3448 
3450  // cppcheck-suppress functionStatic
3452  {
3453  return 0;
3454  }
3455 
3458  {
3459  return std::numeric_limits<unsigned int>::max();
3460  }
3461 
3463  static constexpr rocrand_rng_type type()
3464  {
3466  }
3467 
3468 private:
3469  rocrand_generator m_generator;
3470 
3472  template<class T>
3473  friend class ::rocrand_cpp::uniform_int_distribution;
3474 
3475  template<class T>
3476  friend class ::rocrand_cpp::uniform_real_distribution;
3477 
3478  template<class T>
3479  friend class ::rocrand_cpp::normal_distribution;
3480 
3481  template<class T>
3482  friend class ::rocrand_cpp::lognormal_distribution;
3483 
3484  template<class T>
3485  friend class ::rocrand_cpp::poisson_distribution;
3487 };
3488 
3490 template<unsigned long long DefaultSeed>
3494 
3499 template<unsigned long long DefaultSeed = 0>
3501 {
3502 public:
3504  typedef unsigned long long result_type;
3508  typedef unsigned long long offset_type;
3510  typedef unsigned long long seed_type;
3512  static constexpr seed_type default_seed = DefaultSeed;
3513 
3515  threefry4x64_20_engine(seed_type seed_value = DefaultSeed,
3516  offset_type offset_value = 0,
3518  {
3519  rocrand_status status;
3520  status = rocrand_create_generator(&m_generator, this->type());
3521  if(status != ROCRAND_STATUS_SUCCESS)
3522  throw rocrand_cpp::error(status);
3523  try
3524  {
3525  if(offset_value > 0)
3526  {
3527  this->offset(offset_value);
3528  }
3529  this->order(order_value);
3530  this->seed(seed_value);
3531  }
3532  catch(...)
3533  {
3534  (void)rocrand_destroy_generator(m_generator);
3535  throw;
3536  }
3537  }
3538 
3540  explicit threefry4x64_20_engine(rocrand_generator& generator) : m_generator(generator)
3541  {
3542  if(generator == NULL)
3543  {
3545  }
3546  generator = NULL;
3547  }
3548 
3550 
3551  threefry4x64_20_engine& operator=(const threefry4x64_20_engine&) = delete;
3552 
3554  threefry4x64_20_engine(threefry4x64_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3555  {
3556  rhs.m_generator = nullptr;
3557  }
3558 
3561  {
3562  rocrand_status status = rocrand_destroy_generator(m_generator);
3563  assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3564  (void)status;
3565 
3566  m_generator = rhs.m_generator;
3567  rhs.m_generator = nullptr;
3568  return *this;
3569  }
3570 
3572  ~threefry4x64_20_engine() noexcept(false)
3573  {
3574  rocrand_status status = rocrand_destroy_generator(m_generator);
3575  if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3576  throw rocrand_cpp::error(status);
3577  }
3578 
3580  void stream(hipStream_t value)
3581  {
3582  rocrand_status status = rocrand_set_stream(m_generator, value);
3583  if(status != ROCRAND_STATUS_SUCCESS)
3584  throw rocrand_cpp::error(status);
3585  }
3586 
3588  void order(order_type value)
3589  {
3590  rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3591  if(status != ROCRAND_STATUS_SUCCESS)
3592  throw rocrand_cpp::error(status);
3593  }
3594 
3596  void offset(offset_type value)
3597  {
3598  rocrand_status status = rocrand_set_offset(this->m_generator, value);
3599  if(status != ROCRAND_STATUS_SUCCESS)
3600  throw rocrand_cpp::error(status);
3601  }
3602 
3604  void seed(seed_type value)
3605  {
3606  rocrand_status status = rocrand_set_seed(this->m_generator, value);
3607  if(status != ROCRAND_STATUS_SUCCESS)
3608  throw rocrand_cpp::error(status);
3609  }
3610 
3612  template<class Generator>
3613  void operator()(result_type* output, size_t size)
3614  {
3615  rocrand_status status;
3616  status = rocrand_generate_long_long(m_generator, output, size);
3617  if(status != ROCRAND_STATUS_SUCCESS)
3618  throw rocrand_cpp::error(status);
3619  }
3620 
3622  // cppcheck-suppress functionStatic
3624  {
3625  return 0;
3626  }
3627 
3630  {
3631  return std::numeric_limits<unsigned int>::max();
3632  }
3633 
3635  static constexpr rocrand_rng_type type()
3636  {
3638  }
3639 
3640 private:
3641  rocrand_generator m_generator;
3642 
3644  template<class T>
3645  friend class ::rocrand_cpp::uniform_int_distribution;
3646 
3647  template<class T>
3648  friend class ::rocrand_cpp::uniform_real_distribution;
3649 
3650  template<class T>
3651  friend class ::rocrand_cpp::normal_distribution;
3652 
3653  template<class T>
3654  friend class ::rocrand_cpp::lognormal_distribution;
3655 
3656  template<class T>
3657  friend class ::rocrand_cpp::poisson_distribution;
3659 };
3660 
3662 template<unsigned long long DefaultSeed>
3666 
3713 
3717 
3746 
3749 inline int version()
3750 {
3751  int x;
3752  rocrand_status status = rocrand_get_version(&x);
3753  if(status != ROCRAND_STATUS_SUCCESS)
3754  {
3755  throw rocrand_cpp::error(status);
3756  }
3757  return x;
3758 }
3759 
3761 
3762 } // end namespace rocrand_cpp
3763 
3764 #endif // #if __cplusplus >= 201103L
3765 #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:1845
lfsr113_engine & operator=(lfsr113_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1905
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1958
lfsr113_engine(lfsr113_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1899
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1968
uint4 seed_type
Definition: rocrand.hpp:1852
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1980
void seed(unsigned long long value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1941
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1949
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1855
unsigned int result_type
Definition: rocrand.hpp:1848
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:1865
lfsr113_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1885
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1925
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1974
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1933
rocrand_ordering order_type
Definition: rocrand.hpp:1850
~lfsr113_engine() noexcept(false)
Definition: rocrand.hpp:1917
The type of the distribution parameter set.
Definition: rocrand.hpp:574
RealType m() const
Returns the deviation distribution parameter.
Definition: rocrand.hpp:594
param_type(RealType m=0.0, RealType s=1.0)
Constructs a param_type object with the given distribution parameters.
Definition: rocrand.hpp:583
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition: rocrand.hpp:614
RealType s() const
Returns the deviation distribution parameter.
Definition: rocrand.hpp:602
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:608
Produces positive random numbers according to a log-normal distribution.
Definition: rocrand.hpp:559
void param(const param_type &params)
Sets the distribution parameter object.
Definition: rocrand.hpp:666
RealType result_type
See description for RealType template parameter.
Definition: rocrand.hpp:565
bool operator==(const lognormal_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:714
RealType min() const
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:673
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:639
RealType max() const
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:679
RealType m() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:646
void operator()(Generator &g, RealType *output, size_t size)
Fills output with log-normally distributed random floating-point values.
Definition: rocrand.hpp:704
lognormal_distribution(RealType m=0.0, RealType s=1.0)
Constructs a new distribution object.
Definition: rocrand.hpp:626
RealType s() const
Returns the standard deviation distribution parameter.
Definition: rocrand.hpp:654
bool operator!=(const lognormal_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:722
lognormal_distribution(const param_type &params)
Constructs a new distribution object.
Definition: rocrand.hpp:633
param_type param() const
Returns the distribution parameter object.
Definition: rocrand.hpp:660
Pseudorandom number engine based MRG31k3p CMRG.
Definition: rocrand.hpp:1337
mrg31k3p_engine(mrg31k3p_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1390
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1449
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1465
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1432
mrg31k3p_engine & operator=(mrg31k3p_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1396
rocrand_ordering order_type
Definition: rocrand.hpp:1342
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:1351
unsigned long long seed_type
Definition: rocrand.hpp:1346
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1459
unsigned long long offset_type
Definition: rocrand.hpp:1344
unsigned int result_type
Definition: rocrand.hpp:1340
~mrg31k3p_engine() noexcept(false)
Definition: rocrand.hpp:1408
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1424
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1348
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1416
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1471
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1440
mrg31k3p_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1376
Pseudorandom number engine based MRG32k3a CMRG.
Definition: rocrand.hpp:1510
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1634
mrg32k3a_engine(mrg32k3a_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1563
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1628
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1640
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1604
unsigned long long seed_type
Definition: rocrand.hpp:1519
unsigned long long offset_type
Definition: rocrand.hpp:1517
rocrand_ordering order_type
Definition: rocrand.hpp:1515
unsigned int result_type
Definition: rocrand.hpp:1513
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1611
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1596
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1521
~mrg32k3a_engine() noexcept(false)
Definition: rocrand.hpp:1581
mrg32k3a_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1548
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1589
mrg32k3a_engine & operator=(mrg32k3a_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1569
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1619
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:1524
Random number engine based on the Mersenne Twister algorithm.
Definition: rocrand.hpp:2023
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2126
mt19937_engine & operator=(mt19937_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2073
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:2101
~mt19937_engine() noexcept(false)
Definition: rocrand.hpp:2085
unsigned long long seed_type
Definition: rocrand.hpp:2028
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2110
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2093
mt19937_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2053
mt19937_engine(mt19937_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2067
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2132
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:2030
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2120
mt19937_engine(seed_type seed_value=DefaultSeed)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2035
unsigned int result_type
Definition: rocrand.hpp:2026
Random number engine based on the Mersenne Twister for Graphic Processors algorithm.
Definition: rocrand.hpp:1679
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1792
~mtgp32_engine() noexcept(false)
Definition: rocrand.hpp:1752
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1775
mtgp32_engine & operator=(mtgp32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1740
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1804
unsigned long long seed_type
Definition: rocrand.hpp:1688
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1798
mtgp32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1719
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1760
mtgp32_engine(seed_type seed_value=DefaultSeed, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1700
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1767
unsigned long long offset_type
Definition: rocrand.hpp:1686
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1690
unsigned int result_type
Definition: rocrand.hpp:1682
mtgp32_engine(mtgp32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1734
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1783
rocrand_ordering order_type
Definition: rocrand.hpp:1684
The type of the distribution parameter set.
Definition: rocrand.hpp:372
param_type(const param_type &params)=default
Copy constructor.
RealType mean() const
Returns the deviation distribution parameter.
Definition: rocrand.hpp:392
param_type(RealType mean=0.0, RealType stddev=1.0)
Constructs a param_type object with the given distribution parameters.
Definition: rocrand.hpp:381
bool operator==(const param_type &other) const
Returns true if the param_type is the same as other.
Definition: rocrand.hpp:406
RealType stddev() const
Returns the standard deviation distribution parameter.
Definition: rocrand.hpp:400
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition: rocrand.hpp:412
Produces random numbers according to a normal distribution.
Definition: rocrand.hpp:357
RealType max() const
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:465
normal_distribution(const param_type &params)
Constructs a new distribution object.
Definition: rocrand.hpp:431
void param(const param_type &params)
Sets the distribution parameter object.
Definition: rocrand.hpp:477
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:437
param_type param() const
Returns the distribution parameter object.
Definition: rocrand.hpp:471
RealType mean() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:444
void operator()(Generator &g, RealType *output, size_t size)
Fills output with normally distributed random floating-point values.
Definition: rocrand.hpp:501
bool operator==(const normal_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:511
RealType result_type
See description for RealType template parameter.
Definition: rocrand.hpp:363
RealType min() const
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:459
normal_distribution(RealType mean=0.0, RealType stddev=1.0)
Constructs a new distribution object.
Definition: rocrand.hpp:424
RealType stddev() const
Returns the standard deviation distribution parameter.
Definition: rocrand.hpp:452
bool operator!=(const normal_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:519
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:1131
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1125
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
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
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1119
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
rocrand_ordering order_type
Definition: rocrand.hpp:931
The type of the distribution parameter set.
Definition: rocrand.hpp:775
double mean() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:795
param_type(double mean=1.0)
Constructs a param_type object with the given mean.
Definition: rocrand.hpp:783
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:801
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition: rocrand.hpp:807
Produces random non-negative integer values distributed according to Poisson distribution.
Definition: rocrand.hpp:762
double mean() const
Returns the mean distribution parameter.
Definition: rocrand.hpp:839
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:766
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:831
param_type param() const
Returns the distribution parameter object.
Definition: rocrand.hpp:858
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:825
IntType max() const
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:852
poisson_distribution(double mean=1.0)
Constructs a new distribution object.
Definition: rocrand.hpp:818
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
IntType min() const
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:846
Sobol's scrambled quasi-random sequence generator.
Definition: rocrand.hpp:2372
unsigned int result_type
Definition: rocrand.hpp:2375
scrambled_sobol32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2420
unsigned int dimensions_num_type
Definition: rocrand.hpp:2384
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2468
scrambled_sobol32_engine(scrambled_sobol32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2434
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2533
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:2395
unsigned long long offset_type
Definition: rocrand.hpp:2377
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2460
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2527
~scrambled_sobol32_engine() noexcept(false)
Definition: rocrand.hpp:2452
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2476
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2386
rocrand_ordering order_type
Definition: rocrand.hpp:2379
scrambled_sobol32_engine & operator=(scrambled_sobol32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2440
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2539
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2517
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2493
Sobol's scrambled quasi-random sequence generator.
Definition: rocrand.hpp:2780
unsigned int dimensions_num_type
Definition: rocrand.hpp:2792
scrambled_sobol64_engine(scrambled_sobol64_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2842
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:2803
unsigned long long int offset_type
Definition: rocrand.hpp:2787
unsigned long long int result_type
Definition: rocrand.hpp:2783
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2901
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2884
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2794
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2941
rocrand_ordering order_type
Definition: rocrand.hpp:2785
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2935
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2925
scrambled_sobol64_engine & operator=(scrambled_sobol64_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2848
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2876
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2868
~scrambled_sobol64_engine() noexcept(false)
Definition: rocrand.hpp:2860
scrambled_sobol64_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2828
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2947
Sobol's quasi-random sequence generator.
Definition: rocrand.hpp:2170
sobol32_engine(sobol32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2232
unsigned int result_type
Definition: rocrand.hpp:2173
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:2193
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2289
sobol32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2217
~sobol32_engine() noexcept(false)
Definition: rocrand.hpp:2250
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2265
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2273
unsigned long long offset_type
Definition: rocrand.hpp:2177
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2312
sobol32_engine & operator=(sobol32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2238
unsigned int dimensions_num_type
Definition: rocrand.hpp:2182
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2333
rocrand_ordering order_type
Definition: rocrand.hpp:2175
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2184
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2321
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2327
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2258
Sobol's quasi-random sequence generator.
Definition: rocrand.hpp:2578
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition: rocrand.hpp:2697
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:2681
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:2673
unsigned long long int result_type
Definition: rocrand.hpp:2581
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:2741
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:2601
unsigned int dimensions_num_type
Definition: rocrand.hpp:2590
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition: rocrand.hpp:2592
sobol64_engine & operator=(sobol64_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:2646
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:2666
unsigned long long int offset_type
Definition: rocrand.hpp:2583
sobol64_engine(sobol64_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:2640
sobol64_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:2625
rocrand_ordering order_type
Definition: rocrand.hpp:2585
~sobol64_engine() noexcept(false)
Definition: rocrand.hpp:2658
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:2720
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:2735
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:2729
Pseudorandom number engine based on 2 state ThreeFry.
Definition: rocrand.hpp:2985
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3107
unsigned int result_type
Definition: rocrand.hpp:2988
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3064
threefry2x32_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3024
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3119
threefry2x32_20_engine & operator=(threefry2x32_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3044
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:2999
~threefry2x32_20_engine() noexcept(false)
Definition: rocrand.hpp:3056
unsigned long long seed_type
Definition: rocrand.hpp:2994
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3097
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3088
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3080
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:2996
rocrand_ordering order_type
Definition: rocrand.hpp:2990
unsigned long long offset_type
Definition: rocrand.hpp:2992
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3113
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3072
threefry2x32_20_engine(threefry2x32_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3038
Pseudorandom number engine based 2 state ThreeFry.
Definition: rocrand.hpp:3157
unsigned long long seed_type
Definition: rocrand.hpp:3166
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3168
threefry2x64_20_engine & operator=(threefry2x64_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3216
unsigned long long result_type
Definition: rocrand.hpp:3160
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3260
~threefry2x64_20_engine() noexcept(false)
Definition: rocrand.hpp:3228
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:3171
rocrand_ordering order_type
Definition: rocrand.hpp:3162
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3291
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3252
threefry2x64_20_engine(threefry2x64_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3210
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3269
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3285
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3244
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3279
unsigned long long offset_type
Definition: rocrand.hpp:3164
threefry2x64_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3196
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3236
Pseudorandom number engine based on 2 state ThreeFry.
Definition: rocrand.hpp:3329
threefry4x32_20_engine & operator=(threefry4x32_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3388
~threefry4x32_20_engine() noexcept(false)
Definition: rocrand.hpp:3400
unsigned long long seed_type
Definition: rocrand.hpp:3338
threefry4x32_20_engine(threefry4x32_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3382
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3457
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:3343
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3408
unsigned int result_type
Definition: rocrand.hpp:3332
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3451
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3424
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3432
rocrand_ordering order_type
Definition: rocrand.hpp:3334
threefry4x32_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3368
unsigned long long offset_type
Definition: rocrand.hpp:3336
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3441
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3463
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3340
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3416
Pseudorandom number engine based 2 state ThreeFry.
Definition: rocrand.hpp:3501
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:3515
threefry4x64_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:3540
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:3512
unsigned long long seed_type
Definition: rocrand.hpp:3510
threefry4x64_20_engine & operator=(threefry4x64_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:3560
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:3596
~threefry4x64_20_engine() noexcept(false)
Definition: rocrand.hpp:3572
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:3635
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:3580
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:3623
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:3588
unsigned long long offset_type
Definition: rocrand.hpp:3508
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:3613
threefry4x64_20_engine(threefry4x64_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:3554
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:3629
unsigned long long result_type
Definition: rocrand.hpp:3504
rocrand_ordering order_type
Definition: rocrand.hpp:3506
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:3604
Produces random integer values uniformly distributed on the interval [0, 2^(sizeof(IntType)*8) - 1].
Definition: rocrand.hpp:146
IntType max() const
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:176
bool operator!=(const uniform_int_distribution< IntType > &other) const
Returns true if the distribution is different from other.
Definition: rocrand.hpp:214
IntType min() const
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:170
void operator()(Generator &g, IntType *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:199
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:207
uniform_int_distribution()
Default constructor.
Definition: rocrand.hpp:159
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:164
Produces random floating-point values uniformly distributed on the interval (0, 1].
Definition: rocrand.hpp:252
RealType min() const
Returns the smallest possible value that can be generated.
Definition: rocrand.hpp:276
static void reset()
Resets distribution's internal state if there is any.
Definition: rocrand.hpp:270
RealType result_type
See description for RealType template parameter.
Definition: rocrand.hpp:258
RealType max() const
Returns the largest possible value that can be generated.
Definition: rocrand.hpp:287
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:325
void operator()(Generator &g, RealType *output, size_t size)
Fills output with uniformly distributed random floating-point values.
Definition: rocrand.hpp:310
bool operator==(const uniform_real_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition: rocrand.hpp:318
Pseudorandom number engine based XORWOW algorithm.
Definition: rocrand.hpp:1169
void order(order_type value)
Sets the order of a random number engine.
Definition: rocrand.hpp:1255
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition: rocrand.hpp:1248
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition: rocrand.hpp:1299
result_type min() const
Returns the smallest possible value that can be generated by the engine.
Definition: rocrand.hpp:1287
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition: rocrand.hpp:1270
rocrand_ordering order_type
Definition: rocrand.hpp:1174
xorwow_engine(xorwow_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition: rocrand.hpp:1222
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:1183
xorwow_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition: rocrand.hpp:1207
xorwow_engine & operator=(xorwow_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition: rocrand.hpp:1228
~xorwow_engine() noexcept(false)
Definition: rocrand.hpp:1240
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition: rocrand.hpp:1278
result_type max() const
Returns the largest possible value that can be generated by the engine.
Definition: rocrand.hpp:1293
void offset(offset_type value)
Sets the offset of a random number engine.
Definition: rocrand.hpp:1263
unsigned int result_type
Definition: rocrand.hpp:1172
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition: rocrand.hpp:1180
unsigned long long seed_type
Definition: rocrand.hpp:1178
unsigned long long offset_type
Definition: rocrand.hpp:1176
#define ROCRAND_LFSR113_DEFAULT_SEED_Y
Default Y seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:39
#define ROCRAND_LFSR113_DEFAULT_SEED_W
Default W seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:45
#define ROCRAND_LFSR113_DEFAULT_SEED_Z
Default Z seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:42
#define ROCRAND_LFSR113_DEFAULT_SEED_X
Default X seed for LFSR113 PRNG.
Definition: rocrand_lfsr113.h:36
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:108
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:60
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:79
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:110
@ 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:63
@ ROCRAND_STATUS_LAUNCH_FAILURE
Kernel launch failure.
Definition: rocrand.h:71
@ ROCRAND_STATUS_VERSION_MISMATCH
Header file and linked library version do not match.
Definition: rocrand.h:62
@ ROCRAND_STATUS_LENGTH_NOT_MULTIPLE
Definition: rocrand.h:67
@ ROCRAND_STATUS_DOUBLE_PRECISION_REQUIRED
GPU does not have double precision.
Definition: rocrand.h:70
@ ROCRAND_STATUS_SUCCESS
No errors.
Definition: rocrand.h:61
@ ROCRAND_STATUS_INTERNAL_ERROR
Internal library error.
Definition: rocrand.h:72
@ ROCRAND_STATUS_OUT_OF_RANGE
Argument out of range.
Definition: rocrand.h:66
@ ROCRAND_STATUS_ALLOCATION_FAILED
Memory allocation failed during execution.
Definition: rocrand.h:64
@ ROCRAND_STATUS_TYPE_ERROR
Generator type is wrong.
Definition: rocrand.h:65
@ ROCRAND_RNG_QUASI_SOBOL64
Sobol64 quasirandom generator.
Definition: rocrand.h:99
@ ROCRAND_RNG_PSEUDO_LFSR113
LFSR113 pseudorandom generator.
Definition: rocrand.h:86
@ ROCRAND_RNG_PSEUDO_THREEFRY2_64_20
ThreeFry 64 bit state size 2 pseudorandom generator.
Definition: rocrand.h:90
@ ROCRAND_RNG_PSEUDO_XORWOW
XORWOW pseudorandom generator.
Definition: rocrand.h:81
@ ROCRAND_RNG_PSEUDO_THREEFRY4_32_20
ThreeFry 32 bit state size 4 pseudorandom generator.
Definition: rocrand.h:92
@ ROCRAND_RNG_PSEUDO_MRG31K3P
MRG31k3p pseudorandom generator.
Definition: rocrand.h:85
@ ROCRAND_RNG_PSEUDO_MT19937
Mersenne Twister MT19937 pseudorandom generator.
Definition: rocrand.h:87
@ ROCRAND_RNG_PSEUDO_PHILOX4_32_10
PHILOX-4x32-10 pseudorandom generator.
Definition: rocrand.h:84
@ ROCRAND_RNG_PSEUDO_THREEFRY2_32_20
ThreeFry 32 bit state size 2 pseudorandom generator.
Definition: rocrand.h:88
@ ROCRAND_RNG_PSEUDO_THREEFRY4_64_20
ThreeFry 64 bit state size 4 pseudorandom generator.
Definition: rocrand.h:94
@ ROCRAND_RNG_PSEUDO_MTGP32
Mersenne Twister MTGP32 pseudorandom generator.
Definition: rocrand.h:83
@ ROCRAND_RNG_QUASI_SOBOL32
Sobol32 quasirandom generator.
Definition: rocrand.h:97
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL32
Scrambled Sobol32 quasirandom generator.
Definition: rocrand.h:98
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL64
Scrambled Sobol64 quasirandom generator.
Definition: rocrand.h:100
@ ROCRAND_RNG_PSEUDO_MRG32K3A
MRG32k3a pseudorandom generator.
Definition: rocrand.h:82
threefry2x32_20_engine threefry2x32
Typedef of rocrand_cpp::threefry2x32_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3691
mrg31k3p_engine mrg31k3p
Typedef of rocrand_cpp::mrg31k3p_engine PRNG engine with default seed (ROCRAND_MRG31K3P_DEFAULT_SEED)...
Definition: rocrand.hpp:3675
int version()
Returns rocRAND version.
Definition: rocrand.hpp:3749
mrg32k3a_engine mrg32k3a
Typedef of rocrand_cpp::mrg32k3a_engine PRNG engine with default seed (ROCRAND_MRG32K3A_DEFAULT_SEED)...
Definition: rocrand.hpp:3678
scrambled_sobol64_engine scrambled_sobol64
Typedef of rocrand_cpp::scrambled_sobol64_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3712
scrambled_sobol32_engine scrambled_sobol32
Typedef of rocrand_cpp::scrambled_sobol32_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3706
sobol64_engine sobol64
Typedef of rocrand_cpp::sobol64_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3709
mt19937_engine mt19937
Typedef of rocrand_cpp::mt19937_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3688
sobol32_engine sobol32
Typedef of rocrand_cpp::sobol32_engine QRNG engine with default number of dimensions (1).
Definition: rocrand.hpp:3703
lfsr113_engine lfsr113
Typedef of rocrand_cpp::lfsr113_engine PRNG engine with default seed (ROCRAND_LFSR113_DEFAULT_SEED_X,...
Definition: rocrand.hpp:3685
threefry4x64_20_engine threefry4x64
Typedef of rocrand_cpp::threefry4x64_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3700
xorwow_engine xorwow
Typedef of rocrand_cpp::xorwow_engine PRNG engine with default seed (ROCRAND_XORWOW_DEFAULT_SEED).
Definition: rocrand.hpp:3672
threefry4x32_20_engine threefry4x32
Typedef of rocrand_cpp::threefry4x32_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3697
threefry2x64_20_engine threefry2x64
Typedef of rocrand_cpp::threefry2x64_20_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3694
xorwow default_random_engine
Default random engine.
Definition: rocrand.hpp:3716
philox4x32_10_engine philox4x32_10
Typedef of rocrand_cpp::philox4x32_10_engine PRNG engine with default seed (ROCRAND_PHILOX4x32_DEFAUL...
Definition: rocrand.hpp:3669
mtgp32_engine mtgp32
Typedef of rocrand_cpp::mtgp32_engine PRNG engine with default seed (0).
Definition: rocrand.hpp:3681
std::random_device random_device
A non-deterministic uniform random number generator.
Definition: rocrand.hpp:3745