示例#1
0
 def testprog12(A: dace.float64[10]):
     i = 2
     with dace.tasklet(dace.Language.CPP):
         ii << i
         a << A(1)[:]
         aout >> A(2)[:]
         '''
示例#2
0
def test_simple():
    A = np.random.rand(4)
    B = np.random.rand(4)
    with dace.tasklet():
        a << A[0]
        b >> B[1]
        b = a

    assert np.allclose(B[1], A[0])
示例#3
0
 def nested_offset_access(inp: dc.float64[6, 5, 5]):
     out = np.zeros((5, 5, 5), np.float64)
     for i, j in dc.map[0:5, 0:5]:
         out[i, j, 0] = 0.25 * (inp[i + 1, j, 1] + inp[i, j, 1])
         for k in range(1, 4):
             with dc.tasklet():
                 in1 << inp[i + 1, j, k + 1]
                 in2 << inp[i, j, k + 1]
                 out1 >> out[i, j, k]
                 out1 = 0.25 * (in1 + in2)
     return out
示例#4
0
def test_locals():
    a = 1
    b = 'aa'
    c = 3
    A = np.random.rand(4)
    B = np.random.rand(4)
    with dace.tasklet():
        a << A[0]
        b >> B[1]
        b = a + c

    assert np.allclose(B[1], A[0] + c)
示例#5
0
 def testprog3(A: dace.float32[20, 20]):
     i = 0
     j = 0
     k = dace.ndarray([1], dtype=dace.int32)
     with dace.tasklet(dace.Language.CPP):
         jj << j
         """
         ii = jj + 1;
         """
         ii >> i
     with dace.tasklet(dace.Language.CPP):
         jin << j
         """
         int something = (int)jin;
         jout = something + 1;
         """
         jout >> j
     with dace.tasklet(dace.Language.CPP):
         """
         kout[0] = 0;
         """
         kout >> k
示例#6
0
def DFT(X, Y):
    # Generate DFT matrix
    dft_mat = dace.define_local([N, N], dtype=dace.complex128)

    @dace.map(_[0:N, 0:N])
    def dft_mat_gen(i, j):
        omega >> dft_mat[i, j]

        omega = exp(-dace.complex128(0, 2 * 3.14159265359 * i * j) /
                    dace.complex128(N))

    with dace.tasklet(language=dace.Language.CPP,
                      code_global='#include <mkl.h>'):
        x << X
        omega << dft_mat
        y >> Y
        '''