174k views
4 votes
What is the stride (i.e., distance between elements that need to be put together in vector registers) of matrix B and D in the following code for row-major and column-major methods for storing multidimensional data?

a) Row-major: B = 1, D = 1; Column-major: B = 1, D = 1
b) Row-major: B = 1, D = 1; Column-major: B = 2, D = 2
c) Row-major: B = 1, D = 2; Column-major: B = 1, D = 2
d) Row-major: B = 2, D = 2; Column-major: B = 1, D = 1

User Sham
by
9.0k points

1 Answer

4 votes

Final answer:

The stride of matrix B is 1 for both row-major and column-major methods. For matrix D, the stride is 1 in row-major and 2 in column-major.

Step-by-step explanation:

In this code, the stride represents the distance between elements that need to be put together in vector registers. For matrix B, the stride is the same for both row-major and column-major methods, which is 1. This means that the elements in matrix B are contiguous in memory, with each element being one unit apart.



For matrix D, the stride depends on the storage method. In the row-major method, the stride is also 1, meaning that the elements are contiguous. In the column-major method, however, the stride is 2. This means that the elements in matrix D are separated by two units in memory.

User Schmilblick
by
7.7k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories