使用阿姆达尔定律计算性能提升 [英] Calculate performance gains using Amdahl's Law

查看:137
本文介绍了使用阿姆达尔定律计算性能提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我百思不得其解与阿姆达尔定律来计算性能提升和串行应用程序的一部分,想不通的是,这一个。

I am puzzling with Amdahl's Law to determine performance gains and the serial application part and fail to figure out this one.

已知如下:

S(N) = Speedup factor for (N) CPU's
N = Number of CPU's
f = The part of the program which is executed sequential
S(N) = N / ( 1 + f * ( N - 1 ) ) 

如果我有4个CPU的3倍的和加速比(性能提高)。什么会的 F 的是什么?

If I have 4 CPU's and a speedup factor (performance gain) of 3x. What would f be?

我的猜测:

S(N) = 3 (that's our performance gain using 4 CPU's)
N = 4

因此​​,公式中输入这些值:

So entering these values in the formula:

3 = 4 / ( 1 + f * ( 4 - 1 ) )

我是正确的,当我说,F = 0.11?或者我需要设置S(N)为1(所以除以3)?还是我做其他事情了?

Am I correct when I say that f = 0,11? Or do I need to set S(N) to 1 (so divide by 3)? Or am I doing something else wrong?

推荐答案

我的一个同学给的(到目前为止工作/右)回答这一点。

A classmate of mine gave the (so far working/right) answer for this.

我做了如下分类:     拆下来对抗混乱。

I made the following class: REMOVED TO COUNTERACT CONFUSION.

这应该解决这个问题。

编辑:

好吧,previuos答案是错的,但我找到了解决办法。

Ok, the previuos answer is wrong, but I found the solution.

您先计算可以做平行的部分(这是在维基百科上,但我花了一段时间来理解),然后再计算串行部分。

You first calculate The part that can be done parallel (it's on wikipedia but it took me a while to understand) and THEN you calculate the serial part.

所以最终的类成为这样的:

so the final class becomes this:

/**
* @param s - The maximum performance profit. 
* @param n - The amount of processors that are usable..
* @return f - The sequential part of the program.
*/
public final double sequentialCalculation(final double s, final double n) {
    double p = 0; //Het deel dat parallel kan worden uitgevoerd.
    double f = 0;

    if (s <= 0) {
        throw new IllegalArgumentException("S > 0");
    }

    if (n <= 0) {
        throw new IllegalArgumentException("N > 0");
    }

    p = ((1 / s) - 1) / ((1 / n) - 1);

    f = 1 - p;

    return f;
}

您们的欢迎。

这篇关于使用阿姆达尔定律计算性能提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆