Presentation is loading. Please wait.

Presentation is loading. Please wait.

Upcrc.illinois.edu OpenMP Lab Introduction. Compiling for OpenMP Open project Properties dialog box Select OpenMP Support from C/C++ -> Language.

Similar presentations


Presentation on theme: "Upcrc.illinois.edu OpenMP Lab Introduction. Compiling for OpenMP Open project Properties dialog box Select OpenMP Support from C/C++ -> Language."— Presentation transcript:

1 upcrc.illinois.edu OpenMP Lab Introduction

2 Compiling for OpenMP Open project Properties dialog box Select OpenMP Support from C/C++ -> Language

3 Setting the Number of Threads The default number of threads should be the number of cores available on the system. In command window, use the environment variable, OMP_NUM_THREADS, to set the number of threads desired set OMP_NUM_THREADS=4

4 General Instructions Use OpenMP to parallelize the given serial codes More detailed instructions given in lab directory Consult the OpenMP 3.0 Specification document for more detailed information and additional constructs – http://www.openmp.org for download – API functions listed and explained int omp_get_thread_num() int omp_get_num_threads()

5 Convolution Apply filter masks to a grayscale image Code uses 5-point stencil to simulate shifted image as filters 648 4 3 54 Filter indataoutdata

6 Matrix-Matrix Multiplication Several different formulations of dense matrix-matrix multiplication – Triple-nested loop – Blocked – Recursive Try OpenMP in one or more – Is one version easier to use with OpenMP? – Is there a noticeable difference in execution speed in one version over the others?

7 Sparse Matrix, Dense Vector Multiply a sparse matrix by a dense vector – Matrix is stored in compressed sparse row (CSR) format – Multiply only non-zero elements with corresponding vector elements

8 Prefix Scan Compute the inclusive prefix sum from input array; store results in output array 64843172111253 Prefix scan for j := 1 to log 2 n do for all k in parallel do if (k ≥ 2 j-1 ) then x[k] := x[k – 2 j-1 ] + x[k] fi od Alternate Algorithm:

9 Quicksort Recursive version of Quicksort algorithm Consider using OpenMP tasks – At some point (size of partition), overhead to create new task become prohibitive; switch to serial Quicksort or other sort algorithm 485041340526188739489387988488 188041340387485739489526988488 041188340387485488489526739988

10 Minimum Spanning Tree Construct the Minimum Spanning Tree from a weighted graph using Prim’s Algorithm – Start with arbitrary node in MST – While more nodes not in MST do Find smallest weight edge from node in MST to some node not in MST Add new edge and node to MST Caution: first nested loop finds the index of the minimum

11 Phase 1: May 31, 2010 to July 12, 2010 Phase 2: August 9, 2010 to November 1, 2010 http://www.intel.com/go/threadingchallenge2010/ Apprentice Level Master Level


Download ppt "Upcrc.illinois.edu OpenMP Lab Introduction. Compiling for OpenMP Open project Properties dialog box Select OpenMP Support from C/C++ -> Language."

Similar presentations


Ads by Google