vSMC
vSMC: Scalable Monte Carlo
mkl.hpp
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rng/mkl.hpp
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2016, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_RNG_MKL_HPP
33 #define VSMC_RNG_MKL_HPP
34 
36 
37 #define VSMC_RUNTIME_ASSERT_RNG_MKL_OFFSET(offset) \
38  VSMC_RUNTIME_ASSERT((offset < max()), \
39  "**MKLOffsetDynamic** " \
40  "EXCESS MAXIMUM NUMBER OF INDEPDENT RNG STREAMS")
41 
42 namespace vsmc
43 {
44 
45 namespace internal
46 {
47 
49 {
50  public:
51  static constexpr MKL_INT min() { return 0; }
52  static constexpr MKL_INT max() { return 0; }
53  static void set(MKL_INT) {}
54  static constexpr MKL_INT get() { return 0; }
55 }; // class OffsetZero
56 
57 template <MKL_INT MaxOffset>
59 {
60  public:
61  MKLOffsetDynamic() : offset_(0) {}
62 
63  static constexpr MKL_INT min() { return 0; }
64  static constexpr MKL_INT max() { return MaxOffset; }
65 
66  void set(MKL_INT n)
67  {
69  offset_ = n % MaxOffset;
70  }
71 
72  MKL_INT get() const { return offset_; }
73 
74  private:
75  MKL_INT offset_;
76 }; // class OffsetDynamic
77 
78 template <MKL_INT>
79 class MKLOffset
80 {
81  public:
83 }; // class MKLOffset
84 
85 template <>
87 {
88  public:
90 }; // class MKLOffset
91 
92 template <>
93 class MKLOffset<VSL_BRNG_MT2203>
94 {
95  public:
97 }; // class MKLOffset
98 
99 template <>
100 class MKLOffset<VSL_BRNG_WH>
101 {
102  public:
104 }; // class MKLOffset
105 
106 template <int>
108 
109 template <>
111 {
112  public:
113  using type = unsigned;
114 }; // class MKLResultTypeTrait
115 
116 template <>
118 {
119  public:
120  using type = unsigned MKL_INT64;
121 }; // class MKLResultTypeTrait
122 
123 template <int Bits>
125 
126 template <int>
128 
129 template <>
130 class MKLUniformBits<32>
131 {
132  public:
133  static void eval(MKLStream &stream, MKL_INT n, unsigned *r)
134  {
135  stream.uniform_bits32(n, r);
136  }
137 }; // class MKLUniformBits
138 
139 template <>
140 class MKLUniformBits<64>
141 {
142  public:
143  static void eval(MKLStream &stream, MKL_INT n, unsigned MKL_INT64 *r)
144  {
145  stream.uniform_bits64(n, r);
146  }
147 }; // class MKLUniformBits
148 
150 {
151  public:
152  static void eval(MKLStream &stream, long long nskip)
153  {
154  stream.skip_ahead(nskip);
155  }
156 }; // class DiscardSkipAhead
157 
158 template <MKL_INT BRNG, int Bits>
160 {
161  public:
162  static void eval(MKLStream &stream, long long nskip)
163  {
164  if (nskip == 0)
165  return;
166 
167  std::array<MKLResultType<Bits>, 1024> buffer;
168  const MKL_INT k = static_cast<MKL_INT>(buffer.size());
169  while (nskip > k) {
170  MKLUniformBits<Bits>::eval(stream, k, buffer.data());
171  nskip -= k;
172  }
174  stream, static_cast<MKL_INT>(nskip), buffer.data());
175  }
176 }; // class DiscardGeneral
177 
178 template <MKL_INT BRNG, int Bits>
180 {
181  public:
183 }; // clas MKLDiscard
184 
185 template <int Bits>
186 class MKLDiscard<VSL_BRNG_MCG59, Bits>
187 {
188  public:
190 }; // clas MKLDiscard
191 
192 template <int Bits>
193 class MKLDiscard<VSL_BRNG_MT19937, Bits>
194 {
195  public:
197 }; // clas MKLDiscard
198 
199 template <int Bits>
200 class MKLDiscard<VSL_BRNG_SFMT19937, Bits>
201 {
202  public:
204 }; // clas MKLDiscard
205 
206 } // namespace vsmc::internal
207 
210 template <MKL_INT BRNG, int Bits>
211 class MKLEngine
212 {
213  public:
215 
216  explicit MKLEngine(MKL_UINT s = 1) : index_(M_), stream_(BRNG, 0)
217  {
218  seed(s);
219  }
220 
221  template <typename SeedSeq>
222  explicit MKLEngine(SeedSeq &seq,
223  typename std::enable_if<internal::is_seed_seq<SeedSeq, MKL_UINT,
224  MKLEngine<BRNG, Bits>>::value>::type * = nullptr)
225  : index_(M_), stream_(BRNG, 0)
226  {
227  seed(seq);
228  }
229 
230  MKLEngine(MKL_UINT s, MKL_INT offset) : index_(M_), stream_(BRNG, 0)
231  {
232  seed(s, offset);
233  }
234 
235  void seed(MKL_UINT s) { seed(s, 0); }
236 
237  template <typename SeedSeq>
238  void seed(SeedSeq &seq,
239  typename std::enable_if<
241  {
242  MKL_UINT s;
243  seq.generate(&s, &s + 1);
244  seed(s, 0);
245  }
246 
247  void seed(MKL_UINT s, MKL_INT offset)
248  {
249  typename internal::MKLOffset<BRNG>::type off;
250  off.set(offset);
251  stream_.reset(BRNG + off.get(), s);
252  index_ = M_;
253  }
254 
256  {
257  if (index_ == M_) {
259  stream_, static_cast<MKL_INT>(M_), buffer_.data());
260  index_ = 0;
261  }
262 
263  return buffer_[index_++];
264  }
265 
266  void operator()(std::size_t n, result_type *r)
267  {
268  std::size_t remain = M_ - index_;
269 
270  if (n < remain) {
271  std::memcpy(r, buffer_.data() + index_, sizeof(result_type) * n);
272  index_ += n;
273  return;
274  }
275 
276  std::memcpy(r, buffer_.data() + index_, sizeof(result_type) * remain);
277  r += remain;
278  n -= remain;
279  index_ = M_;
280 
281  const std::size_t m = n / M_;
282  const std::size_t l = n % M_;
283  for (std::size_t i = 0; i != m; ++i) {
285  stream_, static_cast<MKL_INT>(M_), r);
286  r += M_;
287  n -= M_;
288  }
290  stream_, static_cast<MKL_INT>(M_), buffer_.data());
291  std::memcpy(r, buffer_.data(), sizeof(result_type) * l);
292  index_ = l;
293  }
294 
295  void discard(long long nskip)
296  {
298  index_ = M_;
299  }
300 
301  static constexpr result_type min()
302  {
303  return std::numeric_limits<result_type>::min();
304  }
305 
306  static constexpr result_type max()
307  {
308  return std::numeric_limits<result_type>::max();
309  }
310 
311  MKLStream &stream() { return stream_; }
312  const MKLStream &stream() const { return stream_; }
313 
314  friend bool operator==(
315  const MKLEngine<BRNG, Bits> &eng1, const MKLEngine<BRNG, Bits> &eng2)
316  {
317  if (eng1.stream_.get_brng() != eng2.stream_.get_brng())
318  return false;
319  std::size_t n = static_cast<std::size_t>(eng1.stream_.get_size());
320  Vector<char> s1(n);
321  Vector<char> s2(n);
322  eng1.stream_.save_m(s1.data());
323  eng2.stream_.save_m(s2.data());
324  if (s1 != s2)
325  return false;
326  if (eng1.buffer_ != eng2.buffer_)
327  return false;
328  if (eng1.index_ != eng2.index_)
329  return false;
330  return true;
331  }
332 
333  friend bool operator!=(
334  const MKLEngine<BRNG, Bits> &eng1, const MKLEngine<BRNG, Bits> &eng2)
335  {
336  return !(eng1 == eng2);
337  }
338 
339  template <typename CharT, typename Traits>
340  friend std::basic_ostream<CharT, Traits> &operator<<(
341  std::basic_ostream<CharT, Traits> &os,
342  const MKLEngine<BRNG, Bits> &eng)
343  {
344  if (!os.good())
345  return os;
346 
347  os << eng.stream_.get_brng() << ' ';
348  std::size_t n = static_cast<std::size_t>(eng.stream_.get_size());
349  if (n % sizeof(std::uint64_t) != 0)
350  n += sizeof(std::uint64_t) - n % sizeof(std::uint64_t);
351  n /= sizeof(std::uint64_t);
353  eng.stream_.save_m(reinterpret_cast<char *>(s.data()));
354  for (std::size_t i = 0; i != n; ++i)
355  os << s[i] << ' ';
356  os << eng.buffer_ << ' ';
357  os << eng.index_;
358 
359  return os;
360  }
361 
362  template <typename CharT, typename Traits>
363  friend std::basic_istream<CharT, Traits> &operator>>(
364  std::basic_istream<CharT, Traits> &is, MKLEngine<BRNG, Bits> &eng)
365  {
366  if (!is.good())
367  return is;
368 
369  MKL_INT brng = 0;
370  MKLStream stream(BRNG, 1);
371  std::array<result_type, M_> buffer;
372  std::size_t index = 0;
373 
374  is >> std::ws >> brng;
375  if (is.good())
376  stream.reset(brng, 1);
377  else
378  return is;
379 
380  std::size_t n = static_cast<std::size_t>(eng.stream_.get_size());
381  if (n % sizeof(std::uint64_t) != 0)
382  n += sizeof(std::uint64_t) - n % sizeof(std::uint64_t);
383  n /= sizeof(std::uint64_t);
385  for (std::size_t i = 0; i != n; ++i)
386  is >> std::ws >> s[i];
387  if (is.good())
388  stream.load_m(reinterpret_cast<const char *>(s.data()));
389  else
390  return is;
391 
392  is >> std::ws >> buffer;
393  is >> std::ws >> index;
394 
395  if (is.good()) {
396  eng.stream_ = stream;
397  eng.buffer_ = buffer;
398  eng.index_ = index;
399  }
400 
401  return is;
402  }
403 
404  private:
405  static constexpr std::size_t M_ = 1024;
406 
407  alignas(32) std::array<result_type, M_> buffer_;
408  std::size_t index_;
409  MKLStream stream_;
410 }; // class MKLEngine
411 
415 
419 
423 
427 
431 
436 
441 
447 
451 
455 
456 #if INTEL_MKL_VERSION >= 110300
457 
460 using MKL_ARS5 = MKLEngine<VSL_BRNG_ARS5, 32>;
461 
464 using MKL_ARS5_64 = MKLEngine<VSL_BRNG_ARS5, 64>;
465 
468 using MKL_PHILOX4X32X10 = MKLEngine<VSL_BRNG_PHILOX4X32X10, 32>;
469 
472 using MKL_PHILOX4X32X10_64 = MKLEngine<VSL_BRNG_PHILOX4X32X10, 64>;
473 
474 #endif // INTEL_MKL_VERSION >= 110300
475 
476 template <MKL_INT BRNG, int Bits>
477 inline void rng_rand(MKLEngine<BRNG, Bits> &rng, std::size_t n,
479 {
480  rng(n, r);
481 }
482 
483 template <MKL_INT BRNG, int Bits>
484 inline void beta_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
485  float *r, float alpha, float beta)
486 {
487  rng.stream().beta(static_cast<MKL_INT>(n), r, alpha, beta, 0, 1);
488 }
489 
490 template <MKL_INT BRNG, int Bits>
491 inline void beta_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
492  double *r, double alpha, double beta)
493 {
494  rng.stream().beta(static_cast<MKL_INT>(n), r, alpha, beta, 0, 1);
495 }
496 
497 template <MKL_INT BRNG, int Bits>
499  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float a, float b)
500 {
501  rng.stream().cauchy(static_cast<MKL_INT>(n), r, a, b);
502 }
503 
504 template <MKL_INT BRNG, int Bits>
506  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double a, double b)
507 {
508  rng.stream().cauchy(static_cast<MKL_INT>(n), r, a, b);
509 }
510 
511 template <MKL_INT BRNG, int Bits>
513  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float lambda)
514 {
515  rng.stream().exponential(static_cast<MKL_INT>(n), r, 0, 1 / lambda);
516 }
517 
518 template <MKL_INT BRNG, int Bits>
520  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double lambda)
521 {
522  rng.stream().exponential(static_cast<MKL_INT>(n), r, 0, 1 / lambda);
523 }
524 
525 template <MKL_INT BRNG, int Bits>
527  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float a, float b)
528 {
529  rng.stream().gumbel(static_cast<MKL_INT>(n), r, a, b);
530  sub(n, 2 * a, r, r);
531 }
532 
533 template <MKL_INT BRNG, int Bits>
535  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double a, double b)
536 {
537  rng.stream().gumbel(static_cast<MKL_INT>(n), r, a, b);
538  sub(n, 2 * a, r, r);
539 }
540 
541 template <MKL_INT BRNG, int Bits>
542 inline void gamma_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
543  float *r, float alpha, float beta)
544 {
545  rng.stream().gamma(static_cast<MKL_INT>(n), r, alpha, 0, beta);
546 }
547 
548 template <MKL_INT BRNG, int Bits>
549 inline void gamma_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
550  double *r, double alpha, double beta)
551 {
552  rng.stream().gamma(static_cast<MKL_INT>(n), r, alpha, 0, beta);
553 }
554 
555 template <MKL_INT BRNG, int Bits>
556 inline void laplace_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
557  float *r, float location, float scale)
558 {
559  rng.stream().laplace(static_cast<MKL_INT>(n), r, location, scale);
560 }
561 
562 template <MKL_INT BRNG, int Bits>
563 inline void laplace_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
564  double *r, double location, double scale)
565 {
566  rng.stream().laplace(static_cast<MKL_INT>(n), r, location, scale);
567 }
568 
569 template <MKL_INT BRNG, int Bits>
571  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float m, float s)
572 {
573  rng.stream().lognormal(static_cast<MKL_INT>(n), r, m, s, 0, 1);
574 }
575 
576 template <MKL_INT BRNG, int Bits>
578  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double m, double s)
579 {
580  rng.stream().lognormal(static_cast<MKL_INT>(n), r, m, s, 0, 1);
581 }
582 
583 template <MKL_INT BRNG, int Bits>
584 inline void normal_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
585  float *r, float mean, float stddev)
586 {
587  rng.stream().gaussian(static_cast<MKL_INT>(n), r, mean, stddev);
588 }
589 
590 template <MKL_INT BRNG, int Bits>
591 inline void normal_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
592  double *r, double mean, double stddev)
593 {
594  rng.stream().gaussian(static_cast<MKL_INT>(n), r, mean, stddev);
595 }
596 
597 template <MKL_INT BRNG, int Bits>
598 inline void normal_mv_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
599  float *r, std::size_t m, const float *mean, const float *chol)
600 {
601  rng.stream().gaussian_mv(static_cast<MKL_INT>(n), r,
602  static_cast<MKL_INT>(m), VSL_MATRIX_STORAGE_PACKED, mean, chol);
603 }
604 
605 template <MKL_INT BRNG, int Bits>
606 inline void normal_mv_distribution(MKLEngine<BRNG, Bits> &rng, std::size_t n,
607  double *r, std::size_t m, const double *mean, const double *chol)
608 {
609  rng.stream().gaussian_mv(static_cast<MKL_INT>(n), r,
610  static_cast<MKL_INT>(m), VSL_MATRIX_STORAGE_PACKED, mean, chol);
611 }
612 
613 template <MKL_INT BRNG, int Bits>
615  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float sigma)
616 {
617  rng.stream().rayleigh(
618  static_cast<MKL_INT>(n), r, 0, const_sqrt_2<float>() * sigma);
619 }
620 
621 template <MKL_INT BRNG, int Bits>
623  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double sigma)
624 {
625  rng.stream().rayleigh(
626  static_cast<MKL_INT>(n), r, 0, const_sqrt_2<double>() * sigma);
627 }
628 
629 template <MKL_INT BRNG, int Bits>
630 inline void u01_distribution(
631  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r)
632 {
633  rng.stream().uniform(static_cast<MKL_INT>(n), r, 0, 1);
634 }
635 
636 template <MKL_INT BRNG, int Bits>
637 inline void u01_distribution(
638  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r)
639 {
640  rng.stream().uniform(static_cast<MKL_INT>(n), r, 0, 1);
641 }
642 
643 template <MKL_INT BRNG, int Bits>
645  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float a, float b)
646 {
647  rng.stream().uniform(static_cast<MKL_INT>(n), r, a, b);
648 }
649 
650 template <MKL_INT BRNG, int Bits>
652  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double a, double b)
653 {
654  rng.stream().uniform(static_cast<MKL_INT>(n), r, a, b);
655 }
656 
657 template <MKL_INT BRNG, int Bits>
659  MKLEngine<BRNG, Bits> &rng, std::size_t n, float *r, float a, float b)
660 {
661  rng.stream().weibull(static_cast<MKL_INT>(n), r, a, 0, b);
662 }
663 
664 template <MKL_INT BRNG, int Bits>
666  MKLEngine<BRNG, Bits> &rng, std::size_t n, double *r, double a, double b)
667 {
668  rng.stream().weibull(static_cast<MKL_INT>(n), r, a, 0, b);
669 }
670 
671 } // namespace vsmc
672 
673 #endif // VSMC_RNG_MKL_HPP
static void set(MKL_INT)
Definition: mkl.hpp:53
static constexpr MKL_INT max()
Definition: mkl.hpp:64
Definition: monitor.hpp:49
int uniform_bits32(MKL_INT n, unsigned *r, MKL_INT method=VSL_RNG_METHOD_UNIFORMBITS32_STD)
viRngUniform32
Definition: mkl.hpp:601
void seed(MKL_UINT s, MKL_INT offset)
Definition: mkl.hpp:247
typename std::conditional< std::is_scalar< T >::value, AlignedVector< T >, std::vector< T >>::type Vector
AlignedVector for scalar type and std::vector for others.
result_type operator()()
Definition: mkl.hpp:255
void laplace_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating laplace random variates.
void normal_mv_distribution(RNGType &, std::size_t, RealType *, std::size_t, const RealType *, const RealType *)
Generating multivariate Normal random varaites.
constexpr double const_sqrt_2< double >() noexcept
Definition: constants.hpp:215
void cauchy_distribution(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
Generating cauchy random variates.
ulong uint64_t
Definition: opencl.h:40
void lognormal_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating lognormal random variates.
void rng_rand(RNGType &rng, BetaDistribution< RealType > &dist, std::size_t n, RealType *r)
friend bool operator==(const MKLEngine< BRNG, Bits > &eng1, const MKLEngine< BRNG, Bits > &eng2)
Definition: mkl.hpp:314
MKL RNG C++11 engine.
Definition: common.hpp:787
void exponential_distribution(RNGType &rng, std::size_t n, RealType *r, RealType lambda)
Generating exponential random variates.
void u01_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates.
MKLEngine(MKL_UINT s, MKL_INT offset)
Definition: mkl.hpp:230
void seed(MKL_UINT s)
Definition: mkl.hpp:235
void discard(long long nskip)
Definition: mkl.hpp:295
void normal_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating Normal random variates.
MKLEngine(SeedSeq &seq, typename std::enable_if< internal::is_seed_seq< SeedSeq, MKL_UINT, MKLEngine< BRNG, Bits >>::value >::type *=nullptr)
Definition: mkl.hpp:222
void rayleigh_distribution(RNGType &, std::size_t, RealType *, RealType)
Generating rayleigh random variates.
static constexpr result_type min()
Definition: mkl.hpp:301
static constexpr MKL_INT get()
Definition: mkl.hpp:54
static void eval(MKLStream &stream, MKL_INT n, unsigned MKL_INT64 *r)
Definition: mkl.hpp:143
void seed(SeedSeq &seq, typename std::enable_if< internal::is_seed_seq< SeedSeq, MKL_UINT >::value >::type *=nullptr)
Definition: mkl.hpp:238
void weibull_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating weibull random variates.
int reset(MKL_INT brng, MKL_UINT seed)
vslNewStream
Definition: mkl.hpp:192
const MKLStream & stream() const
Definition: mkl.hpp:312
int skip_ahead(long long nskip)
vslSkipAheadStream
Definition: mkl.hpp:286
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, MKLEngine< BRNG, Bits > &eng)
Definition: mkl.hpp:363
void extreme_value_distribution(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
Generating extreme_value random variates.
int load_m(const char *memptr)
vslLoadStreamM
Definition: mkl.hpp:261
int uniform_bits64(MKL_INT n, unsigned MKL_INT64 *r, MKL_INT method=VSL_RNG_METHOD_UNIFORMBITS64_STD)
viRngUniform64
Definition: mkl.hpp:612
static constexpr MKL_INT min()
Definition: mkl.hpp:51
constexpr float const_sqrt_2< float >() noexcept
Definition: constants.hpp:215
friend bool operator!=(const MKLEngine< BRNG, Bits > &eng1, const MKLEngine< BRNG, Bits > &eng2)
Definition: mkl.hpp:333
void sub(std::size_t n, const float *a, const float *b, float *y)
Definition: vmath.hpp:110
static constexpr MKL_INT min()
Definition: mkl.hpp:63
MKL VSLStreamStatePtr
Definition: mkl.hpp:147
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const MKLEngine< BRNG, Bits > &eng)
Definition: mkl.hpp:340
MKLStream & stream()
Definition: mkl.hpp:311
#define VSMC_RUNTIME_ASSERT_RNG_MKL_OFFSET(offset)
Definition: mkl.hpp:37
void beta_distribution(RNGType &rng, std::size_t n, RealType *r, RealType alpha, RealType beta)
Generating beta random variates.
static constexpr result_type max()
Definition: mkl.hpp:306
static constexpr MKL_INT max()
Definition: mkl.hpp:52
void uniform_real_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generate uniform real random variates with open/closed variants.
static void eval(MKLStream &stream, MKL_INT n, unsigned *r)
Definition: mkl.hpp:133
void operator()(std::size_t n, result_type *r)
Definition: mkl.hpp:266
void gamma_distribution(RNGType &rng, std::size_t n, RealType *r, RealType alpha, RealType beta)
Generating gamma random variates.
MKLEngine(MKL_UINT s=1)
Definition: mkl.hpp:216
internal::MKLResultType< Bits > result_type
Definition: mkl.hpp:214
typename MKLResultTypeTrait< Bits >::type MKLResultType
Definition: mkl.hpp:124
static void eval(MKLStream &stream, long long nskip)
Definition: mkl.hpp:152
static void eval(MKLStream &stream, long long nskip)
Definition: mkl.hpp:162