1

Reading some tutorials from OpenMP 4, I found that target regions can participate in the same dependency graph of CPU tasks, using the depend clause.

When programming OpenMP tasks, we know they can be run concurrently. But is this possible on GPUs? Can a GPU run multiple target regions simultaneously?

I tried with this code:

#include <omp.h>
#include <stdio.h>

int main() {
  int i;

#pragma omp parallel
#pragma omp single
  {

#pragma omp task private(i)
#pragma omp target
    {
      for (i = 0; i < 100; i++)
        printf("1 %d\n", i);
    }

#pragma omp task private(i)
#pragma omp target
    {
      for (i = 0; i < 100; i++)
        printf("2 %d\n", i);
    }

#pragma omp task private(i)
#pragma omp target
    {
      for (i = 0; i < 100; i++)
        printf("3 %d\n", i);
    }
  }

#pragma omp taskwait
}

Although the tasks are executed in arbitrary order, the target regions are executed atomically, one region at a time.

648trindade
  • 689
  • 2
  • 5
  • 21
  • Is your goal to run on two different targets? E.g. with a system with two GPUs? – Z boson Mar 09 '18 at 13:27
  • Nope. I want to run multiple target regions simultaneously on same GPU – 648trindade Mar 15 '18 at 14:06
  • I tried your code with GCC and `nvptx-none-gcc` but it won't compile. If I add `-foffload=disable` it compiles and runs on the CPU. – Z boson Mar 15 '18 at 14:25
  • 1
    I have been able to use the GPU with `-fno-stack-protector` for a few weeks now but in this case it does not compile (segmentation fault compiling). – Z boson Mar 15 '18 at 14:26
  • are you trying with gcc-8? I'm experiencing same issues – 648trindade Mar 15 '18 at 14:34
  • it works however in a clang implementation – 648trindade Mar 15 '18 at 14:34
  • I am using GCC 7.2 with Ubuntu 17.10. – Z boson Mar 15 '18 at 14:34
  • How did you get the Clang offloading working? I would like to try that – Z boson Mar 15 '18 at 14:35
  • I installed PGI yesterday but it does not work with Ubuntu 17.10 (due to GCC). The next version of PGI will probably work but that may take a few months (I got the community edition). – Z boson Mar 15 '18 at 14:36
  • i followed an ibm tutorial (https://www.ibm.com/developerworks/community/blogs/8e0d7b52-b996-424b-bb33-345205594e0d/entry/installation?lang=pt_br), but it doesnt works anymore since i upgraded cuda to version 9. I'm trying to recompile at this exact moment – 648trindade Mar 15 '18 at 14:39

0 Answers0