SlideShare a Scribd company logo
1 of 7
Presented by ,
Suveeksha Jain
MTech CSE
OpenMP Library Functions
*In addition to programs, OpenMP provides a set of functions
And environment variables.
*OpenMP requires conditional compilation in programs
#include<omp.h>
#ifdef_OPENMP
Omp_set_num_threads (4);
#endif
The Most Heavily used OpenMP Library Functions
• int omp_get_num_threads (void);
Returns the number of threads currently in use.
• int omp_set_num_threads (int NumThreads);
This function sets the number of threads that will be used when entering
a parallel section. It overrides the OMP_NUM_THREADS environment.
• int omp_get_thread_num(void);
Returns the current thread number between 0 and total number of
threads -1.
• int omp_get_num_procs(void);
Returns the number of available cores. HyperThreading Technology
cores will count as two cores.
• int omp_get_max_threads(void);
Returns the maximum value that can be returned by calls to
omp_get_num_threads.
*Some more OpenMp library functions,
omp_init_lock Initializes a simple
lock.
omp_destroy_lock Removes a simple lock.
omp_set_lock Waits until a simple
lock is available.
omp_unset_lock Releases a simple lock.
omp_test_lock Tests a simple lock.
Float x[8000];
Omp_set_num_threads[4];
#pragma omp parallel private(k)
{
int num_thds = omp_get_num_threads();
Int ElementsperThread = 8000/ num_thds;
Int Tid = omp_get_thread_num();
Int LowBound = Tid*ElementsPerThread;
Int UpperBound = LowBound+ElementsPerThread;
for( k = LowBound; k<UpperBound ; k++ )
DataProcess(x[k]);
}
Loop that uses OpenMP function
OpenMP Environment Variables
*OMP_SCHEDULE sets the run time schedule type and chunk
size
Ex: setenv OMP_SCHEDULE "guided,4"
setenv OMP_SCHEDULE "dynamic"
*OMP_NUM_THREADS sets the number of threads to use
during execution
Ex: setenv OMP_NUM_THREADS 16
*OMP_DYNAMIC enables or disables dynamic adjustment of
the number of threads
Ex: setenv OMP_DYNAMIC TRUE
Open mp library functions and environment variables

More Related Content

What's hot

17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
myrajendra
 
remote procedure calls
  remote procedure calls  remote procedure calls
remote procedure calls
Ashish Kumar
 

What's hot (20)

PAC Learning
PAC LearningPAC Learning
PAC Learning
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Time advance mehcanism
Time advance mehcanismTime advance mehcanism
Time advance mehcanism
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Multithreading
Multithreading Multithreading
Multithreading
 
Java threads
Java threadsJava threads
Java threads
 
Real time-system
Real time-systemReal time-system
Real time-system
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
 
Multithreading
MultithreadingMultithreading
Multithreading
 
remote procedure calls
  remote procedure calls  remote procedure calls
remote procedure calls
 
Neuro-fuzzy systems
Neuro-fuzzy systemsNeuro-fuzzy systems
Neuro-fuzzy systems
 
RPC: Remote procedure call
RPC: Remote procedure callRPC: Remote procedure call
RPC: Remote procedure call
 
Network simulation software
Network simulation softwareNetwork simulation software
Network simulation software
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 
Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 

Viewers also liked

Programming using Open Mp
Programming using Open MpProgramming using Open Mp
Programming using Open Mp
Anshul Sharma
 
Multi core-architecture
Multi core-architectureMulti core-architecture
Multi core-architecture
Piyush Mittal
 

Viewers also liked (20)

OpenMP Tutorial for Beginners
OpenMP Tutorial for BeginnersOpenMP Tutorial for Beginners
OpenMP Tutorial for Beginners
 
Intro to OpenMP
Intro to OpenMPIntro to OpenMP
Intro to OpenMP
 
Wireless languages and content generation technologies
Wireless languages and content generation technologiesWireless languages and content generation technologies
Wireless languages and content generation technologies
 
Span and Div tags in HTML
Span and Div tags in HTMLSpan and Div tags in HTML
Span and Div tags in HTML
 
Bfs dfs
Bfs dfsBfs dfs
Bfs dfs
 
web services
web servicesweb services
web services
 
openmp
openmpopenmp
openmp
 
NUMA optimized Parallel Breadth first Search on Multicore Single node System
NUMA optimized Parallel Breadth first Search on Multicore Single node SystemNUMA optimized Parallel Breadth first Search on Multicore Single node System
NUMA optimized Parallel Breadth first Search on Multicore Single node System
 
RFC and internet standards presentation
RFC and internet standards presentationRFC and internet standards presentation
RFC and internet standards presentation
 
IIS
IISIIS
IIS
 
Course 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment VariablesCourse 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment Variables
 
Intel® MPI Library e OpenMP* - Intel Software Conference 2013
Intel® MPI Library e OpenMP* - Intel Software Conference 2013Intel® MPI Library e OpenMP* - Intel Software Conference 2013
Intel® MPI Library e OpenMP* - Intel Software Conference 2013
 
Programming using Open Mp
Programming using Open MpProgramming using Open Mp
Programming using Open Mp
 
Data leakage detection
Data leakage detection Data leakage detection
Data leakage detection
 
JSP
JSPJSP
JSP
 
Multi core-architecture
Multi core-architectureMulti core-architecture
Multi core-architecture
 
CGI Presentation
CGI PresentationCGI Presentation
CGI Presentation
 
Multicore Processors
Multicore ProcessorsMulticore Processors
Multicore Processors
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
 
Web servers
Web serversWeb servers
Web servers
 

Similar to Open mp library functions and environment variables

Automatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole SuperoptimizersAutomatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole Superoptimizers
keanumit
 
SEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptx
SEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptxSEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptx
SEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptx
SaiDhanushM
 

Similar to Open mp library functions and environment variables (20)

Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
 
Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5Parallel and Distributed Computing Chapter 5
Parallel and Distributed Computing Chapter 5
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
 
OpenMP
OpenMPOpenMP
OpenMP
 
Open mp intro_01
Open mp intro_01Open mp intro_01
Open mp intro_01
 
Parllelizaion
ParllelizaionParllelizaion
Parllelizaion
 
Os lectures
Os lecturesOs lectures
Os lectures
 
Algoritmi e Calcolo Parallelo 2012/2013 - OpenMP
Algoritmi e Calcolo Parallelo 2012/2013 - OpenMPAlgoritmi e Calcolo Parallelo 2012/2013 - OpenMP
Algoritmi e Calcolo Parallelo 2012/2013 - OpenMP
 
memory
memorymemory
memory
 
06 neurolab python
06 neurolab python06 neurolab python
06 neurolab python
 
Automatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole SuperoptimizersAutomatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole Superoptimizers
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
SEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptx
SEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptxSEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptx
SEMAPHORE MANAGEMENT AND TYPES OF SEMAPHORE .pptx
 
Lecture6
Lecture6Lecture6
Lecture6
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
 
6-9-2017-slides-vFinal.pptx
6-9-2017-slides-vFinal.pptx6-9-2017-slides-vFinal.pptx
6-9-2017-slides-vFinal.pptx
 
Exploit techniques - a quick review
Exploit techniques - a quick reviewExploit techniques - a quick review
Exploit techniques - a quick review
 
An eternal question of timing
An eternal question of timingAn eternal question of timing
An eternal question of timing
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 

Recently uploaded

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Open mp library functions and environment variables

  • 1. Presented by , Suveeksha Jain MTech CSE
  • 2. OpenMP Library Functions *In addition to programs, OpenMP provides a set of functions And environment variables. *OpenMP requires conditional compilation in programs #include<omp.h> #ifdef_OPENMP Omp_set_num_threads (4); #endif
  • 3. The Most Heavily used OpenMP Library Functions • int omp_get_num_threads (void); Returns the number of threads currently in use. • int omp_set_num_threads (int NumThreads); This function sets the number of threads that will be used when entering a parallel section. It overrides the OMP_NUM_THREADS environment. • int omp_get_thread_num(void); Returns the current thread number between 0 and total number of threads -1. • int omp_get_num_procs(void); Returns the number of available cores. HyperThreading Technology cores will count as two cores. • int omp_get_max_threads(void); Returns the maximum value that can be returned by calls to omp_get_num_threads.
  • 4. *Some more OpenMp library functions, omp_init_lock Initializes a simple lock. omp_destroy_lock Removes a simple lock. omp_set_lock Waits until a simple lock is available. omp_unset_lock Releases a simple lock. omp_test_lock Tests a simple lock.
  • 5. Float x[8000]; Omp_set_num_threads[4]; #pragma omp parallel private(k) { int num_thds = omp_get_num_threads(); Int ElementsperThread = 8000/ num_thds; Int Tid = omp_get_thread_num(); Int LowBound = Tid*ElementsPerThread; Int UpperBound = LowBound+ElementsPerThread; for( k = LowBound; k<UpperBound ; k++ ) DataProcess(x[k]); } Loop that uses OpenMP function
  • 6. OpenMP Environment Variables *OMP_SCHEDULE sets the run time schedule type and chunk size Ex: setenv OMP_SCHEDULE "guided,4" setenv OMP_SCHEDULE "dynamic" *OMP_NUM_THREADS sets the number of threads to use during execution Ex: setenv OMP_NUM_THREADS 16 *OMP_DYNAMIC enables or disables dynamic adjustment of the number of threads Ex: setenv OMP_DYNAMIC TRUE