memory-access

Efficiency: arrays vs pointers

∥☆過路亽.° 提交于 2019-11-26 12:15:53
问题 Memory access through pointers is said to be more efficient than memory access through an array. I am learning C and the above is stated in K&R. Specifically they say Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster I dis-assembled the following code using visual C++.(Mine is a 686 processor. I have disabled all optimizations.) int a[10], *p = a, temp; void foo() { temp = a[0]; temp = *p; } To my surprise I

In CUDA, what is memory coalescing, and how is it achieved?

只愿长相守 提交于 2019-11-26 10:07:19
问题 What is \"coalesced\" in CUDA global memory transaction? I couldn\'t understand even after going through my CUDA guide. How to do it? In CUDA programming guide matrix example, accessing the matrix row by row is called \"coalesced\" or col.. by col.. is called coalesced? Which is correct and why? 回答1: It's likely that this information applies only to compute capabality 1.x, or cuda 2.0. More recent architectures and cuda 3.0 have more sophisticated global memory access and in fact "coalesced

Using the extra 16 bits in 64-bit pointers

五迷三道 提交于 2019-11-26 06:08:44
问题 I read that a 64-bit machine actually uses only 48 bits of address (specifically, I\'m using Intel core i7). I would expect that the extra 16 bits (bits 48-63) are irrelevant for the address, and would be ignored. But when I try to access such an address I got a signal EXC_BAD_ACCESS . My code is: int *p1 = &val; int *p2 = (int *)((long)p1 | 1ll<<48);//set bit 48, which should be irrelevant int v = *p2; //Here I receive a signal EXC_BAD_ACCESS. Why this is so? Is there a way to use these 16