Skip to content
Snippets Groups Projects
Commit b93d5115 authored by Behrens, Prof. Dr. Jörn's avatar Behrens, Prof. Dr. Jörn
Browse files

initial commit of HelloMP

parent aff2781d
No related branches found
No related tags found
No related merge requests found
# compilation residuals
*.o
# main file
Hello
Hello.c 0 → 100644
/*****************************************************************
NAME:
Hello
Description:
this is about the simplest program thinkable to demonstrate
parallel execution with OpenMP
VERSION(S):
1. original version j. behrens 6/2021
*****************************************************************/
#include <stdio.h>
#include <omp.h>
int main(int argc, char** argv)
{
/* local declarations */
int thrd_id;
/* this is the main print statement parallelized! */
#pragma omp parallel private(thrd_id)
{
thrd_id = omp_get_thread_num();
printf("Hello from process Number %d\n", thrd_id);
}
return 0;
} /* end of main */
Makefile 0 → 100644
# sample makefile for the C PPTemplate
# j. behrens 06/2021
CC = gcc
#
# THIS OPTION IS FOR THE DATA PARALLEL VERSION (-mp)
CCFLAGS = -fopenmp -I/opt/local/include
DATLIBS= -lgomp -lm
OBJECTS = \
Hello.o
# default make
all::
@make Hello
@make clear
# make object files
.c.o:
${CC} ${CCFLAGS} -c $<
# make target (executable)
Hello: ${OBJECTS}
${CC} ${CCFLAGS} -o $@ ${OBJECTS} ${LIBS}
clear::
@rm *.o
# HelloMP
\ No newline at end of file
# HelloMP
Yet another Hello World Program
## Description and Purpose
This O(1)-line code demonstrates parallelization with OpenMP
## Contents of this Project
```
README - this file
Makefile - Makefile tested for macOS
Hello.c - parallelized "Hello World" C-program
```
## What do do here
**First**, build the executable by typing
```
%> make
```
If this fails, you have to adjust your path and settings, however,
I don't know how...
**Second**, set up the number of threads (e.g. to four)
```
%> export OMP_NUM_THREADS=4
```
**Third**, run the program
```
%> Hello
```
(c) 2021, Jörn Behrens (joern.behrens@uni-hamburg.de)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment