A partially present typically means that another variable of a different size has the part of the same host to device address mapping. Often occurs when a variable is included in a enter data directive but missing from a exit data directive.
There not enough information here to determine specifically why you’re getting this error, but given it’s a stack variable, the same stack address could have been used to map a variable in another function that was not deleted on the device.
Though, do you need rows and cols passed by reference? If you can, have these variables passed in by value (i.e. change “int &” to “int”). Passing them by reference causes the compiler to have to implicitly copy them to the device (since they are now pointers) while passing them by value make them scalars that can then be “firstprivate”.
I see that you posted the same question over on StackOverflow but included a link to your source. What’s possibly happening is in “WatershedAlg::thresholdMeasure” you have the following code:
auto *startImg=image.data;
int imgrows=image.rows;
int imgcols=image.cols;
#pragma acc enter data copyin(startImg,startImg[:imgrows*imgcols], threshmat,threshmat.matImg[:imgrows][:imgcols])
... cut ...
#pragma acc exit data delete (startImg[:imgrows*imgcols])
In the enter data directive you have “startimg”, “threshmat” and “threshmat.matImg”, but don’t include them in the corresponding exit data directive. Given these variables are on the stack, when you call “antiInverseImage” later and the compiler needs to implicitly copy “cols”, the same stack address is being reused and the sizes are different. Variables included in an enter data directive should also be in a corresponding exit data directive.
The correct directives would look like this:
#pragma acc enter data copyin(startImg[:imgrows*imgcols], threshmat,threshmat.matImg[:imgrows][:imgcols])
...
#pragma acc exit data delete(startImg,threshmat.matImg,threshmat)
Note that while you need the deep copy for threshmat since it’s a class, startimg is a simple array so can use a shallow copy.
Thanks for your suggestion.I 've updated the parallel region by adding threshmat in exit data part.
But I still have one question about the parallel part in thresholdMeasure.When I changed the code and ran the bin file,the warning said :Complex loop carried dependence of threshmat->,startImg-> prevents parallelization
I used __restrict to initialize the pointer *startImg;
The message is for the loop at line 20 and means that the compiler can’t implicitly auto-parallelize the loop due to the potential dependency.
If you’re wanting to parallelize this loop, you’ll need to either explicit add a “acc loop” directive to the inner loop or add “collapse(2)” or a “tile” clause to the outer parallel loop directive.
If you don’t want it parallelized, you can ignore the message.