# Homework 1

CWID: 10719035

## Problem 1

1. $$CPI_{alu} = 1.1$$

2. $$CPI_{branch} = 3.0$$

3. $$Cache_Hitatio = 60\%$$

4. $$CPI_{hit} = 1$$

5. $$CPI_{miss} = 120$$

6. $$Percentage_{branch} = 20\%$$ of the instructions are loads

7. $$Percentage_{load} = 22\%$$ of the instructions are loads

8. $$Percentage_{stores} = 12\%$$ of the instructions are stores

9. The loads & stores are impacted by the cache hit ratio.

To find the $$CPI_{total}$$ we need to use the equation $CPI_{total} = \sum_{i=1}^{n} {CPI_i \times Percentage_i}$ $$(CPI_{alu} \times Percentage_{alu}) + (CPI_{branch} \times Percentage_{branch}) + (CPI_{load} \times Percentage_{load}) + (CPI_{store} \times Percentage_{store})$$

First

To calculate the $$CPI_{load}$$ and $$CPI_{store}$$ we determine the $$CPI$$ based on the hit ratio of the cache. We’re assuming here that load and store have an even distribution of how the cache and memory is accessed. $$CPI_{cache} = ((CPI_{hit} \times Cache\_Hitatio) + (CPI_{miss} \times (100 - Cache\_Hitratio))) = (60\% \times 1) + (40\% \times 120) = 48.6$$

Second

Next we need to determine the percentage of ALU instructions which is calculated as:

$$Percentage_{alu} = 100 - (Percentage{branch} + Percentage_{load} + Percentage_{branch}) = 100 - (20\% + 22\% + 12\%) = 46\%$$

Third

Now that we have the $$CPI_{cache}$$ we have calcule the $$CPI_{total}$$. Each CPI will be multiplied by the percentage that the instruction type is executed. The $$CPI_{load}$$ and $$CPI_{store}$$ will be substituted with the $$CPI_{cache}$$

$$CPI_{total} = (1.1 \times 46\%) + (3 \times 20\%) + (48.6 \times 22\%) + (48.6 \times 12\%) = \textbf{17.63}$$

## Problem 2

When comparing two processors designs we’ll have to make assumptions so that we can make an equal comparison. In this problem we have two processor options processor A that executes at 1Ghz with an average CPI of 1.2 and processor B that executes at 2Ghz and has a CPI of 2.

To compare two processors we typically would have to compare cost, performance, and energy/power consumption. These three factors will have different weights depending on the intended use of the processor. For example, energy has a hight weight in a decision if the intended use is for a mobile device.

Based on the problem provided not enough details around cost, energy, and intended use are provided. As such perfomance is left in making a comparison, to make this comparison we’ll leverage the Performance Equation. ${L = IC*CPI*CT}$

We can assume that the workload between processors is the same which means that $$IC$$ is contant, which leaves us with $$CPI$$ and $$CT$$.: ${L = CPI*CT}$

Given that we’re given frequency in Ghz we’ll change $$CT$$, which is clock cycles in seconds, to clock speed. This means our equation will change to $$L = \frac{CPI}{f}$$. Table one shows the results of calculting $$L$$ for each processor.

My caption
Processor Latency Calc Latency
A $$\frac{1.2}{1*10^9}$$ $$1.2*10^-9$$
B $$\frac{2}{2*10^9}$$ $$1*10-9$$

\label{my-label}

To determine the improvement from one over the other, we leverage the Speed up equation ${Speedup =\frac{Latency_{a}}{Latency_{b}} = \frac{1.2*10^-9}{1*10^-9} = 1.2}$ this provided a 1.2x speedup over processor A.

### Conculusion

Factors, such as workload or architecture design, are not differnet between the processors. This is critical as if the architecture is different then bandwidth of the two processors can be different. Given the problem these are assumed to be the same and are not factored in the decission. Additionally, cost and power are not considered which can impact the decission making.

This leaves us only with the comparision of performance, for which the Performance Equation was used. When comparing the latency between the processors the speedup of processor B was 1.2x, for which the conclusion based on just performance processor B is a better choice.