COMP 426 Fall 2024 Multicore Programming (TBB) PDF
Document Details
Uploaded by RiskFreeAlien
Concordia University
2024
Arch Robison and Asaf Yaffe
Tags
Summary
This document contains lecture notes for COMP 426, Fall 2024: Multicore Programming. It discusses Intel Threading Building Blocks (TBB), OpenMP, and related topics. The lecture notes cover various methods for parallel programming.
Full Transcript
COMP 426: Multicore Programming Intel® Threading Building Blocks (TBB) Based on slides from Arch Robison and Asaf Yaffe, Intel Corporation COMP 426, Fall 2024 Intel TBB Problems in Multicore Programming Gaining performance from multi-core r...
COMP 426: Multicore Programming Intel® Threading Building Blocks (TBB) Based on slides from Arch Robison and Asaf Yaffe, Intel Corporation COMP 426, Fall 2024 Intel TBB Problems in Multicore Programming Gaining performance from multi-core requires (more than) multithreaded programming Even a simple “parallel for” is tricky for a non- expert to write well with explicit threads Two aspects to multicore programming Correctness : avoiding race conditions and deadlock Performance : efficient use of resources Hardware threads (match parallelism to hardware threads) Memory space (choose right evaluation order) Memory bandwidth (reuse cache) COMP 426, Fall 2024 Intel TBB 1 Problems with Multi-threaded Programming Thread libraries are hard to use P-Threads/Solaris threads have many library calls for initialization, synchronization, thread creation, condition variables, etc. Programmer must code with multiple threads in mind Synchronization between threads introduces a new dimension of program correctness Wouldn’t it be nice to write serial programs and somehow parallelize them “automatically”? OpenMP (a small API) and Cilk (a language extension) hide cumbersome threading calls with simpler directives COMP 426, Fall 2024 Intel TBB 2 Open Multi-Processing (OpenMP) OpenMP is a compiler-based technique to create concurrent code from (mostly) serial code OpenMP can enable (easy) parallelization of loop-based code Lightweight syntactic language extensions OpenMP performs comparably to manually- coded threading Scalable Portable COMP 426, Fall 2024 Intel TBB 3 OpenMP Example Sequential code for (int i=0; i