1 / 6

“Matrix Multiply ― in parallel”

“Matrix Multiply ― in parallel”. Joe Hummel, PhD U. Of Illinois, Chicago Loyola University Chicago joe@joehummel.net. Background…. Class : “ Introduction to CS for Engineers ” Lang : C/C++ Focus : programming basics, vectors, matrices Timing : present this after introducing 2D arrays….

Download Presentation

“Matrix Multiply ― in parallel”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. “Matrix Multiply ― in parallel” Joe Hummel, PhD U. Of Illinois, Chicago Loyola University Chicago joe@joehummel.net

  2. Background… • Class: “Introduction to CS for Engineers” • Lang: C/C++ • Focus: programming basics, vectors, matrices • Timing: present this after introducing 2D arrays…

  3. 1500x1500 matrix: 2.25M elements » 32 seconds… Matrix multiply • Yes, it’s boring, but… • everyone understands the problem • good example of triply-nested loops • non-trivial computation for(inti= 0; i< N; i++) for(int j= 0; j< N; j++) for(int k= 0; k< N; k++) C[i][j] += (A[i][k] * B[k][j]);

  4. Multicore • Matrix multiply is greatcandidate for multicore • embarrassingly-parallel • easy to parallelize viaoutermost loop #pragma omp parallel for for (inti= 0; i< N; i++) for(int j= 0; j< N; j++) for(int k= 0; k< N; k++) C[i][j] += (A[i][k] * B[k][j]); Cores 1500x1500 matrix: Quad-core CPU »8 seconds…

  5. Designing for HPC • Parallelism alone is not enough… HPC == Parallelism + Memory Hierarchy─Contention Expose parallelism • Minimize interaction: • false sharing • locking • synchronization • Maximize data locality: • network • disk • RAM • cache • core

  6. Data locality • What’s the other halfof the chip? • Implications? • No one implements MM this way • Rewrite to use loop interchange,and access B row-wise… Cache! #pragma omp parallel for for (inti= 0; i< N; i++) for(intk = 0; k < N; k++) for(intj = 0; j < N; j++) C[i][j] += (A[i][k] * B[k][j]); X 1500x1500 matrix: Quad-core + cache »2 seconds…

More Related