OpenCL中的高斯分布随机数 [英] Gaussian distributed random numbers in OpenCL

查看:143
本文介绍了OpenCL中的高斯分布随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenCL在GPU上运行计算量大的任务.此任务需要在每个工作人员中生成许多随机数.这些随机数中的一些应该在一定的时间间隔内均匀生成,而另一些则必须围绕(变化的)值进行高斯分布.

I am running a computational expensive task on the GPU using OpenCL. This task requires many random numbers generated within each worker. Some of those random numbers are supposed to be uniformly generated within a certain interval, but some others have to be gaussian distributed around a (changing) value.

  1. 这里有图书馆吗?
  2. 如果没有,实现这种事情的简便方法是什么?

到目前为止,我一直在python中创建随机数,并将其传递给OpenCL.但是现在的瓶颈是这些随机数的传输(至少比实际计算慢一个数量级).

So far I have been creating the random numbers in python and have them passed to OpenCL. However the bottleneck now is the transfer of those random numbers (at least an order of magnitude slower than the actual computations).

推荐答案

框-Muller变换是一种易于并行化的方法,用于将统一的随机变量转换为正态分布的变量.我将它与ddemidov提到的Random123库结合使用.

The Box-Muller transform is an easily parallelized method for transforming uniform random variates into normally distributed ones. I've used it in conjunction with the Random123 library that ddemidov mentioned.

这篇关于OpenCL中的高斯分布随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆