On Windows 10 (1709) ,
LLVM setup:
LLVM 6.0 source is compiled .
Installed Intel SDK for Open CL 2017
Then i compiled TVM with LLVM and OPENCL options enabled sucessfully .
After compilation ,the respective python bindings were done .
Once i started the OPEN CL part of “getstarted.py” code ,after execution the Python crashed .
here is the demo code for open cl :
from future import absolute_import, print_function
import tvm
import numpy as np
tgt_host=“llvm”
tgt=“opencl”
n = tvm.var(“n”)
A = tvm.placeholder((n,), name=‘A’)
B = tvm.placeholder((n,), name=‘B’)
C = tvm.compute(A.shape, lambda i: A[i] + B[i], name=“C”)
print(type©)
s = tvm.create_schedule(C.op)
bx, tx = s[C].split(C.op.axis[0], factor=64)
s[C].bind(bx, tvm.thread_axis(“blockIdx.x”))
s[C].bind(tx, tvm.thread_axis(“threadIdx.x”))
fadd_cl = tvm.build(s, [A, B, C], “opencl”, name=“myadd”)
print("------tvm gen code------")
print(fadd_cl.get_source());
print("------opencl code------")
print(fadd_cl.imported_modules[0].get_source())
ctx = tvm.cl(0)
n = 1024
a = tvm.nd.array(np.random.uniform(size=n).astype(A.dtype), ctx)
b = tvm.nd.array(np.random.uniform(size=n).astype(B.dtype), ctx)
c = tvm.nd.array(np.zeros(n, dtype=C.dtype), ctx)
fadd_cl(a, b, c)
np.testing.assert_allclose(c.asnumpy(), a.asnumpy() + b.asnumpy())
OUTPUT: in the link
console out
from the console output ,i think it generates llvm based IR and finally generates the opencl code . But upon reaching end of execution ,i get a popup “Python stopped working” .
Once i try to debug the crash in visual studio 2015 ,i see in the call stack , that the crash was triggered from " tvm.dll -->IntelOpenCL64.dll ".
Test 2:
Compiled TVM without LLVM and Only OpenCL enabled :
ran the same example program . executed without any crash!! .
From the console output below ,i think tvm used inbuilt stackvm .
Is there any Incompatability with TVM - LLVM ??
I tried with both version of LLVM 6.0 & 4.0.1 sources ,but unfortunately the open cl is crashing !