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

OpenMP offload hangs if omp_get_num_threads used inside parallel team?

CFR
New Contributor II
1,369 Views

Lenovo T570, Ubuntu 18.04.4, icpc (ICC) 2021.1 Beta 20200602

Given the following example code:

#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 follows:

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

Commenting out any of the pragma lines containing "parallel" and the code will hang when executed.  The non-"parallel" pragmas work correctly.  The problem seems to be omp_get_num_threads().  If you remove that from the print statement then all the pragma lines result in execution that works.

I'm new to this offloading part of OpenMP but seems to me it should work properly?

0 Kudos
1 Solution
PrasanthD_intel
Moderator
1,298 Views

Hi Craig,


This thread is a duplicate of https://community.intel.com/t5/Intel-oneAPI-HPC-Toolkit/OpenMP-offload-hangs-if-omp-get-num-threads-used-in-target-quot/m-p/1189420#M6891.

Since there is no problem with teams both the threads raised by you are dealing with the same issue.

We are closing this thread. Please follow the above thread for the solution.


Regards

Prasanth


View solution in original post

0 Kudos
2 Replies
PrasanthD_intel
Moderator
1,299 Views

Hi Craig,


This thread is a duplicate of https://community.intel.com/t5/Intel-oneAPI-HPC-Toolkit/OpenMP-offload-hangs-if-omp-get-num-threads-used-in-target-quot/m-p/1189420#M6891.

Since there is no problem with teams both the threads raised by you are dealing with the same issue.

We are closing this thread. Please follow the above thread for the solution.


Regards

Prasanth


0 Kudos
CFR
New Contributor II
1,282 Views

Sorry the duplicate happened when the new system was flagging everything as SPAM.  I was trying to get around the filter then someone "released" all the various attempts. 

0 Kudos
Reply