parallel for 块中有其他方法代替break吗?

yaojunxi 2009-07-20 07:16:54
加精
才开始学习openmp,知道在parallel for并行快中不能用break,但是有其他方法代替break的作用吗?如果没有的话,岂不是需要在循环里break跳出的代码都不能用parallel for来并行执行?
希望大虾来指点一下,感谢。
代码:
#pragma omp parallel
{
#pragma omp for
for(i=0; i<strlen(url)-7; i++)
{
if(*(url+7+i)=='/')
{
sprintf(path,"/%s",url+7+i+1);
snprintf(host,i+1,"%s",url+7);
break;//出错
}
}
...全文
412 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxpxupeng 2009-07-28
  • 打赏
  • 举报
回复
continue 呢
yaojunxi 2009-07-27
  • 打赏
  • 举报
回复
to 1楼,谢谢,
to 5楼,在parallel for中貌似也不能用return吧,因为要保证for循环的单入单出
xuchengfeifei 2009-07-23
  • 打赏
  • 举报
回复
大家分享
hero_liyi 2009-07-22
  • 打赏
  • 举报
回复
不错瓦
lightwyf 2009-07-22
  • 打赏
  • 举报
回复
要分UP
whoismickey 2009-07-22
  • 打赏
  • 举报
回复
up 要分
l3917055 2009-07-22
  • 打赏
  • 举报
回复
灌水贴。。。。。。
oooO ↘┏━┓ ↙ Oooo
( 踩)→┃你┃ ←(死 )
\ ( →┃√┃ ← ) /
  \_)↗┗━┛ ↖(_/
xuyuanlanlu 2009-07-22
  • 打赏
  • 举报
回复
赚积分
fy_kenny 2009-07-22
  • 打赏
  • 举报
回复
return 行不行?
有可能十并行机制,不需要你break
hhwei1985 2009-07-22
  • 打赏
  • 举报
回复
up
bobotui 2009-07-22
  • 打赏
  • 举报
回复
You’ve probably heard, by now, the jordan shoes or UGG Boots for sale online are under a low price. Why not take a pair of Nike Shoes or UGG Slippers for ur friend or yourself? Oh! Nearly forgot the Silver Jewelry, I mean Tiffany, they are so cheap online. You may curious why I talked about these. I’m a fan of Air Jordan and I collect ugg boots for my collection.As you know, the jordan shoes selling in emporium is too expensive for my income. With the aid of getting more jordan shoes, shopping online is a choice if you are just a air jordans collector. Maybe some air jordans you got wast the real Jordan Shoes, at least we can collect many series of nike shoes.
gis418670826 2009-07-22
  • 打赏
  • 举报
回复
大家分享
JCYYang 2009-07-20
  • 打赏
  • 举报
回复
不能用break,因为本来并行执行,for中就应该没有顺序可言,而break违反了这种规定,按照break原来的语义,应该是break处对应的i,在该i之后的所有i‘都不执行。实际上,在并行时没有方法保证在该i之后的所有i‘都不执行(除非认为加入许多锁语句,但这样比串行慢多了。。。。而且没有并发性可言)。

567

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧