nested parallelism 问题

caijinqing 2009-11-29 09:53:51
下面这段程序是摘取的源程序一部分 只是一个for循环,希望能够把sum-=A.Get(r,k)*A.Get(k,c);并行,这里用了内嵌循环 但是执行以后时间用的比单核运算花的时间多得多,虽然cpu使用率高达97%左右,请高手分析一下这是什么原因,另外类似这种循环用那种方法实现并行比较好呢
#pragma omp parallel
#pragma omp single
{
for(r=0;r<c;r++)
{
sum=A.Get(r,c);
if(r>0)
{

#pragma omp parallel for shared (sum)
for(k=0;k<r;k++)
{
#pragma omp atomic

sum-=A.Get(r,k)*A.Get(k,c);

}
A.Set(r,c,sum);


}
}
}
...全文
164 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
caijinqing 2009-11-29
  • 打赏
  • 举报
回复
纠结了很久了,高人呢?`
This text develops a comprehensive theory of programming languages based on type systems and structural operational semantics. Language concepts are precisely defined by their static and dynamic semantics, presenting the essential tools both intuitively and rigorously while relying on only elementary mathematics. These tools are used to analyze and prove properties of languages and provide the framework for combining and comparing language features. The broad range of concepts includes fundamental data types such as sums and products, polymorphic and abstract types, dynamic typing, dynamic dispatch, subtyping and refinement types, symbols and dynamic classification, parallelism and cost semantics, and concurrency and distribution. The methods are directly applicable to language implementation, to the development of logics for reasoning about programs, and to the formal verification language properties such as type safety. This thoroughly revised second edition includes exercises at the end of nearly every chapter and a new chapter on type refinements. Table of Contents Part I Judgments and Rules Chapter 1 Abstract Syntax Chapter 2 Inductive Definitions Chapter 3 Hypothetical and General Judgments Part II Statics and Dynamics Chapter 4 Statics Chapter 5 Dynamics Chapter 6 Type Safety Chapter 7 Evaluation Dynamics Part III Total Functions Chapter 8 Function Definitions and Values Chapter 9 System T of Higher-Order Recursion Part IV Finite Data Types Chapter 10 Product Types Chapter 11 Sum Types Part V Types and Propositions Chapter 12 Constructive Logic Chapter 13 Classical Logic Part VI Infinite Data Types Chapter 14 Generic Programming Chapter 15 Inductive and Coinductive Types Part VII Variable Types Chapter 16 System F of Polymorphic Types Chapter 17 Abstract Types Chapter 18 Higher Kinds Part VIII Partiality and Recursive Types Chapter 19 System PCF of Recursive Functions Chapter 20 System FPC of Recursive Types Part IX Dynamic Types Chapter 21 The Untyped λ-Calculus Chapter 22 Dynamic Typing Chapter 23 Hybrid Typing Part X Subtyping Chapter 24 Structural Subtyping Chapter 25 Behavioral Typing Chapter Part XI Dynamic Dispatch Chapter 26 Classes and Methods Chapter 27 Inheritance Part XII Control Flow Chapter 28 Control Stacks Chapter 29 Exceptions Chapter 30 Continuations Part XIII Symbolic Data Chapter 31 Symbols Chapter 32 Fluid Binding Chapter 33 Dynamic Classification Part XIV Mutable State Chapter 34 Modernized Algol Chapter 35 Assignable References Chapter 36 Lazy Evaluation Part XV Parallelism Chapter 37 Nested Parallelism Chapter 38 Futures and Speculations Part XVI Concurrency and Distribution Chapter 39 Process Calculus Chapter 40 Concurrent Algol Chapter 41 Distributed Algol Part XVII Modularity Chapter 42 Modularity and Linking Chapter 43 Singleton Kinds and Subkinding Chapter 44 Type Abstractions and Type Classes Chapter 45 Hierarchy and Parameterization Chapter Part XVIII Equational Reasoning Chapter 46 Equality for System T Chapter 47 Equality for System PCF Chapter 48 Parametricity Chapter 49 Process Equivalence Appendix A Background on Finite Sets

567

社区成员

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

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