Can't build samples w/ ptx64 backend

I’m trying to build the samples from the sdk (git checkout with tag v1.1.4) with ComputeCpp-CE-1.1.4 when enabling the ptx64 backend for NVidia hardware. None of the sample code will successfully compile:

> cmake ../ -DComputeCpp_DIR=~/work/sycl/ComputeCpp-CE-1.1.4-CentOS-x86_64 -DCOMPUTECPP_BITCODE=ptx64
> make

parallel-for.cpp:(.text._ZN2cl4sycl7program25create_program_for_kernelI15assign_elementsEES1_NS0_7contextE[_ZN2cl4sycl7program25create_program_for_kernelI15assign_elementsEES1_NS0_7contextE]+0x29d): undefined reference to `cl::sycl::program::create_program_for_kernel_impl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char const*, int, char const* const*, std::shared_ptr<cl::sycl::detail::context>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
CMakeFiles/parallel-for.dir/parallel-for.cpp.o: In function `cl::sycl::kernel cl::sycl::program::get_kernel<assign_elements>() const':
parallel-for.cpp:(.text._ZNK2cl4sycl7program10get_kernelI15assign_elementsEENS0_6kernelEv[_ZNK2cl4sycl7program10get_kernelI15assign_elementsEENS0_6kernelEv]+0x59): undefined reference to `cl::sycl::program::get_kernel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'

This is on a centos7 system with an NVidia GTX 1080Ti. I have the OpenCL libraries installed (both via the cuda sdk and from the ocl-icd-devel )

clinfo finds the hardware and reports it.

computecpp_info finds the hardware, but says (as expected) that it doesn’t support SPIR

Am I doing something wrong?

thanks, Charles.

Hi Charles,
Your commands look correct, I’ll investigate why this might be happening.
Rod

Hi Charles,
It looks like an ABI mismatch. Can you try passing -D_GLIBCXX_USE_CXX11_ABI=0 with the cmake command in the meantime then we will investigate a resolution?
Thanks,
Rod.

Hi Rod -

I continue to get the same problem with the cmake -D_GLIBCXX_USE_CXX11_ABI=0 option :

CMakeFiles/simple-vector-add.dir/simple-vector-add.cpp.o: In function `cl::sycl::program cl::sycl::program::create_program_for_kernel<SimpleVadd<int> >(cl::sycl::context)':
simple-vector-add.cpp:(.text._ZN2cl4sycl7program25create_program_for_kernelI10SimpleVaddIiEEES1_NS0_7contextE[_ZN2cl4sycl7program25create_program_for_kernelI10SimpleVaddIiEEES1_NS0_7contextE]+0x29d): undefined reference to `cl::sycl::program::create_program_for_kernel_impl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char const*, int, char const* const*, std::shared_ptr<cl::sycl::detail::context>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'

I also see a lot of warnings like

warning: [Computecpp:CC0035]: Intrinsic llvm.fmuladd.f32 has been generated in function SYCL_class_pow_comp which is illegal in SPIR and may result in a compilation failure [-Wsycl-undef-func]

I don’t know if that’s because it’s trying to produce ptx code, or something else.

BTW, I’m using gcc8.2 and CMAKE 3.11.1

thanks, Charles.

Hello Charles,

I’m sorry, we should have been more clear.

From the linker error I can tell that it still expects a function with a C++11 ABI std::__cxx11::basic_string.

_GLIBCXX_USE_CXX11_ABI is a preprocessor definition that needs to be passed to the compiler, not CMake. To do so, you can either add target_compile_definitions(simple-vector-add PRIVATE _GLIBCXX_USE_CXX11_ABI=0) to the CMakeLists to enable it for this that target specifically or do add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) in the top-level CMakeLists before you add any target to change it on a default level.

A third option would be to put add_compile_definitions in a CMake toolchain file, which is the way to go if you’d need to recompile an existing codebase and/or don’t want to modify any build scripts.

The reason you have to do this is because our CentOS 7 package is compiled with the old C++03 ABI since that’s what the default gcc 4.8.5 on CentOS 7 supports, but your gcc 8 defaults to the new C++11 ABI.

If you really need to use the C++11 ABI, you could try to use the Ubuntu package instead. CentOS 7’s glibc probably is too old for that to link, so you’d need to upgrade to CentOS 8. Of course, using the Ubuntu package on another distribution is untested and unsupported, but it would be worth a try.

Let me know if that helps
Morris

Thanks for the explanation Morris - that did the trick.

Though I needed to upgrade my cmake from 3.11 to 3.14 for add_compile_definitions to work.

cheers, Charles.

To support older versions of CMake you can write add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) instead. It’s behaviour is a bit curious sometimes, that’s why it was replaced with add_compile_definitions in later versions.