Mapping pointers in C/C++

Discuss the OpenMP 4.0 API Specifications released July 2013 (Read Only)
Locked
omperminator
Posts: 1
Joined: Thu Sep 17, 2015 4:00 am

Mapping pointers in C/C++

Post by omperminator »

Lets' consider this piece of code:

Code: Select all

void foo(int* a){
    #pragma omp target map(a)
    {
        a++;
    }
}
I didn't find exact mention about passing pointer to map clause in the specification.
Does this mapping mean mapping the value of a pointer - address 'a', mapping value pointed by 'a' or something different?

C/C++ examples only pass pointers together with array section but there is no explicit requirement that pointers need to be mapped with array sections.

The same problem occurs when mapping arrays as pointers:

Code: Select all

void foo(int* a){
    #pragma omp target map(a)
    {
        //Can we write 'a[0] = 1' and expect assignment of 1 to the first element of tab?
        //Can we write a++ and expect 'a' to point to the second element after exiting target region?
    }
}

void bar(){
    int tab[100];
    foo(tab);
}

Locked