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 :

Slides:



Advertisements
Similar presentations
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Advertisements

1 OpenMP—An API for Shared Memory Programming Slides are based on:
Games at Bolton OpenMP Techniques Andrew Williams
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
A Very Short Introduction to OpenMP Basile Schaeli EPFL – I&C – LSP Vincent Keller EPFL – STI – LIN.
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.
Instructor: Sagar Karandikar
Chapter 17 Shared-Memory Programming. Introduction OpenMP is an application programming interface (API) for parallel programming on multiprocessors. It.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
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.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Computer Science 320 Load Balancing. Behavior of Parallel Program Why do 3 threads take longer than two?
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Computer Science 320 A First Program in Parallel Java.
Methods.
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.
OpenMP – Part 2 * *UHEM yaz çalıştayı notlarından derlenmiştir. (uhem.itu.edu.tr)
1 ITCS4145 Parallel Programming B. Wilkinson March 23, hybrid-abw.ppt Hybrid Parallel Programming Introduction.
OpenMP Lab Antonio Gómez-Iglesias Texas Advanced Computing Center.
Embedded Systems MPSoC Architectures OpenMP: Exercises Alberto Bosio
Introduction to 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.
CS427 Multicore Architecture and Parallel Computing
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.
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
The Boolean (logical) data type boolean
Hybrid Parallel Programming
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.
Hybrid Parallel Programming
Introduction to OpenMP
OpenMP Quiz.
Hybrid MPI and OpenMP Parallel Programming
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
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 : “>
In this class, we will cover:
Exercise 1 : ex1.java Thread Creation and Execution
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 11th) 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 2 : Numerical Integration Parallelize following code using OpenMP. Test the code with 1,2,3,4,8,16 threads and with different load balancing approach (e.g. static, dynamic, guided, try different chunk size). Measure the time for each case.

Exercise 3 : Matrix multiplication Compile and run omp_ex3.c (available on our class webpage) and try different number of threads (1,2,4,8,16,32) and different load balancing approaches (e.g. static, dynamic, guided). Read and understand the source code omp_ex3.c

Exercise 4 : 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;