本文介绍了打开MP处理时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我正在使用打开mp的简单图像处理程序工作,
但无法使程序达到预期的速度.

波纹管的处理时间为0.5秒.
但是注释掉了mp开头的行,它只有0.1秒.
我看不到发生了什么事.
请告诉我我想念的东西.

在此先感谢!
-carlos

[机器信息]
cpu:英特尔酷睿2 Quad 2.6GHz
内存:4gb
os:win xp professional

[代码]

hi everyone!
i''m working with a simple image process program using open mp,
but can''t get make my program faster as it''s supposed to be.

the process time of the code bellow was 0.5secs.
but with the open mp line commented out, it was only 0.1secs.
i can''t see what is going on.
please tell me what i''m missing.

thanks in advance!
-carlos

[machine info]
cpu:intel core 2 quad 2.6ghz
memory:4gb
os:win xp professional

[code]

int width = 10000;
int length = 10000;
#pragma omp parallel for  // open mp line
for (int y = 0; y < length; y++) {
  int y_offset = y * width;
  const byte* source = SOURCE_IMAGE_ADDRESS_;
  source += y_offset;
  byte* destination = DESTINATION_IMAGE_ADDRESS_;
  destination += y_offset;
  for (int x = 0; x < width; x++) {
    *destination = (*source);
    source++;
    destination++;  
  }
}

推荐答案


#pragma omp parallel for private(x)


这样可以提高性能.但是我不确定是否全部.


This should boost performance. But I''m not sure if this is all.



这篇关于打开MP处理时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 02:32