Pregunta 1
Pregunta
Consider the following code. Assume the compiler is performing no optimization. Which of the following strategies would improve the speed of this code the most in the case where it returns true?
Respuesta
-
Unroll the loop
-
Pull the (x % i)==0 into a function isDivisibleBy
-
Declare int sx = (int)sqrt(x) and change i < sqrt(x) to i < s
-
Move the check for (x % 2) != 0 to before the loop
Pregunta 2
Pregunta
By default, OpenMp _____ assigns loop iterations to threads. When the parallel for block is entered, it assigns each thread the set of loop iterations it is to execute?
Respuesta
-
static
-
runtime
-
dynamic
-
auto
Pregunta 3
Pregunta
OpenMP assigns one iteration to each thread. When the thread finishes, it will be assigned the next iteration that hasn’t been executed yet.
Respuesta
-
runtime
-
dynamic
-
static
-
auto
Pregunta 4
Pregunta
This is an example of? (IMAGE)
/*set elements of array to 0*/
void clear_array (int *desc, int n){
int i;
for (i = 0; i<n; i++)
dest[i] = 0;
}
/*set elements of array to 0, Unrolled X4*/
...
...
Respuesta
-
Loop Unrolling
-
Loop fission
-
none
-
Loop fusion
Pregunta 5
Pregunta
This is an example of? (IMAGE)
/*convert string to lowercase: slow*/
void lower1 (char *s)
{ int i;
for (i = 0; i < strlen(s); i++)
if (s{i} >= 'A' && s[i] <= 'Z')
s[i] -= ('A' - 'a');
}
/*Convert string to lowercase: faster*/
void lower2(char *s) {
...
...
}
Respuesta
-
Loop fission
-
Code motion
-
Loop unrolling
-
Loop blocking
Pregunta 6
Pregunta
In given two C modules which rule will Unix linker use to resolve multiple symbol definition?
Respuesta
-
Given a strong symbol and multiple weak symbols, choose the strong symbol.
-
Given multiple weak symbols, chose any of the weak symbols
-
Multiple strong symbols are not allowed.
-
None of these
Pregunta 7
Pregunta
In C, on a 34-bit x86 machine, the expression (1<<31) results in a negative integer
Pregunta 8
Pregunta
Which of the following move operations is the following instruction an example of: movl (%edx), %eax ?
Pregunta 9
Pregunta
What is the value of the following C expression? x = 0xBC and y = 0x35 (x & !y)
Respuesta
-
0x1200
-
0xFFFF
-
0x0001
-
0x0000
Pregunta 10
Pregunta
In general, which of the following is slowest?
Pregunta 11
Pregunta
Good software design includes writing procedures for code you might otherwise repeat in-line. Pulling code into procedures can help some branch predictors; how else can it improve your program’s performance and/or your compiler’s ability to optimize your code?
Respuesta
-
more opportunities for loop unrolling
-
less chance of compiler having to worry about aliasing and side effects
-
more opportunities for pipeline-level parallelism
-
better instruction cache hit rate
Pregunta 12
Pregunta
This is an example of?
Respuesta
-
Parrallel processing
-
Serial processing
-
none of the above
-
Linear processing
Pregunta 13
Pregunta
This is an example of?
Respuesta
-
Parallel processing
-
Serial processing
-
none of the above
-
Linear processing
Pregunta 14
Pregunta
The code ( a && b ) || (!a && !b) implements —
Respuesta
-
Equality
-
MUX
-
Adder
-
Set membership
Pregunta 15
Pregunta
Consider the following code fragment (IMAGE)
int a; int b;
int main(int argc, char * argv[]){
int x;
int y;
… /* some code*/
}
Respuesta
-
The value of &y is closer to the value of &x than to the value &
-
The values of &a and &b are closer to each other then the values &x and &y
-
The values of *a and *b are closer to each other than the values of *x and *y
-
The value of *y is closer to the value of *x than to the value of *a
Pregunta 16
Pregunta
Compare the size of int and int*
Pregunta 17
Pregunta
In C, if x is an integer variable, the expression “x << 3” computes x * 8 but does not change the value of x.
Pregunta 18
Pregunta
Using a base address [Eb]%edx=0x1000, and index register [ei]%ecx=0x02, compute the effective address for (IMAGE) :
movl 8(%edx,%ecx, 4), %eax)
Respuesta
-
0x1032
-
0x1016
-
0x1064
-
0x1010
Pregunta 19
Pregunta
Using a base address [Eb]%edx=0x1000, and index register [ei]%ecx=0x03, compute the effective address for (IMAGE):
movl 8(%edx, %ecx, 4), %eax
Respuesta
-
0x1032
-
0x1016
-
0x1064
-
0x1014
Pregunta 20
Pregunta
What value ends up in EAX after the following code is executed?
Respuesta
-
48 (decimal) or 00110000 (binary) or 0x30 (hex)
-
50 (decimal) or 00110010 (binary) or 0x32 (hex)
-
46 (decimal) or 00101110 (binary) or 0x2E (hex)
-
52 (decimal) or 00110100 (binary) or 0x34 (hex)
Pregunta 21
Pregunta
Two computers A and B with a cache in the CPU chip differ only in that A has an L2 cache and B does not. Which of the following are possible?
Respuesta
-
1 and 2 only
-
1 only
-
2 only
-
2 and 3 only
Pregunta 22
Pregunta
Which of the following code snippets is fastest ? Assume n is very large(more than ten thousand)
Respuesta
-
for(k=0; k<n; k+=16) for(l=0; l<n; l+=16)
for(j=0;j<16;j+=1) for(i=0;i<16;i+=1)
a[i+l][j+k] = b[j+k][i+l];
-
two or more of the above are equivalently the fastest
-
for(j=0;j<n;j+=1) for(i=0;i<n;i+=1) a[i][j] = b[j][i];
-
for(i=0;i<n;i+=1) for(j=0;j<n;j+=1) a[i][j] = b[j][i];
Pregunta 23
Pregunta
Which of the following code snippets is fastest? Assume n is very large (more than ten thousand).
Respuesta
-
for(i=0;i<n;i+=1) for(j=0;j<n;j+=1) a[i][j] = b[j][i];
-
for(j=0;j<n;j+=1) for(i=0;i<n;i+=1) a[i][j] = b[j][i
-
for(k=0; k<n; k+=16) for(l=0; l<n; l+=16)
for(j=0;j<16;j+=1) for(i=0;i<16;i+=1)
a[i+l][j+k] = b[i+l][j+k];
-
two or more of the above are equivalently the fastest
Pregunta 24
Pregunta
Good software design includes writing procedures for code you might otherwise repeat in-line. Pulling code into procedures involves call/return overhead; how else can it HURT your program's performance and/or your compiler's ability to optimize your code?
Respuesta
-
more chance of compiler having to worry about aliasing and side effects
-
fewer opportunities for pipeline-level parallelism
-
worse instruction cache hit rate
-
fewer opportunities for loop unrolling
Pregunta 25
Pregunta
Good software design includes writing procedures for code you might otherwise repeat in-line. Pulling code into procedures can help some branch predictors; how else can it IMPROVE your program’s performance and/or your compiler’s ability to optimize your code?
Respuesta
-
more opportunities for loop unrollin
-
less chance of compiler having to worry about aliasing and side effects
-
more opportunities for pipeline-level parallelism
-
better instruction cache hit rate
Pregunta 26
Pregunta
Consider a direct-mapped cache with 256 sets and 16 byte blocks. In this cache the address 0x12345 maps to the same set as which of the following addresses?
Respuesta
-
0x02345
-
0x22244
-
0x12354
-
0x12040
Pregunta 27
Pregunta
Parallel processing mechanisms to achieve parallelism in uniprocessor system are:
Pregunta 28
Pregunta
This is an example of?
Pregunta 29
Pregunta
This is an example of? (IMAGE)
Respuesta
-
None
-
Loop unrolling
-
Loop fusion
-
Loop fission
Pregunta 30
Pregunta
This is an example of?
Respuesta
-
Loop fission
-
Loop fusion
-
None
-
Loop unrolling
Pregunta 31
Pregunta
Program take as input a collection of relocatable object files and command-line arguments and generate as output a fully linked executable object file that can be loaded and run:
Respuesta
-
Static linker
-
Dynamic linker
-
Both
-
None
Pregunta 32
Pregunta
... involve identifying a computation that is performed multiple times (e.g., within a loop), but such that the result of the computation will not change.
Respuesta
-
Side effect
-
Code motion
-
Loop unrollin
-
Memory aliasing
Pregunta 33
Pregunta
... construct encloses code, forming a parallel region.
Pregunta 34
Pregunta
... is the default schedule type. Upon entering the loop, each thread independently decides which chunk of the loop they will process.
Respuesta
-
static
-
dynamic
-
runtime
-
guided
Pregunta 35
Pregunta
By default, OpenMP _____ assigns loop iterations to threads. When the parallel for block is entered, it assigns each thread the set of loop iterations it is to execute?
Respuesta
-
static
-
dynamic
-
runtime
-
auto
Pregunta 36
Pregunta
The _______ directive causes threads encountering the barrier to wait until all the other threads in the same team have encountered the barrier.
Respuesta
-
single
-
barrier
-
nowait
-
private