Loading in 5 sec....

OpenMP Lab IntroductionPowerPoint Presentation

OpenMP Lab Introduction

- 111 Views
- Uploaded on
- Presentation posted in: General

OpenMP Lab Introduction

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

OpenMP Lab Introduction

Open project Properties dialog box

Select OpenMP Support from C/C++ -> Language

set OMP_NUM_THREADS=4

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

- 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
- intomp_get_thread_num()
- intomp_get_num_threads()

Filter

6

4

8

4

3

5

4

indata

outdata

Apply filter masks to a grayscale image

Code uses 5-point stencil to simulate shifted image as filters

- 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?

- 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

- Alternate Algorithm:

17

21

11

25

6

4

8

4

3

3

- for j := 1 to log2n do
- for all k in parallel do
- if (k ≥ 2j-1) then
- x[k] := x[k – 2j-1] + x[k]
- fi
- od
- od

Prefix scan

Compute the inclusive prefix sum from input array; store results in output array

485

041

340

526

188

739

489

387

988

488

188

041

340

387

485

739

489

526

988

488

041

188

340

387

485

488

489

526

739

988

- 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

- 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

http://www.intel.com/go/threadingchallenge2010/

Apprentice Level

Master Level

Phase 1: May 31, 2010 to July 12, 2010

Phase 2: August 9, 2010 to November 1, 2010