Lab. 3 (May 1st) You may use either cygwin or visual studio for using OpenMP Compiling in cygwin “> gcc –fopenmp ex1.c” will generate a.exe Execute : “>

Slides:



Advertisements
Similar presentations
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Advertisements

Mohsan Jameel Department of Computing NUST School of Electrical Engineering and Computer Science 1.
1 OpenMP—An API for Shared Memory Programming Slides are based on:
Iteration and Loop Statements Horstmann Chapter 7 Loop statements control repeated execution of a block of statements Each time the statements in the block.
A Very Short Introduction to OpenMP Basile Schaeli EPFL – I&C – LSP Vincent Keller EPFL – STI – LIN.
CS 470/570 Lecture 7 Dot Product Examples Odd-even transposition sort More OpenMP Directives.
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Thread-Level Parallelism (TLP) and OpenMP Instructors: Krste Asanovic & Vladimir Stojanovic.
Lab. 2 (April 27th) Modify the multithreaded JAVA code we practiced in Lab. 1 to C code with pthread library. Pthread library works in UNIX environment.
Programming with Shared Memory Introduction to OpenMP
CS470/570 Lecture 5 Introduction to OpenMP Compute Pi example OpenMP directives and options.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Chapter 5 Shared Memory Programming with OpenMP An Introduction to Parallel Programming Peter Pacheco.
Lecture 5: Shared-memory Computing with Open MP. Shared Memory Computing.
Chapter 17 Shared-Memory Programming. Introduction OpenMP is an application programming interface (API) for parallel programming on multiprocessors. It.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Mixing integer and floating point numbers in an arithmetic operation.
Exercise 1 : ex1.java class C extends Thread { int i; C(int i) { this.i = i; } public void run() { System.out.println("Thread " + i + " says hi"); System.out.println("Thread.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Xiaoying Gao Computer Science Victoria University of Wellington Copyright: Xiaoying Gao, Peter Andreae, Victoria University of Wellington Creating Objects.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Computer Science 320 A First Program in Parallel Java.
CSE 1030: Implementing Static Features Mark Shtern.
Methods.
Structured Programming Dr. Atif Alhejali Lecture 4 Modifiers Parameters passing 1Structured Programming.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Heterogeneous Computing using openMP lecture 2 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
CS240A, T. Yang, Parallel Programming with OpenMP.
CS 110 Computer Architecture Lecture 20: Thread-Level Parallelism (TLP) and OpenMP Intro Instructor: Sören Schwertfeger School.
COMP7330/7336 Advanced Parallel and Distributed Computing OpenMP: Programming Model Dr. Xiao Qin Auburn University
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Heterogeneous Computing using openMP lecture 1 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
1 ITCS4145 Parallel Programming B. Wilkinson March 23, hybrid-abw.ppt Hybrid Parallel Programming Introduction.
Introduction to OpenMP
SHARED MEMORY PROGRAMMING WITH OpenMP
Department of Computer Science
Lecture 5: Shared-memory Computing with Open MP
Lab. 2 (April 15th) Modify the multithreaded JAVA code we practiced in Lab. 1 to C code with pthread library. Pthread library works in UNIX environment.
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing A bug in the rwlock program Dr. Xiao Qin.
Introduction to OpenMP
Shared-Memory Programming
September 4, 1997 Parallel Processing (CS 667) Lecture 5: Shared Memory Parallel Programming with OpenMP* Jeremy R. Johnson Parallel Processing.
John Wawrzynek & Vladimir Stojanovic
Lab. 3 (May 6st) You may use either cygwin or visual studio for using OpenMP Compiling in cygwin “> gcc –fopenmp ex1.c” will generate a.exe Execute : “>
OpenMP Quiz B. Wilkinson January 22, 2016.
Lab. 2 Modify the multithreaded JAVA code we practiced in Lab. 1 to C code with pthread library. Pthread library works in UNIX environment. Use cygwin.
Building Java Programs
Multi-core CPU Computing Straightforward with OpenMP
Parallel Programming.
Parallel Programming with OpenMP
Lab. 2 (May 12th) Modify the multithreaded JAVA code we practiced in Lab. 1 to C code with pthread library. Pthread library works in UNIX environment.
Writing Methods.
Computing Adjusted Quiz Total Score
An Introduction to Java – Part I, language basics
Hybrid Parallel Programming
Lab. 3 (May 11th) You may use either cygwin or visual studio for using OpenMP Compiling in cygwin “> gcc –fopenmp ex1.c” will generate a.exe Execute :
AP Java Warm-up Boolean Array.
Instructors: Yuanqing Cheng
class PrintOnetoTen { public static void main(String args[]) {
Lab. 2 (May 2nd) Modify the multithreaded JAVA code we practiced in Lab. 1 to C code with pthread library. Pthread library works in UNIX environment. Use.
Lecture Notes – Week 4 Chapter 5 (Loops).
DNA microarrays. Infinite Mixture Model-Based Clustering of DNA Microarray Data Using openMP.
Introduction to OpenMP
OpenMP Quiz.
Hybrid MPI and OpenMP Parallel Programming
Introduction to Parallel Computing
Exercise 1 : ex1.java Thread Creation and Execution
Introduction to Object-Oriented Concepts in Java
Building Java Programs
Exercise 1 : ex1.java Thread Creation and Execution (sleep() and join()) class C extends Thread {   int i;   C(int i) { this.i = i; }   public void run()
OpenMP Parallel Programming
Presentation transcript:

Lab. 3 (May 1st) You may use either cygwin or visual studio for using OpenMP Compiling in cygwin “> gcc –fopenmp ex1.c” will generate a.exe Execute : “> ./a.exe” Compiling in visual studio : setting

Exercise 1-1 : lab3_ex1-1.c Compute sum=1+2+3+…+10000 using 1,2,3,4 threads using OpenMP and measure time for each case. Use reduction // sample solution #include <omp.h> #include <stdio.h> #define NUM_THREADS 4 #define END_NUM 10000 int main () { int i; int sum=0; double start_time, end_time; omp_set_num_threads(NUM_THREADS); start_time = omp_get_wtime( ); #pragma omp parallel #pragma omp for reduction(+:sum) for (i = 1; i <= END_NUM; i++) { sum+=i; //printf_f("(%d/%d) : %d\n",omp_get_thread_num(),omp_get_num_threads(),i); } end_time = omp_get_wtime( ); printf("sum = 1+2+..+%d = %d\n",END_NUM,sum); printf("time elapsed: %lfs\n",end_time-start_time); return 1;

Exercise 1-2 : lab3_ex1-2.c Compute fact=1*2*…*10 using 1,2,3,4 threads using OpenMP and measure time for each case. Use reduction

Exercise 2 : lab3_ex2.c Parallelize following code using OpenMP. Test the code with 1,2,3,4,8,16 threads and measure the time for each case.

Exercise 3 : Prime numbers Modify following multithreaded JAVA code to C code with OpenMP library. Test your code with 1,2,4,8,16 threads and measure performance. Test your code with static load balancing and dynamic load balancing using schedule(static|dynamic|guided [,4]) class ex4_serial { private static final int NUM_END = 200000; public static void main(String[] args) { int counter=0; int i; long startTime = System.currentTimeMillis(); for (i=0;i<NUM_END;i++) { if (isPrime(i)) counter++; } long endTime = System.currentTimeMillis(); long timeDiff = endTime - startTime; System.out.println("Execution Time : "+timeDiff+"ms"); System.out.println("1..."+(NUM_END-1)+" prime# counter=" + counter +"\n"); private static boolean isPrime(int x) { if (x<=1) return false; for (i=2;i<x;i++) { if ((x%i == 0) && (i!=x)) return false; return true;