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