/*
	Print OpenMP status.
	WindyHana's Solanara: OpenMP http://www.solanara.net/solanara/openmp
	cc -O3 -xopenmp=parallel -o openmpstatus openmp_status.c
*/
#include <stdio.h>
#include <omp.h>

int main(int argc, char *argv[]) {
	int mt = 1, iam = 0, np = 1, omp = 0;

	#pragma omp parallel default(shared) private(mt, iam, np, omp)
	{
		#if defined (_OPENMP)
			mt = omp_get_max_threads();
			np = omp_get_num_threads();
			iam = omp_get_thread_num();
			omp = 1;
		#endif
		if (omp) {
			printf("MaxThreads: %d, UsedThreads: %d, ThreadNum: %d\n", mt, np, iam);
		} else {
			printf("No OpenMP used.\n");
		}
	}
	return 0;
}

