- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

I'm using cblas_dgemm to calculate matrix multiplication. For random generated matrix X of size N * N (N could be 100), I calculate Y = X^T * X. (X^T is the tranpose of X). I can do it in two ways: (1) using cblas_dgemm to calculate Y directly (2) using a forloop that for i = 1:N, Y += X* * X ^T, where X is the i_th column of X. *

By comparing the speed, theoretically, they should have same complexity of N^3. But in reality, (2) way might take 4 times longer than (1). Could you help me to understand this?

Thanks

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

In the first case of blas dgemm, there are multiple optimizations techniques are used, that include loop reordering, loop unrolling, subdividing into blocks, vectorization, parallelizations etc. These help to keep the frequently used data in cache, reduce branch instructions, utilize DLP (data level parallelism) and TLP (thread level parallelism) etc. Many other optimizations are also done in various MKL routines.

--Vipin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Comparison of your code vs. reference BLAS source, and consideration of your compile options (and choice of compiler), would also be relevant to understanding these performance questions.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page