Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prof. Zhang Gang School of Computer Sci. & Tech.

Similar presentations


Presentation on theme: "Prof. Zhang Gang School of Computer Sci. & Tech."— Presentation transcript:

1 Chapter 4 Data-Level Parallelism in Vector, SIMD, and GPU Architectures Topic 11 Gather-Scatter
Prof. Zhang Gang School of Computer Sci. & Tech. Tianjin University, Tianjin, P. R. China

2 Gather-Scatter In a sparse matrix, the elements of a vector are usually stored in some compacted form and then accessed indirectly. The primary mechanism for supporting sparse matrices is gather-scatter operations using index vectors. The goal is to support moving between a compressed representation (i.e., zeros are not included) and normal representation (i.e., the zeros are included) of a sparse matrix.

3 Gather-Scatter A gather operation takes an index vector and fetches the vector whose elements are at the addresses given by adding a base address to the offsets given in the index vector. The result is a dense vector in a vector register.

4 Gather-Scatter Consider sparse vectors A & C and vector indices K & M
A and C have the same number (n) of non-zeros: for (i = 0; i < n; i=i+1) A[K[i]] = A[K[i]] + C[M[i]]; Ra, Rc, Rk and Rm are the starting addresses of vectors Use index vector: LV Vk, Rk ;load K LVI Va, (Ra+Vk) ;load A[K[]] LV Vm, Rm ;load M LVI Vc, (Rc+Vm) ;load C[M[]] ADDVV.D Va, Va, Vc ;add them SVI (Ra+Vk), Va ;store A[K[]]

5 Gather-Scatter This technique allows code with sparse matrices to run in vector mode. Although indexed loads and stores (gather and scatter) can be pipelined, they typically run much more slowly than non-indexed loads or stores, since the memory banks are not known at the start of the instruction.

6 Gather-Scatter Each element has an individual address, so they can’t be handled in groups, and there can be conflicts at many places throughout the memory system. Thus, each individual access incurs significant latency.

7 Exercises What is the meaning of gather?
What is the meaning of scatter? Where do gather-scatter operations are needed? What is stored in the index vector?


Download ppt "Prof. Zhang Gang School of Computer Sci. & Tech."

Similar presentations


Ads by Google