diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..88d050b1908057b53d38b42702ebc659e3d7f696 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +main \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..523e4ecb0ce3cca569fb9468e3df334299cae4ad --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +CC = gcc +flags = -g -Wall -o +output = main +file = omp_hello.c +opemp_directive = -fopenmp + +make : + $(CC) $(flags) $(output) $(file) $(opemp_directive) diff --git a/omp_hello b/omp_hello new file mode 100755 index 0000000000000000000000000000000000000000..13362db8530af56ee558fc7524a2f9fbbe75d341 Binary files /dev/null and b/omp_hello differ diff --git a/omp_hello.c b/omp_hello.c new file mode 100644 index 0000000000000000000000000000000000000000..34d6b946b1151e1843f09d63ead555d393d772fd --- /dev/null +++ b/omp_hello.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <omp.h> + + +void Hello(void); /* Thread function */ + +int main(int argc, char *argv[]) { + int thread_count = strtol(argv[1], NULL, 10); + + #pragma omp parallel num_threads(thread_count) + Hello(); + + return 0; +} + +void Hello(void) { + int my_rank = omp_get_thread_num(); + int thread_count = omp_get_num_threads(); + + printf("Hello from thread %d of %d\n", my_rank, thread_count); +}