Arsitektur Komputer: Tugas Matrikulasi BAB I.

EXERCISES
6. Consider having a program that runs in 50 s on computer A, which has a 500 MHz clock. We would like to run the same program on another machine, B, in 20 s. If machine B requires 2.5 times as many clock cycles as machine A for the same program, what clock rate must machine B have in MHz?
7. Suppose that we have two implementations of the same instruction set architecture. Machine A has a clock cycle time of 50 ns and a CPI of 4.0 for some program, and machine B has a clock cycle of 65 ns and a CPI of 2.5 for the same program. Which machine is faster and by how much?
8. A compiler designer is trying to decide between two code sequences for a particular machine. The hardware designers have supplied the following facts:
Instruction
class
CPI of the
instruction class
A 1
B 3
C 4
For a particular high-level language, the compiler writer is considering two sequences that require the following instruction counts:
Code
sequence
Instruction counts
(in millions)
A B C
1 2 1 2
2 4 3 1
What is the CPI for each sequence? Which code sequence is faster? By how
much?
9. Consider a machine with three instruction classes and CPI measurements as follows:
Instruction
class
CPI of the
instruction class
A 2
B 5
C 7
Suppose that we measured the code for a given program in two different
compilers and obtained the following data:
Code
sequence
Instruction counts
(in millions)
A B C
Compiler 1 15 5 3
Compiler 2 25 2 2
Assume that the machine’s clock rate is 500 MHz. Which code sequence will execute faster according to MIPS? And according to execution time?
10. Three enhancements with the following speedups are proposed for a new machine: Speedup(a) ¼ 30, Speedup(b) ¼ 20, and Speedup(c) ¼ 15.
Assume that for some set of programs, the fraction of use is 25% for enhancement (a), 30% for enhancement (b), and 45% for enhancement (c). If only one enhancement can be implemented, which should be chosen to maximize the speedup? If two enhancements can be implemented, which should be chosen, to maximize the speedup?

dari e-book:

C# Programming: Konversi Bilangan Desimal ke Biner

From Decimal to Binary…

using System;

class Program{

static void Main(string[] args){

try{

int i = (int)Convert.ToInt64(args[0]);
Console.WriteLine(“n{0} converted to Binary is {1}n”,i,ToBinary(i));

}catch(Exception e){

Console.WriteLine(“n{0}n”,e.Message);

}

}//end Main

public static string ToBinary(Int64 Decimal)
{
// Declare a few variables we’re going to need
Int64 BinaryHolder;
char[] BinaryArray;
string BinaryResult = “”;

while (Decimal > 0)
{
BinaryHolder = Decimal % 2;
BinaryResult += BinaryHolder;
Decimal = Decimal / 2;
}

// The algoritm gives us the binary number in reverse order (mirrored)
// We store it in an array so that we can reverse it back to normal
BinaryArray = BinaryResult.ToCharArray();
Array.Reverse(BinaryArray);
BinaryResult = new string(BinaryArray);

return BinaryResult;
}

}//end class Program

——————————————————————————–

From Binary to Decimal…

using System;

class Program{

static void Main(string[] args){

try{

int i = ToDecimal(args[0]);
Console.WriteLine(“n{0} converted to Decimal is {1}”,args[0],i);

}catch(Exception e){

Console.WriteLine(“n{0}n”,e.Message);

}

}//end Main

public static int ToDecimal(string bin)
{
long l = Convert.ToInt64(bin,2);
int i = (int)l;
return i;
}

}//end class Program

Create a free website or blog at WordPress.com.

Up ↑