-
Notifications
You must be signed in to change notification settings - Fork 802
Closed
Description
I had llvm(this project) and oneapi-construction-kit installed on my RISC-V CPU hardware.
- OCK here is to provide OpenCL implementation for RISC-V CPU.
clinfo and sycl-ls output as below:
For example:
main.cpp
#include <sycl/sycl.hpp>
#include <vector>
#include <iostream>
using namespace sycl;
using namespace std;
constexpr int N = 16;
int main()
{
cpu_selector d_selector;
queue q(d_selector);
vector<int> v(N);
{
buffer buf(v);
q.submit([&](handler &h)
{
accessor a(buf, h, write_only);
h.parallel_for(N, [=](auto i)
{ a[i] = i; }); })
.wait();
}
for (int i = 0; i < N; i++)
cout << v[i] << " ";
cout << "\n";
return 0;
}# compile and execute command
clang++ -fsycl main.cpp -o main
./mainOutput is as below:
What is the exactly SYCL code compilation flow and execution process on RISC-V CPU?
- Code is splited into two parts, host code and device code, respectively.
- Host code is compiled with integration header by host compiler.
- Device code is compiled by device compiler and is translated into LLVM IR.
- llvm-spirv converts the LLVM IR of device code to SPIR-V.
- Device compiler then compile the SPIR-V to target binary or wrap the SPIR-V to the object file of host code.
- Executable binary file is generated.
During execution:
- If JIT is enabled, the SPIR-V needs to be compiled by device compiler. In this scenario, device compiler find OpenCL environment as mentioned. So SPIR-V is translated to OpenCL code then the rest of the compilation is done by OpenCL runtime?
- If AOT is enabled, the binary can run directly.
- Host and device are the same RISC-V CPU in this scenario. Therefore host compiler and device compiler are the same?
- How to set the mode of compilation, AOT or JIT? Is JIT enabled in default?
Please correct me if I was wrong. Thanks a lot!
Metadata
Metadata
Assignees
Labels
No labels

