0% found this document useful (0 votes)
46 views10 pages

Runtime Environment Routines

The document discusses OpenMP runtime routines, including routines for execution time (omp_get_wtime() and clock()), thread ID (omp_get_thread_num()), and maximum number of threads (omp_get_max_threads()). It also lists various OpenMP data environment routines and provides an example OpenMP program demo. The presentation was given by Dr M Rajasekhara Babu from Vellore Institute of Technology in India.

Uploaded by

Variable 14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views10 pages

Runtime Environment Routines

The document discusses OpenMP runtime routines, including routines for execution time (omp_get_wtime() and clock()), thread ID (omp_get_thread_num()), and maximum number of threads (omp_get_max_threads()). It also lists various OpenMP data environment routines and provides an example OpenMP program demo. The presentation was given by Dr M Rajasekhara Babu from Vellore Institute of Technology in India.

Uploaded by

Variable 14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

OpenMP RUNTIME ENVIRONMENT ROUTINES

Dr M Rajasekhara Babu
Vellore Institute of Technology (VIT)
Vellore-632014, Tamil Nadu, India
Outline
Session objectives

OepnMP runtime routines

Time, thread ID, max no. of threads

Sample Program Demo

Summary

Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 2


Objectives

To provide knowledge
on OpenMP runtime
routines

To explore functionality
of Time, thread ID and
max threads routines

Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 3


 About Runtime routines Routine for Execution Time
 Routine for execution time
• There are two types of routines to estimate
Execution Time (E.T) of a program
– OpenMP directive
– Windows clock
• OpenMP directive: omp_get_wtime();
• Example
double start, end;
start = omp_get_wtime();
Parallel Region……………..
end = omp_get_wtime();
printf("Program Execution Time= %f \n",end - start);
Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 4
 About Runtime routines Routine for Execution Time
 Routine for execution time
• Windows clock
– clock();
• Example
#include<time.h>
clock_t start_clock = clock();
Parallel Region……………..
clock_t end_clock = clock();
printf("\nProgram Execution Time Using
Windows Clock : %f ms\n", (end_clock-
start_clock));

Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 5


 About Runtime routines Routine for Thread ID
 Routine for execution time
 Routine for thread ID • Using OpenMP directives find the thread id
– Threads are numbered from 0 ton n-1
– It returns an integer
• OpenMP directive: omp_get_thread_num();
• Example
int id;
#pragma omp parallel
{
id=omp_get_thread_num();
printf("\n Hello printed by %d \n“,id); }
Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 6
 About Runtime routines Routine for Maximum Number of threads
 Routine for execution time, thread ID
 Maximum Number of threads Routine • Example
int a = omp_get_max_threads();
printf("Max no of threads running : %d\n",a);
#pragma omp parallel
{
int b = omp_get_max_threads();
printf("Max no of threads running(inside
parallel region) : %d \n",b);
}

Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 7


 About Runtime routines OpenMP Data Environment routines
 Routine for execution time, thread ID
 Maximum Number of threads Routine 1 omp_set_num_threads 14 omp_get_thread_limit
 OpenMP Data Environment routines 2 omp_get_num_threads 15 omp_set_max_active_levels
16 omp_get_max_active_levels
3 omp_get_max_threads
17 omp_get_level
4 omp_get_thread_num
5 omp_get_num_procs 18 omp_get_ancestor_thread_num
6 omp_in_parallel 19 omp_get_team_size
7 omp_set_dynamic 20 omp_get_active_level
21 omp_in_final
8 omp_get_dynamic
22 omp_get_proc_bind
9 omp_get_cancellation
23 omp_set_default_device
10 omp_set_nested
24 omp_get_default_device
11 omp_get_nested 25 omp_get_num_devices
12 omp_set_schedule 26 omp_get_num_teams
13 omp_get_schedule 27 omp_get_team_num
Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 8
 About Runtime routines
 Routine for execution time, thread ID
OpenMP program Demo
 Maximum Number of threads Routine
 OpenMP Data Environment routines

Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 9


Summary
• About Runtime routines
• Routine for execution time
– OpenMP
• omp_get_wtime();
– Windows
• clock_t start_clock = clock();
• Routine for thread ID
– omp_get_thread_num()
• Maximum Number of threads Routine
– omp_get_max_threads();
• List of OpenMP Data Environment routines
Dr M Rajasekhara Babu, Vellore Institute of Technology (VIT)-Vellore Slide.# 10

You might also like