OpenMP - Serialize for-loop在并行区域中包含并行for循环(OpenMP - Serialise for-loop in Parallel Region which Contains Parallel for-loop)
我问这个问题一个非常相似的问题,但那里只有一个答案,但对我来说并没有用。
我在
main()
有一个并行区域,它带有一个调用函数new_value()
的for循环:int main(int argc, char** argv) { omp_set_num_threads(4); #pragma omp parallel default(shared) private(...) { for(int i = 0; i < MAX_VALUE; i++) new_value(...); } return 0; }
new_value()
看起来像:void new_value(...) { #pragma omp for schedule(static, chunk_width) for(int i = 0; i < N; i++) arr[i] = update(); }
我遇到的问题是我不希望
main()
的for循环被并行化(即总共运行MAX_VALUE * 4
次)。我基本上希望这个循环能够连续运行,但
new_value()
的for循环要使用四个线程运行。我在循环之前尝试了
#pragma omp single
,但它导致程序死锁或挂起某些东西。 我也尝试了由已经链接的线程提示的嵌套并行方法,但是我得到了相同的结果。任何解决方案将不胜感激。
I'm asking a very similar question to this chap but there is only one answer there and it hasn't proved useful for me.
I have a parallel region in
main()
with a for-loop which calls the functionnew_value()
:int main(int argc, char** argv) { omp_set_num_threads(4); #pragma omp parallel default(shared) private(...) { for(int i = 0; i < MAX_VALUE; i++) new_value(...); } return 0; }
And
new_value()
looks like:void new_value(...) { #pragma omp for schedule(static, chunk_width) for(int i = 0; i < N; i++) arr[i] = update(); }
The issue I am having is that I do not want the for-loop in
main()
to be parallelised (i.e. ranMAX_VALUE * 4
times in total).I essentially want that one loop to be ran serially but the for-loop in
new_value()
to be ran with four threads.I tried
#pragma omp single
before the loop but it caused the program to deadlock or hang on something. I also tried the nested parallelism approach as suggest by the already linked thread but I got the same result.Any solutions would be appreciated.
原文:https://stackoverflow.com/questions/47475715
满意答案
这不是Oracle错误。 首先,您不应该在
FROM
子句中使用逗号。 您应该始终使用显式JOIN
语法。但这不是你的具体问题。 可变分辨率和范围是。
如果在查询中有诸如
interface_name
的引用,则Oracle首先查找具有该名称的列。 它永远不会看到变量。 将变量命名为区别对象,因此最终得到的代码更像是:. . . FROM payments.multi_value_lookup_config mvlc JOIN payments.message_source ms ON ms.pk_message_source = mvlc.fk_pk_message_source WHERE ms.interface_name = v_interface_name ms.message_format_name = v_message_format_name /*'MT202'*/ mvlc.mapping_column_name = v_source_field mvlc.lookup_category_type = v_determined_field_type
This is not an Oracle bug. First, you should never use commas in the
FROM
clause. You should always use explicitJOIN
syntax.But that is not your specific problem. Variable resolution and scoping is.
When you have a reference such as
interface_name
in a query, then Oracle looks first for columns with that name. It never sees the variables. Name the variables something distinguishing, so you end up with code that is more like this:. . . FROM payments.multi_value_lookup_config mvlc JOIN payments.message_source ms ON ms.pk_message_source = mvlc.fk_pk_message_source WHERE ms.interface_name = v_interface_name ms.message_format_name = v_message_format_name /*'MT202'*/ mvlc.mapping_column_name = v_source_field mvlc.lookup_category_type = v_determined_field_type
相关问答
更多具有内部联接的ORACLE Listagg(ORACLE Listagg with an Inner Join)
Oracle右外连接(Oracle right outer join)
PreparedStatement和Oracle 10g错误(PreparedStatement and Oracle 10g bug)
如何在Oracle中的一个条件HAVING和AND中组合(How to combine in one condition HAVING and AND in Oracle)
Oracle 12c:错误的截断(日期)导致错误的数据(Oracle 12c: Bug with trunc(date) results in wrong data)
使用INNER JOIN添加另一个WHERE条件时,Oracle SELECT失败(Oracle SELECT fails when adding another WHERE condition with INNER JOINs)
基于内部联接oracle sql插入(Insert based on inner join oracle sql)
Oracle:文件和表之间的内部联接(Oracle:inner join between file and table)
Rownum处于连接状态(Rownum in the join condition)
内部联接条件被忽略 - 看起来像Oracle错误(Inner join condition is disregarded - looks like an Oracle bug)
相关文章
更多Hadoop lzo文件的并行map处理
Linux内核Bridge代码的STP的实现(转)
Hadoop 通过distcp进行并行复制
Hadoop集群lzo文件的并行map处理
用 Hadoop 进行分布式并行编程, 第 1 部分基本概念与安装部署
Hadoop是什么 分享 PPT
用 Hadoop 进行分布式并行编程, 第 2 部分程序实例与分析
Hadoop真实分布式并行环境部署经验
物理专业英语词汇(H-N)
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!