【发布时间】:2020-02-08 17:29:56
【问题描述】:
我正在使用 Ray-trace 进行模拟开发激光雷达传感器。模拟可配置为以每秒所需的帧数运行(在我的情况下为 30 fps。即 1 帧在 33.34 毫秒内运行)。
目前每秒进行 300000 次光线追踪(包括水平和垂直)。在 30 fps 时,每帧进行 10000 次光线追踪。代码如下所示
//call back at the start of frame (just for understanding - not the actual code, data type conversions and some other basics are ignored)
uint32 channels = 16;
float vert_angle[] = {15, 13, 11, 9, 7, 5, 3, 1, -1, -3, -5, -7, -9, -11, -13, -15};
float hor_angle_ref = 0;
uint32 points_per_second = 300000;
float rotation_frequency = 10;
/* 300000 points per second is divided into points per frame.
These points are distributed horizontally and vertically*/
void callback_scan(){
uint32 poits_to_scan_with_one_laser = points_per_second/ (fps * channels);
auto hor_angle_covered_this_frame = points_per_second* rotation_frequency * (1/fps);
auto hor_angle_resolution = hor_angle_covered_this_frame / poits_to_scan_with_one_laser ;
auto hor_angle = hor_angle_ref ;
for(auto i= 0u; i< poits_to_scan_with_one_laser ; ++i){
for(auto ch= 0u; ch< channels; ++ch){
auto hitPoint = raytrace(hor_angle, vert_angle[ch]);
// process_data(); -> distance, time and energy are calculated
/* distance -> Euclidean distance calculation and addition of noise
time -> c=d/t
energy -> Pr = Pt*pow(D,2)*nsys*natm*row/ pow(dist,2);*/
}
hor_angle += hor_angle_resolution ;
}
hor_angle_ref = hor_angle;
}
以上代码运行良好。一切都在 33.33 毫秒的预期时间内完成。现在需要引入效果散度https://en.wikipedia.org/wiki/Beam_divergence。
使用的解决方案:每个点取 8 个样本。即嵌套 for 循环内还有 8 个光线跟踪。总共(8+1)*300000 光线追踪。该解决方案占用了大量时间,并且不可能在 33 毫秒内完成。任何人都可以建议任何其他替代方案来构建代码/算法的体系结构/一种不同的方法,我可以用它来实现这一点,并且计算复杂度更低。
附加信息:
虚幻引擎 4.22,在 GPU 上运行
【问题讨论】:
-
这个算法已经在 GPU 上运行了吗?
-
是的,这已经在 GPU 上运行了
标签: c++ algorithm optimization time-complexity