0% found this document useful (0 votes)
4 views4 pages

Govind 5

The document outlines a practical exercise for a High Performance Computing course, focusing on using Gprof to analyze program performance. It explains Gprof's utility in optimizing performance, load balancing, debugging, and resource management, and includes example C programs for demonstration. The conclusion emphasizes the importance of identifying bottlenecks and improving efficiency in large-scale applications.

Uploaded by

reddygovind4550
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)
4 views4 pages

Govind 5

The document outlines a practical exercise for a High Performance Computing course, focusing on using Gprof to analyze program performance. It explains Gprof's utility in optimizing performance, load balancing, debugging, and resource management, and includes example C programs for demonstration. The conclusion emphasizes the importance of identifying bottlenecks and improving efficiency in large-scale applications.

Uploaded by

reddygovind4550
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/ 4

Faculty of Engineering & Technology

Subject Name: High Perfomance Computing


Subject Code: 303105356
B.Tech-CSE (AI) 3rd Year 6th Semester

Practical-05
Aim: Write a program to check task distribution using Gprof.

What is Gprof?
Gprof is a GNU profiler used to analyze program performance. It provides detailed insights into
the time spent in each function, the number of times each function is called, and the relationships
between functions. Profiling helps identify performance bottlenecks, optimize code, and ensure
efficient task distribution.

Applications of gprof in Daily Life


1. Performance Optimization:
Identify and optimize slow parts of applications, such as
data processing or computational functions.
2. Load Balancing:
Ensure that different tasks in a program are evenly
distributed to prevent overloading one part of the system.
3. Debugging:
Analyze unexpected performance degradation in real-
world scenarios.
4. Resource Management:
Improve resource utilization in time-critical systems like
real-time applications, game engines, and embedded
systems.
5. Software Development:
Help developers write efficient code by pinpointing
inefficiencies.

1)Gprof steps on small C program.


Source code:
%%writefile govind_5.c
#include "stdio.h"
void add();
int main()
{
Name: KISTIPATI GOVINDREDDY
Enrollment No: 2203031240607 1
Division: 6AI8
Faculty of Engineering & Technology
Subject Name: High Perfomance Computing
Subject Code: 303105356
B.Tech-CSE (AI) 3rd Year 6th Semester

add();
return 0;
}
void add()
{
int a,b,c,d;
printf("\nEnter The Two values:");
scanf("%d%d",&a,&b);
c=a+b;
d=a-b;
printf("Addition:%d\n",c);
printf("Substraction:%d",d);
}
Output:

2) 1)Gprof steps on large C program.

Source code:
%%writefile govind_5.2.c
#include <stdio.h>
#include <time.h>

void perform_computation() {

Name: KISTIPATI GOVINDREDDY


Enrollment No: 2203031240607 2
Division: 6AI8
Faculty of Engineering & Technology
Subject Name: High Perfomance Computing
Subject Code: 303105356
B.Tech-CSE (AI) 3rd Year 6th Semester
// Simulate some computations

volatile long long sum = 0;


for (long long i = 0; i < 1e9; i++) {
sum += i % 10; // Prevent compiler optimizations
}
}

int main() {
clock_t start, end;
double elapsed_time;

start = clock();
printf("Starting computation...\n");

// Run a function that takes some time to complete


perform_computation();

// Ensure the program runs for at least 10 seconds


do {
perform_computation();
end = clock();
elapsed_time = (double)(end - start)
} while (elapsed_time < 10.0);

printf("Computation completed. Elapsed time: %.2f


seconds\n", elapsed_time);

return 0;
}
Output:

Name: KISTIPATI GOVINDREDDY


Enrollment No: 2203031240607 3
Division: 6AI8
Faculty of Engineering & Technology
Subject Name: High Perfomance Computing
Subject Code: 303105356
B.Tech-CSE (AI) 3rd Year 6th Semester

Conclusion: Task Distribution: The profiling report shows how much time each function (task)
takes.
Bottleneck Identification :If one task is disproportionately time-consuming, consider optimizing it
or parallelizing tasks.
Improved Efficiency: By focusing optimization efforts on high-time-consuming tasks, you can
reduce overall runtime and improve resource utilization.
Practical Usage: This process is invaluable in large-scale applications like database systems,
simulations, or any software requiring performance optimization.

Name: KISTIPATI GOVINDREDDY


Enrollment No: 2203031240607 4
Division: 6AI8

You might also like