From 1a3a988aadd4a835b2c4f46dba5ce55688d8a417 Mon Sep 17 00:00:00 2001 From: 13513022 <13513022@hpc.if.itb.ac.id> Date: Fri, 19 Feb 2016 10:21:42 +0700 Subject: [PATCH] Add omp_hello --- omp_hello.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 omp_hello.c diff --git a/omp_hello.c b/omp_hello.c new file mode 100644 index 0000000..0c8ec58 --- /dev/null +++ b/omp_hello.c @@ -0,0 +1,23 @@ +#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); +} + -- GitLab