0% found this document useful (0 votes)
9 views

Assignment 1

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Assignment 1

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Walchand College of Engineering, Sangli

Department of Computer Science and Engineering

Course: High Performance Computing Lab

Practical No 1

PRN:21510021
Name:Vaibhavi Hakke
Batch:B2

Title: Introduction to OpenMP

Problem Statement 1 – Demonstrate Installation and Running of OpenMP code in C


Recommended Linux based System:
Following steps are for windows:
OpenMP – Open Multi-Processing is an API that supports multi-platform shared-memory
multiprocessing programming in C, C++ and Fortran on multiple OS. OpenMP uses a portable,
scalable model that gives programmers a simple and flexible interface for developing parallel
applications for platforms ranging from the standard desktop computer to the supercomputer.

To set up OpenMP,
We need to first install C, C++ compiler if not already done. This is possible through the MinGW
Installer.
Reference: Article on GCC and G++ installer (Link)
Note: Also install `mingw32-pthreads-w32` package.

Then, to run a program in OpenMP, we have to pass a flag `-fopenmp`.


Example:
To run a basic Hello World,
#include <stdio.h>
#include <omp.h>

int main(void)
{
#pragma omp parallel
printf("Hello, world.\n");
Class: Final Year (CSE) Year: 2024-25 Semester:
1
Walchand College of Engineering, Sangli
Department of Computer Science and Engineering

return 0;
}

gcc -fopenmp test.c -o hello


.\hello.exe

Problem Statement 2 – Print ‘Hello, World’ in Sequential and Parallel in OpenMP


We first ask the user for number of threads – OpenMP allows to set the threads at runtime. Then, we
print the Hello, World in sequential – number of times of threads count and then run the code in
parallel in each thread.

Code snapshot:

Class: Final Year (CSE) Year: 2024-25 Semester:


1
Walchand College of Engineering, Sangli
Department of Computer Science and Engineering

Output snapshot:

Class: Final Year (CSE) Year: 2024-25 Semester:


1
Walchand College of Engineering, Sangli
Department of Computer Science and Engineering

Analysis:

GitHub Link: make a public repository upload code of an assignment and paste its link here.

Problem statement 3: Calculate theoretical FLOPS of your system on which you are running the
above codes.

Elaborate the parameters and show calculation.

Parameters:
Base clock speed: 3.00 GHz

Class: Final Year (CSE) Year: 2024-25 Semester:


1
Walchand College of Engineering, Sangli
Department of Computer Science and Engineering

Number of cores: 2

Number of floating-point operations per cycle: 2

Calculation:
Step1: 3.00 GHz = 3.00 × 10^9 Hz
Step2:
FLOPS=(Number of Cores)×(Clock Speed in Hz)×(Floating-Point Operations per Cycle)
FLOPS=2×3×10^9×2
FLOPS=12×10^FLOPS= 12GFLOPS

Github: https://github.com/VaibhaviHakke/HPC-

Class: Final Year (CSE) Year: 2024-25 Semester:


1

You might also like