自己做的部分习题解答,因为时间关系,有些马虎,也不全面,欢迎探讨或指出错误 5.1 Consider the matrixaddition in Exercise 3.1. Can one use shared memory to reduce theglobal memory bandwidth consumption? Hint: analyze the elementsaccessed by each thread and see if there is any commonality b
对于下面的值,写出变量x的C语言表达式.代码应该对任何字长w≥8都能工作.我们给出当x=0x87654321以及w=32时表达式的结果,仅供参考. A.x的最低有效字节,其他位均为0.[0x00000021]. B.除了x的最低有效字节外,其他位都取补,最低有效字节保持不变.[0x789ABC21]. C.x的最低有效字节设置成全1,其他字节都保持不变.[0x876543FF]. 解答: A. x & 0xFF B. ~(x ^ 0xFF)或者x ^ (~0xFF) C. x | 0xFF
在2.10中的inplace_swap函数的基础上,你决定写一段代码,实现将一个数组中的元素两端依次对调,你写出下面这个函数: void reverse_array(int a[], int cnt) { int first, last; , last = cnt - ; first <= last; first ++, last --) { inplace_swap(&a[first], &a[last]); } } 当对一个数组包含1.2.3.4时,得到预期的结果4.3.2.1.