OpenACC and OMP?

Hello everyone!

I have a dozen of subroutines which together make MLP neural network written in f90. At the moment all of them use omp in order to parallelize the code. I would like to switch feedforward and backprop routines to GPU but leave the rest to CPUs. Is there a way to compile code in which I can use both OpenACC and OMP? If not, is there a possibility to switch everything to OpenACC? But then how to tell compiler which loops to parallelize on CPU and which on GPU?

Thanks in advance,

confused physics student

Hi zugec.ivan,

Is there a way to compile code in which I can use both OpenACC and OMP?

Sure, it’s fine to mix OpenMP and OpenACC together in the same code. Just start incrementally porting the loops you want to offload to OpenACC and add the “-acc” flag. If you want to stick to pure OpenMP, you can use OpenMP “target teams loop” directives to offload to GPUs instead of OpenACC. But either works fine.

If not, is there a possibility to switch everything to OpenACC? But then how to tell compiler which loops to parallelize on CPU and which on GPU?

OpenACC has a new clause, “self”, that you can put on a “loop” directive to indicate that the loop should be parallelized on the host rather than the GPU. Essentially the same as if you were to use an OpenMP parallel do. However, we don’t have this implemented as of yet, so you’d still need to mix in OpenMP for now.

-Mat