Mode-1 Multi-Core Memory Allocators OpenMP Intel TBB Pthreads Java - Threads Charm++ Prog. Message Passing (MPI) MPI - OpenMP MPI - Intel TBB MPI - Pthreads Compiler Opt. Features Threads-Perf. Math.Lib. Threads-Prof. & Tools Threads-I/O Perf. PGAS : UPC / CAF / GA Power-Perf. Home




hyPACK-2013 : Prog. on Multi-Core Processors Using Memory Allocators

Example 1.1

Write a TBB program to vector vector multiplication using Memory Allocator

Example 1.2

Write a TBB program to Matrix vector multiplication using Memory Allocator

Example 1.3

Write a TBB program to Matrix matrix multiplication using blockrange2d directive using Memory Allocator



Description of Programs Using mmap & Different Memory Allocators
 

Makefile : To compile the program : (Download source code ; Makefile )

Example 1.1 : Vector Vector multiplication using TBB.

Download source code ; tbb-vect-vect-scalable-malloc.cpp

Download source code ; mmap - tbb vect-vect multiplication (WinRAR ZIP archive)
(using mmap memory allocator )

Download source code ; malloc- tbb vect-vect multiplication (WinRAR ZIP archive)
(using malloc - memory allocator )
  • Objective
  • To write a TBB program to compute the vector-vector multiplication with TBB using block_range.

  • Description
  • This is an implementation of Vector-Vector multiplication using TBB block_range directive. A block_range is a template class provided by the library. It describes a one-dimensional iteration space over type T. parallel_for divides this entire iteration space into subspaces for each processor.

  • Input
  • Vector Size and Number Threads.

  • Output
  • Time taken for vector-vector computation.

Example 1.2 : Matrix Vector multiplication using TBB.

Download source code ; tbb-mat-vect-scalable-malloc.cpp

Download source code ; mmap - tbb mat-vect multiplication (WinRAR ZIP archive)
(using mmap memory allocator )

Download source code ; malloc- tbb mat-vect multiplication (WinRAR ZIP archive)
(using malloc - memory allocator )
  • Objective
  • Write a programme for performing matrix-vector multiplication using TBB and measure the performance. .

  • Description
  • In this code we are doing multiplication of matrix ma and vector vb and the resultant vector is stored in vector vc.

    This example illustrates the use of parallel_for which breaks the iteration space into chunks and runs each chunk on a separate thread. Operator() function processes a chunk given by parallel_for.

    It is assumed that number of columns of the matrix A and size of the vector are same.

  • Input
  • Size (nrows=ncols=vecsize) , Number of Threads

  • Output
  • Execution time in seconds required for matrix-vector multiplication.

Example 1.3 : Matrix Matrix multiplication using TBB blockranged2d directive.

( Download source code :
tbb-mat-mat-scalable-malloc.cpp (Scalable malloc)
Download source code ; mmap - tbb mat-mat multiplication (WinRAR ZIP archive)
(using mmap memory allocator )

Download source code ; malloc- tbb mat-mat multiplication (WinRAR ZIP archive)
(using malloc - memory allocator )

  • Objective
  • Write a TBB program for matrix-matrix multiplication using TBB blockranged2d directive and measure the performance.

  • Description
  • In this example, we have shown how to use a blocked_range2d to specify two dimensional iteration space. The blocked_range2d enables the two outermost loops of the serial version to become parallel loops.The Parallel_for recursively splits the blocked_range2d. it invokes operator() for each piece. It is assumed that both matrices size are same.

  • Input
  • Number of threads, Size of matrix.

  • Output
  • Time taken for matrix-matrix computation.

Centre for Development of Advanced Computing