Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.
2272 讨论

OpenMP offload hangs if omp_get_num_threads used in target "parallel"

CFR
新分销商 II
2,773 次查看

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 项奖励
1 解答
AbhishekD_Intel
主持人
2,697 次查看

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


在原帖中查看解决方案

0 项奖励
5 回复数
CFR
新分销商 II
2,731 次查看

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.

0 项奖励
AbhishekD_Intel
主持人
2,698 次查看

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


0 项奖励
CFR
新分销商 II
2,664 次查看

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.

0 项奖励
AbhishekD_Intel
主持人
2,643 次查看

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


0 项奖励
CFR
新分销商 II
2,513 次查看

Appears fixed as of Beta08

0 项奖励
回复