Last active
March 15, 2020 14:49
-
-
Save romeroyonatan/6a380e189cee4b1290700cbc5259c837 to your computer and use it in GitHub Desktop.
Hello world in OpenMP. Minimal example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <omp.h> | |
#define PARENT_TID 0 | |
int main() { | |
int tid; | |
#pragma omp parallel | |
{ | |
tid = omp_get_thread_num(); | |
if(tid == PARENT_TID) | |
printf("Parent: %d threads running\n", omp_get_num_threads()); | |
else | |
printf("Thread# %d: Hello world\n", tid); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile with