Community
cancel
Showing results for 
Search instead for 
Did you mean: 
CFR
Beginner
641 Views

OpenMP offload hangs if omp_get_num_threads used in target "parallel"

Jump to solution

Lenovo T570, Ubuntu 18.04.4, l_BaseKit_b_2021.1.7.1506_offline l_HPCKit_b_2021.1.7.1465_offline

Given the following source:

#include <omp.h>
#include <cstdio>

int
main(int argc, char *argv[])
{

  printf("Devices= %d\n", omp_get_num_devices());
  printf("Initial device %d (is initial %c)\n", omp_get_initial_device(), omp_is_initial_device()?'Y':'N');
  printf("Default device %d\n", omp_get_default_device());

//#pragma omp target parallel
//#pragma omp target parallel for
//#pragma omp target teams
//#pragma omp target teams distribute
//#pragma omp target teams distribute parallel for

  for (int i=0; i<8; i++) 
  {
    printf( "%d Team %d of %d, Thread %d of %d\n", i,
        omp_get_team_num(), omp_get_num_teams(),
        omp_get_thread_num(), omp_get_num_threads());
  }
}

Compiled as:

icpc -std=c++17 -O3 -o bug1 bug1.cpp -qnextgen -fiopenmp -fopenmp-targets=spir64

If you individually comment out the various pragma lines you'll find that the ones containing "parallel" all result in the executable hanging.  Non-"parallel" work find.  The culprit seems to be the omp_get_num_threads() call.  If that is removed from the print statement all the pragmas then work properly.

I'm new to the offloading part of OpenMP but it's not obvious to me why this should be a problem.

0 Kudos
1 Solution
AbhishekD_Intel
Moderator
565 Views

Hi,

We tried the same code that you have provided and we are also getting the same error, try saving the values into say array instead of printing and print it after target section and check if you are getting the same error.


We will also try to debug it more and will reach to you. Thanks for reporting the issue.


Warm Regards,

Abhishek


View solution in original post

5 Replies
CFR
Beginner
599 Views

I've since noticed that if you change "omp_get_num_threads()" to "1*omp_get_num_threads()" then the code will not hang.  So, maybe that will help diagnose the issue.

AbhishekD_Intel
Moderator
566 Views

Hi,

We tried the same code that you have provided and we are also getting the same error, try saving the values into say array instead of printing and print it after target section and check if you are getting the same error.


We will also try to debug it more and will reach to you. Thanks for reporting the issue.


Warm Regards,

Abhishek


View solution in original post

CFR
Beginner
532 Views

I think I've got enough work-arounds to keep me working, but it seems like a bug so I just want to make sure someone looks into it and (if necessary) fixes it in a future release.

AbhishekD_Intel
Moderator
511 Views

Hi,

Thanks for your reply. I have tried this scenario and I came to know that this is might be the bug with the device printf.

Thanks for reporting this issue, We are escalating this thread to the concerned team for reporting it as a bug.



Warm Regards,

Abhishek


CFR
Beginner
381 Views

Appears fixed as of Beta08

Reply