Skip to content
0:00 / 0:00

#matrixmultiplication#cacheoptimization#vectorization

1. Introduction and Matrix Multiplication

MIT OpenCourseWare

6.5M subscribers • 37 videos on Hallway • University channel

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Charles Leiserson, MIT Professor

Intermediate. Assumes working knowledge.

292K views5 years ago2 recommendations

Systems programmingComputer sciencePerformance and optimizationAlgorithmsC

Charles Leiserson introduces software performance engineering, comparing Python, Java, and C, and demonstrates optimizing matrix multiplication through cache-friendly loop ordering.

MIT 6.172 Performance Engineering of Software Systems, Fall 2018 Instructor: Charles Leiserson View the complete course: ocw.mit.edu/6-172F18 YouTube Playlist: youtube.com/playlist?list=PLUl4u3cNGP63VIBQVWguXxZZi0566y7Wf Professor Leiserson introduces 6.172 Performance Engineering of Software Systems. The class examines an example of code optimization using matrix multiplication and discusses the differences between programming languages Python, Java, and C. License: Creative Commons BY-NC-SA More information at ocw.mit.edu/terms More courses at ocw.mit.edu

Why it's here

2 people recommend this

What people say. Highly recommended as the definitive lecture on cache-friendly code optimization, loop tiling, and hardware-level performance tuning.

u/HaydnHin r/C_Programming • Recommends

On “Beating NumPy matrix multiplication in 150 lines of C”

MIT has a whole lecture on matrix multiplication: link to this video

u/HaydnHin r/C_Programming • Recommends

On “Optimizing matrix multiplication”

There's an open MIT lecture specifically on this subject. Similar to you they start with a "naive" approach for n=4096, but also include Java and Python for good measure. They managed to get it down from about 1100 second to <0.5, which is impressive. It might give you some ideas for the next steps: link to this video

u/HaydnHin r/C_Programming • Recommends

On “Know any good podcasts or youtube series to learn C?”

MIT post their lectures for free online: https://ocw.mit.edu/ I actually have a favourite if you want a sample. It might be a bit serious/dry though: link to this video

u/HaydnHin r/C_Programming • Recommends

On “Need help with implementing a matrix library in C.”

MIT lecture on matrix multiplication: link to this video

u/HaydnHin r/C_Programming • Recommends

On “Machine learning in C?”

MIT lecture on matrix multiplication if that helps: link to this video

u/HaydnHin r/C_Programming • Recommends

On “Musings on "faster than C" ”

If you're asking this question you may be interested in this MIT lecture. It's more to do with interpreted Vs JIT Vs compiled to start with, but the optimisations later on in C are interesting, and the end results are really impressive (although it's a somewhat perfectly setup example from what I recall): link to this video

u/tstanislin r/C_Programming • Recommends

On “Matrix multiplication in C”

Please watch link to this video to see how "old fashioned" matrix multiplication is inferior to mkl or blas.

u/tstanislin r/C_Programming • Recommends

On “memory manipulation tricks for n-dimensional array multiplication”

From standard C you can reorganize the loops to be more cache friendly. Use some tiling to improve memory reuse. Try using `restrict` to make vectorization easier. If possible try using multithreading (like OpenMP). See this movie to find some inspiration.

u/HaydnHin r/C_Programming • Mentions

On “Critique Code: Matrix Multiplication”

Not sure if this is useful to you, but MIT have a free lecture on matrix multiplication performance: link to this video

u/HaydnHin r/C_Programming • Mentions

On “What is the most efficient way to paralelise a portion of code in C++ (a for loop) without using vectors?”

Ignoring the fact this is a C sub and not C++... This really depends on the context, you can't just magically make a for loop quicker without knowing what to for loop is doing. There are generic ways to *possibly* improve performance, like using Intel's cilk_for instead of for. But without the context it's hard to say, and even with the context the theoretical improvements are often wrong in practice, so you'd need to test. Perhaps this will help: link to this video