Nvc++; openmp; "distributed" is considered as invalid text in pragma and "parallel" results in error

I am trying to GPU offload my code using OpenMP and compiling with nvc++. However, when I compile with nvc++, I get this error:

error: invalid text in pragma
                #pragma omp target teams distributed parallel for collapse(2) map(centroidPnts)
                                         ^

error: extra text after expected end of preprocessing directive
                #pragma omp target teams distributed parallel for collapse(2) map(centroidPnts)
                                                     ^

These is how I compile the code:

nvc++ --compiler-options -std=c++17 -Xcompiler -openmp -mp=gpu -o <NAME> <NAME>.cpp

This is the part of the code where the problem occurs:

        #pragma omp target teams distributed parallel for collapse(2) map(centroidPnts)
		for (int i = 0; i < k; ++i)
		{
			for (int j = 0; j < args; ++j)
			{
				centroidPnts[i].args[j] = 0;
			}
		}

Any ideas what might be the problem?

The syntax is “distribute” not “distributed” i.e. no “d”.

Note that you might see better performance using the “loop” construct instead. For example:

#pragma omp target teams loop collapse(2) map(centroidPnts)

Hope this helps,
Mat

Thanks, that helped me!