Intial commit of source code samples for GitHub repo.
This commit is contained in:
parent
5793080047
commit
9462407ba8
14 changed files with 397 additions and 1 deletions
43
openmp-c/hello-omp.c
Normal file
43
openmp-c/hello-omp.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <omp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _OPENMP
|
||||
|
||||
static char versionbuf[16];
|
||||
static char gitversion[] = VERSIONINFO;
|
||||
|
||||
int main()
|
||||
{
|
||||
int tcount = 0;
|
||||
char *versionp;
|
||||
|
||||
/* Tell about the version of OpenMP API we're using.
|
||||
* Specification source: www.openmp.org.
|
||||
*/
|
||||
switch (_OPENMP) {
|
||||
case 200805:
|
||||
versionp = "3.0 (May 2008)"; break;
|
||||
case 201107:
|
||||
versionp = "3.1 (Jul 2011)"; break;
|
||||
case 201307:
|
||||
versionp = "4.0 (Jul 2013)"; break;
|
||||
default:
|
||||
sprintf(versionbuf, "(%6.6d)", _OPENMP);
|
||||
versionp = versionbuf;
|
||||
break;
|
||||
}
|
||||
printf("Using OpenMP version: %s\n", versionp);
|
||||
printf("Program git commit info: %s\n", gitversion);
|
||||
printf("Max threads = %d\n", omp_get_max_threads());
|
||||
|
||||
#pragma omp parallel
|
||||
#pragma omp atomic
|
||||
tcount++;
|
||||
|
||||
#pragma omp parallel
|
||||
/* Hello parallel world... */
|
||||
printf("Hello OpenMP World from thread %3.3d of %3.3d! (tcount=%d)\n",
|
||||
omp_get_thread_num() + 1, omp_get_num_threads(), tcount);
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue