我正在使用 OpenCL(通过 JOCL)在光线行进的一系列距离计算中找到最小值。伪代码看起来像这样:
Start with a point in 3d space.
There are a number of functions to calculate distances
to that point from various other points.
These may be rather complex (transforms, csg etc).
Calculate all of the distances, perhaps into an array
Get the index of the minimum distance in the array..
Use that index to do up other stuff (pigmentation etc).
我的实现有点废话。我目前没有并行化距离计算,但我想这样做。这就是我不这样做的原因:
获得最小距离很容易,但检索这个索引并不明显。我最终迭代了距离并跟踪了当前的最小值及其索引,但这在并行环境中显然是垃圾。
基本上可以在这里使用提示将我引向正确的方向,或者告诉我我是否完全吠错了树?(例如,这是一个 CPU 工作吗?)
谢谢!