Skip to content

Instantly share code, notes, and snippets.

@wkrea
Forked from romeroyonatan/hello-openmp.c
Created March 15, 2020 14:49
Show Gist options
  • Save wkrea/56f269011061d47f89b9a5be2470f4f5 to your computer and use it in GitHub Desktop.
Save wkrea/56f269011061d47f89b9a5be2470f4f5 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment