내장 함수를 사용하여 실행중인 openCV 코드를 가속화하고 있습니다. 하지만 코드를 Intrinsics로 대체 한 후 코드의 런타임 비용은 거의 동일하거나 더 나빠질 수 있습니다. 나는 무엇이 왜 일어나는지를 알 수 없다. 나는 꽤 오랫동안이 문제를 조사해 왔지만 변화를 주목했다. 누군가가 나를 도울 수 있으면 고맙게 생각합니다. 고마워요! 여기인텔 내장 함수를 사용하는 동안 코드 속도가 향상되지 않습니다.
// if useSSE is true,run the code with intrinsics and takes 1.45ms in my computer
// and if not run the general code and takes the same time.
cv::Mat<float> results(shape.rows,2);
if (useSSE) {
float* pshape = (float*)shape.data;
results = shape.clone();
float* presults = (float*)results.data;
// use SSE
__m128 xyxy_center = _mm_set_ps(bbox.center_y, bbox.center_x, bbox.center_y, bbox.center_x);
float bbox_width = bbox.width/2;
float bbox_height = bbox.height/2;
__m128 xyxy_size = _mm_set_ps(bbox_height, bbox_width, bbox_height, bbox_width);
gettimeofday(&start, NULL); // this is for counting time
int shape_size = shape.rows*shape.cols;
for (int i=0; i<shape_size; i +=4) {
__m128 a = _mm_loadu_ps(pshape+i);
__m128 result = _mm_div_ps(_mm_sub_ps(a, xyxy_center), xyxy_size);
_mm_storeu_ps(presults+i, result);
}
}else {
//SSE TO BE DONE
for (int i = 0; i < shape.rows; i++){
results(i, 0) = (shape(i, 0) - bbox.center_x)/(bbox.width/2.0);
results(i, 1) = (shape(i, 1) - bbox.center_y)/(bbox.height/2.0);
}
}
gettimeofday(&end, NULL);
diff = 1000000*(end.tv_sec-start.tv_sec)+end.tv_sec-start.tv_usec;
std::cout<<diff<<"-----"<<std::endl;
return results;
_ _ _ _ 코드는 답변을 얻는 데 도움이 될 수 있습니다. [mcve]를 수행하는 방법을 참조하십시오 – Miki
또한 코드에서 수행하는 작업을 설명해야합니다. – Catree
정말로 거기에'div_ps'가 필요한가요? 아니면 역으로 번식해도 괜찮습니까? – harold