Multicore Manual

Download Multicore Manual

Post on 27-Oct-2014

24 views

Category:

Documents

2 download

Embed Size (px)

TRANSCRIPT

VITUNIVERSITY(Estd. u/s 3 of UGC Act 1956)

Vellore - 632 014, Tamil Nadu, India

School of Computing Sciences

Multi-Core Programming Lab (CSE512)

1. Syllabus 2. Guide lines for a. Observation b. Soft Record 3. Cycle sheets 4. Literaturea. OpenMP b. Introduction to Multi-core architectures

c. Virtual & Cache Memory d. Fundamentals of parallel Computers e. Parallel Programming

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

CSE 512 MULTICORE PROGRAMMING LAB L0Objective To provide hands on experience on parallel programming for multi-core architectures.

T0

P3

C2

Expected Outcome After completion of this course, student able to Parallelize code for an application Understand the issues and recent trends in the area of parallel programming Prerequisites/Exposure Advanced Computer Architecture Guidelines for experiments 1. 2. 3. 4. Parallelize C/C++ programs using OpenMP on dual core or quad core system Parallelize C/C++ programming using PThreading on dual core or quad core system Analysis of performance of parallelized programs using VTune analyzer Students asked to write a C/C++ program for an application and parallelize the application using OpenMP and PThreading and observe the interesting findings by using VTune analyzer

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

Instructions to write observation: There is no record writing for this Multi-core programming lab, so students should maintain this observation as a record. 1. Every student should have a 200 pages long note book 2. Leave empty first four pages for the index. 3. Maintain the index as per prescribed format. 4. Write the program as per given format in the right side of note book. 5. Results should be written in left side of book. 6. Start every new program in a fresh page. 7. specify the page numbers as per prescribed format Students asked to submit the soft Record at the end of course: Guide lines to prepare Soft Record for Multi-Core Programming Lab 1. Front Page 2. Contents Prepare index list as per the prescribed format given for the observation. 3. Programs a. Prepare a separate file for every program, which includes aim, requirements, program and results. b. Results should be placed as snapshots of your program outputs. Provide brief information on the each result. c. Rename this file with _ (Eg: C1_5 represents Cycle 1 and 5th Program) d. Page numbers of every file should be continued from previous file ( Eg: file1 for program1 ends at page number 5, then the subsequent file should start at 6) e. Subheadings f. Information under subheadings is 4. Rename each file with program number 5. all .doc, and source code files burn into CD and submit the same to the faculty member on or before 6th April 2008. 6. 10% of marks will be awarded for this Soft record. So, any student fails to submit/ poor submission will be discredited.

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

1

2

3

OpenMP C and C++ Application Program InterfaceVersion 2.0 March 2002

4

5 6 7 8 9

Copyright 1997-2002 OpenMP Architecture Review Board. Permission to copy without fee all or part of this material is granted, provided the OpenMP Architecture Review Board copyright notice and the title of this document appear. Notice is given that copying is by permission of OpenMP Architecture Review Board.

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

1

Contents

2 3 4 5 6 7 8

1.

Introduction 1.1 1.2 1.3 1.4 1.5 1.6 Scope

...............................................1 ................................................1 ......................................2 ........................................3

Definition of Terms Execution Model Compliance

...........................................4 ...................................5

Normative References Organization

...........................................5

9 10 11 12 13 14 15 16 17 18 19 20 21

2.

Directives 2.1 2.2 2.3 2.4

.................................................7 ........................................7 ..................................8 ....................................8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 . . . . . . . . . . . . . . . . . . 16

Directive Format

Conditional Compilation parallel Construct

Work-sharing Constructs 2.4.1 2.4.2 2.4.3 for Construct

sections Construct single Construct

2.5

Combined Parallel Work-sharing Constructs 2.5.1 2.5.2 parallel for Construct

. . . . . . . . . . . . . . . . . . . . . . . . . . 16 . . . . . . . . . . . . . . . . . . . . . 17 . . . . . . . . . . . . . . . . . . . . . . 17

parallel sections Construct

2.6

Master and Synchronization Directives 2.6.1 master Construct

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Contents iii

22

Compiled by: M.Rajasekhara Babu, M.Narayana Moorthy, Kaushik S., K.Manikandan Faculty / School of Computing Science and Engineering/VIT University;

http://sites.google.com/site/mrajasekharababu/mtech09/multi-corelab

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.7

critical Construct barrier Directive atomic Construct flush Directive

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

ordered Construct

Data Environment 2.7.1 2.7.2

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 . . . . . . . . . . . . . . . . . . . . . . . . . 23 . . . . . . . . . . . . . . . . . . . . . . 25

threadprivate Directive

Data-Sharing Attribute Clauses 2.7.2.1 2.7.2.2 2.7.2.3 2.7.2.4 2.7.2.5 2.7.2.6 2.7.2.7 2.7.2.8 private

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 . . . . . . . . . . . . . . . . . . . . . . . . . 26 . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

firstprivate lastprivate shared default

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

reduction copyin

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

copyprivate

2.8 2.9 3.

Directive Binding Directive Nesting

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 . . . . . . . . . . . . . . . . . . . . . . . . . . 35 . . . . . . . . . . . . . . . . . . . 36 . . . . . . . . . . . . . . . . . . . 37 . . . . . . . . . . . . . . . . . . . 37 . . . . . . . . . . . . . . . . . . . . 38 . . . . . . . . . . . . . . . . . . . . . 38 . . . . . . . . . . . . . . . . . . . . . . . 38 . . . . . . . . . . . . . . . . . . . . . . . 39 . . . . . . . . . . . . . . . . . . . . . . . 40 . . . . . . . . . . . . . . . . . . . . . . . . 40

19 20 21 22 23 24 25 26 27 28 29

Run-time Library Functions 3.1

Execution Environment Functions 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9

omp_set_num_threads Function omp_get_num_threads Function omp_get_max_threads Function omp_get_thread_num Function omp_get_num_procs