It is my understanding that to switch on openMP the make file has to be called with "make -fopenmp".
I am trying to run a threaded program using Code::Blocks and keep getting the compiler build message of:
| |=== Build file: "no target" in "no project" (compiler: unknown) ===|
/home/gary/testing/hello.c| |In function ‘main’:|
/home/gary/testing/hello.c|24|error: assignment to expression with array type|
| |=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
I'm not sure whether this is an IDE setup problem or a code problem. I am running:
Debian (9) Stretch
KDE Desktop
Athlon FX 4 core processor
The code I am trying to compile and build is:
/*Test program for lecture on openMP parallel computing*/
#include <stdio.h>
#include <omp.h>
static long num_steps = 100000; double step;
#define PAD 8 //assume 64 byte L1 cache line size
#define NUM_THREADS 4
void main()
{
double step;
int i,nthreads; double pi, sum[NUM_THREADS][PAD];
step = 1.0/(double)num_steps;
omp_set_num_threads(NUM_THREADS);
#pragma omp parallel
{ int i, id, nthrds;
double x;
id = omp_get_thread_num();
nthrds = omp_get_num_threads();
if(id == 0) nthreads = nthrds;
for(i=id,sum[id]=0.0; i<num_steps; i=i+nthrds)
{
x = (i+0.5)*step;
sum[id][0] += 4.0/(1.0+x*x);
}
for(i=0,pi=0.0;i<nthreads;i++)pi += step*sum[0];
printf("PI %.20f \n",pi);
}
}
If someone would sort out where my root problem resides it would be sincerely appreciated. I'm new to Code::Blocks and to threaded programming. I am really confused.
Gary R.