Skip to content
Official PYQ · 2024

GATE CS 2024 Set 1 Q45 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI
The baseline execution time of a program on a 2GHz2 \mathrm{GHz} single core machine is 100100 nanoseconds ( ns)n s). The code corresponding to 90%90 \% of the execution time can be fully parallelized. The overhead for using an additional core is 10 ns10 ~ns when running on a multicore system. Assume that all cores in the multicore system run their share of the parallelized code for an equal amount of time.

The number of cores that minimize the execution time of the program is __________.
View worked solution

Answer: 3

To find the number of cores that minimizes the execution time, we can model the execution time as a function of the number of cores, NN.

1. Analyze the Baseline Execution Time

The baseline execution time on a single core (N=1N = 1) is 100 ns100\text{ ns}.

  • Parallelizable portion: 90%90\% of 100 ns=90 ns100\text{ ns} = 90\text{ ns}
  • Sequential portion: 10%10\% of 100 ns=10 ns100\text{ ns} = 10\text{ ns}

2. Formulate the Execution Time for NN Cores

When running on a multicore system with NN cores (N≥1N \ge 1):

  • The sequential portion still takes 10 ns10\text{ ns}.
  • The parallelizable portion is divided equally among the NN cores, taking 90N ns\frac{90}{N}\text{ ns}.
  • There are N−1N - 1 additional cores, each contributing an overhead of 10 ns10\text{ ns}. Thus, the total overhead is 10(N−1) ns10(N - 1)\text{ ns}.

The total execution time T(N)T(N) is given by:

T(N)=10+90N+10(N−1)T(N) = 10 + \frac{90}{N} + 10(N - 1)

3. Minimize the Execution Time

To find the value of NN that minimizes T(N)T(N), we can differentiate T(N)T(N) with respect to NN and set it to zero:

dT(N)dN=−90N2+10=0\frac{dT(N)}{dN} = -\frac{90}{N^2} + 10 = 0 90N2=10  ⟹  N2=9  ⟹  N=3\frac{90}{N^2} = 10 \implies N^2 = 9 \implies N = 3

Since the second derivative d2T(N)dN2=180N3>0\frac{d^2T(N)}{dN^2} = \frac{180}{N^3} > 0 for N=3N = 3, this point represents a local and global minimum.

4. Verification for Integer Values

Let us evaluate T(N)T(N) for nearby integer values of NN to confirm:

  • For N=1N = 1: T(1)=10+90+0=100 nsT(1) = 10 + 90 + 0 = 100\text{ ns}
  • For N=2N = 2: T(2)=10+45+10=65 nsT(2) = 10 + 45 + 10 = 65\text{ ns}
  • For N=3N = 3: T(3)=10+30+20=60 nsT(3) = 10 + 30 + 20 = 60\text{ ns}
  • For N=4N = 4: T(4)=10+22.5+30=62.5 nsT(4) = 10 + 22.5 + 30 = 62.5\text{ ns}

The execution time is minimized when the number of cores is 3.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Hierarchy: Cache, Main Memory and Secondary Storage questions