Replies: 13 comments
-
For OpenCL it is: clCreateProgramWithIL (https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/clCreateProgramWithIL.html). I think this is an OK example. |
Beta Was this translation helpful? Give feedback.
-
thx your reply @MrSidims , I will try it. |
Beta Was this translation helpful? Give feedback.
-
@malixian, could you clarify how are you going to use the program object? |
Beta Was this translation helpful? Give feedback.
-
I want to build a program object by myopencl with spir that is generated by dpcpp. And codes the main program to emti kernel in spir style to myopencl. I think the examples from the link shows me how to program. |
Beta Was this translation helpful? Give feedback.
-
I'd like to note that ABI for SPIR kernels generated by DPC++ compiler is implementation defined. Some implementation details are documented here: https://github.com/intel/llvm/blob/sycl/sycl/doc/CompilerAndRuntimeDesign.md, but it's subject to change. I would not recommend using this approach "in production". |
Beta Was this translation helpful? Give feedback.
-
Whether the SPIR generated by dpcpp can be used to program with amd-opencl |
Beta Was this translation helpful? Give feedback.
-
No.
It depends on the DPC++ features used by the application, but in most cases the answer is yes. |
Beta Was this translation helpful? Give feedback.
-
thx very much @bader . |
Beta Was this translation helpful? Give feedback.
-
BTW, if my amd-opencl supports SPIR-V and the SPIR-V generated by DPC++ don't have extensioncan, it's work? |
Beta Was this translation helpful? Give feedback.
-
This setup should work. |
Beta Was this translation helpful? Give feedback.
-
Can you give me some code that can be compiled into spirv without extensions? thank you very much. |
Beta Was this translation helpful? Give feedback.
-
For example: #include <CL/sycl.hpp>
int main() {
// Creating buffer of 4 ints to be used inside the kernel code
cl::sycl::buffer<cl::sycl::cl_int, 1> Buffer(4);
// Creating SYCL queue
cl::sycl::queue Queue;
// Size of index space for kernel
cl::sycl::range<1> NumOfWorkItems{Buffer.get_count()};
// Submitting command group(work) to queue
Queue.submit([&](cl::sycl::handler &cgh) {
// Getting write only access to the buffer on a device
auto Accessor = Buffer.get_access<cl::sycl::access::mode::write>(cgh);
// Executing kernel
cgh.parallel_for<class FillBuffer>(
NumOfWorkItems, [=](cl::sycl::id<1> WIid) {
// Fill buffer with indexes
Accessor[WIid] = (cl::sycl::cl_int)WIid.get(0);
});
});
// Getting read only access to the buffer on the host.
// Implicit barrier waiting for queue to complete the work.
const auto HostAccessor = Buffer.get_access<cl::sycl::access::mode::read>();
// Check the results
bool MismatchFound = false;
for (size_t I = 0; I < Buffer.get_count(); ++I) {
if (HostAccessor[I] != I) {
std::cout << "The result is incorrect for element: " << I
<< " , expected: " << I << " , got: " << HostAccessor[I]
<< std::endl;
MismatchFound = true;
}
}
if (!MismatchFound) {
std::cout << "The results are correct!" << std::endl;
}
return MismatchFound;
} |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your generous help @bader ! |
Beta Was this translation helpful? Give feedback.
-
I can emit SPIRV with command
clang++ -fsycl -fsycl-device-only -fno-sycl-use-bitcode test.cpp
.And I would like to know how to create program objects from SPIRV with
clCreateProgramWithBinary
runtime API .If this way works, can you give me some examples?
Beta Was this translation helpful? Give feedback.
All reactions