Got: RuntimeError: [llvm_context.cpp:taichi::lang::TaichiLLVMContext::get_data_type@98] Not supported

I got a “RuntimeError: [llvm_context.cpp:taichi::lang::TaichiLLVMContext::get_data_type@98] Not supported.” error when running the following code. The code copies the submatrix of a tensor to another tensor.

The funny thing is that if I run the code ONLY with the line 59 - 67 (the lines currently commented out) or the line 38 - 57, I won’t get this error, and the results for those loops are correct. However, if I run the code with those lines together, I will get the error.

What could go wrong here? Thank you for your help.

import taichi as ti
import numpy as np

#ti.init(debug = True, arch = ti.gpu)
ti.init(arch = ti.gpu)

# simulation parameters
n_no_x = 5 #no. of nodes in x direction
n_no_y = 2 #no. of nodes in y direction
n_no = n_no_x * n_no_y
n_no_active = (n_no_x - 1) * n_no_y #excluding Dirichlet nodes

K = ti.var(dt = ti.f32, shape = (2 * n_no, 2 * n_no)) #stiffness matrix
Kc = ti.var(dt = ti.f32, shape = (2 * n_no_active, 2 * n_no_active)) #condensed stiffness matrix


dirichletLength = 2 * n_no_y
dirichletBC = ti.var(dt = ti.i32, shape = dirichletLength) #Dirichlet nodes


@ti.kernel
def init():
    # fill in the connectivity matrix, the initial position and assemble the stiffness matrix

    for i in range(n_no_y):
        dirichletBC[2 * i] = 2 * n_no_x * i
        dirichletBC[2 * i + 1] = 2 * n_no_x * i + 1

    for i, j in Kc:
        Kc[i, j] = 0.0

    for i, j in K:
        K[i, j] = 0.0

    # The lines below: running either part is fine. Running both parts produces an error.
    for i in range(dirichletBC[0]):
        print(i)
        for j in range(dirichletBC[0]):
            Kc[i, j] = K[i, j]
        for jj in range(1, dirichletLength):
            for j in range(dirichletBC[jj - 1] + 1, dirichletBC[jj]):
                Kc[i, j - jj] = K[i, j]
        for j in range(dirichletBC[dirichletLength - 1] + 1, 2 * n_no):
            Kc[i, j - dirichletLength] = K[i, j]

    for ii in range(1, dirichletLength):
        for i in range(dirichletBC[ii - 1] + 1, dirichletBC[ii]):
            print(i)
            for j in range(dirichletBC[0]):
                Kc[i - ii, j] = K[i, j]
            for jj in range(1, dirichletLength):
                for j in range(dirichletBC[jj - 1] + 1, dirichletBC[jj]):
                    Kc[i - ii, j - jj] = K[i, j]
            for j in range(dirichletBC[dirichletLength - 1] + 1, 2 * n_no):
                Kc[i - ii, j - dirichletLength] = K[i, j]
    '''
    for i in range(dirichletBC[dirichletLength - 1] + 1, 2 * n_no):
        print(i)
        for j in range(dirichletBC[0]):
            Kc[i - dirichletLength, j] = K[i, j]
        for jj in range(1, dirichletLength):
            for j in range(dirichletBC[jj - 1] + 1, dirichletBC[jj]):
                Kc[i - dirichletLength, j - jj] = K[i, j]
        for j in range(dirichletBC[dirichletLength - 1] + 1, 2 * n_no):
            Kc[i - dirichletLength, j - dirichletLength] = K[i, j]
    '''
    #print(K[2, 2])

init()

A simplified version.

import taichi as ti

ti.init(debug = True, arch = ti.cpu)
# ti.init(arch = ti.gpu)


dirichletLength = 4
dirichletBC = ti.var(dt = ti.i32, shape = dirichletLength)

@ti.kernel
def init():
    """
    1. open all block 1~4: 
        RuntimeError: [llvm_context.cpp:taichi::lang::TaichiLLVMContext::get_data_type@105] Not supported.
    
    2. only comment block [2 or 3 or 4]:
        works well
    
    3. comment block 1:
        RuntimeError
    """
    ## block 1
    for i in range(dirichletLength):
        dirichletBC[i] = i
    
    ## block 2
    print("dirichletBC[0] =", dirichletBC[0])

    ## block 3
    for i in dirichletBC:
        pass

    ## block 4
    print("dirichletBC[3] =", dirichletBC[3])

init()

version

❯ ti
[Taichi] mode=release
[Taichi] version 0.6.8, supported archs: [cpu, cuda, opengl], commit 9f4fd27c, python 3.8.3

Maybe related to

Thanks. Splitting the kernel into two does avoid this problem.

A good news is that a PR by xumingkuan just merged provids a fix to this

1 个赞