/build/rocrand-7S8maf/rocrand-7.1.1/library/include/rocrand/rocrand.hpp Source File

/build/rocrand-7S8maf/rocrand-7.1.1/library/include/rocrand/rocrand.hpp Source File#

API library: /build/rocrand-7S8maf/rocrand-7.1.1/library/include/rocrand/rocrand.hpp Source File
rocrand.hpp
1// Copyright (c) 2017-2025 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 // IWYU pragma: begin_exports
28 #include "rocrand/rocrand.h"
29 #include "rocrand/rocrand_kernel.h"
30 // IWYU pragma: end_exports
31
32 #include <cassert>
33 #include <exception>
34 #include <limits>
35 #include <random>
36 #include <sstream>
37 #include <string>
38 #include <type_traits>
39
40namespace rocrand_cpp
41{
42
45
51class error : public std::exception
52{
53public:
56
60 explicit error(error_type error) noexcept
61 : m_error(error),
62 m_error_string(to_string(error))
63 {
64 }
65
67 error_type error_code() const noexcept
68 {
69 return m_error;
70 }
71
73 std::string error_string() const noexcept
74 {
75 return m_error_string;
76 }
77
79 const char* what() const noexcept override
80 {
81 return m_error_string.c_str();
82 }
83
90 static std::string to_string(error_type error)
91 {
92 switch(error)
93 {
95 return "Success";
97 return "Header file and linked library version do not match";
99 return "Generator was not created using rocrand_create_generator";
101 return "Memory allocation failed during execution";
103 return "Generator type is wrong";
105 return "Argument out of range";
107 return "Length requested is not a multiple of dimension";
109 return "GPU does not have double precision";
111 return "Kernel launch failure";
113 return "Internal library error";
114 default: {
115 std::stringstream s;
116 s << "Unknown rocRAND error (" << error << ")";
117 return s.str();
118 }
119 }
120 }
121
123 friend
124 bool operator==(const error& l, const error& r)
125 {
126 return l.error_code() == r.error_code();
127 }
128
130 friend
131 bool operator!=(const error& l, const error& r)
132 {
133 return !(l == r);
134 }
135
136private:
137 error_type m_error;
138 std::string m_error_string;
139};
140
146template<class IntType = unsigned int>
148{
149 static_assert(std::is_same<unsigned char, IntType>::value
150 || std::is_same<unsigned short, IntType>::value
151 || std::is_same<unsigned long long int, IntType>::value
152 || std::is_same<unsigned int, IntType>::value,
153 "Only unsigned char, unsigned short, unsigned int and unsigned long long int "
154 "types are supported in uniform_int_distribution");
155
156public:
158 typedef IntType result_type;
159
164
166 static void reset()
167 {
168 }
169
171 static constexpr IntType min()
172 {
173 return 0;
174 }
175
177 static constexpr IntType max()
178 {
179 return std::numeric_limits<IntType>::max();
180 }
181
199 template<class Generator>
200 void operator()(Generator& g, IntType * output, size_t size)
201 {
202 rocrand_status status;
203 status = this->generate(g, output, size);
204 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
205 }
206
209 {
210 (void) other;
211 return true;
212 }
213
216 {
217 return !(*this == other);
218 }
219
220private:
221 template<class Generator>
222 static rocrand_status generate(Generator& g, unsigned char * output, size_t size)
223 {
224 return rocrand_generate_char(g.m_generator, output, size);
225 }
226
227 template<class Generator>
228 static rocrand_status generate(Generator& g, unsigned short * output, size_t size)
229 {
230 return rocrand_generate_short(g.m_generator, output, size);
231 }
232
233 template<class Generator>
234 static rocrand_status generate(Generator& g, unsigned int * output, size_t size)
235 {
236 return rocrand_generate(g.m_generator, output, size);
237 }
238
239 template<class Generator>
240 static rocrand_status generate(Generator& g, unsigned long long int* output, size_t size)
241 {
242 return rocrand_generate_long_long(g.m_generator, output, size);
243 }
244};
245
251
252template<class RealType = float>
254{
255 static_assert(
256 std::is_same<float, RealType>::value
257 || std::is_same<double, RealType>::value
258 || std::is_same<half, RealType>::value,
259 "Only float, double, and half types are supported in uniform_real_distribution"
260 );
261
262public:
264 typedef RealType result_type;
265
270
272 static void reset()
273 {
274 }
275
277 static constexpr RealType min()
278 {
279 return static_cast<RealType>(ROCRAND_2POW32_INV_DOUBLE);
280 }
281
283 static constexpr RealType max()
284 {
285 return 1.0;
286 }
287
305 template<class Generator>
306 void operator()(Generator& g, RealType * output, size_t size)
307 {
308 rocrand_status status;
309 status = this->generate(g, output, size);
310 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
311 }
312
315 {
316 (void) other;
317 return true;
318 }
319
322 {
323 return !(*this == other);
324 }
325
326private:
327 template<class Generator>
328 static rocrand_status generate(Generator& g, float * output, size_t size)
329 {
330 return rocrand_generate_uniform(g.m_generator, output, size);
331 }
332
333 template<class Generator>
334 static rocrand_status generate(Generator& g, double * output, size_t size)
335 {
336 return rocrand_generate_uniform_double(g.m_generator, output, size);
337 }
338
339 template<class Generator>
340 static rocrand_status generate(Generator& g, half * output, size_t size)
341 {
342 return rocrand_generate_uniform_half(g.m_generator, output, size);
343 }
344};
345
351template<class RealType = float>
353{
354 static_assert(
355 std::is_same<float, RealType>::value
356 || std::is_same<double, RealType>::value
357 || std::is_same<half, RealType>::value,
358 "Only float, double and half types are supported in normal_distribution"
359 );
360
361public:
363 typedef RealType result_type;
364
368 {
369 public:
372
377 param_type(RealType mean = 0.0, RealType stddev = 1.0)
378 : m_mean(mean), m_stddev(stddev)
379 {
380 }
381
383 param_type(const param_type& params) = default;
384
386 param_type& operator=(const param_type& params) = default;
387
391 RealType mean() const
392 {
393 return m_mean;
394 }
395
399 RealType stddev() const
400 {
401 return m_stddev;
402 }
403
405 bool operator==(const param_type& other) const
406 {
407 return m_mean == other.m_mean && m_stddev == other.m_stddev;
408 }
409
411 bool operator!=(const param_type& other) const
412 {
413 return !(*this == other);
414 }
415 private:
416 RealType m_mean;
417 RealType m_stddev;
418 };
419
423 normal_distribution(RealType mean = 0.0, RealType stddev = 1.0)
424 : m_params(mean, stddev)
425 {
426 }
427
430 explicit normal_distribution(const param_type& params)
431 : m_params(params)
432 {
433 }
434
436 static void reset()
437 {
438 }
439
443 RealType mean() const
444 {
445 return m_params.mean();
446 }
447
451 RealType stddev() const
452 {
453 return m_params.stddev();
454 }
455
457 static constexpr RealType min()
458 {
459 return std::numeric_limits<RealType>::lowest();
460 }
461
463 static constexpr RealType max()
464 {
465 return std::numeric_limits<RealType>::max();
466 }
467
469 param_type param() const
470 {
471 return m_params;
472 }
473
475 void param(const param_type& params)
476 {
477 m_params = params;
478 }
479
498 template<class Generator>
499 void operator()(Generator& g, RealType * output, size_t size)
500 {
501 rocrand_status status;
502 status = this->generate(g, output, size);
503 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
504 }
505
510 {
511 return this->m_params == other.m_params;
512 }
513
518 {
519 return !(*this == other);
520 }
521
522private:
523 template<class Generator>
524 rocrand_status generate(Generator& g, float * output, size_t size)
525 {
527 g.m_generator, output, size, this->mean(), this->stddev()
528 );
529 }
530
531 template<class Generator>
532 rocrand_status generate(Generator& g, double * output, size_t size)
533 {
535 g.m_generator, output, size, this->mean(), this->stddev()
536 );
537 }
538
539 template<class Generator>
540 rocrand_status generate(Generator& g, half * output, size_t size)
541 {
543 g.m_generator, output, size, this->mean(), this->stddev()
544 );
545 }
546
547 param_type m_params;
548};
549
555template<class RealType = float>
557{
558 static_assert(
559 std::is_same<float, RealType>::value
560 || std::is_same<double, RealType>::value
561 || std::is_same<half, RealType>::value,
562 "Only float, double and half types are supported in lognormal_distribution"
563 );
564
565public:
567 typedef RealType result_type;
568
572 {
573 public:
576
581 param_type(RealType m = 0.0, RealType s = 1.0)
582 : m_mean(m), m_stddev(s)
583 {
584 }
585
587 param_type(const param_type& params) = default;
588
590 param_type& operator=(const param_type& params) = default;
591
595 RealType m() const
596 {
597 return m_mean;
598 }
599
603 RealType s() const
604 {
605 return m_stddev;
606 }
607
609 bool operator==(const param_type& other) const
610 {
611 return m_mean == other.m_mean && m_stddev == other.m_stddev;
612 }
613
615 bool operator!=(const param_type& other) const
616 {
617 return !(*this == other);
618 }
619 private:
620 RealType m_mean;
621 RealType m_stddev;
622 };
623
627 lognormal_distribution(RealType m = 0.0, RealType s = 1.0)
628 : m_params(m, s)
629 {
630 }
631
634 explicit lognormal_distribution(const param_type& params)
635 : m_params(params)
636 {
637 }
638
640 static void reset()
641 {
642 }
643
647 RealType m() const
648 {
649 return m_params.m();
650 }
651
655 RealType s() const
656 {
657 return m_params.s();
658 }
659
661 param_type param() const
662 {
663 return m_params;
664 }
665
667 void param(const param_type& params)
668 {
669 m_params = params;
670 }
671
673 static constexpr RealType min()
674 {
675 return 0;
676 }
677
679 static RealType max()
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
727private:
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
760template<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
768public:
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
792 param_type& operator=(const param_type& params) = default;
793
798 double mean() const
799 {
800 return m_mean;
801 }
802
804 bool operator==(const param_type& other) const
805 {
806 return m_mean == other.m_mean;
807 }
808
810 bool operator!=(const param_type& other) const
811 {
812 return !(*this == other);
813 }
814
815 private:
816 double m_mean;
817 };
818
822 : m_params(mean)
823 {
824 }
825
828 explicit poisson_distribution(const param_type& params)
829 : m_params(params)
830 {
831 }
832
834 static void reset()
835 {
836 }
837
842 double mean() const
843 {
844 return m_params.mean();
845 }
846
848 static constexpr IntType min()
849 {
850 return 0;
851 }
852
854 static constexpr IntType max()
855 {
856 return std::numeric_limits<IntType>::max();
857 }
858
860 param_type param()
861 {
862 return m_params;
863 }
864
866 void param(const param_type& params)
867 {
868 m_params = params;
869 }
870
889 template<class Generator>
890 void operator()(Generator& g, IntType * output, size_t size)
891 {
892 rocrand_status status;
893 status = rocrand_generate_poisson(g.m_generator, output, size, this->mean());
894 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
895 }
896
901 {
902 return this->m_params == other.m_params;
903 }
904
909 {
910 return !(*this == other);
911 }
912
913private:
914 param_type m_params;
915};
916
921template<unsigned long long DefaultSeed = ROCRAND_PHILOX4x32_DEFAULT_SEED>
923{
924public:
927 typedef unsigned int result_type;
928 // \typedef order_type
940 typedef unsigned long long offset_type;
945 typedef unsigned long long seed_type;
947 static constexpr seed_type default_seed = DefaultSeed;
948
956 philox4x32_10_engine(seed_type seed_value = DefaultSeed,
957 offset_type offset_value = 0,
959 {
960 rocrand_status status;
961 status = rocrand_create_generator(&m_generator, this->type());
962 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
963 try
964 {
965 if(offset_value > 0)
966 {
967 this->offset(offset_value);
968 }
969 this->order(order_value);
970 this->seed(seed_value);
971 }
972 catch(...)
973 {
974 (void)rocrand_destroy_generator(m_generator);
975 throw;
976 }
977 }
978
987 explicit philox4x32_10_engine(rocrand_generator& generator)
988 : m_generator(generator)
989 {
990 if(generator == NULL)
991 {
993 }
994 generator = NULL;
995 }
996
998
999 philox4x32_10_engine& operator=(const philox4x32_10_engine&) = delete;
1000
1007 philox4x32_10_engine(philox4x32_10_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1008 {
1009 rhs.m_generator = nullptr;
1010 }
1011
1019 {
1020 rocrand_status status = rocrand_destroy_generator(m_generator);
1021 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1022 (void)status;
1023
1024 m_generator = rhs.m_generator;
1025 rhs.m_generator = nullptr;
1026 return *this;
1027 }
1028
1032 ~philox4x32_10_engine() noexcept(false)
1033 {
1034 rocrand_status status = rocrand_destroy_generator(m_generator);
1035 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1036 throw rocrand_cpp::error(status);
1037 }
1038
1041 void stream(hipStream_t value)
1042 {
1043 rocrand_status status = rocrand_set_stream(m_generator, value);
1044 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1045 }
1046
1058 void order(order_type value)
1059 {
1060 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1061 if(status != ROCRAND_STATUS_SUCCESS)
1062 throw rocrand_cpp::error(status);
1063 }
1064
1077 {
1078 rocrand_status status = rocrand_set_offset(this->m_generator, value);
1079 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1080 }
1081
1092 void seed(seed_type value)
1093 {
1094 rocrand_status status = rocrand_set_seed(this->m_generator, value);
1095 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1096 }
1097
1111 template<class Generator>
1112 void operator()(result_type * output, size_t size)
1113 {
1114 rocrand_status status;
1115 status = rocrand_generate(m_generator, output, size);
1116 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1117 }
1118
1120 static constexpr result_type min()
1121 {
1122 return 0;
1123 }
1124
1126 static constexpr result_type max()
1127 {
1128 return std::numeric_limits<unsigned int>::max();
1129 }
1130
1132 static constexpr rocrand_rng_type type()
1133 {
1135 }
1136
1137private:
1138 rocrand_generator m_generator;
1139
1141 template<class T>
1142 friend class ::rocrand_cpp::uniform_int_distribution;
1143
1144 template<class T>
1145 friend class ::rocrand_cpp::uniform_real_distribution;
1146
1147 template<class T>
1148 friend class ::rocrand_cpp::normal_distribution;
1149
1150 template<class T>
1151 friend class ::rocrand_cpp::lognormal_distribution;
1152
1153 template<class T>
1154 friend class ::rocrand_cpp::poisson_distribution;
1156};
1157
1159template<unsigned long long DefaultSeed>
1162
1168template<unsigned long long DefaultSeed = ROCRAND_XORWOW_DEFAULT_SEED>
1170{
1171public:
1173 typedef unsigned int result_type;
1177 typedef unsigned long long offset_type;
1179 typedef unsigned long long seed_type;
1181 static constexpr seed_type default_seed = DefaultSeed;
1182
1184 xorwow_engine(seed_type seed_value = DefaultSeed,
1185 offset_type offset_value = 0,
1187 {
1188 rocrand_status status;
1189 status = rocrand_create_generator(&m_generator, this->type());
1190 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1191 try
1192 {
1193 this->order(order_value);
1194 if(offset_value > 0)
1195 {
1196 this->offset(offset_value);
1197 }
1198 this->seed(seed_value);
1199 }
1200 catch(...)
1201 {
1202 (void)rocrand_destroy_generator(m_generator);
1203 throw;
1204 }
1205 }
1206
1208 explicit xorwow_engine(rocrand_generator& generator)
1209 : m_generator(generator)
1210 {
1211 if(generator == NULL)
1212 {
1214 }
1215 generator = NULL;
1216 }
1217
1218 xorwow_engine(const xorwow_engine&) = delete;
1219
1220 xorwow_engine& operator=(const xorwow_engine&) = delete;
1221
1223 xorwow_engine(xorwow_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1224 {
1225 rhs.m_generator = nullptr;
1226 }
1227
1230 {
1231 rocrand_status status = rocrand_destroy_generator(m_generator);
1232 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1233 (void)status;
1234
1235 m_generator = rhs.m_generator;
1236 rhs.m_generator = nullptr;
1237 return *this;
1238 }
1239
1241 ~xorwow_engine() noexcept(false)
1242 {
1243 rocrand_status status = rocrand_destroy_generator(m_generator);
1244 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1245 throw rocrand_cpp::error(status);
1246 }
1247
1249 void stream(hipStream_t value)
1250 {
1251 rocrand_status status = rocrand_set_stream(m_generator, value);
1252 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1253 }
1254
1256 void order(order_type value)
1257 {
1258 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1259 if(status != ROCRAND_STATUS_SUCCESS)
1260 throw rocrand_cpp::error(status);
1261 }
1262
1265 {
1266 rocrand_status status = rocrand_set_offset(this->m_generator, value);
1267 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1268 }
1269
1271 void seed(seed_type value)
1272 {
1273 rocrand_status status = rocrand_set_seed(this->m_generator, value);
1274 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1275 }
1276
1278 template<class Generator>
1279 void operator()(result_type * output, size_t size)
1280 {
1281 rocrand_status status;
1282 status = rocrand_generate(m_generator, output, size);
1283 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1284 }
1285
1287 static constexpr result_type min()
1288 {
1289 return 0;
1290 }
1291
1293 static constexpr result_type max()
1294 {
1295 return std::numeric_limits<unsigned int>::max();
1296 }
1297
1299 static constexpr rocrand_rng_type type()
1300 {
1302 }
1303
1304private:
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
1326template<unsigned long long DefaultSeed>
1329
1335template<unsigned long long DefaultSeed = ROCRAND_MRG31K3P_DEFAULT_SEED>
1337{
1338public:
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
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 static constexpr result_type min()
1459 {
1460 return 1;
1461 }
1462
1464 static constexpr result_type max()
1465 {
1466 return std::numeric_limits<unsigned int>::max();
1467 }
1468
1470 static constexpr rocrand_rng_type type()
1471 {
1473 }
1474
1475private:
1476 rocrand_generator m_generator;
1477
1479 template<class T>
1480 friend class ::rocrand_cpp::uniform_int_distribution;
1481
1482 template<class T>
1483 friend class ::rocrand_cpp::uniform_real_distribution;
1484
1485 template<class T>
1486 friend class ::rocrand_cpp::normal_distribution;
1487
1488 template<class T>
1489 friend class ::rocrand_cpp::lognormal_distribution;
1490
1491 template<class T>
1492 friend class ::rocrand_cpp::poisson_distribution;
1494};
1495
1497template<unsigned long long DefaultSeed>
1498constexpr
1501
1507template<unsigned long long DefaultSeed = ROCRAND_MRG32K3A_DEFAULT_SEED>
1509{
1510public:
1512 typedef unsigned int result_type;
1516 typedef unsigned long long offset_type;
1518 typedef unsigned long long seed_type;
1520 static constexpr seed_type default_seed = DefaultSeed;
1521
1523 mrg32k3a_engine(seed_type seed_value = DefaultSeed,
1524 offset_type offset_value = 0,
1526 {
1527 rocrand_status status;
1528 status = rocrand_create_generator(&m_generator, this->type());
1529 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1530 try
1531 {
1532 this->order(order_value);
1533 if(offset_value > 0)
1534 {
1535 this->offset(offset_value);
1536 }
1537 this->seed(seed_value);
1538 }
1539 catch(...)
1540 {
1541 (void)rocrand_destroy_generator(m_generator);
1542 throw;
1543 }
1544 }
1545
1547 explicit mrg32k3a_engine(rocrand_generator& generator)
1548 : m_generator(generator)
1549 {
1550 if(generator == NULL)
1551 {
1553 }
1554 generator = NULL;
1555 }
1556
1557 mrg32k3a_engine(const mrg32k3a_engine&) = delete;
1558
1559 mrg32k3a_engine& operator=(const mrg32k3a_engine&) = delete;
1560
1562 mrg32k3a_engine(mrg32k3a_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1563 {
1564 rhs.m_generator = nullptr;
1565 }
1566
1569 {
1570 rocrand_status status = rocrand_destroy_generator(m_generator);
1571 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1572 (void)status;
1573
1574 m_generator = rhs.m_generator;
1575 rhs.m_generator = nullptr;
1576 return *this;
1577 }
1578
1580 ~mrg32k3a_engine() noexcept(false)
1581 {
1582 rocrand_status status = rocrand_destroy_generator(m_generator);
1583 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1584 throw rocrand_cpp::error(status);
1585 }
1586
1588 void stream(hipStream_t value)
1589 {
1590 rocrand_status status = rocrand_set_stream(m_generator, value);
1591 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1592 }
1593
1595 void order(order_type value)
1596 {
1597 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1598 if(status != ROCRAND_STATUS_SUCCESS)
1599 throw rocrand_cpp::error(status);
1600 }
1601
1604 {
1605 rocrand_status status = rocrand_set_offset(this->m_generator, value);
1606 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1607 }
1608
1610 void seed(seed_type value)
1611 {
1612 rocrand_status status = rocrand_set_seed(this->m_generator, value);
1613 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1614 }
1615
1617 template<class Generator>
1618 void operator()(result_type * output, size_t size)
1619 {
1620 rocrand_status status;
1621 status = rocrand_generate(m_generator, output, size);
1622 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1623 }
1624
1626 static constexpr result_type min()
1627 {
1628 return 1;
1629 }
1630
1632 static constexpr result_type max()
1633 {
1634 return std::numeric_limits<unsigned int>::max();
1635 }
1636
1638 static constexpr rocrand_rng_type type()
1639 {
1641 }
1642
1643private:
1644 rocrand_generator m_generator;
1645
1647 template<class T>
1648 friend class ::rocrand_cpp::uniform_int_distribution;
1649
1650 template<class T>
1651 friend class ::rocrand_cpp::uniform_real_distribution;
1652
1653 template<class T>
1654 friend class ::rocrand_cpp::normal_distribution;
1655
1656 template<class T>
1657 friend class ::rocrand_cpp::lognormal_distribution;
1658
1659 template<class T>
1660 friend class ::rocrand_cpp::poisson_distribution;
1662};
1663
1665template<unsigned long long DefaultSeed>
1668
1675template<unsigned long long DefaultSeed = 0>
1677{
1678public:
1680 typedef unsigned int result_type;
1684 typedef unsigned long long offset_type;
1686 typedef unsigned long long seed_type;
1688 static constexpr seed_type default_seed = DefaultSeed;
1689
1698 mtgp32_engine(seed_type seed_value = DefaultSeed,
1700 {
1701 rocrand_status status;
1702 status = rocrand_create_generator(&m_generator, this->type());
1703 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1704 try
1705 {
1706 this->order(order_value);
1707 this->seed(seed_value);
1708 }
1709 catch(...)
1710 {
1711 (void)rocrand_destroy_generator(m_generator);
1712 throw;
1713 }
1714 }
1715
1717 explicit mtgp32_engine(rocrand_generator& generator)
1718 : m_generator(generator)
1719 {
1720 if(generator == NULL)
1721 {
1723 }
1724 generator = NULL;
1725 }
1726
1727 mtgp32_engine(const mtgp32_engine&) = delete;
1728
1729 mtgp32_engine& operator=(const mtgp32_engine&) = delete;
1730
1732 mtgp32_engine(mtgp32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1733 {
1734 rhs.m_generator = nullptr;
1735 }
1736
1739 {
1740 rocrand_status status = rocrand_destroy_generator(m_generator);
1741 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1742 (void)status;
1743
1744 m_generator = rhs.m_generator;
1745 rhs.m_generator = nullptr;
1746 return *this;
1747 }
1748
1750 ~mtgp32_engine() noexcept(false)
1751 {
1752 rocrand_status status = rocrand_destroy_generator(m_generator);
1753 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1754 throw rocrand_cpp::error(status);
1755 }
1756
1758 void stream(hipStream_t value)
1759 {
1760 rocrand_status status = rocrand_set_stream(m_generator, value);
1761 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1762 }
1763
1765 void order(order_type value)
1766 {
1767 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1768 if(status != ROCRAND_STATUS_SUCCESS)
1769 throw rocrand_cpp::error(status);
1770 }
1771
1773 void seed(seed_type value)
1774 {
1775 rocrand_status status = rocrand_set_seed(this->m_generator, value);
1776 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1777 }
1778
1780 template<class Generator>
1781 void operator()(result_type * output, size_t size)
1782 {
1783 rocrand_status status;
1784 status = rocrand_generate(m_generator, output, size);
1785 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
1786 }
1787
1789 static constexpr result_type min()
1790 {
1791 return 0;
1792 }
1793
1795 static constexpr result_type max()
1796 {
1797 return std::numeric_limits<unsigned int>::max();
1798 }
1799
1801 static constexpr rocrand_rng_type type()
1802 {
1804 }
1805
1806private:
1807 rocrand_generator m_generator;
1808
1810 template<class T>
1811 friend class ::rocrand_cpp::uniform_int_distribution;
1812
1813 template<class T>
1814 friend class ::rocrand_cpp::uniform_real_distribution;
1815
1816 template<class T>
1817 friend class ::rocrand_cpp::normal_distribution;
1818
1819 template<class T>
1820 friend class ::rocrand_cpp::lognormal_distribution;
1821
1822 template<class T>
1823 friend class ::rocrand_cpp::poisson_distribution;
1825};
1826
1828template<unsigned long long DefaultSeed>
1831
1837template<unsigned int DefaultSeedX = ROCRAND_LFSR113_DEFAULT_SEED_X,
1838 unsigned int DefaultSeedY = ROCRAND_LFSR113_DEFAULT_SEED_Y,
1839 unsigned int DefaultSeedZ = ROCRAND_LFSR113_DEFAULT_SEED_Z,
1840 unsigned int DefaultSeedW = ROCRAND_LFSR113_DEFAULT_SEED_W>
1842{
1843public:
1845 typedef unsigned int result_type;
1849 typedef uint4 seed_type;
1851 static constexpr seed_type default_seed
1852 = {DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW};
1853
1862 lfsr113_engine(seed_type seed_value = {DefaultSeedX, DefaultSeedY, DefaultSeedZ, DefaultSeedW},
1864 {
1865 rocrand_status status;
1866 status = rocrand_create_generator(&m_generator, this->type());
1867 if(status != ROCRAND_STATUS_SUCCESS)
1868 throw rocrand_cpp::error(status);
1869 try
1870 {
1871 this->order(order_value);
1872 this->seed(seed_value);
1873 }
1874 catch(...)
1875 {
1876 (void)rocrand_destroy_generator(m_generator);
1877 throw;
1878 }
1879 }
1880
1882 lfsr113_engine(unsigned long long seed_value,
1884 {
1885 rocrand_status status;
1886 status = rocrand_create_generator(&m_generator, this->type());
1887 if(status != ROCRAND_STATUS_SUCCESS)
1888 throw rocrand_cpp::error(status);
1889 try
1890 {
1891 this->order(order_value);
1892 this->seed(seed_value);
1893 }
1894 catch(...)
1895 {
1896 (void)rocrand_destroy_generator(m_generator);
1897 throw;
1898 }
1899 }
1900
1902 explicit lfsr113_engine(rocrand_generator& generator) : m_generator(generator)
1903 {
1904 if(generator == NULL)
1905 {
1907 }
1908 generator = NULL;
1909 }
1910
1911 lfsr113_engine(const lfsr113_engine&) = delete;
1912
1913 lfsr113_engine& operator=(const lfsr113_engine&) = delete;
1914
1916 lfsr113_engine(lfsr113_engine&& rhs) noexcept : m_generator(rhs.m_generator)
1917 {
1918 rhs.m_generator = nullptr;
1919 }
1920
1923 {
1924 rocrand_status status = rocrand_destroy_generator(m_generator);
1925 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
1926 (void)status;
1927
1928 m_generator = rhs.m_generator;
1929 rhs.m_generator = nullptr;
1930 return *this;
1931 }
1932
1934 ~lfsr113_engine() noexcept(false)
1935 {
1936 rocrand_status status = rocrand_destroy_generator(m_generator);
1937 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
1938 throw rocrand_cpp::error(status);
1939 }
1940
1942 void stream(hipStream_t value)
1943 {
1944 rocrand_status status = rocrand_set_stream(m_generator, value);
1945 if(status != ROCRAND_STATUS_SUCCESS)
1946 throw rocrand_cpp::error(status);
1947 }
1948
1950 void order(order_type value)
1951 {
1952 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
1953 if(status != ROCRAND_STATUS_SUCCESS)
1954 throw rocrand_cpp::error(status);
1955 }
1956
1958 void seed(unsigned long long value)
1959 {
1960 rocrand_status status = rocrand_set_seed(this->m_generator, value);
1961 if(status != ROCRAND_STATUS_SUCCESS)
1962 throw rocrand_cpp::error(status);
1963 }
1964
1966 void seed(seed_type value)
1967 {
1968 rocrand_status status = rocrand_set_seed_uint4(this->m_generator, value);
1969 if(status != ROCRAND_STATUS_SUCCESS)
1970 throw rocrand_cpp::error(status);
1971 }
1972
1974 template<class Generator>
1975 void operator()(result_type* output, size_t size)
1976 {
1977 rocrand_status status;
1978 status = rocrand_generate(m_generator, output, size);
1979 if(status != ROCRAND_STATUS_SUCCESS)
1980 throw rocrand_cpp::error(status);
1981 }
1982
1984 static constexpr result_type min()
1985 {
1986 return 0;
1987 }
1988
1990 static constexpr result_type max()
1991 {
1992 return std::numeric_limits<unsigned int>::max();
1993 }
1994
1996 static constexpr rocrand_rng_type type()
1997 {
1999 }
2000
2001private:
2002 rocrand_generator m_generator;
2003
2005 template<class T>
2006 friend class ::rocrand_cpp::uniform_int_distribution;
2007
2008 template<class T>
2009 friend class ::rocrand_cpp::uniform_real_distribution;
2010
2011 template<class T>
2012 friend class ::rocrand_cpp::normal_distribution;
2013
2014 template<class T>
2015 friend class ::rocrand_cpp::lognormal_distribution;
2016
2017 template<class T>
2018 friend class ::rocrand_cpp::poisson_distribution;
2020};
2021
2023template<unsigned int DefaultSeedX,
2024 unsigned int DefaultSeedY,
2025 unsigned int DefaultSeedZ,
2026 unsigned int DefaultSeedW>
2030
2037template<unsigned long long DefaultSeed = 0ULL>
2039{
2040public:
2042 typedef unsigned int result_type;
2046 typedef unsigned long long seed_type;
2048 static constexpr seed_type default_seed = DefaultSeed;
2049
2058 mt19937_engine(seed_type seed_value = DefaultSeed,
2060 {
2061 rocrand_status status;
2062 status = rocrand_create_generator(&m_generator, this->type());
2063 if(status != ROCRAND_STATUS_SUCCESS)
2064 throw rocrand_cpp::error(status);
2065 try
2066 {
2067 this->order(order_value);
2068 this->seed(seed_value);
2069 }
2070 catch(...)
2071 {
2072 (void)rocrand_destroy_generator(m_generator);
2073 throw;
2074 }
2075 }
2076
2078 explicit mt19937_engine(rocrand_generator& generator) : m_generator(generator)
2079 {
2080 if(generator == NULL)
2081 {
2083 }
2084 generator = NULL;
2085 }
2086
2087 mt19937_engine(const mt19937_engine&) = delete;
2088
2089 mt19937_engine& operator=(const mt19937_engine&) = delete;
2090
2092 mt19937_engine(mt19937_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2093 {
2094 rhs.m_generator = nullptr;
2095 }
2096
2099 {
2100 rocrand_status status = rocrand_destroy_generator(m_generator);
2101 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2102 (void)status;
2103
2104 m_generator = rhs.m_generator;
2105 rhs.m_generator = nullptr;
2106 return *this;
2107 }
2108
2110 ~mt19937_engine() noexcept(false)
2111 {
2112 rocrand_status status = rocrand_destroy_generator(m_generator);
2113 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2114 throw rocrand_cpp::error(status);
2115 }
2116
2118 void stream(hipStream_t value)
2119 {
2120 rocrand_status status = rocrand_set_stream(m_generator, value);
2121 if(status != ROCRAND_STATUS_SUCCESS)
2122 throw rocrand_cpp::error(status);
2123 }
2124
2126 void order(order_type value)
2127 {
2128 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2129 if(status != ROCRAND_STATUS_SUCCESS)
2130 throw rocrand_cpp::error(status);
2131 }
2132
2134 void seed(seed_type value)
2135 {
2136 rocrand_status status = rocrand_set_seed(this->m_generator, value);
2137 if(status != ROCRAND_STATUS_SUCCESS)
2138 throw rocrand_cpp::error(status);
2139 }
2140
2142 template<class Generator>
2143 void operator()(result_type* output, size_t size)
2144 {
2145 rocrand_status status;
2146 status = rocrand_generate(m_generator, output, size);
2147 if(status != ROCRAND_STATUS_SUCCESS)
2148 throw rocrand_cpp::error(status);
2149 }
2150
2152 static constexpr result_type min()
2153 {
2154 return 0;
2155 }
2156
2158 static constexpr result_type max()
2159 {
2160 return std::numeric_limits<unsigned int>::max();
2161 }
2162
2164 static constexpr rocrand_rng_type type()
2165 {
2167 }
2168
2169private:
2170 rocrand_generator m_generator;
2171
2173 template<class T>
2174 friend class ::rocrand_cpp::uniform_int_distribution;
2175
2176 template<class T>
2177 friend class ::rocrand_cpp::uniform_real_distribution;
2178
2179 template<class T>
2180 friend class ::rocrand_cpp::normal_distribution;
2181
2182 template<class T>
2183 friend class ::rocrand_cpp::lognormal_distribution;
2184
2185 template<class T>
2186 friend class ::rocrand_cpp::poisson_distribution;
2188};
2189
2191template<unsigned long long DefaultSeed>
2194
2200template<unsigned int DefaultNumDimensions = 1>
2202{
2203public:
2205 typedef unsigned int result_type;
2209 typedef unsigned long long offset_type;
2214 typedef unsigned int dimensions_num_type;
2216 static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2217
2225 sobol32_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2226 offset_type offset_value = 0,
2228 {
2229 rocrand_status status;
2230 status = rocrand_create_generator(&m_generator, this->type());
2231 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2232 try
2233 {
2234 this->order(order_value);
2235 if(offset_value > 0)
2236 {
2237 this->offset(offset_value);
2238 }
2239 this->dimensions(num_of_dimensions);
2240 }
2241 catch(...)
2242 {
2243 (void)rocrand_destroy_generator(m_generator);
2244 throw;
2245 }
2246 }
2247
2249 explicit sobol32_engine(rocrand_generator& generator)
2250 : m_generator(generator)
2251 {
2252 if(generator == NULL)
2253 {
2255 }
2256 generator = NULL;
2257 }
2258
2259 sobol32_engine(const sobol32_engine&) = delete;
2260
2261 sobol32_engine& operator=(const sobol32_engine&) = delete;
2262
2264 sobol32_engine(sobol32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2265 {
2266 rhs.m_generator = nullptr;
2267 }
2268
2271 {
2272 rocrand_status status = rocrand_destroy_generator(m_generator);
2273 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2274 (void)status;
2275
2276 m_generator = rhs.m_generator;
2277 rhs.m_generator = nullptr;
2278 return *this;
2279 }
2280
2282 ~sobol32_engine() noexcept(false)
2283 {
2284 rocrand_status status = rocrand_destroy_generator(m_generator);
2285 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2286 throw rocrand_cpp::error(status);
2287 }
2288
2290 void stream(hipStream_t value)
2291 {
2292 rocrand_status status = rocrand_set_stream(m_generator, value);
2293 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2294 }
2295
2297 void order(order_type value)
2298 {
2299 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2300 if(status != ROCRAND_STATUS_SUCCESS)
2301 throw rocrand_cpp::error(status);
2302 }
2303
2306 {
2307 rocrand_status status = rocrand_set_offset(this->m_generator, value);
2308 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2309 }
2310
2322 {
2323 rocrand_status status =
2324 rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2325 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2326 }
2327
2343 template<class Generator>
2344 void operator()(result_type * output, size_t size)
2345 {
2346 rocrand_status status;
2347 status = rocrand_generate(m_generator, output, size);
2348 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2349 }
2350
2352 static constexpr result_type min()
2353 {
2354 return 0;
2355 }
2356
2358 static constexpr result_type max()
2359 {
2360 return std::numeric_limits<unsigned int>::max();
2361 }
2362
2364 static constexpr rocrand_rng_type type()
2365 {
2367 }
2368
2369private:
2370 rocrand_generator m_generator;
2371
2373 template<class T>
2374 friend class ::rocrand_cpp::uniform_int_distribution;
2375
2376 template<class T>
2377 friend class ::rocrand_cpp::uniform_real_distribution;
2378
2379 template<class T>
2380 friend class ::rocrand_cpp::normal_distribution;
2381
2382 template<class T>
2383 friend class ::rocrand_cpp::lognormal_distribution;
2384
2385 template<class T>
2386 friend class ::rocrand_cpp::poisson_distribution;
2388};
2389
2391template<unsigned int DefaultNumDimensions>
2395
2401template<unsigned int DefaultNumDimensions = 1>
2403{
2404public:
2406 typedef unsigned int result_type;
2408 typedef unsigned long long offset_type;
2415 typedef unsigned int dimensions_num_type;
2417 static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2418
2426 scrambled_sobol32_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2427 offset_type offset_value = 0,
2429 {
2430 rocrand_status status;
2431 status = rocrand_create_generator(&m_generator, this->type());
2432 if(status != ROCRAND_STATUS_SUCCESS)
2433 throw rocrand_cpp::error(status);
2434 try
2435 {
2436 this->order(order_value);
2437 if(offset_value > 0)
2438 {
2439 this->offset(offset_value);
2440 }
2441 this->dimensions(num_of_dimensions);
2442 }
2443 catch(...)
2444 {
2445 (void)rocrand_destroy_generator(m_generator);
2446 throw;
2447 }
2448 }
2449
2451 explicit scrambled_sobol32_engine(rocrand_generator& generator) : m_generator(generator)
2452 {
2453 if(generator == NULL)
2454 {
2456 }
2457 generator = NULL;
2458 }
2459
2461
2462 scrambled_sobol32_engine& operator=(const scrambled_sobol32_engine&) = delete;
2463
2465 scrambled_sobol32_engine(scrambled_sobol32_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2466 {
2467 rhs.m_generator = nullptr;
2468 }
2469
2472 {
2473 rocrand_status status = rocrand_destroy_generator(m_generator);
2474 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2475 (void)status;
2476
2477 m_generator = rhs.m_generator;
2478 rhs.m_generator = nullptr;
2479 return *this;
2480 }
2481
2484 {
2485 rocrand_status status = rocrand_destroy_generator(m_generator);
2486 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2487 throw rocrand_cpp::error(status);
2488 }
2489
2491 void stream(hipStream_t value)
2492 {
2493 rocrand_status status = rocrand_set_stream(m_generator, value);
2494 if(status != ROCRAND_STATUS_SUCCESS)
2495 throw rocrand_cpp::error(status);
2496 }
2497
2499 void order(order_type value)
2500 {
2501 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2502 if(status != ROCRAND_STATUS_SUCCESS)
2503 throw rocrand_cpp::error(status);
2504 }
2505
2508 {
2509 rocrand_status status = rocrand_set_offset(this->m_generator, value);
2510 if(status != ROCRAND_STATUS_SUCCESS)
2511 throw rocrand_cpp::error(status);
2512 }
2513
2525 {
2526 rocrand_status status
2527 = rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2528 if(status != ROCRAND_STATUS_SUCCESS)
2529 throw rocrand_cpp::error(status);
2530 }
2531
2547 template<class Generator>
2548 void operator()(result_type* output, size_t size)
2549 {
2550 rocrand_status status;
2551 status = rocrand_generate(m_generator, output, size);
2552 if(status != ROCRAND_STATUS_SUCCESS)
2553 throw rocrand_cpp::error(status);
2554 }
2555
2557 static constexpr result_type min()
2558 {
2559 return 0;
2560 }
2561
2563 static constexpr result_type max()
2564 {
2565 return std::numeric_limits<unsigned int>::max();
2566 }
2567
2569 static constexpr rocrand_rng_type type()
2570 {
2572 }
2573
2574private:
2575 rocrand_generator m_generator;
2576
2578 template<class T>
2579 friend class ::rocrand_cpp::uniform_int_distribution;
2580
2581 template<class T>
2582 friend class ::rocrand_cpp::uniform_real_distribution;
2583
2584 template<class T>
2585 friend class ::rocrand_cpp::normal_distribution;
2586
2587 template<class T>
2588 friend class ::rocrand_cpp::lognormal_distribution;
2589
2590 template<class T>
2591 friend class ::rocrand_cpp::poisson_distribution;
2593};
2594
2596template<unsigned int DefaultNumDimensions>
2600
2606template<unsigned int DefaultNumDimensions = 1>
2608{
2609public:
2611 typedef unsigned long long int result_type;
2613 typedef unsigned long long int offset_type;
2620 typedef unsigned int dimensions_num_type;
2622 static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2623
2631 sobol64_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2632 offset_type offset_value = 0,
2634 {
2635 rocrand_status status;
2636 status = rocrand_create_generator(&m_generator, this->type());
2637 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2638 try
2639 {
2640 this->order(order_value);
2641 if(offset_value > 0)
2642 {
2643 this->offset(offset_value);
2644 }
2645 this->dimensions(num_of_dimensions);
2646 }
2647 catch(...)
2648 {
2649 (void)rocrand_destroy_generator(m_generator);
2650 throw;
2651 }
2652 }
2653
2655 explicit sobol64_engine(rocrand_generator& generator)
2656 : m_generator(generator)
2657 {
2658 if(generator == NULL)
2659 {
2661 }
2662 generator = NULL;
2663 }
2664
2665 sobol64_engine(const sobol64_engine&) = delete;
2666
2667 sobol64_engine& operator=(const sobol64_engine&) = delete;
2668
2670 sobol64_engine(sobol64_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2671 {
2672 rhs.m_generator = nullptr;
2673 }
2674
2677 {
2678 rocrand_status status = rocrand_destroy_generator(m_generator);
2679 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2680 (void)status;
2681
2682 m_generator = rhs.m_generator;
2683 rhs.m_generator = nullptr;
2684 return *this;
2685 }
2686
2688 ~sobol64_engine() noexcept(false)
2689 {
2690 rocrand_status status = rocrand_destroy_generator(m_generator);
2691 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2692 throw rocrand_cpp::error(status);
2693 }
2694
2696 void stream(hipStream_t value)
2697 {
2698 rocrand_status status = rocrand_set_stream(m_generator, value);
2699 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2700 }
2701
2703 void order(order_type value)
2704 {
2705 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2706 if(status != ROCRAND_STATUS_SUCCESS)
2707 throw rocrand_cpp::error(status);
2708 }
2709
2712 {
2713 rocrand_status status = rocrand_set_offset(this->m_generator, value);
2714 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2715 }
2716
2728 {
2729 rocrand_status status =
2730 rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2731 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2732 }
2733
2749 template<class Generator>
2750 void operator()(result_type * output, size_t size)
2751 {
2752 rocrand_status status;
2753 status = rocrand_generate_long_long(m_generator, output, size);
2754 if(status != ROCRAND_STATUS_SUCCESS) throw rocrand_cpp::error(status);
2755 }
2756
2758 static constexpr result_type min()
2759 {
2760 return 0;
2761 }
2762
2764 static constexpr result_type max()
2765 {
2766 return std::numeric_limits<result_type>::max();
2767 }
2768
2770 static constexpr rocrand_rng_type type()
2771 {
2773 }
2774
2775private:
2776 rocrand_generator m_generator;
2777
2779 template<class T>
2780 friend class ::rocrand_cpp::uniform_int_distribution;
2781
2782 template<class T>
2783 friend class ::rocrand_cpp::uniform_real_distribution;
2784
2785 template<class T>
2786 friend class ::rocrand_cpp::normal_distribution;
2787
2788 template<class T>
2789 friend class ::rocrand_cpp::lognormal_distribution;
2790
2791 template<class T>
2792 friend class ::rocrand_cpp::poisson_distribution;
2794};
2795
2797template<unsigned int DefaultNumDimensions>
2801
2807template<unsigned int DefaultNumDimensions = 1>
2809{
2810public:
2812 typedef unsigned long long int result_type;
2816 typedef unsigned long long int offset_type;
2821 typedef unsigned int dimensions_num_type;
2823 static constexpr dimensions_num_type default_num_dimensions = DefaultNumDimensions;
2824
2832 scrambled_sobol64_engine(dimensions_num_type num_of_dimensions = DefaultNumDimensions,
2833 offset_type offset_value = 0,
2835 {
2836 rocrand_status status;
2837 status = rocrand_create_generator(&m_generator, this->type());
2838 if(status != ROCRAND_STATUS_SUCCESS)
2839 throw rocrand_cpp::error(status);
2840 try
2841 {
2842 this->order(order_value);
2843 if(offset_value > 0)
2844 {
2845 this->offset(offset_value);
2846 }
2847 this->dimensions(num_of_dimensions);
2848 }
2849 catch(...)
2850 {
2851 (void)rocrand_destroy_generator(m_generator);
2852 throw;
2853 }
2854 }
2855
2857 explicit scrambled_sobol64_engine(rocrand_generator& generator) : m_generator(generator)
2858 {
2859 if(generator == NULL)
2860 {
2862 }
2863 generator = NULL;
2864 }
2865
2867
2868 scrambled_sobol64_engine& operator=(const scrambled_sobol64_engine&) = delete;
2869
2871 scrambled_sobol64_engine(scrambled_sobol64_engine&& rhs) noexcept : m_generator(rhs.m_generator)
2872 {
2873 rhs.m_generator = nullptr;
2874 }
2875
2878 {
2879 rocrand_status status = rocrand_destroy_generator(m_generator);
2880 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
2881 (void)status;
2882
2883 m_generator = rhs.m_generator;
2884 rhs.m_generator = nullptr;
2885 return *this;
2886 }
2887
2890 {
2891 rocrand_status status = rocrand_destroy_generator(m_generator);
2892 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
2893 throw rocrand_cpp::error(status);
2894 }
2895
2897 void stream(hipStream_t value)
2898 {
2899 rocrand_status status = rocrand_set_stream(m_generator, value);
2900 if(status != ROCRAND_STATUS_SUCCESS)
2901 throw rocrand_cpp::error(status);
2902 }
2903
2905 void order(order_type value)
2906 {
2907 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
2908 if(status != ROCRAND_STATUS_SUCCESS)
2909 throw rocrand_cpp::error(status);
2910 }
2911
2914 {
2915 rocrand_status status = rocrand_set_offset(this->m_generator, value);
2916 if(status != ROCRAND_STATUS_SUCCESS)
2917 throw rocrand_cpp::error(status);
2918 }
2919
2931 {
2932 rocrand_status status
2933 = rocrand_set_quasi_random_generator_dimensions(this->m_generator, value);
2934 if(status != ROCRAND_STATUS_SUCCESS)
2935 throw rocrand_cpp::error(status);
2936 }
2937
2953 template<class Generator>
2954 void operator()(result_type* output, size_t size)
2955 {
2956 rocrand_status status;
2957 status = rocrand_generate_long_long(m_generator, output, size);
2958 if(status != ROCRAND_STATUS_SUCCESS)
2959 throw rocrand_cpp::error(status);
2960 }
2961
2963 static constexpr result_type min()
2964 {
2965 return 0;
2966 }
2967
2969 static constexpr result_type max()
2970 {
2971 return std::numeric_limits<result_type>::max();
2972 }
2973
2975 static constexpr rocrand_rng_type type()
2976 {
2978 }
2979
2980private:
2981 rocrand_generator m_generator;
2982
2984 template<class T>
2985 friend class ::rocrand_cpp::uniform_int_distribution;
2986
2987 template<class T>
2988 friend class ::rocrand_cpp::uniform_real_distribution;
2989
2990 template<class T>
2991 friend class ::rocrand_cpp::normal_distribution;
2992
2993 template<class T>
2994 friend class ::rocrand_cpp::lognormal_distribution;
2995
2996 template<class T>
2997 friend class ::rocrand_cpp::poisson_distribution;
2999};
3000
3002template<unsigned int DefaultNumDimensions>
3006
3011template<unsigned long long DefaultSeed = 0>
3013{
3014public:
3016 typedef unsigned int result_type;
3020 typedef unsigned long long offset_type;
3022 typedef unsigned long long seed_type;
3024 static constexpr seed_type default_seed = DefaultSeed;
3025
3027 threefry2x32_20_engine(seed_type seed_value = DefaultSeed,
3028 offset_type offset_value = 0,
3030 {
3031 rocrand_status status;
3032 status = rocrand_create_generator(&m_generator, this->type());
3033 if(status != ROCRAND_STATUS_SUCCESS)
3034 throw rocrand_cpp::error(status);
3035 try
3036 {
3037 if(offset_value > 0)
3038 {
3039 this->offset(offset_value);
3040 }
3041 this->order(order_value);
3042 this->seed(seed_value);
3043 }
3044 catch(...)
3045 {
3046 (void)rocrand_destroy_generator(m_generator);
3047 throw;
3048 }
3049 }
3050
3052 explicit threefry2x32_20_engine(rocrand_generator& generator) : m_generator(generator)
3053 {
3054 if(generator == NULL)
3055 {
3057 }
3058 generator = NULL;
3059 }
3060
3062
3063 threefry2x32_20_engine& operator=(const threefry2x32_20_engine&) = delete;
3064
3066 threefry2x32_20_engine(threefry2x32_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3067 {
3068 rhs.m_generator = nullptr;
3069 }
3070
3073 {
3074 rocrand_status status = rocrand_destroy_generator(m_generator);
3075 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3076 (void)status;
3077
3078 m_generator = rhs.m_generator;
3079 rhs.m_generator = nullptr;
3080 return *this;
3081 }
3082
3084 ~threefry2x32_20_engine() noexcept(false)
3085 {
3086 rocrand_status status = rocrand_destroy_generator(m_generator);
3087 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3088 throw rocrand_cpp::error(status);
3089 }
3090
3092 void stream(hipStream_t value)
3093 {
3094 rocrand_status status = rocrand_set_stream(m_generator, value);
3095 if(status != ROCRAND_STATUS_SUCCESS)
3096 throw rocrand_cpp::error(status);
3097 }
3098
3100 void order(order_type value)
3101 {
3102 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3103 if(status != ROCRAND_STATUS_SUCCESS)
3104 throw rocrand_cpp::error(status);
3105 }
3106
3109 {
3110 rocrand_status status = rocrand_set_offset(this->m_generator, value);
3111 if(status != ROCRAND_STATUS_SUCCESS)
3112 throw rocrand_cpp::error(status);
3113 }
3114
3116 void seed(seed_type value)
3117 {
3118 rocrand_status status = rocrand_set_seed(this->m_generator, value);
3119 if(status != ROCRAND_STATUS_SUCCESS)
3120 throw rocrand_cpp::error(status);
3121 }
3122
3124 template<class Generator>
3125 void operator()(result_type* output, size_t size)
3126 {
3127 rocrand_status status;
3128 status = rocrand_generate(m_generator, output, size);
3129 if(status != ROCRAND_STATUS_SUCCESS)
3130 throw rocrand_cpp::error(status);
3131 }
3132
3134 static constexpr result_type min()
3135 {
3136 return 0;
3137 }
3138
3140 static constexpr result_type max()
3141 {
3142 return std::numeric_limits<unsigned int>::max();
3143 }
3144
3146 static constexpr rocrand_rng_type type()
3147 {
3149 }
3150
3151private:
3152 rocrand_generator m_generator;
3153
3155 template<class T>
3156 friend class ::rocrand_cpp::uniform_int_distribution;
3157
3158 template<class T>
3159 friend class ::rocrand_cpp::uniform_real_distribution;
3160
3161 template<class T>
3162 friend class ::rocrand_cpp::normal_distribution;
3163
3164 template<class T>
3165 friend class ::rocrand_cpp::lognormal_distribution;
3166
3167 template<class T>
3168 friend class ::rocrand_cpp::poisson_distribution;
3170};
3171
3173template<unsigned long long DefaultSeed>
3177
3182template<unsigned long long DefaultSeed = 0>
3184{
3185public:
3187 typedef unsigned long long result_type;
3191 typedef unsigned long long offset_type;
3193 typedef unsigned long long seed_type;
3195 static constexpr seed_type default_seed = DefaultSeed;
3196
3198 threefry2x64_20_engine(seed_type seed_value = DefaultSeed,
3199 offset_type offset_value = 0,
3201 {
3202 rocrand_status status;
3203 status = rocrand_create_generator(&m_generator, this->type());
3204 if(status != ROCRAND_STATUS_SUCCESS)
3205 throw rocrand_cpp::error(status);
3206 try
3207 {
3208 if(offset_value > 0)
3209 {
3210 this->offset(offset_value);
3211 }
3212 this->order(order_value);
3213 this->seed(seed_value);
3214 }
3215 catch(...)
3216 {
3217 (void)rocrand_destroy_generator(m_generator);
3218 throw;
3219 }
3220 }
3221
3223 explicit threefry2x64_20_engine(rocrand_generator& generator) : m_generator(generator)
3224 {
3225 if(generator == NULL)
3226 {
3228 }
3229 generator = NULL;
3230 }
3231
3233
3234 threefry2x64_20_engine& operator=(const threefry2x64_20_engine&) = delete;
3235
3237 threefry2x64_20_engine(threefry2x64_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3238 {
3239 rhs.m_generator = nullptr;
3240 }
3241
3244 {
3245 rocrand_status status = rocrand_destroy_generator(m_generator);
3246 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3247 (void)status;
3248
3249 m_generator = rhs.m_generator;
3250 rhs.m_generator = nullptr;
3251 return *this;
3252 }
3253
3255 ~threefry2x64_20_engine() noexcept(false)
3256 {
3257 rocrand_status status = rocrand_destroy_generator(m_generator);
3258 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3259 throw rocrand_cpp::error(status);
3260 }
3261
3263 void stream(hipStream_t value)
3264 {
3265 rocrand_status status = rocrand_set_stream(m_generator, value);
3266 if(status != ROCRAND_STATUS_SUCCESS)
3267 throw rocrand_cpp::error(status);
3268 }
3269
3271 void order(order_type value)
3272 {
3273 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3274 if(status != ROCRAND_STATUS_SUCCESS)
3275 throw rocrand_cpp::error(status);
3276 }
3277
3280 {
3281 rocrand_status status = rocrand_set_offset(this->m_generator, value);
3282 if(status != ROCRAND_STATUS_SUCCESS)
3283 throw rocrand_cpp::error(status);
3284 }
3285
3287 void seed(seed_type value)
3288 {
3289 rocrand_status status = rocrand_set_seed(this->m_generator, value);
3290 if(status != ROCRAND_STATUS_SUCCESS)
3291 throw rocrand_cpp::error(status);
3292 }
3293
3295 template<class Generator>
3296 void operator()(result_type* output, size_t size)
3297 {
3298 rocrand_status status;
3299 status = rocrand_generate_long_long(m_generator, output, size);
3300 if(status != ROCRAND_STATUS_SUCCESS)
3301 throw rocrand_cpp::error(status);
3302 }
3303
3305 static constexpr result_type min()
3306 {
3307 return 0;
3308 }
3309
3311 static constexpr result_type max()
3312 {
3313 return std::numeric_limits<unsigned int>::max();
3314 }
3315
3317 static constexpr rocrand_rng_type type()
3318 {
3320 }
3321
3322private:
3323 rocrand_generator m_generator;
3324
3326 template<class T>
3327 friend class ::rocrand_cpp::uniform_int_distribution;
3328
3329 template<class T>
3330 friend class ::rocrand_cpp::uniform_real_distribution;
3331
3332 template<class T>
3333 friend class ::rocrand_cpp::normal_distribution;
3334
3335 template<class T>
3336 friend class ::rocrand_cpp::lognormal_distribution;
3337
3338 template<class T>
3339 friend class ::rocrand_cpp::poisson_distribution;
3341};
3342
3344template<unsigned long long DefaultSeed>
3348
3353template<unsigned long long DefaultSeed = 0>
3355{
3356public:
3358 typedef unsigned int result_type;
3362 typedef unsigned long long offset_type;
3364 typedef unsigned long long seed_type;
3366 static constexpr seed_type default_seed = DefaultSeed;
3367
3369 threefry4x32_20_engine(seed_type seed_value = DefaultSeed,
3370 offset_type offset_value = 0,
3372 {
3373 rocrand_status status;
3374 status = rocrand_create_generator(&m_generator, this->type());
3375 if(status != ROCRAND_STATUS_SUCCESS)
3376 throw rocrand_cpp::error(status);
3377 try
3378 {
3379 if(offset_value > 0)
3380 {
3381 this->offset(offset_value);
3382 }
3383 this->order(order_value);
3384 this->seed(seed_value);
3385 }
3386 catch(...)
3387 {
3388 (void)rocrand_destroy_generator(m_generator);
3389 throw;
3390 }
3391 }
3392
3394 explicit threefry4x32_20_engine(rocrand_generator& generator) : m_generator(generator)
3395 {
3396 if(generator == NULL)
3397 {
3399 }
3400 generator = NULL;
3401 }
3402
3404
3405 threefry4x32_20_engine& operator=(const threefry4x32_20_engine&) = delete;
3406
3408 threefry4x32_20_engine(threefry4x32_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3409 {
3410 rhs.m_generator = nullptr;
3411 }
3412
3415 {
3416 rocrand_status status = rocrand_destroy_generator(m_generator);
3417 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3418 (void)status;
3419
3420 m_generator = rhs.m_generator;
3421 rhs.m_generator = nullptr;
3422 return *this;
3423 }
3424
3426 ~threefry4x32_20_engine() noexcept(false)
3427 {
3428 rocrand_status status = rocrand_destroy_generator(m_generator);
3429 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3430 throw rocrand_cpp::error(status);
3431 }
3432
3434 void stream(hipStream_t value)
3435 {
3436 rocrand_status status = rocrand_set_stream(m_generator, value);
3437 if(status != ROCRAND_STATUS_SUCCESS)
3438 throw rocrand_cpp::error(status);
3439 }
3440
3442 void order(order_type value)
3443 {
3444 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3445 if(status != ROCRAND_STATUS_SUCCESS)
3446 throw rocrand_cpp::error(status);
3447 }
3448
3451 {
3452 rocrand_status status = rocrand_set_offset(this->m_generator, value);
3453 if(status != ROCRAND_STATUS_SUCCESS)
3454 throw rocrand_cpp::error(status);
3455 }
3456
3458 void seed(seed_type value)
3459 {
3460 rocrand_status status = rocrand_set_seed(this->m_generator, value);
3461 if(status != ROCRAND_STATUS_SUCCESS)
3462 throw rocrand_cpp::error(status);
3463 }
3464
3466 template<class Generator>
3467 void operator()(result_type* output, size_t size)
3468 {
3469 rocrand_status status;
3470 status = rocrand_generate(m_generator, output, size);
3471 if(status != ROCRAND_STATUS_SUCCESS)
3472 throw rocrand_cpp::error(status);
3473 }
3474
3476 static constexpr result_type min()
3477 {
3478 return 0;
3479 }
3480
3482 static constexpr result_type max()
3483 {
3484 return std::numeric_limits<unsigned int>::max();
3485 }
3486
3488 static constexpr rocrand_rng_type type()
3489 {
3491 }
3492
3493private:
3494 rocrand_generator m_generator;
3495
3497 template<class T>
3498 friend class ::rocrand_cpp::uniform_int_distribution;
3499
3500 template<class T>
3501 friend class ::rocrand_cpp::uniform_real_distribution;
3502
3503 template<class T>
3504 friend class ::rocrand_cpp::normal_distribution;
3505
3506 template<class T>
3507 friend class ::rocrand_cpp::lognormal_distribution;
3508
3509 template<class T>
3510 friend class ::rocrand_cpp::poisson_distribution;
3512};
3513
3515template<unsigned long long DefaultSeed>
3519
3524template<unsigned long long DefaultSeed = 0>
3526{
3527public:
3529 typedef unsigned long long result_type;
3533 typedef unsigned long long offset_type;
3535 typedef unsigned long long seed_type;
3537 static constexpr seed_type default_seed = DefaultSeed;
3538
3540 threefry4x64_20_engine(seed_type seed_value = DefaultSeed,
3541 offset_type offset_value = 0,
3543 {
3544 rocrand_status status;
3545 status = rocrand_create_generator(&m_generator, this->type());
3546 if(status != ROCRAND_STATUS_SUCCESS)
3547 throw rocrand_cpp::error(status);
3548 try
3549 {
3550 if(offset_value > 0)
3551 {
3552 this->offset(offset_value);
3553 }
3554 this->order(order_value);
3555 this->seed(seed_value);
3556 }
3557 catch(...)
3558 {
3559 (void)rocrand_destroy_generator(m_generator);
3560 throw;
3561 }
3562 }
3563
3565 explicit threefry4x64_20_engine(rocrand_generator& generator) : m_generator(generator)
3566 {
3567 if(generator == NULL)
3568 {
3570 }
3571 generator = NULL;
3572 }
3573
3575
3576 threefry4x64_20_engine& operator=(const threefry4x64_20_engine&) = delete;
3577
3579 threefry4x64_20_engine(threefry4x64_20_engine&& rhs) noexcept : m_generator(rhs.m_generator)
3580 {
3581 rhs.m_generator = nullptr;
3582 }
3583
3586 {
3587 rocrand_status status = rocrand_destroy_generator(m_generator);
3588 assert(status == ROCRAND_STATUS_SUCCESS || status == ROCRAND_STATUS_NOT_CREATED);
3589 (void)status;
3590
3591 m_generator = rhs.m_generator;
3592 rhs.m_generator = nullptr;
3593 return *this;
3594 }
3595
3597 ~threefry4x64_20_engine() noexcept(false)
3598 {
3599 rocrand_status status = rocrand_destroy_generator(m_generator);
3600 if(status != ROCRAND_STATUS_SUCCESS && status != ROCRAND_STATUS_NOT_CREATED)
3601 throw rocrand_cpp::error(status);
3602 }
3603
3605 void stream(hipStream_t value)
3606 {
3607 rocrand_status status = rocrand_set_stream(m_generator, value);
3608 if(status != ROCRAND_STATUS_SUCCESS)
3609 throw rocrand_cpp::error(status);
3610 }
3611
3613 void order(order_type value)
3614 {
3615 rocrand_status status = rocrand_set_ordering(this->m_generator, value);
3616 if(status != ROCRAND_STATUS_SUCCESS)
3617 throw rocrand_cpp::error(status);
3618 }
3619
3622 {
3623 rocrand_status status = rocrand_set_offset(this->m_generator, value);
3624 if(status != ROCRAND_STATUS_SUCCESS)
3625 throw rocrand_cpp::error(status);
3626 }
3627
3629 void seed(seed_type value)
3630 {
3631 rocrand_status status = rocrand_set_seed(this->m_generator, value);
3632 if(status != ROCRAND_STATUS_SUCCESS)
3633 throw rocrand_cpp::error(status);
3634 }
3635
3637 template<class Generator>
3638 void operator()(result_type* output, size_t size)
3639 {
3640 rocrand_status status;
3641 status = rocrand_generate_long_long(m_generator, output, size);
3642 if(status != ROCRAND_STATUS_SUCCESS)
3643 throw rocrand_cpp::error(status);
3644 }
3645
3647 static constexpr result_type min()
3648 {
3649 return 0;
3650 }
3651
3653 static constexpr result_type max()
3654 {
3655 return std::numeric_limits<unsigned int>::max();
3656 }
3657
3659 static constexpr rocrand_rng_type type()
3660 {
3662 }
3663
3664private:
3665 rocrand_generator m_generator;
3666
3668 template<class T>
3669 friend class ::rocrand_cpp::uniform_int_distribution;
3670
3671 template<class T>
3672 friend class ::rocrand_cpp::uniform_real_distribution;
3673
3674 template<class T>
3675 friend class ::rocrand_cpp::normal_distribution;
3676
3677 template<class T>
3678 friend class ::rocrand_cpp::lognormal_distribution;
3679
3680 template<class T>
3681 friend class ::rocrand_cpp::poisson_distribution;
3683};
3684
3686template<unsigned long long DefaultSeed>
3690
3737
3741
3769typedef std::random_device random_device;
3770
3773inline int version()
3774{
3775 int x;
3777 if(status != ROCRAND_STATUS_SUCCESS)
3778 {
3779 throw rocrand_cpp::error(status);
3780 }
3781 return x;
3782}
3783
3785
3786} // end namespace rocrand_cpp
3787
3788#endif // #if __cplusplus >= 201103L
3789#endif // ROCRAND_HPP_
A run-time rocRAND error.
Definition rocrand.hpp:52
error_type error_code() const noexcept
Returns the numeric error code.
Definition rocrand.hpp:67
std::string error_string() const noexcept
Returns a string description of the error.
Definition rocrand.hpp:73
friend bool operator!=(const error &l, const error &r)
Compares two error objects for inequality.
Definition rocrand.hpp:131
static std::string to_string(error_type error)
Definition rocrand.hpp:90
error(error_type error) noexcept
Definition rocrand.hpp:60
const char * what() const noexcept override
Returns a C-string description of the error.
Definition rocrand.hpp:79
rocrand_status error_type
rocRAND error code type
Definition rocrand.hpp:55
friend bool operator==(const error &l, const error &r)
Compares two error objects for equality.
Definition rocrand.hpp:124
Random number engine based on the LFSR113 algorithm.
Definition rocrand.hpp:1842
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:1975
lfsr113_engine(lfsr113_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:1916
uint4 seed_type
Definition rocrand.hpp:1849
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:1996
void seed(unsigned long long value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:1958
lfsr113_engine & operator=(lfsr113_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:1922
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:1966
lfsr113_engine(unsigned long long seed_value, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:1882
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:1852
unsigned int result_type
Definition rocrand.hpp:1845
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:1862
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:1990
lfsr113_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:1902
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:1942
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:1950
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:1984
rocrand_ordering order_type
Definition rocrand.hpp:1847
~lfsr113_engine() noexcept(false)
Definition rocrand.hpp:1934
The type of the distribution parameter set.
Definition rocrand.hpp:572
RealType m() const
Returns the deviation distribution parameter.
Definition rocrand.hpp:595
param_type(RealType m=0.0, RealType s=1.0)
Constructs a param_type object with the given distribution parameters.
Definition rocrand.hpp:581
param_type & operator=(const param_type &params)=default
Copy assignment operator.
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition rocrand.hpp:615
RealType s() const
Returns the deviation distribution parameter.
Definition rocrand.hpp:603
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:609
lognormal_distribution< RealType > distribution_type
Alias for convenience.
Definition rocrand.hpp:575
void param(const param_type &params)
Sets the distribution parameter object.
Definition rocrand.hpp:667
RealType result_type
See description for RealType template parameter.
Definition rocrand.hpp:567
bool operator==(const lognormal_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition rocrand.hpp:714
static void reset()
Resets distribution's internal state if there is any.
Definition rocrand.hpp:640
static constexpr RealType min()
Returns the smallest possible value that can be generated.
Definition rocrand.hpp:673
RealType m() const
Definition rocrand.hpp:647
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:627
static RealType max()
Returns the largest possible value that can be generated.
Definition rocrand.hpp:679
RealType s() const
Definition rocrand.hpp:655
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:634
param_type param() const
Returns the distribution parameter object.
Definition rocrand.hpp:661
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
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:1432
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
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
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:1458
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 result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:1464
mrg31k3p_engine & operator=(mrg31k3p_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:1396
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:1470
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:1509
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:1626
mrg32k3a_engine(mrg32k3a_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:1562
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:1638
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:1603
mrg32k3a_engine & operator=(mrg32k3a_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:1568
unsigned long long seed_type
Definition rocrand.hpp:1518
unsigned long long offset_type
Definition rocrand.hpp:1516
rocrand_ordering order_type
Definition rocrand.hpp:1514
unsigned int result_type
Definition rocrand.hpp:1512
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:1610
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:1595
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:1520
~mrg32k3a_engine() noexcept(false)
Definition rocrand.hpp:1580
mrg32k3a_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:1547
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:1632
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:1588
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:1618
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:1523
Random number engine based on the Mersenne Twister algorithm.
Definition rocrand.hpp:2039
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:2126
rocrand_ordering order_type
Definition rocrand.hpp:2044
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:2134
~mt19937_engine() noexcept(false)
Definition rocrand.hpp:2110
unsigned long long seed_type
Definition rocrand.hpp:2046
mt19937_engine(seed_type seed_value=DefaultSeed, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:2058
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:2152
mt19937_engine & operator=(mt19937_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:2098
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:2143
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:2118
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:2158
mt19937_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:2078
mt19937_engine(mt19937_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:2092
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:2164
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:2048
unsigned int result_type
Definition rocrand.hpp:2042
Random number engine based on the Mersenne Twister for Graphic Processors algorithm.
Definition rocrand.hpp:1677
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:1795
~mtgp32_engine() noexcept(false)
Definition rocrand.hpp:1750
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:1789
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:1773
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:1801
unsigned long long seed_type
Definition rocrand.hpp:1686
mtgp32_engine & operator=(mtgp32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:1738
mtgp32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:1717
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:1758
mtgp32_engine(seed_type seed_value=DefaultSeed, order_type order_value=ROCRAND_ORDERING_PSEUDO_DEFAULT)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:1698
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:1765
unsigned long long offset_type
Definition rocrand.hpp:1684
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:1688
unsigned int result_type
Definition rocrand.hpp:1680
mtgp32_engine(mtgp32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:1732
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:1781
rocrand_ordering order_type
Definition rocrand.hpp:1682
The type of the distribution parameter set.
Definition rocrand.hpp:368
normal_distribution< RealType > distribution_type
Alias for convenience.
Definition rocrand.hpp:371
param_type(const param_type &params)=default
Copy constructor.
RealType mean() const
Returns the deviation distribution parameter.
Definition rocrand.hpp:391
param_type(RealType mean=0.0, RealType stddev=1.0)
Constructs a param_type object with the given distribution parameters.
Definition rocrand.hpp:377
bool operator==(const param_type &other) const
Returns true if the param_type is the same as other.
Definition rocrand.hpp:405
param_type & operator=(const param_type &params)=default
Copy assignment operator.
RealType stddev() const
Returns the standard deviation distribution parameter.
Definition rocrand.hpp:399
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition rocrand.hpp:411
static constexpr RealType max()
Returns the largest possible value that can be generated.
Definition rocrand.hpp:463
normal_distribution(const param_type &params)
Constructs a new distribution object.
Definition rocrand.hpp:430
static constexpr RealType min()
Returns the smallest possible value that can be generated.
Definition rocrand.hpp:457
void param(const param_type &params)
Sets the distribution parameter object.
Definition rocrand.hpp:475
static void reset()
Resets distribution's internal state if there is any.
Definition rocrand.hpp:436
param_type param() const
Returns the distribution parameter object.
Definition rocrand.hpp:469
RealType mean() const
Definition rocrand.hpp:443
void operator()(Generator &g, RealType *output, size_t size)
Fills output with normally distributed random floating-point values.
Definition rocrand.hpp:499
bool operator==(const normal_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition rocrand.hpp:509
RealType result_type
See description for RealType template parameter.
Definition rocrand.hpp:363
normal_distribution(RealType mean=0.0, RealType stddev=1.0)
Constructs a new distribution object.
Definition rocrand.hpp:423
RealType stddev() const
Definition rocrand.hpp:451
bool operator!=(const normal_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition rocrand.hpp:517
Pseudorandom number engine based Philox algorithm.
Definition rocrand.hpp:923
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:1132
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:947
philox4x32_10_engine(philox4x32_10_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:1007
philox4x32_10_engine & operator=(philox4x32_10_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:1018
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:1076
philox4x32_10_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:987
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:1126
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:1041
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:1092
~philox4x32_10_engine() noexcept(false)
Definition rocrand.hpp:1032
unsigned int result_type
Definition rocrand.hpp:927
unsigned long long offset_type
Definition rocrand.hpp:940
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:1112
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:1058
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:956
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:1120
unsigned long long seed_type
Definition rocrand.hpp:945
rocrand_ordering order_type
Definition rocrand.hpp:933
double mean() const
Returns the mean distribution parameter.
Definition rocrand.hpp:798
param_type & operator=(const param_type &params)=default
Copy assignment operator.
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:804
bool operator!=(const param_type &other) const
Returns true if the param_type is different from other.
Definition rocrand.hpp:810
poisson_distribution< IntType > distribution_type
Alias for convenience.
Definition rocrand.hpp:778
static constexpr IntType min()
Returns the smallest possible value that can be generated.
Definition rocrand.hpp:848
double mean() const
Definition rocrand.hpp:842
bool operator==(const poisson_distribution< IntType > &other) const
Returns true if the distribution is the same as other.
Definition rocrand.hpp:900
IntType result_type
See description for IntType template parameter.
Definition rocrand.hpp:770
param_type param()
Returns the distribution parameter object.
Definition rocrand.hpp:860
static void reset()
Resets distribution's internal state if there is any.
Definition rocrand.hpp:834
static constexpr IntType max()
Returns the largest possible value that can be generated.
Definition rocrand.hpp:854
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:890
poisson_distribution(const param_type &params)
Constructs a new distribution object.
Definition rocrand.hpp:828
poisson_distribution(double mean=1.0)
Constructs a new distribution object.
Definition rocrand.hpp:821
void param(const param_type &params)
Sets the distribution parameter object.
Definition rocrand.hpp:866
bool operator!=(const poisson_distribution< IntType > &other) const
Returns true if the distribution is different from other.
Definition rocrand.hpp:908
Sobol's scrambled quasi-random sequence generator.
Definition rocrand.hpp:2403
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:2563
unsigned int result_type
Definition rocrand.hpp:2406
scrambled_sobol32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:2451
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:2499
scrambled_sobol32_engine(scrambled_sobol32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:2465
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:2426
unsigned long long offset_type
Definition rocrand.hpp:2408
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:2491
scrambled_sobol32_engine & operator=(scrambled_sobol32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:2471
~scrambled_sobol32_engine() noexcept(false)
Definition rocrand.hpp:2483
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:2507
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition rocrand.hpp:2417
rocrand_ordering order_type
Definition rocrand.hpp:2410
unsigned int dimensions_num_type
Definition rocrand.hpp:2415
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:2569
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:2557
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:2548
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition rocrand.hpp:2524
Sobol's scrambled quasi-random sequence generator.
Definition rocrand.hpp:2809
scrambled_sobol64_engine(scrambled_sobol64_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:2871
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:2832
unsigned long long int offset_type
Definition rocrand.hpp:2816
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:2963
unsigned long long int result_type
Definition rocrand.hpp:2812
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition rocrand.hpp:2930
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:2969
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:2913
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition rocrand.hpp:2823
rocrand_ordering order_type
Definition rocrand.hpp:2814
unsigned int dimensions_num_type
Definition rocrand.hpp:2821
scrambled_sobol64_engine & operator=(scrambled_sobol64_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:2877
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:2954
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:2905
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:2897
~scrambled_sobol64_engine() noexcept(false)
Definition rocrand.hpp:2889
scrambled_sobol64_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:2857
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:2975
Sobol's quasi-random sequence generator.
Definition rocrand.hpp:2202
sobol32_engine(sobol32_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:2264
unsigned int result_type
Definition rocrand.hpp:2205
sobol32_engine & operator=(sobol32_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:2270
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:2225
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:2352
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition rocrand.hpp:2321
sobol32_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:2249
~sobol32_engine() noexcept(false)
Definition rocrand.hpp:2282
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:2297
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:2305
unsigned long long offset_type
Definition rocrand.hpp:2209
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:2344
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:2364
rocrand_ordering order_type
Definition rocrand.hpp:2207
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition rocrand.hpp:2216
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:2358
unsigned int dimensions_num_type
Definition rocrand.hpp:2214
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:2290
Sobol's quasi-random sequence generator.
Definition rocrand.hpp:2608
sobol64_engine & operator=(sobol64_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:2676
void dimensions(dimensions_num_type value)
Set the number of dimensions of a quasi-random number generator.
Definition rocrand.hpp:2727
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:2711
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:2703
unsigned long long int result_type
Definition rocrand.hpp:2611
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:2770
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:2764
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:2631
unsigned int dimensions_num_type
Definition rocrand.hpp:2620
static constexpr dimensions_num_type default_num_dimensions
The default number of dimenstions, equal to DefaultNumDimensions.
Definition rocrand.hpp:2622
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:2696
unsigned long long int offset_type
Definition rocrand.hpp:2613
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:2758
sobol64_engine(sobol64_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:2670
sobol64_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:2655
rocrand_ordering order_type
Definition rocrand.hpp:2615
~sobol64_engine() noexcept(false)
Definition rocrand.hpp:2688
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:2750
Pseudorandom number engine based on 2 state ThreeFry.
Definition rocrand.hpp:3013
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:3134
unsigned int result_type
Definition rocrand.hpp:3016
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:3092
threefry2x32_20_engine & operator=(threefry2x32_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:3072
threefry2x32_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:3052
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:3146
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:3027
~threefry2x32_20_engine() noexcept(false)
Definition rocrand.hpp:3084
unsigned long long seed_type
Definition rocrand.hpp:3022
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:3125
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:3116
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:3108
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:3024
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:3140
rocrand_ordering order_type
Definition rocrand.hpp:3018
unsigned long long offset_type
Definition rocrand.hpp:3020
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:3100
threefry2x32_20_engine(threefry2x32_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:3066
Pseudorandom number engine based 2 state ThreeFry.
Definition rocrand.hpp:3184
unsigned long long seed_type
Definition rocrand.hpp:3193
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:3195
unsigned long long result_type
Definition rocrand.hpp:3187
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:3287
~threefry2x64_20_engine() noexcept(false)
Definition rocrand.hpp:3255
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:3198
rocrand_ordering order_type
Definition rocrand.hpp:3189
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:3317
threefry2x64_20_engine & operator=(threefry2x64_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:3243
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:3279
threefry2x64_20_engine(threefry2x64_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:3237
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:3296
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:3271
unsigned long long offset_type
Definition rocrand.hpp:3191
threefry2x64_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:3223
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:3263
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:3305
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:3311
Pseudorandom number engine based on 2 state ThreeFry.
Definition rocrand.hpp:3355
threefry4x32_20_engine & operator=(threefry4x32_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:3414
~threefry4x32_20_engine() noexcept(false)
Definition rocrand.hpp:3426
unsigned long long seed_type
Definition rocrand.hpp:3364
threefry4x32_20_engine(threefry4x32_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:3408
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:3476
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:3369
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:3434
unsigned int result_type
Definition rocrand.hpp:3358
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:3450
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:3458
rocrand_ordering order_type
Definition rocrand.hpp:3360
threefry4x32_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:3394
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:3482
unsigned long long offset_type
Definition rocrand.hpp:3362
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:3467
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:3488
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:3366
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:3442
Pseudorandom number engine based 2 state ThreeFry.
Definition rocrand.hpp:3526
threefry4x64_20_engine & operator=(threefry4x64_20_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:3585
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:3647
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:3540
threefry4x64_20_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:3565
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:3537
unsigned long long seed_type
Definition rocrand.hpp:3535
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:3621
~threefry4x64_20_engine() noexcept(false)
Definition rocrand.hpp:3597
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:3659
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:3605
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:3613
unsigned long long offset_type
Definition rocrand.hpp:3533
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:3638
threefry4x64_20_engine(threefry4x64_20_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:3579
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:3653
unsigned long long result_type
Definition rocrand.hpp:3529
rocrand_ordering order_type
Definition rocrand.hpp:3531
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:3629
bool operator!=(const uniform_int_distribution< IntType > &other) const
Returns true if the distribution is different from other.
Definition rocrand.hpp:215
void operator()(Generator &g, IntType *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:200
IntType result_type
See description for IntType template parameter.
Definition rocrand.hpp:158
bool operator==(const uniform_int_distribution< IntType > &other) const
Returns true if the distribution is the same as other.
Definition rocrand.hpp:208
uniform_int_distribution()
Default constructor.
Definition rocrand.hpp:161
static constexpr IntType max()
Returns the largest possible value that can be generated.
Definition rocrand.hpp:177
static void reset()
Resets distribution's internal state if there is any.
Definition rocrand.hpp:166
static constexpr IntType min()
Returns the smallest possible value that can be generated.
Definition rocrand.hpp:171
static void reset()
Resets distribution's internal state if there is any.
Definition rocrand.hpp:272
static constexpr RealType min()
Returns the smallest possible value that can be generated.
Definition rocrand.hpp:277
static constexpr RealType max()
Returns the largest possible value that can be generated.
Definition rocrand.hpp:283
RealType result_type
See description for RealType template parameter.
Definition rocrand.hpp:264
uniform_real_distribution()
Default constructor.
Definition rocrand.hpp:267
bool operator!=(const uniform_real_distribution< RealType > &other) const
Returns true if the distribution is different from other.
Definition rocrand.hpp:321
void operator()(Generator &g, RealType *output, size_t size)
Fills output with uniformly distributed random floating-point values.
Definition rocrand.hpp:306
bool operator==(const uniform_real_distribution< RealType > &other) const
Returns true if the distribution is the same as other.
Definition rocrand.hpp:314
Pseudorandom number engine based XORWOW algorithm.
Definition rocrand.hpp:1170
void order(order_type value)
Sets the order of a random number engine.
Definition rocrand.hpp:1256
void stream(hipStream_t value)
Sets the random number engine's hipStream for kernel launches.
Definition rocrand.hpp:1249
xorwow_engine & operator=(xorwow_engine &&rhs) noexcept
Move assign from an other engine, moving the state over.
Definition rocrand.hpp:1229
static constexpr rocrand_rng_type type()
Returns type of the rocRAND pseudo-random number generator associated with the engine.
Definition rocrand.hpp:1299
void seed(seed_type value)
Sets the seed of the pseudo-random number engine.
Definition rocrand.hpp:1271
static constexpr result_type min()
Returns the smallest possible value that can be generated by the engine.
Definition rocrand.hpp:1287
rocrand_ordering order_type
Definition rocrand.hpp:1175
static constexpr result_type max()
Returns the largest possible value that can be generated by the engine.
Definition rocrand.hpp:1293
xorwow_engine(xorwow_engine &&rhs) noexcept
Move construct from an other engine, moving the state over.
Definition rocrand.hpp:1223
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:1184
xorwow_engine(rocrand_generator &generator)
Constructs the pseudo-random number engine.
Definition rocrand.hpp:1208
~xorwow_engine() noexcept(false)
Definition rocrand.hpp:1241
void operator()(result_type *output, size_t size)
Fills output with uniformly distributed random integer values.
Definition rocrand.hpp:1279
void offset(offset_type value)
Sets the offset of a random number engine.
Definition rocrand.hpp:1264
unsigned int result_type
Definition rocrand.hpp:1173
static constexpr seed_type default_seed
The default seed equal to DefaultSeed.
Definition rocrand.hpp:1181
unsigned long long seed_type
Definition rocrand.hpp:1179
unsigned long long offset_type
Definition rocrand.hpp:1177
#define ROCRAND_LFSR113_DEFAULT_SEED_Y
Default Y seed for LFSR113 PRNG.
Definition rocrand_lfsr113.h:37
#define ROCRAND_LFSR113_DEFAULT_SEED_W
Default W seed for LFSR113 PRNG.
Definition rocrand_lfsr113.h:43
#define ROCRAND_LFSR113_DEFAULT_SEED_Z
Default Z seed for LFSR113 PRNG.
Definition rocrand_lfsr113.h:40
#define ROCRAND_LFSR113_DEFAULT_SEED_X
Default X seed for LFSR113 PRNG.
Definition rocrand_lfsr113.h:34
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:115
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:61
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:84
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:117
@ ROCRAND_ORDERING_QUASI_DEFAULT
n-dimensional ordering for quasirandom results
Definition rocrand.h:122
@ ROCRAND_STATUS_NOT_CREATED
Generator was not created using rocrand_create_generator.
Definition rocrand.h:64
@ ROCRAND_STATUS_LAUNCH_FAILURE
Kernel launch failure.
Definition rocrand.h:73
@ ROCRAND_STATUS_VERSION_MISMATCH
Header file and linked library version do not match.
Definition rocrand.h:63
@ ROCRAND_STATUS_LENGTH_NOT_MULTIPLE
Definition rocrand.h:68
@ ROCRAND_STATUS_DOUBLE_PRECISION_REQUIRED
GPU does not have double precision.
Definition rocrand.h:72
@ ROCRAND_STATUS_SUCCESS
No errors.
Definition rocrand.h:62
@ ROCRAND_STATUS_INTERNAL_ERROR
Internal library error.
Definition rocrand.h:74
@ ROCRAND_STATUS_OUT_OF_RANGE
Argument out of range.
Definition rocrand.h:67
@ ROCRAND_STATUS_ALLOCATION_FAILED
Memory allocation failed during execution.
Definition rocrand.h:65
@ ROCRAND_STATUS_TYPE_ERROR
Generator type is wrong.
Definition rocrand.h:66
@ ROCRAND_RNG_QUASI_SOBOL64
Sobol64 quasirandom generator.
Definition rocrand.h:104
@ ROCRAND_RNG_PSEUDO_LFSR113
LFSR113 pseudorandom generator.
Definition rocrand.h:91
@ ROCRAND_RNG_PSEUDO_THREEFRY2_64_20
ThreeFry 64 bit state size 2 pseudorandom generator.
Definition rocrand.h:95
@ ROCRAND_RNG_PSEUDO_XORWOW
XORWOW pseudorandom generator.
Definition rocrand.h:86
@ ROCRAND_RNG_PSEUDO_THREEFRY4_32_20
ThreeFry 32 bit state size 4 pseudorandom generator.
Definition rocrand.h:97
@ ROCRAND_RNG_PSEUDO_MRG31K3P
MRG31k3p pseudorandom generator.
Definition rocrand.h:90
@ ROCRAND_RNG_PSEUDO_MT19937
Mersenne Twister MT19937 pseudorandom generator.
Definition rocrand.h:92
@ ROCRAND_RNG_PSEUDO_PHILOX4_32_10
PHILOX-4x32-10 pseudorandom generator.
Definition rocrand.h:89
@ ROCRAND_RNG_PSEUDO_THREEFRY2_32_20
ThreeFry 32 bit state size 2 pseudorandom generator.
Definition rocrand.h:93
@ ROCRAND_RNG_PSEUDO_THREEFRY4_64_20
ThreeFry 64 bit state size 4 pseudorandom generator.
Definition rocrand.h:99
@ ROCRAND_RNG_PSEUDO_MTGP32
Mersenne Twister MTGP32 pseudorandom generator.
Definition rocrand.h:88
@ ROCRAND_RNG_QUASI_SOBOL32
Sobol32 quasirandom generator.
Definition rocrand.h:102
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL32
Scrambled Sobol32 quasirandom generator.
Definition rocrand.h:103
@ ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL64
Scrambled Sobol64 quasirandom generator.
Definition rocrand.h:105
@ ROCRAND_RNG_PSEUDO_MRG32K3A
MRG32k3a pseudorandom generator.
Definition rocrand.h:87
philox4x32_10_engine philox4x32_10
Typedef of rocrand_cpp::philox4x32_10_engine PRNG engine with default seed (ROCRAND_PHILOX4x32_DEFAUL...
Definition rocrand.hpp:3693
threefry4x32_20_engine threefry4x32
Typedef of rocrand_cpp::threefry4x32_20_engine PRNG engine with default seed (0).
Definition rocrand.hpp:3721
int version()
Returns rocRAND version.
Definition rocrand.hpp:3773
mt19937_engine mt19937
Typedef of rocrand_cpp::mt19937_engine PRNG engine with default seed (0).
Definition rocrand.hpp:3712
mrg32k3a_engine mrg32k3a
Typedef of rocrand_cpp::mrg32k3a_engine PRNG engine with default seed (ROCRAND_MRG32K3A_DEFAULT_SEED)...
Definition rocrand.hpp:3702
threefry2x64_20_engine threefry2x64
Typedef of rocrand_cpp::threefry2x64_20_engine PRNG engine with default seed (0).
Definition rocrand.hpp:3718
sobol64_engine sobol64
Typedef of rocrand_cpp::sobol64_engine QRNG engine with default number of dimensions (1).
Definition rocrand.hpp:3733
mtgp32_engine mtgp32
Typedef of rocrand_cpp::mtgp32_engine PRNG engine with default seed (0).
Definition rocrand.hpp:3705
mrg31k3p_engine mrg31k3p
Typedef of rocrand_cpp::mrg31k3p_engine PRNG engine with default seed (ROCRAND_MRG31K3P_DEFAULT_SEED)...
Definition rocrand.hpp:3699
xorwow default_random_engine
Default random engine.
Definition rocrand.hpp:3740
threefry2x32_20_engine threefry2x32
Typedef of rocrand_cpp::threefry2x32_20_engine PRNG engine with default seed (0).
Definition rocrand.hpp:3715
xorwow_engine xorwow
Typedef of rocrand_cpp::xorwow_engine PRNG engine with default seed (ROCRAND_XORWOW_DEFAULT_SEED).
Definition rocrand.hpp:3696
threefry4x64_20_engine threefry4x64
Typedef of rocrand_cpp::threefry4x64_20_engine PRNG engine with default seed (0).
Definition rocrand.hpp:3724
sobol32_engine sobol32
Typedef of rocrand_cpp::sobol32_engine QRNG engine with default number of dimensions (1).
Definition rocrand.hpp:3727
scrambled_sobol64_engine scrambled_sobol64
Typedef of rocrand_cpp::scrambled_sobol64_engine QRNG engine with default number of dimensions (1).
Definition rocrand.hpp:3736
scrambled_sobol32_engine scrambled_sobol32
Typedef of rocrand_cpp::scrambled_sobol32_engine QRNG engine with default number of dimensions (1).
Definition rocrand.hpp:3730
lfsr113_engine lfsr113
Typedef of rocrand_cpp::lfsr113_engine PRNG engine with default seed (ROCRAND_LFSR113_DEFAULT_SEED_X,...
Definition rocrand.hpp:3709
std::random_device random_device
A non-deterministic uniform random number generator.
Definition rocrand.hpp:3769