Skip to content

[SYCL] Failing to compile SYCL code on C++ mode only #27

Closed
@Ruyk

Description

@Ruyk

The following simplified application

#include <array>

#include <CL/sycl.hpp>

constexpr cl::sycl::access::mode sycl_read = cl::sycl::access::mode::read;
constexpr cl::sycl::access::mode sycl_write = cl::sycl::access::mode::write;
constexpr size_t N = 10u;

template<typename T>
class SimpleVadd;

int main() {
        using T = int;
       using array_type = std::array<T, N>;
        array_type VA, VB, VC;

  {
                cl::sycl::queue deviceQueue;
                cl::sycl::range<1> numOfItems{N};
                cl::sycl::buffer<T, 1> bufferA(VA.data(), numOfItems);
                cl::sycl::buffer<T, 1> bufferB(VB.data(), numOfItems);
                cl::sycl::buffer<T, 1> bufferC(VC.data(), numOfItems);

                deviceQueue.submit([&](cl::sycl::handler& cgh) {
                        auto accessorA = bufferA.template get_access<sycl_read>(cgh);
                        auto accessorB = bufferB.template get_access<sycl_read>(cgh);
                        auto accessorC = bufferC.template get_access<sycl_write>(cgh);

                        cgh.parallel_for<class SimpleVadd<T>>(numOfItems,
                        [=](cl::sycl::id<1> wiID) {
                                accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
                        });
                });
        }
        return VC[0] == (VA[0] + VB[0]);
}

fails to compile when not passing the -fsycl option to the driver with the following error:

$ intel_sycl --std=c++11 k.cpp  -lOpenCL  -lsycl
In file included from k.cpp:3:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl.hpp:11:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/accessor.hpp:14:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/buffer.hpp:10:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/detail/buffer_impl.hpp:15:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/detail/queue_impl.hpp:15:
/home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/handler.hpp:363:13: error: implicit instantiation of
      undefined template 'cl::sycl::detail::KernelInfo<SimpleVadd<int> >'
            KI::getName(), KI::getNumParams(), &KI::getParamDesc(0),
            ^
k.cpp:30:8: note: in instantiation of function template specialization
      'cl::sycl::handler::parallel_for<SimpleVadd<int>, (lambda at k.cpp:31:4), 1>' requested here
                        cgh.parallel_for<class SimpleVadd<T>>(numOfItems,
                            ^
/home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/detail/kernel_desc.hpp:38:40: note: template is
      declared here
template <class KernelNameType> struct KernelInfo;
                                       ^
In file included from k.cpp:3:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl.hpp:11:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/accessor.hpp:14:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/buffer.hpp:10:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/detail/buffer_impl.hpp:15:
In file included from /home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/detail/queue_impl.hpp:15:
/home/ruyman/Projects/sycl/build/lib/clang/9.0.0/include/CL/sycl/handler.hpp:363:15: error: incomplete definition of
      type 'cl::sycl::detail::KernelInfo<SimpleVadd<int> >'
            KI::getName(), KI::getNumParams(), &KI::getParamDesc(0),
            ~~^~
2 errors generated.

However, it works with when -fsycl is passed.

Looks like something in the handler header requires/expect the KernelInfo but is not there on non-SYCL mode

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions