I am looking for the correct way to use OMP_PLACES
and OMP_PROC_BIND=close
in my code. when I run this, I get the eror that :
error: ‘OMP_PLACES’ was not declared in this scope
#include <iostream>
#include <random>
#include <fstream>
#include <iomanip>
#include <cfloat>
#include <omp.h>
#include <stdlib.h>
using namespace std;
int main()
{
const int N = 100;
unsigned seed = 0;
double sum = 0.0;
double avg;
srand(seed);
default_random_engine g(seed);
uniform_real_distribution<double> distribution(0.0f, nextafter(1.0f, DBL_MAX));
#pragma omp parallel
{
OMP_PLACES="cores(4)";
OMP_PROC_BIND=close;
#pragma omp for reduction (+: sum)
for (int i = 0; i < N; i++) {
double x = distribution(g);
sum = sum + x;
}
avg = sum / static_cast<double> (N);
}
}