I'm having trouble understanding an assigment I'm doing for my Parallel Computing course. The problem in question is this:
我无法理解我正在为并行计算课程做的一项任务。问题在于:
Consider the following code:
请考虑以下代码:
for(int i = 0; i < 1024; i++){ int arg = ... compute(arg); }
Where the execution time of
compute()
is proportional to the value of its argument. We want to parallelize this loop using OpenMP, with one of the schedulesstatic
,dynamic
orguided
. Find an example of an expression forarg
(i.e. complete line 2) so that the best schedule to use would be:其中compute()的执行时间与其参数的值成比例。我们希望使用OpenMP并行化此循环,其中一个计划是静态的,动态的或指导的。找到arg的表达式示例(即完整的第2行),以便使用的最佳计划是:
static
静态的
dynamic
动态
guided
引导
Explain your answers.
解释你的答案。
I don't have any problem understanding the OpenMP Schedules, but I'm having trouble finding any sort of information that can help me decide which arguments to use, and why.
我对OpenMP Schedules的理解没有任何问题,但是我很难找到任何可以帮助我决定使用哪些参数的信息,以及为什么。
The curriculum is of no use, and I haven't had any luck with Google.
课程没有用,我也没跟谷歌好运。
I understand if people "don't want to give me homework solutions", but a solid pointer in the right direction would be nice. Simply put, how can I evaluate which argument to use for any of the Schedules?
我理解人们“不想给我作业解决方案”,但是朝着正确方向的坚实指针会很好。简单地说,我如何评估哪个参数用于任何时间表?
1 个解决方案
#1
2
They are asking you to come up with 3 different things 'arg' could be to suit each of the 3 scheduling methods.
他们要求你提出3种不同的东西'arg'可能适合3种调度方法。
Keep in mind they have told you that the processing time is proportional to the int value of arg.
请记住,他们已经告诉过你,处理时间与arg的int值成正比。
So for static scheduling, arg must always be the same number, so the processing time is always identical. Thus something like arg=10;
因此,对于静态调度,arg必须始终为相同的数字,因此处理时间始终相同。因此像arg = 10;
For dynamic scheduling, this would be when arg is changing value, so something like arg=rand();
As that would result in randomly different time for each compute.
对于动态调度,这可能是当arg正在改变值时,所以像arg = rand();因为这会导致每个计算的随机时间不同。
For guiding scheduling, maying something like arg = i / 10;
because arg will remain static for a while at each value, while still dynamically changing through values.
为了指导安排,可能会像arg = i / 10;因为arg将在每个值保持静态一段时间,同时仍然通过值动态更改。
#1
2
They are asking you to come up with 3 different things 'arg' could be to suit each of the 3 scheduling methods.
他们要求你提出3种不同的东西'arg'可能适合3种调度方法。
Keep in mind they have told you that the processing time is proportional to the int value of arg.
请记住,他们已经告诉过你,处理时间与arg的int值成正比。
So for static scheduling, arg must always be the same number, so the processing time is always identical. Thus something like arg=10;
因此,对于静态调度,arg必须始终为相同的数字,因此处理时间始终相同。因此像arg = 10;
For dynamic scheduling, this would be when arg is changing value, so something like arg=rand();
As that would result in randomly different time for each compute.
对于动态调度,这可能是当arg正在改变值时,所以像arg = rand();因为这会导致每个计算的随机时间不同。
For guiding scheduling, maying something like arg = i / 10;
because arg will remain static for a while at each value, while still dynamically changing through values.
为了指导安排,可能会像arg = i / 10;因为arg将在每个值保持静态一段时间,同时仍然通过值动态更改。