Skip to content

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

Closed

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

Activity

  1. changed the title [-]Failing to compile SYCL code on C++ mode only[/-] [+][SYCL] Failing to compile SYCL code on C++ mode only[/+] on Feb 13, 2019
  2. bader commented on Feb 13, 2019

    @bader
    Contributor

    Yep. "C++ mode only" hasn't been regularly tested.

  3. wangliwei-intel commented on Mar 25, 2019

    @wangliwei-intel

    @Ruyk
    Where did you get sycl.hpp? I can't find it from Khronos or this source tree.
    Thank you!

  4. bader commented on Mar 25, 2019

    @bader
    Contributor
  5. wangliwei-intel commented on Mar 25, 2019

    @wangliwei-intel

    @bader
    Thank you very much. I found I made a stupid mistake: git clone without -b, so it defaults to branch 'intel', not 'sycl', so I couldn't find the headers relating to SYCL.

  6. bader commented on Apr 24, 2019

    @bader
    Contributor

    @romanovvlad, please, verify if this issue is resolved by #101 and close.

  7. wangliwei-intel commented on May 22, 2019

    @wangliwei-intel

    I tried the latest build, it's fixed. @bader

  8. bader commented on Jun 20, 2019

    @bader
    Contributor

    I verified that problem is fixed.
    @Ruyk, let me know if it doesn't work for you.

  9. 4 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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