(mode)
| 4 | describe('features: add custom function'); |
| 5 | |
| 6 | function inGPUInstanceSettings(mode) { |
| 7 | function customAdder(a, b) { |
| 8 | return a + b; |
| 9 | } |
| 10 | const gpu = new GPU({mode, functions: [customAdder] }); |
| 11 | const kernel = gpu.createKernel(function (a, b) { |
| 12 | return customAdder(a[this.thread.x], b[this.thread.x]); |
| 13 | }, { |
| 14 | output: [6] |
| 15 | }); |
| 16 | |
| 17 | const a = [1, 2, 3, 5, 6, 7]; |
| 18 | const b = [4, 5, 6, 1, 2, 3]; |
| 19 | |
| 20 | const result = kernel(a, b); |
| 21 | |
| 22 | const expected = [5, 7, 9, 6, 8, 10]; |
| 23 | |
| 24 | assert.deepEqual(Array.from(result), expected); |
| 25 | gpu.destroy(); |
| 26 | } |
| 27 | |
| 28 | test('in GPU instance settings auto', () => { |
| 29 | inGPUInstanceSettings(null); |
no test coverage detected
searching dependent graphs…