(mode)
| 51 | |
| 52 | |
| 53 | function withGPUAddFunctionMethod(mode) { |
| 54 | function customAdder(a, b) { |
| 55 | return a + b; |
| 56 | } |
| 57 | const gpu = new GPU({ mode }) |
| 58 | .addFunction(customAdder); |
| 59 | const kernel = gpu.createKernel(function (a, b) { |
| 60 | return customAdder(a[this.thread.x], b[this.thread.x]); |
| 61 | }, { |
| 62 | output: [6] |
| 63 | }); |
| 64 | |
| 65 | const a = [1, 2, 3, 5, 6, 7]; |
| 66 | const b = [4, 5, 6, 1, 2, 3]; |
| 67 | |
| 68 | const result = kernel(a, b); |
| 69 | |
| 70 | const expected = [5, 7, 9, 6, 8, 10]; |
| 71 | |
| 72 | assert.deepEqual(Array.from(result), expected); |
| 73 | gpu.destroy(); |
| 74 | } |
| 75 | |
| 76 | test('with GPU addFunction method auto', () => { |
| 77 | withGPUAddFunctionMethod(null); |
no test coverage detected
searching dependent graphs…