I’ve created new sycl project in Visual Studio 2019. It contains method with simple matrix multiplication, which works perfectly. The solution cotains one more project. Is it possible to call that same method for matrix multiplication in the sycl project and pass data to it from non-sycl project (default c++ console project)?
I’ve also tried to make .lib from sycl project and include it to non-sycl project, but when I call method I get error 102 (The requested kernel name could not be found). I suppose that sycl file is not created.
Thanks for all answers.
EDIT:
I’ve tried to pre-compile kernel, but now when I call my method I get new error, because vector of devices is empty.
Hi @adamgolman94, yes it is possible. A library made with sycl code is not different from a library made without sycl code.
You are seeing the message that the kernel name could not be found because you may have forgot to include the kernel binary in the library itself.
To help you I would need a little bit more information and, if possible, your project, if you are able to share it so I can try it myself to see exactly what is going on.
I would also like a little bit more clarification on how did you “pre-compile” the kernel. Are you a professional edition user?
As I said in my previous post, my suspicion was correct. Your library, called PPR_GPU is not being compiled against the ComputeCpp compiler (compute++). That’s why you are seeing the message that the kernel cannot be found, because it is not there.
When you build a SYCL application in Visual Studio using a Solution, you must mark each cpp file that contains SYCL kernel code to be compiled with compute++. You do this by right-clicking in the file and change its compilation type to ComputeCpp SYCL Cpp, like in the following image:
Thank you very much, I didn’t know that. One more think, when I try to call my method from PPR project (it is included using #include “…/PPR_GPU/gpu.cpp”), it does not compile because it says it cannot open file CL/sycl.hpp.Do I also need to add sycl paths to the PPR project? I guess maybe add path to computecpp lib folder to additional library directories in linker settings?
You shouldn’t include the your gpu.cpp in other files. Ideally you expose functions in your gpu.h and you include that. In this way you don’t need to have sycl.hpp in your include path.
Thanks again, I’ve included gpu.h as you advised and add path to compiled .lib to the linker additional dependencies. Previous error is gone, but now I get around 40 new unresolved external symbol errors.
Finally, all errors are gone and both projects are successfully compiled. But now, when I run application I get runtime error std::bad_array_new_length on line with sycl::queue queue(device_selector). It seems that the list of available devices is empty. I’m very sorry to bother you again.
Yes, it is gpu.cpp. No reason, I was trying different selectors. But the error occurs even if I use default_selector. It’s weird that when I compile PPR_GPU as .exe and run everything works as expected, but when I compile project as .lib I get this error.
The reason you are getting this error is because you are building a debug version of your application and linking against a release version of ComputeCpp. You were probably linking against the correct version when the PPR_GPU was being built as an executable.
In your PPR project, change the ComputeCpp library being linked from ComputeCpp.lib to ComputeCpp_d.lib