Using openacc for loop which contains CPU code

Hi all,

Currently, i’m trying Openacc to accelerator for my source code.
I’m using openacc for FOR LOOP, but FOR LOOP contains ‘cvCopy’ ‘cvSaveImage’ method which run on CPU.

for ( y = 0; y < nHeightScale; y += nHieghtStep )
{
    for ( x = 0; x < nWidthScale); x += nWidthStep )
    {
        // Image resizing
        cvSetImageROI(imgData, ......); // Run on CPU
        cvCopy(imgData, imgCSSizeData);         // Run on CPU 

        // Median filter
        AdaptiveMedianFilterOneImage(imgCSSizeData, imgCSSizeData, gtFltBlock); // Used OpenAcc for loop inside function

        // Create μ histogram
        make_image2muhist(imgCSSizeData, lpImgGenTh->cs, &muHist, 0);  // Used OpenAcc for loop inside function
        
        cvSaveImage(savefile, imgData); // Run on CPU
    }
}

How to apply openacc for two LOOPs?
Can i using OpenMP for them?

Hi DanhNam,

How to apply openacc for two LOOPs?

Currently, all routines called within an OpenACC compute construct that’s offloaded to a GPU must have a device routine. Hence, you will not be able to offload these loops to the GPU.

Though depending on how you have organized your data, you can put OpenACC data directives around these loops to better managed the device data.

Can i using OpenMP for them?

Possibly, assuming that the loops are parallelizable.

Note that OpenACC is compatible with OpenMP and OpenACC constructs can be used within OpenMP parallel regions. Data management can be a bit tricky when using multiple devices, but if the OpenMP threads share the same device, it’s straight-forward to implement.

-Mat