【发布时间】:2017-04-03 03:40:13
【问题描述】:
当我多次调用thrust::inclusive_scan时,为什么第一次比后面的调用慢很多?
这里是代码
float ttime;
for(int i=0;i<5;i++){
cudaEvent_t start,stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start,0);
thrust::device_ptr<int > din(device_input);
thrust::device_ptr<int > dout(device_output);
thrust::inclusive_scan(din,din+N,dout);
cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&ttime,start,stop);
printf("cost %fms\n",ttime);
}
我在GTX1080上运行,结果是
cost 39.180702ms
cost 0.200704ms
cost 0.201728ms
cost 0.202752ms
cost 0.197632ms
谁能帮忙解释一下?
【问题讨论】: