Skip to content

Instantly share code, notes, and snippets.

@romeroyonatan
Last active March 15, 2020 14:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save romeroyonatan/6a380e189cee4b1290700cbc5259c837 to your computer and use it in GitHub Desktop.
Save romeroyonatan/6a380e189cee4b1290700cbc5259c837 to your computer and use it in GitHub Desktop.
Hello world in OpenMP. Minimal example
#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;
}
@romeroyonatan
Copy link
Author

Compile with

gcc -fopenmp hello-openmp.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment