Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎04-28-2020

OpenCL Singleton Ctor error on U250 sw_emu

I am getting a runtime_error exception running in sw_emu. I'm building C++ host code using Vitis 2020.1 xocc compiler on RedHat 7.9. The same configuration works on an Ubuntu 18.04 machine with the same version of Vitis. Here is my stack trace starting at the call to get_xil_devices(). It seems to be associated with /opt/xilinx/xrt/lib/libxrt_core. XCL_EMULATION_MODE=sw_emu. 

The error I'm getting is:


terminate called after throwing an instance of 'std::runtime_error'
  what():  singleton ctor error


My test program is:


#include <CL/cl2.hpp>
#include <iostream>
int main()
   int err;
   std::vector<cl::Platform> platforms;
   cl::Platform::get(&platforms);   // <-- Errors out here
   for (auto &p : platforms) {
      std::cout<<"   "<<p.getInfo<CL_PLATFORM_NAME>(&err)<<std::endl;
   return 0;


Note that the program only depends on OpenCL, not any Xilinx library. It works fine when I don't include But as soon as that lib is added (because my real app needs it), I get the singleton error. In gdb, the backtrace shows:

#0 0x00007ffff3aba387 in raise () from /lib64/
#1 0x00007ffff3abba78 in abort () from /lib64/
#2 0x00007ffff43fa33d in __gnu_cxx::__verbose_terminate_handler () at ../../../../../src/lnx64/libstdc++-v3/libsupc++/
#3 0x00007ffff43f8316 in __cxxabiv1::__terminate (handler=<optimized out>)
at ../../../../../src/lnx64/libstdc++-v3/libsupc++/
#4 0x00007ffff43f7349 in __cxa_call_terminate (ue_header=ue_header@entry=0x706ed0)
at ../../../../../src/lnx64/libstdc++-v3/libsupc++/
#5 0x00007ffff43f7c9d in __cxxabiv1::__gxx_personality_v0 (version=<optimized out>, actions=<optimized out>, 
exception_class=5138137972254386944, ue_header=<optimized out>, context=0x7fffffffbcb0)
at ../../../../../src/lnx64/libstdc++-v3/libsupc++/
#6 0x00007ffff3e61f43 in _Unwind_RaiseException_Phase2 (exc=exc@entry=0x706ed0, context=context@entry=0x7fffffffbcb0)
at ../../../../src/lnx64/libgcc/
#7 0x00007ffff3e62447 in _Unwind_Resume (exc=0x706ed0) at ../../../../src/lnx64/libgcc/
#8 0x00007ffff14abd70 in (anonymous namespace)::singleton_instance() [clone .cold] () from /opt/xilinx/xrt/lib/
#9 0x00007ffff7dea9c3 in _dl_init_internal () from /lib64/
#10 0x00007ffff7def59e in dl_open_worker () from /lib64/
#11 0x00007ffff7dea7d4 in _dl_catch_error () from /lib64/
#12 0x00007ffff7deeb8b in _dl_open () from /lib64/
#13 0x00007ffff334cfab in dlopen_doit () from /lib64/
#14 0x00007ffff7dea7d4 in _dl_catch_error () from /lib64/
#15 0x00007ffff334d5ad in _dlerror_run () from /lib64/
#16 0x00007ffff334d041 in dlopen@@GLIBC_2.2.5 () from /lib64/
#17 0x00007ffff3a52e12 in (anonymous namespace)::createHalDevices(std::vector<std::unique_ptr<xrt::hal::device, std::default_delete<xrt::hal::device> >, std::allocator<std::unique_ptr<xrt::hal::device, std::default_delete<xrt::hal::device> > > >&, std::string const&, unsigned int) [clone .constprop.0] () from /opt/xilinx/xrt/lib/
#18 0x00007ffff3a5368d in xrt::hal::loadDevices() () from /opt/xilinx/xrt/lib/
#19 0x00007ffff7fa5482 in std::vector<xrt::device, std::allocator<std::vector> > xrt::loadDevices<xrt::loadDevices()::{lambda(std::string const&)#1}>(xrt::loadDevices()::{lambda(std::string const&)#1}) () from /opt/xilinx/xrt/lib/
#20 0x00007ffff7fa438e in xocl::platform::platform() () from /opt/xilinx/xrt/lib/
#21 0x00007ffff7fa49b9 in xocl::platform::get_shared_platform() () from /opt/xilinx/xrt/lib/
#22 0x00007ffff7fa4a58 in xocl::get_global_platform() () from /opt/xilinx/xrt/lib/
#23 0x00007ffff7f5606e in xocl::clGetPlatformIDs(unsigned int, _cl_platform_id**, unsigned int*) ()
from /opt/xilinx/xrt/lib/
#24 0x00007ffff7f5614a in clGetPlatformIDs () from /opt/xilinx/xrt/lib/
#25 0x0000000000448f7b in cl::Platform::get (platforms=0x7fffffffc770) at /usr/include/CL/cl2.hpp:2475
#26 0x0000000000447f8d in xcl::get_devices (vendor_name=...) at /home/okramer/dev/ortho/host/xcl2.cpp:41
#27 0x0000000000448585 in xcl::get_xil_devices () at /home/okramer/dev/ortho/host/xcl2.cpp:64


Tags (4)
0 Kudos
1 Reply
Registered: ‎11-04-2010

Please test in the supported operating system:

Don't forget to reply, kudo, and accept as solution.
0 Kudos