(self)
| 82 | testing.assert_array_equal(x, expected) |
| 83 | |
| 84 | def test_static_array(self): |
| 85 | code = ''' |
| 86 | struct double5 { |
| 87 | double value[5]; |
| 88 | __device__ const double& operator[](size_t i) const { return value[i]; } |
| 89 | }; |
| 90 | |
| 91 | extern "C" __global__ void test_kernel(const double* a, double5 b, double* x) { |
| 92 | int i = threadIdx.x; |
| 93 | x[i] = a[i] + b[0] + b[1] + b[2] + b[3] + b[4]; |
| 94 | } |
| 95 | ''' |
| 96 | |
| 97 | a_cpu = numpy.arange(24, dtype=numpy.float64) |
| 98 | a = cupy.array(a_cpu) |
| 99 | x = cupy.empty_like(a) |
| 100 | |
| 101 | func = _compile_func('test_kernel', code) |
| 102 | |
| 103 | # We cannot pass np.ndarray kernel arguments of size > 1 |
| 104 | b = numpy.arange(5).astype(numpy.float64) |
| 105 | with pytest.raises(TypeError): |
| 106 | func.linear_launch(a.size, (a, b, x)) |
| 107 | |
| 108 | double5 = numpy.dtype({ |
| 109 | 'names': ['dummy'], |
| 110 | 'formats': [(numpy.float64, (5,))] |
| 111 | }) |
| 112 | func.linear_launch(a.size, (a, b.view(double5), x)) |
| 113 | |
| 114 | expected = a_cpu + b.sum() |
| 115 | testing.assert_array_equal(x, expected) |
| 116 | |
| 117 | def test_custom_user_struct(self): |
| 118 | struct_definition = ''' |
nothing calls this directly
no test coverage detected