(mode)
| 147 | }); |
| 148 | |
| 149 | function withKernelAddFunctionMethod(mode) { |
| 150 | function customAdder(a, b) { |
| 151 | return a + b; |
| 152 | } |
| 153 | const gpu = new GPU({ mode }); |
| 154 | const kernel = gpu.createKernel(function (a, b) { |
| 155 | return customAdder(a[this.thread.x], b[this.thread.x]); |
| 156 | }, { |
| 157 | output: [6] |
| 158 | }) |
| 159 | .addFunction(customAdder); |
| 160 | |
| 161 | const a = [1, 2, 3, 5, 6, 7]; |
| 162 | const b = [4, 5, 6, 1, 2, 3]; |
| 163 | |
| 164 | const result = kernel(a, b); |
| 165 | |
| 166 | const expected = [5, 7, 9, 6, 8, 10]; |
| 167 | |
| 168 | assert.deepEqual(Array.from(result), expected); |
| 169 | gpu.destroy(); |
| 170 | } |
| 171 | |
| 172 | test('with Kernel addFunction method auto', () => { |
| 173 | withKernelAddFunctionMethod(null); |
no test coverage detected
searching dependent graphs…