This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OpenMP 4.0 target map

Hi,

I recently wrote a very simple OpenMP 4.0 program using OpenMP Target directive, What I found a very strange issue is when I use the OpenMP target directive to switch the control from host to device, it must follow a map clause, even though It is not necessarily to do that:

#pragma omp declare target
2 #include <stdio.h>
3 #include <omp.h>
4 #pragma omp declare target end
5
6 void hello_world_from_target(void) {
7 int num_procs_to_set = 8;
8 //#pragma omp target map(to:num_procs_to_set)
9 #pragma omp target
10 #pragma omp parallel
11 {
12 #pragma omp master
13 printf("Number of OpenMP threads: %d\n",
14 omp_get_num_threads()
15 );
16
17 printf("Hello from thread: %d\n",
18 omp_get_thread_num()
19 );
20 }
21 }

In this code snippet, without the map clause, I got compilation error:

arm-linux-gnueabihf-gcc -O3 -I/opt/ti_hawking/openmpacc-66ak2h-0.2.1/include -c hello_world_main.c
clacc --target_cc_opts="-O3 -I/opt/ti_hawking/openmp_dsp_2_01_12_00/packages/ti/runtime/openmp" hello_world_main.o hello_world_target.c -o hello_world
"hello_world_target.c", line 7: warning: variable "num_procs_to_set" was declared but never referenced

INTERNAL ERROR: acpia6x experienced a segmentation fault
while processing function hello_world_from_target file hello_world_target.c line 21

This is caused by a defect in the compiler itself. TI Customer
Support may be able to suggest a workaround to avoid this.

Upgrading to the newest version of the compiler may fix this problem.

Contact TI in the E2E support forums at http://e2e.ti.com under
"Development Tools", "TI C/C++ Compiler". See the link titled
"Submitting an issue". Include this ENTIRE error message and a
copy of the .pp file created when option --preproc_with_comment
(-ppc) is used.


>> Compilation failure
"hello_world_target.c", line 7: warning: variable "num_procs_to_set" was declared but never referenced

INTERNAL ERROR: cbeia6x experienced a segmentation fault
while processing function hello_world_from_target file hello_world_target.c line 21

This is caused by a defect in the compiler itself. TI Customer
Support may be able to suggest a workaround to avoid this.

Upgrading to the newest version of the compiler may fix this problem.

Contact TI in the E2E support forums at http://e2e.ti.com under
"Development Tools", "TI C/C++ Compiler". See the link titled
"Submitting an issue". Include this ENTIRE error message and a
copy of the .pp file created when option --preproc_with_comment
(-ppc) is used.


>> Compilation failure

But after I add the map, the compilation works fine, although there is another issue that only one thread is running in the parallel region, as I have posted in my previous question. 

I just checked with the OpenMP 4.0 spec, it did not say we must use the map clause with target, right? Is it a potential compiler issue?

Thanks

Cheng