Undefined reference to __hxdGetDeviceFunc

Hi,

The code below attempts to access heap-allocated memory via a std::shared_ptr, within the body of the value-capturing lambda function given to std::transform.

#include <memory>
#include <execution>
#include <algorithm>

int main(int argc, char *argv[])
{
  using namespace std;
  const unsigned sz{1024};
  shared_ptr<int> nine{new int{9}};
  vector<unsigned> v(sz);

  const auto pol = execution::par_unseq;  
  transform(pol, v.begin(), v.end(), v.begin(), [=](auto) { return *nine; });

  return 0;
}

Compiling with nvc++ fails with the following message:

nvlink error   : Undefined reference to '__hxdGetDeviceFunc' in '/tmp/nvc++pDvdTPsfRv7O.o'
pgacclnk: child process exit status 2: /opt/nvidia/hpc_sdk_multi/Linux_x86_64/20.11/compilers/bin/tools/nvdd

The compile command is nvc++ -stdpar -std=c++17 prog.cpp. I’m using the HPC SDK 20.11 and CUDA 11.0 under 64-bit Ubuntu 20.10. I think it’s a bug, but as we plan to use std::shared_ptr in this way, I wanted to double-check.

Cheers,
Paul

Thanks Paul. I’ve added an issue report, TPR #29384, and will have our engineers investigate.

-Mat

1 Like